[Haiku-commits] r31087 - in haiku/trunk/src/apps/debugger: . gui/team_window

bonefish at BerliOS bonefish at mail.berlios.de
Wed Jun 17 16:18:55 CEST 2009


Author: bonefish
Date: 2009-06-17 16:18:55 +0200 (Wed, 17 Jun 2009)
New Revision: 31087
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31087&view=rev

Added:
   haiku/trunk/src/apps/debugger/gui/team_window/ImageListView.cpp
   haiku/trunk/src/apps/debugger/gui/team_window/ImageListView.h
Modified:
   haiku/trunk/src/apps/debugger/Jamfile
   haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.cpp
   haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.h
Log:
* Added ImageListView showing the list of images. It will probably eventually
  become a tree view, showing the source files as subitems of the images.
* Added the image list to the team window and changed the layout more towards
  what it's intended to look like.


Modified: haiku/trunk/src/apps/debugger/Jamfile
===================================================================
--- haiku/trunk/src/apps/debugger/Jamfile	2009-06-17 14:09:40 UTC (rev 31086)
+++ haiku/trunk/src/apps/debugger/Jamfile	2009-06-17 14:18:55 UTC (rev 31087)
@@ -28,6 +28,7 @@
 	Variant.cpp
 
 	# gui/team_window
+	ImageListView.cpp
 	TeamWindow.cpp
 	ThreadListView.cpp
 

