[prev in list] [next in list] [prev in thread] [next in thread] 

List:       haiku-commits
Subject:    [haiku-commits] haiku: hrev45914 - src/apps/haiku-depot
From:       superstippi () gmx ! de
Date:       2013-07-28 13:01:27
Message-ID: 20130728130127.A50AC5C0BE8 () vmrepo ! haiku-os ! org
[Download RAW message or body]

hrev45914 adds 2 changesets to branch 'master'
old head: 6d367ba43983361c24af7b5e87f2015fde464703
new head: 3883c02097d4e8819c39d49456d5488c3319bd52
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=3883c02+%5E6d367ba

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

686357a: HaikuDepot: MainWindow: Class members for the created views

3883c02: HaikuDepot: Create dummy model (2 items)
   * Added methods to fill the package list view, creating PackageRows
     from PackageInfos, various TODOs.
   * Some additions in the info classes, UserRating needs language.

                                      [ Stephan Aßmus <superstippi@gmx.de> ]

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

6 files changed, 224 insertions(+), 30 deletions(-)
src/apps/haiku-depot/MainWindow.cpp      | 106 ++++++++++++++++++++++-----
src/apps/haiku-depot/MainWindow.h        |  21 ++++++
src/apps/haiku-depot/PackageInfo.cpp     |  20 +++--
src/apps/haiku-depot/PackageInfo.h       |   7 +-
src/apps/haiku-depot/PackageListView.cpp |  78 +++++++++++++++++++-
src/apps/haiku-depot/PackageListView.h   |  22 ++++++

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

Commit:      686357a30c669aec2e8e6c0de2daaa1eb4cd0b93
URL:         http://cgit.haiku-os.org/haiku/commit/?id=686357a
Author:      Stephan Aßmus <superstippi@gmx.de>
Date:        Sun Jul 28 12:12:37 2013 UTC

HaikuDepot: MainWindow: Class members for the created views

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

diff --git a/src/apps/haiku-depot/MainWindow.cpp b/src/apps/haiku-depot/MainWindow.cpp
index 6008c49..ffd288d 100644
--- a/src/apps/haiku-depot/MainWindow.cpp
+++ b/src/apps/haiku-depot/MainWindow.cpp
@@ -34,35 +34,31 @@ MainWindow::MainWindow(BRect frame)
 		B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
 		B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS)
 {
-	BMenuBar* mainMenu = new BMenuBar(B_TRANSLATE("Main Menu"));
-	BMenu* menu = new BMenu(B_TRANSLATE("Package"));
-	mainMenu->AddItem(menu);
-	
-	FilterView* filterView = new FilterView();
+	BMenuBar* menuBar = new BMenuBar(B_TRANSLATE("Main Menu"));
+	_BuildMenu(menuBar);
 	
-	PackageListView* packageListView = new PackageListView();
-
-	PackageActionsView* packageActionsView = new PackageActionsView();
-
-	PackageInfoView* packageInfoView = new PackageInfoView();
+	fFilterView = new FilterView();
+	fPackageListView = new PackageListView();
+	fPackageActionsView = new PackageActionsView();
+	fPackageInfoView = new PackageInfoView();
 	
-	BSplitView* splitView = new BSplitView(B_VERTICAL, B_USE_SMALL_SPACING);
+	fSplitView = new BSplitView(B_VERTICAL, B_USE_SMALL_SPACING);
 	
 	BLayoutBuilder::Group<>(this, B_VERTICAL, 0.0f)
-		.Add(mainMenu)
-		.Add(filterView)
+		.Add(menuBar)
+		.Add(fFilterView)
 		.AddGroup(B_VERTICAL)
-			.AddSplit(splitView)
-				.Add(packageListView)
-				.Add(packageInfoView)
+			.AddSplit(fSplitView)
+				.Add(fPackageListView)
+				.Add(fPackageInfoView)
 			.End()
-			.Add(packageActionsView)
+			.Add(fPackageActionsView)
 			.SetInsets(B_USE_DEFAULT_SPACING, 0.0f, B_USE_DEFAULT_SPACING,
 				B_USE_DEFAULT_SPACING)
 		.End()
 	;
 
-	splitView->SetCollapsible(0, false);
+	fSplitView->SetCollapsible(0, false);
 }
 
 
@@ -94,3 +90,12 @@ MainWindow::MessageReceived(BMessage* message)
 			break;
 	}
 }
