aboutsummaryrefslogtreecommitdiff
path: root/gui/ListWidget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gui/ListWidget.cpp')
-rw-r--r--gui/ListWidget.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/gui/ListWidget.cpp b/gui/ListWidget.cpp
index 8e5ef99f06..b96019af04 100644
--- a/gui/ListWidget.cpp
+++ b/gui/ListWidget.cpp
@@ -122,7 +122,12 @@ void ListWidget::setList(const StringList &list) {
if (_editMode && _caretVisible)
drawCaret(true);
int size = list.size();
+ _dataList = list;
+
+ // Copy everything
_list = list;
+ _filter = "";
+
if (_currentPos >= size)
_currentPos = size - 1;
if (_currentPos < 0)
@@ -134,6 +139,7 @@ void ListWidget::setList(const StringList &list) {
}
void ListWidget::append(const String &s) {
+ _dataList.push_back(s);
_list.push_back(s);
scrollBarRecalc();
}
@@ -529,4 +535,35 @@ void ListWidget::reflowLayout() {
}
}
+void ListWidget::setFilter(const String &filter) {
+ String filt;
+
+ filt = filter;
+
+ filt.toLowercase();
+ _filter = filt;
+
+ if (_filter == "") {
+ _list = _dataList;
+ } else {
+ String tmp;
+
+ _list.clear();
+
+ for (StringList::iterator i = _dataList.begin(); i != _dataList.end(); ++i) {
+ tmp = *i;
+ tmp.toLowercase();
+ if (tmp.contains(_filter.c_str())) {
+ _list.push_back(*i);
+ }
+ }
+ }
+
+ _currentPos = 0;
+ _selectedItem = -1;
+ scrollBarRecalc();
+
+ draw();
+}
+
} // End of namespace GUI