- remember the search type which was used before OpenLP was closed and restore it on startup (Bug #746243)

bzr-revno: 1465
Fixes: https://launchpad.net/bugs/746243
This commit is contained in:
Andreas Preikschat 2011-04-15 22:32:54 +02:00
commit 84fdb9bb0a
4 changed files with 37 additions and 9 deletions

View File

@ -110,6 +110,21 @@ class SearchEdit(QtGui.QLineEdit):
"""
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
self.emit(QtCore.SIGNAL(u'searchTypeChanged(int)'), identifier)
return True
def setSearchTypes(self, items):
"""
A list of tuples to be used in the search type menu. The first item in

View File

@ -99,12 +99,6 @@ class BibleMediaItem(MediaManagerItem):
self.quickSearchEdit = SearchEdit(self.quickTab)
self.quickSearchEdit.setObjectName(u'quickSearchEdit')
self.quickSearchLabel.setBuddy(self.quickSearchEdit)
self.quickSearchEdit.setSearchTypes([
(BibleSearch.Reference, u':/bibles/bibles_search_reference.png',
translate('BiblesPlugin.MediaItem', 'Scripture Reference')),
(BibleSearch.Text, u':/bibles/bibles_search_text.png',
translate('BiblesPlugin.MediaItem', 'Text Search'))
])
self.quickLayout.addRow(self.quickSearchLabel, self.quickSearchEdit)
self.quickLayoutLabel = QtGui.QLabel(self.quickTab)
self.quickLayoutLabel.setObjectName(u'quickClearLabel')
@ -295,7 +289,15 @@ class BibleMediaItem(MediaManagerItem):
self.settingsSection + u'/quick bible', QtCore.QVariant(
self.quickVersionComboBox.currentText())).toString()
find_and_set_in_combo_box(self.quickVersionComboBox, bible)
self.updateAutoCompleter()
self.quickSearchEdit.setSearchTypes([
(BibleSearch.Reference, u':/bibles/bibles_search_reference.png',
translate('BiblesPlugin.MediaItem', 'Scripture Reference')),
(BibleSearch.Text, u':/bibles/bibles_search_text.png',
translate('BiblesPlugin.MediaItem', 'Text Search'))
])
self.quickSearchEdit.setCurrentSearchType(QtCore.QSettings().value(
u'%s/last search type' % self.settingsSection,
QtCore.QVariant(BibleSearch.Reference)).toInt()[0])
self.configUpdated()
log.debug(u'bible manager initialise complete')
@ -386,6 +388,11 @@ class BibleMediaItem(MediaManagerItem):
completion depends on the bible. It is only updated when we are doing a
reference search, otherwise the auto completion list is removed.
"""
# Save the current search type to the configuration.
QtCore.QSettings().setValue(u'%s/last search type' %
self.settingsSection,
QtCore.QVariant(self.quickSearchEdit.currentSearchType()))
# Save the current bible to the configuration.
QtCore.QSettings().setValue(self.settingsSection + u'/quick bible',
QtCore.QVariant(self.quickVersionComboBox.currentText()))
books = []

View File

@ -155,9 +155,17 @@ class SongMediaItem(MediaManagerItem):
SongStrings.Authors),
(SongSearch.Themes, u':/slides/slide_theme.png', UiStrings.Themes)
])
self.searchTextEdit.setCurrentSearchType(QtCore.QSettings().value(
u'%s/last search type' % self.settingsSection,
QtCore.QVariant(SongSearch.Entire)).toInt()[0])
self.configUpdated()
def onSearchTextButtonClick(self):
# Save the current search type to the configuration.
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_results = []
search_type = self.searchTextEdit.currentSearchType()

View File

@ -70,8 +70,6 @@ class SongsPlugin(Plugin):
action_list.add_action(self.SongImportItem, UiStrings.Import)
action_list.add_action(self.SongExportItem, UiStrings.Export)
action_list.add_action(self.toolsReindexItem, UiStrings.Tools)
self.mediaItem.displayResultsSong(
self.manager.get_all_objects(Song, order_by_ref=Song.search_title))
def addImportMenuItem(self, import_menu):
"""