}
}
-void Dropdown::set_selected_index(int index)
-{
- list.set_selected_index(index);
- if(index<0)
- text.set(string());
-}
-
void Dropdown::rebuild_special(const Part &part)
{
if(part.get_name()=="text")
template<typename T>
void set_item_type() { list.set_item_type<T>(); }
- void set_selected_index(int);
+ void set_selected_index(int i) { list.set_selected_index(i); }
int get_selected_index() const { return list.get_selected_index(); }
private:
if(i>=static_cast<int>(data->size()))
throw out_of_range("List::set_selected_index");
- if(i==sel_index)
+ if(i==sel_index || (i<0 && sel_index<0))
return;
if(sel_index>=0)
items[sel_index]->set_active(false);
if(i<0)
+ {
sel_index = -1;
+ signal_selection_cleared.emit();
+ }
else
{
sel_index = i;
void List::DataObserver::item_removed(unsigned i)
{
+ bool had_selection = (list.sel_index>=0);
if(list.sel_index>static_cast<int>(i))
--list.sel_index;
else if(list.sel_index==static_cast<int>(i))
delete list.items[i];
list.items.erase(list.items.begin()+i);
list.items_changed();
+
+ if(had_selection && list.sel_index<0)
+ list.signal_selection_cleared.emit();
}
void List::DataObserver::cleared()
delete *i;
list.items.clear();
list.items_changed();
+
+ list.signal_selection_cleared.emit();
}
void List::DataObserver::refresh_item(unsigned i)