Added copy constructor and assignment operator.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34574 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2009-12-08 23:25:24 +00:00
parent 2df254bea3
commit 63481b10d3
2 changed files with 28 additions and 3 deletions

View File

@ -11,12 +11,16 @@
ListSelectionModel::ListSelectionModel()
:
fItemCount(0)
{
}
ListSelectionModel::ListSelectionModel(const ListSelectionModel& other)
{
*this = other;
}
ListSelectionModel::~ListSelectionModel()
{
}
@ -148,6 +152,24 @@ ListSelectionModel::RemoveListener(Listener* listener)
}
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
{

View File

@ -19,6 +19,8 @@ public:
public:
ListSelectionModel();
ListSelectionModel(
const ListSelectionModel& other);
~ListSelectionModel();
int32 CountSelectedItems() const
@ -40,6 +42,8 @@ public:
bool AddListener(Listener* listener);
void RemoveListener(Listener* listener);
ListSelectionModel& operator=(const ListSelectionModel& other);
private:
typedef BObjectList<Listener> ListenerList;
@ -53,7 +57,6 @@ private:
int32 count);
private:
int32 fItemCount;
Array<int32> fSelectedItems;
ListenerList fListeners;
};