X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flist.cpp;h=7227f0c59f6cd971ec330f6de266b84d8ecadc82;hb=8716fc73506869a7b1b435819428470d8eafd0fa;hp=b969ec038994bbe9d9609bf558b4d0b732e57ca4;hpb=d2d5b4c4dedf90a42dd2baff8334318b1d000f64;p=libs%2Fgltk.git diff --git a/source/list.cpp b/source/list.cpp index b969ec0..7227f0c 100644 --- a/source/list.cpp +++ b/source/list.cpp @@ -82,6 +82,17 @@ void List::set_data(ListData &d) own_data = false; observer = new DataObserver(*this); + for(vector::iterator i=items.begin(); i!=items.end(); ++i) + delete *i; + items.clear(); + unsigned n_items = data->size(); + for(unsigned i=0; istatic_cast(data->size())) + if(i>=static_cast(data->size())) throw out_of_range("List::set_selected_index"); if(sel_index>=0) items[sel_index]->set_active(false); if(i<0) sel_index = -1; - else + else if(i!=sel_index) { sel_index = i; items[sel_index]->set_active(true); @@ -264,7 +275,7 @@ List::DataObserver::DataObserver(List &l): list.data->signal_item_added.connect(sigc::mem_fun(this, &DataObserver::item_added)); list.data->signal_item_removed.connect(sigc::mem_fun(this, &DataObserver::item_removed)); list.data->signal_cleared.connect(sigc::mem_fun(this, &DataObserver::cleared)); - list.data->signal_refresh_strings.connect(sigc::mem_fun(this, &DataObserver::refresh_strings)); + list.data->signal_refresh_item.connect(sigc::mem_fun(this, &DataObserver::refresh_item)); } void List::DataObserver::item_added(unsigned i) @@ -299,8 +310,10 @@ void List::DataObserver::cleared() list.items_changed(); } -void List::DataObserver::refresh_strings() +void List::DataObserver::refresh_item(unsigned i) { + delete list.items[i]; + list.items[i] = list.create_item(i); list.items_changed(); } @@ -358,6 +371,7 @@ List::Loader::Loader(List &l): DataFile::DerivedObjectLoader(l) { add("item", &Loader::item); + add("view_size", &List::view_size); } void List::Loader::item(const string &v)