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)
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();
}
void item_added(unsigned);
void item_removed(unsigned);
void cleared();
- void refresh_strings();
+ void refresh_item(unsigned);
};
protected:
#ifndef MSP_GLTK_LISTDATA_H_
#define MSP_GLTK_LISTDATA_H_
+#include <stdexcept>
#include <string>
#include <vector>
#include <sigc++/signal.h>
sigc::signal<void, unsigned> signal_item_added;
sigc::signal<void, unsigned> signal_item_removed;
sigc::signal<void> signal_cleared;
- sigc::signal<void> signal_refresh_strings;
+ sigc::signal<void, unsigned> signal_refresh_item;
protected:
ListData() { }
virtual unsigned size() const = 0;
virtual std::string get_string(unsigned) const = 0;
- void refresh_strings() const { signal_refresh_strings.emit(); }
+ void refresh(unsigned i) const
+ {
+ if(i>=size())
+ throw std::out_of_range("ListData::refresh");
+ signal_refresh_item.emit(i);
+ }
};
template<typename T>
return -1;
}
+ using ListData::refresh;
+ void refresh(const T &v) const
+ {
+ int i = find(v);
+ if(i>=0)
+ signal_refresh_item.emit(i);
+ }
+
void remove(unsigned i)
{
if(i>=items.size())