Added: haiku/trunk/src/apps/debugger/gui/team_window/ImageListView.cpp
===================================================================
--- haiku/trunk/src/apps/debugger/gui/team_window/ImageListView.cpp	2009-06-17 14:09:40 UTC (rev 31086)
+++ haiku/trunk/src/apps/debugger/gui/team_window/ImageListView.cpp	2009-06-17 14:18:55 UTC (rev 31087)
@@ -0,0 +1,244 @@
+/*
+ * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de.
+ * Distributed under the terms of the MIT License.
+ */
+
+#include "ImageListView.h"
+
+#include <stdio.h>
+
+#include <new>
+
+#include <Looper.h>
+#include <Message.h>
+
+#include <AutoLocker.h>
+#include <ObjectList.h>
+
+#include "table/TableColumns.h"
+
+
+enum {
+	MSG_SYNC_IMAGE_LIST	= 'sytl'
+};
+
+
+// #pragma mark - ImagesTableModel
+
+
+class ImageListView::ImagesTableModel : public TableModel {
+public:
+	ImagesTableModel(Team* team)
+		:
+		fTeam(team)
+	{
+		Update();
+	}
+
+	~ImagesTableModel()
+	{
+		fTeam = NULL;
+		Update();
+	}
+
+	bool Update()
+	{
+		if (fTeam == NULL) {
+			for (int32 i = 0; Image* image = fImages.ItemAt(i); i++)
+				image->RemoveReference();
+			fImages.MakeEmpty();
+
+			return true;
+		}
+
+		AutoLocker<Team> locker(fTeam);
+
+		ImageList::ConstIterator it = fTeam->Images().GetIterator();
+		Image* newImage = it.Next();
+		int32 index = 0;
+
+		// remove no longer existing images
+		while (Image* oldImage = fImages.ItemAt(index)) {
+			if (oldImage == newImage) {
+				index++;
+				newImage = it.Next();
+			} else {
+				// TODO: Not particularly efficient!
+				fImages.RemoveItemAt(index);
+				oldImage->RemoveReference();
+				NotifyRowsRemoved(index, 1);
+			}
+		}
+
+		// add new images
+		int32 countBefore = fImages.CountItems();
+		while (newImage != NULL) {
+			if (!fImages.AddItem(newImage))
+				return false;
+
+			newImage->AddReference();
+			newImage = it.Next();
+		}
+
+		int32 count = fImages.CountItems();
+		if (count > countBefore)
+			NotifyRowsAdded(countBefore, count - countBefore);
+
+		return true;
+	}
+
+	virtual int32 CountColumns() const
+	{
+		return 2;
+	}
+
+	virtual int32 CountRows() const
+	{
+		return fImages.CountItems();
+	}
+
+	virtual bool GetValueAt(int32 rowIndex, int32 columnIndex, Variant& value)
+	{
+		Image* image = fImages.ItemAt(rowIndex);
+		if (image == NULL)
+			return false;
+
+		switch (columnIndex) {
+			case 0:
+				value.SetTo(image->ID());
+				return true;
+			case 1:
+				value.SetTo(image->Name(), VARIANT_DONT_COPY_DATA);
+				return true;
+			default:
+				return false;
+		}
+	}
+
+	Image* ImageAt(int32 index) const
+	{
+		return fImages.ItemAt(index);
+	}
+
+private:
+	Team*				fTeam;
+	BObjectList<Image>	fImages;
+};
+
+
+// #pragma mark - ImageListView
+
+
+ImageListView::ImageListView()
+	:
+	BGroupView(B_VERTICAL),
+	fTeam(NULL),
+	fImagesTable(NULL),
+	fImagesTableModel(NULL)
+{
+	SetName("Images");
+}
+
+
+ImageListView::~ImageListView()
+{
+	SetTeam(NULL);
+	fImagesTable->SetTableModel(NULL);
+	delete fImagesTableModel;
+}
+
+
+/*static*/ ImageListView*
+ImageListView::Create()
+{
+	ImageListView* self = new ImageListView;
+
+	try {
+		self->_Init();
+	} catch (...) {
+		delete self;
+		throw;
+	}
+
+	return self;
+}
+
+
+void
+ImageListView::SetTeam(Team* team)
+{
+	if (team == fTeam)
+		return;
+
+	if (fTeam != NULL) {
+		fTeam->RemoveListener(this);
+		fImagesTable->SetTableModel(NULL);
+		delete fImagesTableModel;
+		fImagesTableModel = NULL;
+	}
+
+	fTeam = team;
+
+	if (fTeam != NULL) {
+		fImagesTableModel = new(std::nothrow) ImagesTableModel(fTeam);
+		fImagesTable->SetTableModel(fImagesTableModel);
+		fImagesTable->ResizeAllColumnsToPreferred();
+		fTeam->AddListener(this);
+	}
+}
+
+
+void
+ImageListView::MessageReceived(BMessage* message)
+{
+	switch (message->what) {
+		case MSG_SYNC_IMAGE_LIST:
+			if (fImagesTableModel != NULL)
+				fImagesTableModel->Update();
+			break;
+		default:
+			BGroupView::MessageReceived(message);
+			break;
+	}
+}
+
+
+void
+ImageListView::ImageAdded(Team* team, Image* image)
+{
+	Looper()->PostMessage(MSG_SYNC_IMAGE_LIST, this);
+}
+
+
+void
+ImageListView::ImageRemoved(Team* team, Image* image)
+{
+	Looper()->PostMessage(MSG_SYNC_IMAGE_LIST, this);
+}
+
+
+void
+ImageListView::TableRowInvoked(Table* table, int32 rowIndex)
+{
+//	if (fImagesTableModel != NULL) {
+//		Image* image = fImagesTableModel->ImageAt(rowIndex);
+//		if (image != NULL)
+//			fParent->OpenImageWindow(image);
+//	}
+}
+
+
+void
+ImageListView::_Init()
+{
+	fImagesTable = new Table("images list", 0);
+	AddChild(fImagesTable->ToView());
+	
+	// columns
+	fImagesTable->AddColumn(new Int32TableColumn(0, "ID", 40, 20, 1000,
+		B_TRUNCATE_MIDDLE, B_ALIGN_RIGHT));
+	fImagesTable->AddColumn(new StringTableColumn(1, "Name", 80, 40, 1000,
+		B_TRUNCATE_END, B_ALIGN_LEFT));
+	
+	fImagesTable->AddTableListener(this);
+}

