32 #ifndef TBX_VIEWITEMS_H_ 33 #define TBX_VIEWITEMS_H_ 50 std::vector<T> _items;
71 if (_items.size()) v->
inserted(0, _items.size());
78 unsigned int size()
const {
return _items.size();}
87 if (_view) _view->
changed(index,1);
93 const T &
item(
unsigned int index)
const 103 return _items[index];
114 void changing(
unsigned int index,
unsigned int how_many = 1)
116 if (_view) _view->
changing(index, how_many);
127 void changed(
unsigned int index,
unsigned int how_many = 1)
129 if (_view) _view->
changed(index, how_many);
139 _items.push_back(item);
140 if (_view) _view->
inserted(_items.size()-1, 1);
152 if (index == _items.size())
add(item);
155 _items.insert(_items.begin() + index,
item);
156 if (_view) _view->
inserted(index, 1);
165 if (_view) _view->
removing(index, 1);
166 _items.erase(_items.begin() + index);
167 if (_view) _view->
removed(index, 1);
const T & operator[](unsigned int index) const
Get item at specified index.
Definition: viewitems.h:101
A library for creating RISC OS toolbox applications.
Definition: abouttobeshownlistener.cc:34
void insert(unsigned int index, const T &item)
Insert an item in the list.
Definition: viewitems.h:150
void changed(unsigned int index, unsigned int how_many=1)
If the items contain method and fields that can be changed call this function after a change to infor...
Definition: viewitems.h:127
Helper classes to display and edit data.
virtual void cleared()=0
Inform the view that all the data has been cleared.
void add(const T &item)
Add an item to the end of the list.
Definition: viewitems.h:137
const T & item(unsigned int index) const
Get the item at the specified index.
Definition: viewitems.h:93
Base class for views that show an indexed list of items.
Definition: itemview.h:63
unsigned int size() const
Return size of items.
Definition: viewitems.h:78
virtual void removed(unsigned int where, unsigned int how_many)=0
Inform the view that items have been removed.
virtual void changing(unsigned int where, unsigned int how_many)
Inform the view that items are about to be changed.
Definition: itemview.h:235
void view(ItemView *v)
Set view for the items.
Definition: viewitems.h:64
virtual void removing(unsigned int where, unsigned int how_many)
Inform the view that items are about to be removed.
Definition: itemview.h:216
Template class to store a list of items for an item view and to call the item view update routines au...
Definition: viewitems.h:48
void item(unsigned int index, const T &item)
Set the item at a specified index.
Definition: viewitems.h:83
void clear()
Clear the whole list.
Definition: viewitems.h:173
virtual void changed(unsigned int where, unsigned int how_many)=0
Inform the view that items have been changed.
void erase(unsigned int index)
Delete an item from a list.
Definition: viewitems.h:163
void changing(unsigned int index, unsigned int how_many=1)
If the items contain method and fields that can be changed call this function prior to a change to in...
Definition: viewitems.h:114
ViewItems(ItemView *v=0)
Construct the view items.
Definition: viewitems.h:59
virtual void inserted(unsigned int where, unsigned int how_many)=0
Inform the view that items have been inserted.