Author: bonefish Date: 2009-12-09 00:25:24 +0100 (Wed, 09 Dec 2009) New Revision: 34574 Changeset: http://dev.haiku-os.org/changeset/34574/haiku Modified: haiku/trunk/src/apps/debuganalyzer/gui/ListSelectionModel.cpp haiku/trunk/src/apps/debuganalyzer/gui/ListSelectionModel.h Log: Added copy constructor and assignment operator. Modified: haiku/trunk/src/apps/debuganalyzer/gui/ListSelectionModel.cpp =================================================================== --- haiku/trunk/src/apps/debuganalyzer/gui/ListSelectionModel.cpp 2009-12-08 23:24:58 UTC (rev 34573) +++ haiku/trunk/src/apps/debuganalyzer/gui/ListSelectionModel.cpp 2009-12-08 23:25:24 UTC (rev 34574) @@ -11,12 +11,16 @@ ListSelectionModel::ListSelectionModel() - : - fItemCount(0) { } +ListSelectionModel::ListSelectionModel(const ListSelectionModel& other) +{ + *this = other; +} + + ListSelectionModel::~ListSelectionModel() { } @@ -148,6 +152,24 @@ } +ListSelectionModel& +ListSelectionModel::operator=(const ListSelectionModel& other) +{ + Clear(); + + fSelectedItems = other.fSelectedItems; + + int32 selectedCount = CountSelectedItems(); + if (selectedCount > 0) { + int32 firstSelected = fSelectedItems[0]; + int32 lastSelected = fSelectedItems[selectedCount - 1]; + _NotifyItemsDeselected(firstSelected, lastSelected - firstSelected + 1); + } + + return *this; +} + + int32 ListSelectionModel::_FindItem(int32 itemIndex) const { Modified: haiku/trunk/src/apps/debuganalyzer/gui/ListSelectionModel.h =================================================================== --- haiku/trunk/src/apps/debuganalyzer/gui/ListSelectionModel.h 2009-12-08 23:24:58 UTC (rev 34573) +++ haiku/trunk/src/apps/debuganalyzer/gui/ListSelectionModel.h 2009-12-08 23:25:24 UTC (rev 34574) @@ -19,6 +19,8 @@ public: ListSelectionModel(); + ListSelectionModel( + const ListSelectionModel& other); ~ListSelectionModel(); int32 CountSelectedItems() const @@ -40,6 +42,8 @@ bool AddListener(Listener* listener); void RemoveListener(Listener* listener); + ListSelectionModel& operator=(const ListSelectionModel& other); + private: typedef BObjectList<Listener> ListenerList; @@ -53,7 +57,6 @@ int32 count); private: - int32 fItemCount; Array<int32> fSelectedItems; ListenerList fListeners; };