[Haiku-commits] r31123 - haiku/trunk/src/apps/debuganalyzer/gui/table

bonefish at BerliOS bonefish at mail.berlios.de
Fri Jun 19 23:54:48 CEST 2009


Author: bonefish
Date: 2009-06-19 23:54:48 +0200 (Fri, 19 Jun 2009)
New Revision: 31123
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31123&view=rev

Modified:
   haiku/trunk/src/apps/debuganalyzer/gui/table/Table.cpp
   haiku/trunk/src/apps/debuganalyzer/gui/table/Table.h
Log:
Use a BObjectList instead of a DoublyLinkedList for the TableModelListeners.
Otherwise we can't add a listener to more than one model.


Modified: haiku/trunk/src/apps/debuganalyzer/gui/table/Table.cpp
===================================================================
--- haiku/trunk/src/apps/debuganalyzer/gui/table/Table.cpp	2009-06-19 17:31:24 UTC (rev 31122)
+++ haiku/trunk/src/apps/debuganalyzer/gui/table/Table.cpp	2009-06-19 21:54:48 UTC (rev 31123)
@@ -66,25 +66,26 @@
 }
 
 
-void
+bool
 TableModel::AddListener(TableModelListener* listener)
 {
-	fListeners.Add(listener);
+	return fListeners.AddItem(listener);
 }
 
 
 void
 TableModel::RemoveListener(TableModelListener* listener)
 {
-	fListeners.Remove(listener);
+	fListeners.RemoveItem(listener);
 }
 
 
 void
 TableModel::NotifyRowsAdded(int32 rowIndex, int32 count)
 {
-	for (ListenerList::Iterator it = fListeners.GetIterator();
-			TableModelListener* listener = it.Next();) {
+	int32 listenerCount = fListeners.CountItems();
+	for (int32 i = listenerCount - 1; i >= 0; i--) {
+		TableModelListener* listener = fListeners.ItemAt(i);
 		listener->TableRowsAdded(this, rowIndex, count);
 	}
 }
@@ -93,8 +94,9 @@
 void
 TableModel::NotifyRowsRemoved(int32 rowIndex, int32 count)
 {
-	for (ListenerList::Iterator it = fListeners.GetIterator();
-			TableModelListener* listener = it.Next();) {
+	int32 listenerCount = fListeners.CountItems();
+	for (int32 i = listenerCount - 1; i >= 0; i--) {
+		TableModelListener* listener = fListeners.ItemAt(i);
 		listener->TableRowsRemoved(this, rowIndex, count);
 	}
 }
@@ -103,8 +105,9 @@
 void
 TableModel::NotifyRowsChanged(int32 rowIndex, int32 count)
 {
-	for (ListenerList::Iterator it = fListeners.GetIterator();
-			TableModelListener* listener = it.Next();) {
+	int32 listenerCount = fListeners.CountItems();
+	for (int32 i = listenerCount - 1; i >= 0; i--) {
+		TableModelListener* listener = fListeners.ItemAt(i);
 		listener->TableRowsChanged(this, rowIndex, count);
 	}
 }

Modified: haiku/trunk/src/apps/debuganalyzer/gui/table/Table.h
===================================================================
--- haiku/trunk/src/apps/debuganalyzer/gui/table/Table.h	2009-06-19 17:31:24 UTC (rev 31122)
+++ haiku/trunk/src/apps/debuganalyzer/gui/table/Table.h	2009-06-19 21:54:48 UTC (rev 31123)
@@ -20,7 +20,7 @@
 class TableModel;
 
 
-class TableModelListener : public DoublyLinkedListLinkImpl<TableModelListener> {
+class TableModelListener {
 public:
 	virtual						~TableModelListener();
 
@@ -42,11 +42,11 @@
 	virtual	bool				GetValueAt(int32 rowIndex, int32 columnIndex,
 									Variant& value) = 0;
 
-	virtual	void				AddListener(TableModelListener* listener);
+	virtual	bool				AddListener(TableModelListener* listener);
 	virtual	void				RemoveListener(TableModelListener* listener);
 
 protected:
-			typedef DoublyLinkedList<TableModelListener> ListenerList;
+			typedef BObjectList<TableModelListener> ListenerList;
 
 protected:
 			void				NotifyRowsAdded(int32 rowIndex, int32 count);




More information about the Haiku-commits mailing list