← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~googol-hush/openlp/tweaks into lp:openlp

 

Andreas Preikschat has proposed merging lp:~googol-hush/openlp/tweaks into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)
Related bugs:
  Bug #746243 in OpenLP: "Default song search type setting"
  https://bugs.launchpad.net/openlp/+bug/746243

For more details, see:
https://code.launchpad.net/~googol-hush/openlp/tweaks/+merge/57867

Hello,

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

(For bibles and songs)
-- 
https://code.launchpad.net/~googol-hush/openlp/tweaks/+merge/57867
Your team OpenLP Core is requested to review the proposed merge of lp:~googol-hush/openlp/tweaks into lp:openlp.
=== modified file 'openlp/core/lib/searchedit.py'
--- openlp/core/lib/searchedit.py	2011-04-04 16:15:38 +0000
+++ openlp/core/lib/searchedit.py	2011-04-15 12:58:31 +0000
@@ -110,6 +110,21 @@
         """
         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

=== modified file 'openlp/plugins/bibles/lib/mediaitem.py'
--- openlp/plugins/bibles/lib/mediaitem.py	2011-04-13 18:18:25 +0000
+++ openlp/plugins/bibles/lib/mediaitem.py	2011-04-15 12:58:31 +0000
@@ -99,12 +99,6 @@
         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 @@
             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 @@
         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 = []

=== modified file 'openlp/plugins/songs/lib/mediaitem.py'
--- openlp/plugins/songs/lib/mediaitem.py	2011-04-10 18:44:27 +0000
+++ openlp/plugins/songs/lib/mediaitem.py	2011-04-15 12:58:31 +0000
@@ -155,9 +155,17 @@
                 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()

=== modified file 'openlp/plugins/songs/songsplugin.py'
--- openlp/plugins/songs/songsplugin.py	2011-04-09 16:11:02 +0000
+++ openlp/plugins/songs/songsplugin.py	2011-04-15 12:58:31 +0000
@@ -70,8 +70,6 @@
         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):
         """


Follow ups