+
+
+void
+MainWindow::_BuildMenu(BMenuBar* menuBar)
+{
+	BMenu* menu = new BMenu(B_TRANSLATE("Package"));
+	menuBar->AddItem(menu);
+
+}
diff --git a/src/apps/haiku-depot/MainWindow.h b/src/apps/haiku-depot/MainWindow.h
index 7f3476c..f148a7a 100644
--- a/src/apps/haiku-depot/MainWindow.h
+++ b/src/apps/haiku-depot/MainWindow.h
@@ -7,6 +7,14 @@
 
 #include <Window.h>
 
+#include "Model.h"
+
+
+class BSplitView;
+class FilterView;
+class PackageActionsView;
+class PackageInfoView;
+class PackageListView;
 
 enum {
 	MSG_MAIN_WINDOW_CLOSED		= 'mwcl',
@@ -23,6 +31,16 @@ public:
 	virtual	void				MessageReceived(BMessage* message);
 
 private:
+			void				_BuildMenu(BMenuBar* menuBar);
+
+private:
+			FilterView*			fFilterView;
+			PackageActionsView*	fPackageActionsView;
+			PackageInfoView*	fPackageInfoView;
+			PackageListView*	fPackageListView;
+			BSplitView*			fSplitView;
+
+			Model				fModel;
 };
 
 #endif // MAIN_WINDOW_H

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

Revision:    hrev45914
Commit:      3883c02097d4e8819c39d49456d5488c3319bd52
URL:         http://cgit.haiku-os.org/haiku/commit/?id=3883c02
Author:      Stephan Aßmus <superstippi@gmx.de>
Date:        Sun Jul 28 12:59:11 2013 UTC

HaikuDepot: Create dummy model (2 items)
 * Added methods to fill the package list view, creating PackageRows
   from PackageInfos, various TODOs.
 * Some additions in the info classes, UserRating needs language.

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

diff --git a/src/apps/haiku-depot/MainWindow.cpp b/src/apps/haiku-depot/MainWindow.cpp
index ffd288d..e00ca2c 100644
--- a/src/apps/haiku-depot/MainWindow.cpp
+++ b/src/apps/haiku-depot/MainWindow.cpp
@@ -39,8 +39,8 @@ MainWindow::MainWindow(BRect frame)
 	
 	fFilterView = new FilterView();
 	fPackageListView = new PackageListView();
-	fPackageActionsView = new PackageActionsView();
 	fPackageInfoView = new PackageInfoView();
+	fPackageActionsView = new PackageActionsView();
 	
 	fSplitView = new BSplitView(B_VERTICAL, B_USE_SMALL_SPACING);
 	
@@ -59,6 +59,9 @@ MainWindow::MainWindow(BRect frame)
 	;
 
 	fSplitView->SetCollapsible(0, false);
+
+	_InitDummyModel();
+	_AdoptModel();
 }
 
 
@@ -99,3 +102,65 @@ MainWindow::_BuildMenu(BMenuBar* menuBar)
 	menuBar->AddItem(menu);
 
 }
+
+
+void
+MainWindow::_AdoptModel()
+{
+	PackageInfoList packages = fModel.CreatePackageList();
+	
+	fPackageListView->Clear();
+	for (int32 i = 0; i < packages.CountItems(); i++) {
+		fPackageListView->AddPackage(packages.ItemAtFast(i));
+	}
+}
+
+
+void
+MainWindow::_InitDummyModel()
+{
+	// TODO: The Model could be filled from another thread by 
+	// sending messages which contain collected package information.
+	// The Model could be cached on disk.
+	
+	DepotInfo depot(B_TRANSLATE("Default"));
+
+	PackageInfo wonderbrush(
+		"WonderBrush",
+		"2.1.2",
+		"A vector based graphics editor.",
+		"2.1.2 - Initial Haiku release.");
+	wonderbrush.AddUserRating(
+		UserRating(UserInfo("humdinger"), 4.5f,
+		"Awesome!", "en", "2.1.2")
+	);
+	wonderbrush.AddUserRating(
+		UserRating(UserInfo("bonefish"), 5.0f,
+		"The best!", "en", "2.1.2")
+	);
+	depot.AddPackage(wonderbrush);
+
+	PackageInfo paladin(
+		"Paladin",
+		"1.2.0",
+		"A C/C++ IDE based on Pe.",
+		"");
+	paladin.AddUserRating(
+		UserRating(UserInfo("stippi"), 3.5f,
+		"Could be more integrated from the sounds of it.",
+		"en", "1.2.0")
+	);
+	paladin.AddUserRating(
+		UserRating(UserInfo("mmadia"), 5.0f,
+		"It rocks! Give a try",
+		"en", "1.1.0")
+	);
+	paladin.AddUserRating(
+		UserRating(UserInfo("bonefish"), 2.0f,
+		"It just needs to use my jam-rewrite 'ham' and it will be great.",
+		"en", "1.1.0")
+	);
+	depot.AddPackage(paladin);
+
+	fModel.AddDepot(depot);
+}
diff --git a/src/apps/haiku-depot/MainWindow.h b/src/apps/haiku-depot/MainWindow.h
index f148a7a..f1aff79 100644
--- a/src/apps/haiku-depot/MainWindow.h
+++ b/src/apps/haiku-depot/MainWindow.h
@@ -32,12 +32,15 @@ public:
 
 private:
 			void				_BuildMenu(BMenuBar* menuBar);
