HaikuDepot: Beginnings of Model class
This commit is contained in:
@@ -7,6 +7,7 @@ Application HaikuDepot :
|
|||||||
FilterView.cpp
|
FilterView.cpp
|
||||||
main.cpp
|
main.cpp
|
||||||
MainWindow.cpp
|
MainWindow.cpp
|
||||||
|
Model.cpp
|
||||||
PackageActionsView.cpp
|
PackageActionsView.cpp
|
||||||
PackageInfo.cpp
|
PackageInfo.cpp
|
||||||
PackageInfoView.cpp
|
PackageInfoView.cpp
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2013, Stephan Aßmus <[email protected]>.
|
||||||
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Model.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
|
Model::Model()
|
||||||
|
:
|
||||||
|
fSearchTerms(),
|
||||||
|
fDepots()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PackageInfoList
|
||||||
|
Model::CreatePackageList() const
|
||||||
|
{
|
||||||
|
// TODO: Allow to restrict depot, filter by search terms, ...
|
||||||
|
|
||||||
|
// Return all packages from all depots.
|
||||||
|
PackageInfoList resultList;
|
||||||
|
|
||||||
|
for (int32 i = 0; i < fDepots.CountItems(); i++) {
|
||||||
|
const PackageInfoList& packageList
|
||||||
|
= fDepots.ItemAtFast(i).PackageList();
|
||||||
|
|
||||||
|
for (int32 j = 0; j < packageList.CountItems(); j++) {
|
||||||
|
resultList.Add(packageList.ItemAtFast(j));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return resultList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
Model::AddDepot(const DepotInfo& depot)
|
||||||
|
{
|
||||||
|
return fDepots.Add(depot);
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2013, Stephan Aßmus <[email protected]>.
|
||||||
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
#ifndef MODEL_H
|
||||||
|
#define MODEL_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "PackageInfo.h"
|
||||||
|
|
||||||
|
|
||||||
|
class Model {
|
||||||
|
public:
|
||||||
|
Model();
|
||||||
|
|
||||||
|
// !Returns new PackageInfoList from current parameters
|
||||||
|
PackageInfoList CreatePackageList() const;
|
||||||
|
|
||||||
|
bool AddDepot(const DepotInfo& depot);
|
||||||
|
|
||||||
|
private:
|
||||||
|
BString fSearchTerms;
|
||||||
|
|
||||||
|
DepotInfoList fDepots;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // PACKAGE_INFO_H
|
||||||
Reference in New Issue
Block a user