HaikuDepot: Beginnings of Model class

This commit is contained in:
Stephan Aßmus 2013-07-28 12:20:27 +02:00
parent f34f805b1a
commit 6d367ba439
3 changed files with 74 additions and 0 deletions

View File

@ -7,6 +7,7 @@ Application HaikuDepot :
FilterView.cpp
main.cpp
MainWindow.cpp
Model.cpp
PackageActionsView.cpp
PackageInfo.cpp
PackageInfoView.cpp

View File

@ -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);
}

View File

@ -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