From 6d367ba43983361c24af7b5e87f2015fde464703 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Sun, 28 Jul 2013 12:20:27 +0200 Subject: [PATCH] HaikuDepot: Beginnings of Model class --- src/apps/haiku-depot/Jamfile | 1 + src/apps/haiku-depot/Model.cpp | 45 ++++++++++++++++++++++++++++++++++ src/apps/haiku-depot/Model.h | 28 +++++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 src/apps/haiku-depot/Model.cpp create mode 100644 src/apps/haiku-depot/Model.h diff --git a/src/apps/haiku-depot/Jamfile b/src/apps/haiku-depot/Jamfile index d9e290775b..2a91934ea5 100644 --- a/src/apps/haiku-depot/Jamfile +++ b/src/apps/haiku-depot/Jamfile @@ -7,6 +7,7 @@ Application HaikuDepot : FilterView.cpp main.cpp MainWindow.cpp + Model.cpp PackageActionsView.cpp PackageInfo.cpp PackageInfoView.cpp diff --git a/src/apps/haiku-depot/Model.cpp b/src/apps/haiku-depot/Model.cpp new file mode 100644 index 0000000000..78c7c2d5b1 --- /dev/null +++ b/src/apps/haiku-depot/Model.cpp @@ -0,0 +1,45 @@ +/* + * Copyright 2013, Stephan Aßmus . + * All rights reserved. Distributed under the terms of the MIT License. + */ + +#include "Model.h" + +#include + + +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); +} + diff --git a/src/apps/haiku-depot/Model.h b/src/apps/haiku-depot/Model.h new file mode 100644 index 0000000000..d498a32db5 --- /dev/null +++ b/src/apps/haiku-depot/Model.h @@ -0,0 +1,28 @@ +/* + * Copyright 2013, Stephan Aßmus . + * 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