Added: haiku/trunk/src/apps/debugger/gui/team_window/ImageListView.h
===================================================================
--- haiku/trunk/src/apps/debugger/gui/team_window/ImageListView.h	2009-06-17 14:09:40 UTC (rev 31086)
+++ haiku/trunk/src/apps/debugger/gui/team_window/ImageListView.h	2009-06-17 14:18:55 UTC (rev 31087)
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de.
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef IMAGE_LIST_VIEW_H
+#define IMAGE_LIST_VIEW_H
+
+#include <GroupView.h>
+
+#include "table/Table.h"
+#include "Team.h"
+
+
+class ImageListView : public BGroupView, private Team::Listener,
+	private TableListener {
+public:
+								ImageListView();
+								~ImageListView();
+
+	static	ImageListView*		Create();
+									// throws
+
+			void				SetTeam(Team* team);
+
+	virtual	void				MessageReceived(BMessage* message);
+
+private:
+			class ImagesTableModel;
+
+private:
+	// Team::Listener
+	virtual	void				ImageAdded(Team* team, Image* image);
+	virtual	void				ImageRemoved(Team* team, Image* image);
+
+	// TableListener
+	virtual	void				TableRowInvoked(Table* table, int32 rowIndex);
+
+			void				_Init();
+
+private:
+			Team*				fTeam;
+			Table*				fImagesTable;
+			ImagesTableModel*	fImagesTableModel;
+};
+
+
+#endif	// IMAGE_LIST_VIEW_H

Modified: haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.cpp
===================================================================
--- haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.cpp	2009-06-17 14:09:40 UTC (rev 31086)
+++ haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.cpp	2009-06-17 14:18:55 UTC (rev 31087)
@@ -8,7 +8,10 @@
 #include <GroupLayoutBuilder.h>
 #include <Message.h>
 #include <TabView.h>
+#include <SplitView.h>
+#include <TextView.h>
 
+#include "ImageListView.h"
 #include "Team.h"
 #include "ThreadListView.h"
 
@@ -18,12 +21,13 @@
 
 TeamWindow::TeamWindow(::Team* team, Listener* listener)
 	:
-	BWindow(BRect(100, 100, 399, 299), _GetWindowTitle(team).String(),
+	BWindow(BRect(100, 100, 699, 499), _GetWindowTitle(team).String(),
 		B_DOCUMENT_WINDOW, B_ASYNCHRONOUS_CONTROLS),
 	fTeam(team),
 	fListener(listener),
 	fTabView(NULL),
-	fThreadListView(NULL)
+	fThreadListView(NULL),
+	fImageListView(NULL)
 {
 }
 
@@ -83,16 +87,26 @@
 	BGroupLayout* rootLayout = new BGroupLayout(B_VERTICAL);
 	SetLayout(rootLayout);
 
+	BSplitView* mainSplitView = new BSplitView(B_VERTICAL, 3.0f);
+	BGroupLayoutBuilder(rootLayout)
+		.Add(mainSplitView);
+	
 	fTabView = new BTabView("tab view");
+	mainSplitView->AddChild(fTabView, 0.4f);
 
-	BGroupLayoutBuilder(rootLayout)
-		.Add(fTabView);
-
 	fTabView->AddTab(fThreadListView = ThreadListView::Create());
 //	fTabView->AddTab(fTeamsPage = new TeamsPage(this));
 //	fTabView->AddTab(fThreadsPage = new ThreadsPage(this));
 
+	BSplitView* imageAndSourceSplitView = new BSplitView(B_HORIZONTAL, 3.0f);
+	mainSplitView->AddChild(imageAndSourceSplitView);
+
+	fImageListView = ImageListView::Create();
+	imageAndSourceSplitView->AddChild(fImageListView);
+	imageAndSourceSplitView->AddChild(new BTextView("source view"), 2.0f);
+
 	fThreadListView->SetTeam(fTeam);
+	fImageListView->SetTeam(fTeam);
 }
 
 

Modified: haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.h
===================================================================
--- haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.h	2009-06-17 14:09:40 UTC (rev 31086)
+++ haiku/trunk/src/apps/debugger/gui/team_window/TeamWindow.h	2009-06-17 14:18:55 UTC (rev 31087)
@@ -10,6 +10,7 @@
 
 
 class BTabView;
+class ImageListView;
 class Team;
 class ThreadListView;
 
@@ -37,6 +38,7 @@
 			Listener*			fListener;
 			BTabView*			fTabView;
 			ThreadListView*		fThreadListView;
+			ImageListView*		fImageListView;
 };
 
 




More information about the Haiku-commits mailing list