From 14a2e8e4c2c332984bafe52a2a63ccfd52cfe914 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Fri, 15 Apr 2011 14:55:56 +0200 Subject: [PATCH] finished work on restoring current search methods --- openlp/core/lib/searchedit.py | 1 + openlp/plugins/bibles/lib/mediaitem.py | 21 ++++++++++++++------- openlp/plugins/songs/lib/mediaitem.py | 5 ++--- openlp/plugins/songs/songsplugin.py | 2 -- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/openlp/core/lib/searchedit.py b/openlp/core/lib/searchedit.py index 00e0f3ed3..94152ef2f 100644 --- a/openlp/core/lib/searchedit.py +++ b/openlp/core/lib/searchedit.py @@ -122,6 +122,7 @@ class SearchEdit(QtGui.QLineEdit): 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): diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 118bdfc66..241854985 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -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 = [] diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 2ce2478cb..5890fc76d 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -155,14 +155,13 @@ class SongMediaItem(MediaManagerItem): SongStrings.Authors), (SongSearch.Themes, u':/slides/slide_theme.png', UiStrings.Themes) ]) - 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]) + self.configUpdated() def onSearchTextButtonClick(self): - # Save the current search type to the config. so it can be restored. + # Save the current search type to the configuration. QtCore.QSettings().setValue(u'%s/last search type' % self.settingsSection, QtCore.QVariant(self.searchTextEdit.currentSearchType())) diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index af50f3f94..4fc098949 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -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): """