started to implement #746243

Fixes: https://launchpad.net/bugs/746243
This commit is contained in:
Andreas Preikschat 2011-04-14 23:32:21 +02:00
parent 3c8b6d5467
commit 77559e0210
2 changed files with 23 additions and 0 deletions

View File

@ -110,6 +110,20 @@ class SearchEdit(QtGui.QLineEdit):
""" """
return self._currentSearchType return self._currentSearchType
def setCurrentSearchType(self, identifier):
"""
Set a new current search type.
``identifier``
The search type identifier (int).
"""
menu = self.menuButton.menu()
for action in menu.actions():
if identifier == action.data().toInt()[0]:
self.menuButton.setDefaultAction(action)
self._currentSearchType = identifier
return True
def setSearchTypes(self, items): def setSearchTypes(self, items):
""" """
A list of tuples to be used in the search type menu. The first item in A list of tuples to be used in the search type menu. The first item in

View File

@ -156,8 +156,17 @@ class SongMediaItem(MediaManagerItem):
(SongSearch.Themes, u':/slides/slide_theme.png', UiStrings.Themes) (SongSearch.Themes, u':/slides/slide_theme.png', UiStrings.Themes)
]) ])
self.configUpdated() self.configUpdated()
# FIXME: Saved search type need to be considered when loading the list.
self.searchTextEdit.setCurrentSearchType(QtCore.QSettings().value(
u'%s/last search type' % self.settingsSection,
QtCore.QVariant(SongSearch.Entire)).toInt()[0])
def onSearchTextButtonClick(self): def onSearchTextButtonClick(self):
# Save the current search type to the config. so it can be restored.
QtCore.QSettings().setValue(u'%s/last search type' %
self.settingsSection,
QtCore.QVariant(self.searchTextEdit.currentSearchType()))
# Reload the list considering the new search type.
search_keywords = unicode(self.searchTextEdit.displayText()) search_keywords = unicode(self.searchTextEdit.displayText())
search_results = [] search_results = []
search_type = self.searchTextEdit.currentSearchType() search_type = self.searchTextEdit.currentSearchType()