+			void				_AdoptModel();
+
+			void				_InitDummyModel();
 
 private:
 			FilterView*			fFilterView;
-			PackageActionsView*	fPackageActionsView;
-			PackageInfoView*	fPackageInfoView;
 			PackageListView*	fPackageListView;
+			PackageInfoView*	fPackageInfoView;
+			PackageActionsView*	fPackageActionsView;
 			BSplitView*			fSplitView;
 
 			Model				fModel;
diff --git a/src/apps/haiku-depot/PackageInfo.cpp b/src/apps/haiku-depot/PackageInfo.cpp
index ef0fac6..10a6724 100644
--- a/src/apps/haiku-depot/PackageInfo.cpp
+++ b/src/apps/haiku-depot/PackageInfo.cpp
@@ -60,19 +60,22 @@ UserInfo::operator!=(const UserInfo& other) const
 UserRating::UserRating()
 	:
 	fUserInfo(),
-	fComment(),
 	fRating(0.0f),
+	fComment(),
+	fLanguage(),
 	fPackageVersion()
 {
 }
 
 
-UserRating::UserRating(const UserInfo& userInfo, const BString& comment,
-		float rating, const BString& packageVersion)
+UserRating::UserRating(const UserInfo& userInfo, float rating,
+		const BString& comment, const BString& language,
+		const BString& packageVersion)
 	:
 	fUserInfo(userInfo),
-	fComment(comment),
 	fRating(rating),
