aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Sandulenko2009-06-06 17:54:59 +0000
committerEugene Sandulenko2009-06-06 17:54:59 +0000
commitf6d06085d5b7e4723117147d84eec477c0b6f9db (patch)
tree5950ccc2e6fc7bc8d87ca0cdb56d6ae919439cb8
parent020450465d72cc9c97aa9d9b145ed56984becd9f (diff)
downloadscummvm-rg350-f6d06085d5b7e4723117147d84eec477c0b6f9db.tar.gz
scummvm-rg350-f6d06085d5b7e4723117147d84eec477c0b6f9db.tar.bz2
scummvm-rg350-f6d06085d5b7e4723117147d84eec477c0b6f9db.zip
Fix item selection on filtered out list in launcher
svn-id: r41271
-rw-r--r--gui/ListWidget.cpp19
-rw-r--r--gui/ListWidget.h5
2 files changed, 18 insertions, 6 deletions
diff --git a/gui/ListWidget.cpp b/gui/ListWidget.cpp
index 10e2bc53c3..22a9081d89 100644
--- a/gui/ListWidget.cpp
+++ b/gui/ListWidget.cpp
@@ -129,6 +129,7 @@ void ListWidget::setList(const StringList &list) {
// Copy everything
_list = list;
_filter = "";
+ setFilter(_filter, false);
if (_currentPos >= size)
_currentPos = size - 1;
@@ -143,6 +144,9 @@ void ListWidget::setList(const StringList &list) {
void ListWidget::append(const String &s) {
_dataList.push_back(s);
_list.push_back(s);
+
+ setFilter(_filter, false);
+
scrollBarRecalc();
}
@@ -538,7 +542,7 @@ void ListWidget::reflowLayout() {
}
}
-void ListWidget::setFilter(const String &filter) {
+void ListWidget::setFilter(const String &filter, bool redraw) {
String filt;
filt = filter;
@@ -550,23 +554,30 @@ void ListWidget::setFilter(const String &filter) {
_list = _dataList;
} else {
String tmp;
+ int n = 0;
_list.clear();
+
+ _listIndex.clear();
- for (StringList::iterator i = _dataList.begin(); i != _dataList.end(); ++i) {
+ for (StringList::iterator i = _dataList.begin(); i != _dataList.end(); ++i, n++) {
tmp = *i;
tmp.toLowercase();
if (tmp.contains(_filter.c_str())) {
_list.push_back(*i);
+ _listIndex.push_back(n);
}
}
}
_currentPos = 0;
_selectedItem = -1;
- scrollBarRecalc();
- draw();
+ if (redraw) {
+ scrollBarRecalc();
+
+ draw();
+ }
}
} // End of namespace GUI
diff --git a/gui/ListWidget.h b/gui/ListWidget.h
index aac853111f..69f309b970 100644
--- a/gui/ListWidget.h
+++ b/gui/ListWidget.h
@@ -54,6 +54,7 @@ public:
protected:
StringList _list;
StringList _dataList;
+ Common::Array<int> _listIndex;
bool _editable;
bool _editMode;
NumberingMode _numberingMode;
@@ -89,7 +90,7 @@ public:
void setList(const StringList &list);
void append(const String &s);
const StringList &getList() const { return _dataList; }
- int getSelected() const { return _selectedItem; }
+ int getSelected() const { return (_filter == "" || _selectedItem == -1) ? _selectedItem : _listIndex[_selectedItem]; }
void setSelected(int item);
const String &getSelectedString() const { return _list[_selectedItem]; }
void setNumberingMode(NumberingMode numberingMode) { _numberingMode = numberingMode; }
@@ -100,7 +101,7 @@ public:
void enableQuickSelect(bool enable) { _quickSelect = enable; }
String getQuickSelectString() const { return _quickSelectStr; }
- void setFilter(const String &filter);
+ void setFilter(const String &filter, bool redraw = true);
virtual void handleTickle();
virtual void handleMouseDown(int x, int y, int button, int clickCount);