HaikuDepot: Beginnings of Model class
This commit is contained in:
parent
f34f805b1a
commit
6d367ba439
|
@ -7,6 +7,7 @@ Application HaikuDepot :
|
|||
FilterView.cpp
|
||||
main.cpp
|
||||
MainWindow.cpp
|
||||
Model.cpp
|
||||
PackageActionsView.cpp
|
||||
PackageInfo.cpp
|
||||
PackageInfoView.cpp
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Copyright 2013, Stephan Aßmus <superstippi@gmx.de>.
|
||||
* 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 <superstippi@gmx.de>.
|
||||
* 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
|
Loading…
Reference in New Issue