+	fComment(comment),
+	fLanguage(language),
 	fPackageVersion(packageVersion)
 	
 {
@@ -82,8 +85,9 @@ UserRating::UserRating(const UserInfo& userInfo, const BString& comment,
 UserRating::UserRating(const UserRating& other)
 	:
 	fUserInfo(other.fUserInfo),
-	fComment(other.fComment),
 	fRating(other.fRating),
+	fComment(other.fComment),
+	fLanguage(other.fLanguage),
 	fPackageVersion(other.fPackageVersion)
 {
 }
@@ -93,8 +97,9 @@ UserRating&
 UserRating::operator=(const UserRating& other)
 {
 	fUserInfo = other.fUserInfo;
-	fComment = other.fComment;
 	fRating = other.fRating;
+	fComment = other.fComment;
+	fLanguage = other.fLanguage;
 	fPackageVersion = other.fPackageVersion;
 	return *this;
 }
@@ -104,8 +109,9 @@ bool
 UserRating::operator==(const UserRating& other) const
 {
 	return fUserInfo == other.fUserInfo
-		&& fComment == other.fComment
 		&& fRating == other.fRating
+		&& fComment == other.fComment
+		&& fLanguage == other.fLanguage
 		&& fPackageVersion == other.fPackageVersion;
 }
 
diff --git a/src/apps/haiku-depot/PackageInfo.h b/src/apps/haiku-depot/PackageInfo.h
index db5db30..10e3419 100644
--- a/src/apps/haiku-depot/PackageInfo.h
+++ b/src/apps/haiku-depot/PackageInfo.h
@@ -32,7 +32,9 @@ class UserRating {
 public:
 								UserRating();
 								UserRating(const UserInfo& userInfo,
-									const BString& comment, float rating,
+									float rating,
+									const BString& comment,
+									const BString& language,
 									const BString& packageVersion);
 								UserRating(const UserRating& other);
 
@@ -51,8 +53,9 @@ public:
 
 private:
 			UserInfo			fUserInfo;
-			BString				fComment;
 			float				fRating;
+			BString				fComment;
+			BString				fLanguage;
 			BString				fPackageVersion;
 };
 
diff --git a/src/apps/haiku-depot/PackageListView.cpp b/src/apps/haiku-depot/PackageListView.cpp
index 2877d6f..9a92470 100644
--- a/src/apps/haiku-depot/PackageListView.cpp
+++ b/src/apps/haiku-depot/PackageListView.cpp
@@ -171,11 +171,11 @@ PackageColumn::InitTextMargin(BView* parent)
 }
 
 
-// #pragma mark - PackageListView
+// #pragma mark - PackageRow
 
 
 enum {
-	kNameColumn,
+	kTitleColumn,
 	kRatingColumn,
 	kDescriptionColumn,
 	kSizeColumn,
@@ -183,12 +183,44 @@ enum {
 };
 
 
+PackageRow::PackageRow(const PackageInfo& package)
+	:
+	Inherited(),
+	fPackage(package)
+{
+	// Package icon
+
+	BBitmap* icon = NULL;
+	// TODO: Fetch package icon
+
+	SetField(new BBitmapStringField(icon, package.Title()), kTitleColumn);
+
+	// Rating
+	// TODO: Method to compute and cache rating
+	SetField(new BStringField("n/a"), kRatingColumn);
+
+	// Description
+	SetField(new BStringField(package.Description()), kDescriptionColumn);
+
+	// Size
+	// TODO: Store package size
+	SetField(new BStringField("0 KiB"), kSizeColumn);
+
+	// Status
+	// TODO: Fetch info about installed/deactivated/unintalled/...
+	SetField(new BStringField("n/a"), kStatusColumn);
+}
+
+
+// #pragma mark - PackageListView
+
+
 PackageListView::PackageListView()
 	:
 	BColumnListView("package list view", 0, B_FANCY_BORDER, true)
 {
 	AddColumn(new PackageColumn(B_TRANSLATE("Name"), 150, 50, 500,
-		B_TRUNCATE_MIDDLE), kNameColumn);
+		B_TRUNCATE_MIDDLE), kTitleColumn);
 	AddColumn(new PackageColumn(B_TRANSLATE("Rating"), 100, 50, 500,
 		B_TRUNCATE_MIDDLE), kRatingColumn);
 	AddColumn(new PackageColumn(B_TRANSLATE("Description"), 130, 50, 500,
@@ -221,3 +253,43 @@ PackageListView::MessageReceived(BMessage* message)
 			break;
 	}
 }
+
+
+void
+PackageListView::AddPackage(const PackageInfo& package)
+{
+	PackageRow* packageRow = _FindRow(package);
+
+	// forget about it if this package is already in the listview
+	if (packageRow != NULL)
+		return;
+
+	// create the row for this package
+	packageRow = new PackageRow(package);
+
+	// add the row, parent may be NULL (add at top level)
+	AddRow(packageRow);
+
+	// make sure the row is initially expanded
+	ExpandOrCollapse(packageRow, true);
+}
+
+
+PackageRow*
+PackageListView::_FindRow(const PackageInfo& package, PackageRow* parent)
+{
+	for (int32 i = CountRows(parent) - 1; i >= 0; i--) {
+		PackageRow* row = dynamic_cast<PackageRow*>(RowAt(i, parent));
+		if (row != NULL && row->Package() == package)
+			return row;
+		if (CountRows(row) > 0) {
+			// recurse into child rows
+			row = _FindRow(package, row);
+			if (row != NULL)
+				return row;
+		}
+	}
+
+	return NULL;
+}
+
diff --git a/src/apps/haiku-depot/PackageListView.h b/src/apps/haiku-depot/PackageListView.h
index ac23889..cf588f8 100644
--- a/src/apps/haiku-depot/PackageListView.h
+++ b/src/apps/haiku-depot/PackageListView.h
@@ -9,6 +9,8 @@
 #include <ColumnListView.h>
 #include <ColumnTypes.h>
 
+#include "PackageInfo.h"
+
 
 // A field type displaying both a bitmap and a string so that the
 // tree display looks nicer (both text and bitmap are indented)
@@ -55,6 +57,20 @@ private:
 };
 
 
+// BRow for the PartitionListView
+class PackageRow : public BRow {
+	typedef BRow Inherited;
+public:
+								PackageRow(const PackageInfo& package);
+
+			const PackageInfo&	Package() const
+									{ return fPackage; }
+
+private:
+			PackageInfo			fPackage;
+};
+
+
 class PackageListView : public BColumnListView {
 public:
 								PackageListView();
@@ -62,6 +78,12 @@ public:
 
 	virtual void				AttachedToWindow();
 	virtual	void				MessageReceived(BMessage* message);
+
+			void				AddPackage(const PackageInfo& package);
+			
+private:
+			PackageRow*			_FindRow(const PackageInfo& package,
+									PackageRow* parent = NULL);
 };
 
 #endif // PACKAGE_LIST_VIEW_H


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic