[haiku-commits] haiku: hrev45913 - src/apps/haiku-depot

  • From: superstippi@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 28 Jul 2013 12:21:16 +0200 (CEST)

hrev45913 adds 2 changesets to branch 'master'
old head: 82bdec56d40be5b37d18e42a74651a79cabd6c10
new head: 6d367ba43983361c24af7b5e87f2015fde464703
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=6d367ba+%5E82bdec5

----------------------------------------------------------------------------

f34f805: HaikuDepot: Added DepotInfo class

6d367ba: HaikuDepot: Beginnings of Model class

                                      [ Stephan Aßmus <superstippi@xxxxxx> ]

----------------------------------------------------------------------------

5 files changed, 159 insertions(+)
src/apps/haiku-depot/Jamfile         |  1 +
src/apps/haiku-depot/Model.cpp       | 45 +++++++++++++++++++++++++
src/apps/haiku-depot/Model.h         | 28 +++++++++++++++
src/apps/haiku-depot/PackageInfo.cpp | 58 ++++++++++++++++++++++++++++++++
src/apps/haiku-depot/PackageInfo.h   | 27 +++++++++++++++

############################################################################

Commit:      f34f805b1ae73e81f4acdbe49faeb15f21439a87
URL:         http://cgit.haiku-os.org/haiku/commit/?id=f34f805
Author:      Stephan Aßmus <superstippi@xxxxxx>
Date:        Sun Jul 28 10:20:00 2013 UTC

HaikuDepot: Added DepotInfo class

----------------------------------------------------------------------------

diff --git a/src/apps/haiku-depot/PackageInfo.cpp 
b/src/apps/haiku-depot/PackageInfo.cpp
index 78a617d..ef0fac6 100644
--- a/src/apps/haiku-depot/PackageInfo.cpp
+++ b/src/apps/haiku-depot/PackageInfo.cpp
@@ -189,3 +189,61 @@ PackageInfo::AddUserRating(const UserRating& rating)
 {
        return fUserRatings.Add(rating);
 }
+
+
+// #pragma mark -
+
+
+DepotInfo::DepotInfo()
+       :
+       fTitle(),
+       fPackages()
+{
+}
+
+
+DepotInfo::DepotInfo(const BString& title)
+       :
+       fTitle(title),
+       fPackages()
+{
+}
+
+
+DepotInfo::DepotInfo(const DepotInfo& other)
+       :
+       fTitle(other.fTitle),
+       fPackages(other.fPackages)
+{
+}
+
+
+DepotInfo&
+DepotInfo::operator=(const DepotInfo& other)
+{
+       fTitle = other.fTitle;
+       fPackages = other.fPackages;
+       return *this;
+}
+
+
+bool
+DepotInfo::operator==(const DepotInfo& other) const
+{
+       return fTitle == other.fTitle
+               && fPackages == other.fPackages;
+}
+
+
+bool
+DepotInfo::operator!=(const DepotInfo& other) const
+{
+       return !(*this == other);
+}
+
+
+bool
+DepotInfo::AddPackage(const PackageInfo& package)
+{
+       return fPackages.Add(package);
+}
diff --git a/src/apps/haiku-depot/PackageInfo.h 
b/src/apps/haiku-depot/PackageInfo.h
index 24d4c8e..db5db30 100644
--- a/src/apps/haiku-depot/PackageInfo.h
+++ b/src/apps/haiku-depot/PackageInfo.h
@@ -96,4 +96,31 @@ private:
 typedef List<PackageInfo, false> PackageInfoList;
 
 
+class DepotInfo {
+public:
+                                                               DepotInfo();
+                                                               DepotInfo(const 
BString& title);
+                                                               DepotInfo(const 
DepotInfo& other);
+
+                       DepotInfo&                      operator=(const 
DepotInfo& other);
+                       bool                            operator==(const 
DepotInfo& other) const;
+                       bool                            operator!=(const 
DepotInfo& other) const;
+
+                       const BString&          Title() const
+                                                                       { 
return fTitle; }
+
+                       const PackageInfoList& PackageList() const
+                                                                       { 
return fPackages; }
+
+                       bool                            AddPackage(const 
PackageInfo& package);
+
+private:
+                       BString                         fTitle;
+                       PackageInfoList         fPackages;
+};
+
+
+typedef List<DepotInfo, false> DepotInfoList;
+
+
 #endif // PACKAGE_INFO_H

############################################################################

Revision:    hrev45913
Commit:      6d367ba43983361c24af7b5e87f2015fde464703
URL:         http://cgit.haiku-os.org/haiku/commit/?id=6d367ba
Author:      Stephan Aßmus <superstippi@xxxxxx>
Date:        Sun Jul 28 10:20:27 2013 UTC

HaikuDepot: Beginnings of Model class

----------------------------------------------------------------------------

diff --git a/src/apps/haiku-depot/Jamfile b/src/apps/haiku-depot/Jamfile
index d9e2907..2a91934 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 0000000..78c7c2d
--- /dev/null
+++ b/src/apps/haiku-depot/Model.cpp
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2013, Stephan Aßmus <superstippi@xxxxxx>.
+ * 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);
+}
+
diff --git a/src/apps/haiku-depot/Model.h b/src/apps/haiku-depot/Model.h
new file mode 100644
index 0000000..d498a32
--- /dev/null
+++ b/src/apps/haiku-depot/Model.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2013, Stephan Aßmus <superstippi@xxxxxx>.
+ * 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


Other related posts:

  • » [haiku-commits] haiku: hrev45913 - src/apps/haiku-depot - superstippi