[Scummvm-cvs-logs] SF.net SVN: scummvm:[41271] scummvm/trunk/gui

sev at users.sourceforge.net sev at users.sourceforge.net
Sat Jun 6 19:54:59 CEST 2009


Revision: 41271
          http://scummvm.svn.sourceforge.net/scummvm/?rev=41271&view=rev
Author:   sev
Date:     2009-06-06 17:54:59 +0000 (Sat, 06 Jun 2009)

Log Message:
-----------
Fix item selection on filtered out list in launcher

Modified Paths:
--------------
    scummvm/trunk/gui/ListWidget.cpp
    scummvm/trunk/gui/ListWidget.h

Modified: scummvm/trunk/gui/ListWidget.cpp
===================================================================
--- scummvm/trunk/gui/ListWidget.cpp	2009-06-06 17:54:43 UTC (rev 41270)
+++ scummvm/trunk/gui/ListWidget.cpp	2009-06-06 17:54:59 UTC (rev 41271)
@@ -129,6 +129,7 @@
 	// Copy everything
 	_list = list;
 	_filter = "";
+	setFilter(_filter, false);
 
 	if (_currentPos >= size)
 		_currentPos = size - 1;
@@ -143,6 +144,9 @@
 void ListWidget::append(const String &s) {
 	_dataList.push_back(s);
 	_list.push_back(s);
+
+	setFilter(_filter, false);
+
 	scrollBarRecalc();
 }
 
@@ -538,7 +542,7 @@
 	}
 }
 
-void ListWidget::setFilter(const String &filter) {
+void ListWidget::setFilter(const String &filter, bool redraw) {
 	String filt;
 
 	filt = filter;
@@ -550,23 +554,30 @@
 		_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

Modified: scummvm/trunk/gui/ListWidget.h
===================================================================
--- scummvm/trunk/gui/ListWidget.h	2009-06-06 17:54:43 UTC (rev 41270)
+++ scummvm/trunk/gui/ListWidget.h	2009-06-06 17:54:59 UTC (rev 41271)
@@ -54,6 +54,7 @@
 protected:
 	StringList		_list;
 	StringList		_dataList;
+	Common::Array<int>		_listIndex;
 	bool			_editable;
 	bool			_editMode;
 	NumberingMode	_numberingMode;
@@ -89,7 +90,7 @@
 	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 @@
 	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);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list