From ffeb776034ad22566cbc923daac3c349c527346a Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Tue, 23 Apr 2013 23:04:37 +0200 Subject: Fix unsorted filelist problem. --- plugingui/listboxbasic.cc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/plugingui/listboxbasic.cc b/plugingui/listboxbasic.cc index 25cf00d..3d903a4 100644 --- a/plugingui/listboxbasic.cc +++ b/plugingui/listboxbasic.cc @@ -84,16 +84,13 @@ void GUI::ListBoxBasic::addItem(std::string name, std::string value) void GUI::ListBoxBasic::addItems(std::vector &is) { + DEBUG(list, "addItems %d\n", is.size()); std::vector::iterator i = is.begin(); while(i != is.end()) { items.push_back(*i); i++; } - int numitems = height() / (font.textHeight() + padding); - scroll.setRange(numitems); - scroll.setMaximum(items.size()); - // sort for(int x = 0; x < (int)items.size() - 1; x++) { for(int y = 0; y < (int)items.size() - 1; y++) { @@ -110,6 +107,10 @@ void GUI::ListBoxBasic::addItems(std::vector &is) } if(selected == -1) setSelection((int)items.size() - 1); + + int numitems = height() / (font.textHeight() + padding); + scroll.setRange(numitems); + scroll.setMaximum(items.size()); } void GUI::ListBoxBasic::clear() @@ -161,6 +162,7 @@ void GUI::ListBoxBasic::registerValueChangeHandler(void (*handler)(void *), void GUI::ListBoxBasic::repaintEvent(GUI::RepaintEvent *e) { + DEBUG(list, "repaint\n"); GUI::Painter p(this); p.clear(); @@ -175,7 +177,8 @@ void GUI::ListBoxBasic::repaintEvent(GUI::RepaintEvent *e) int yoffset = padding / 2; int skip = scroll.value(); - for(int idx = skip; idx < (int)items.size(); idx++) { + int numitems = height() / (font.textHeight() + padding) + 1; + for(int idx = skip; idx < (int)items.size() && idx < skip + numitems; idx++) { GUI::ListBoxBasic::Item *i = &items[idx]; if(idx == selected) { p.setColour(GUI::Colour(183.0/255.0, 219.0/255.0 , 255.0/255.0, 0.5)); -- cgit v1.2.3