← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~trb143/openlp/bugs into lp:openlp

 

Tim Bentley has proposed merging lp:~trb143/openlp/bugs into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)


Add Autocompletion to the Songs Dialog
Fix up some lost and confused Camels 
-- 
https://code.launchpad.net/~trb143/openlp/bugs/+merge/43461
Your team OpenLP Core is requested to review the proposed merge of lp:~trb143/openlp/bugs into lp:openlp.
=== modified file 'openlp/core/lib/plugin.py'
--- openlp/core/lib/plugin.py	2010-10-07 17:52:40 +0000
+++ openlp/core/lib/plugin.py	2010-12-12 08:41:34 +0000
@@ -108,7 +108,7 @@
     """
     log.info(u'loaded')
 
-    def __init__(self, name, version=None, plugin_helpers=None):
+    def __init__(self, name, version=None, pluginHelpers=None):
         """
         This is the constructor for the plugin object. This provides an easy
         way for descendent plugins to populate common data. This method *must*
@@ -124,7 +124,7 @@
         ``version``
             Defaults to *None*. The version of the plugin.
 
-        ``plugin_helpers``
+        ``pluginHelpers``
             Defaults to *None*. A list of helper objects.
         """
         QtCore.QObject.__init__(self)
@@ -139,14 +139,14 @@
         self.status = PluginStatus.Inactive
         # Set up logging
         self.log = logging.getLogger(self.name)
-        self.previewController = plugin_helpers[u'preview']
-        self.liveController = plugin_helpers[u'live']
-        self.renderManager = plugin_helpers[u'render']
-        self.serviceManager = plugin_helpers[u'service']
-        self.settingsForm = plugin_helpers[u'settings form']
-        self.mediadock = plugin_helpers[u'toolbox']
-        self.pluginManager = plugin_helpers[u'pluginmanager']
-        self.formparent = plugin_helpers[u'formparent']
+        self.previewController = pluginHelpers[u'preview']
+        self.liveController = pluginHelpers[u'live']
+        self.renderManager = pluginHelpers[u'render']
+        self.serviceManager = pluginHelpers[u'service']
+        self.settingsForm = pluginHelpers[u'settings form']
+        self.mediadock = pluginHelpers[u'toolbox']
+        self.pluginManager = pluginHelpers[u'pluginmanager']
+        self.formparent = pluginHelpers[u'formparent']
         QtCore.QObject.connect(Receiver.get_receiver(),
             QtCore.SIGNAL(u'%s_add_service_item' % self.name),
             self.processAddServiceEvent)

=== modified file 'openlp/core/ui/mainwindow.py'
--- openlp/core/ui/mainwindow.py	2010-12-02 14:37:38 +0000
+++ openlp/core/ui/mainwindow.py	2010-12-12 08:41:34 +0000
@@ -97,16 +97,16 @@
         self.ControlSplitter.setObjectName(u'ControlSplitter')
         self.MainContentLayout.addWidget(self.ControlSplitter)
         # Create slide controllers
-        self.PreviewController = SlideController(self, self.settingsmanager,
+        self.previewController = SlideController(self, self.settingsmanager,
             self.screens)
-        self.LiveController = SlideController(self, self.settingsmanager,
+        self.liveController = SlideController(self, self.settingsmanager,
             self.screens, True)
         previewVisible = QtCore.QSettings().value(
             u'user interface/preview panel', QtCore.QVariant(True)).toBool()
-        self.PreviewController.Panel.setVisible(previewVisible)
+        self.previewController.Panel.setVisible(previewVisible)
         liveVisible = QtCore.QSettings().value(u'user interface/live panel',
             QtCore.QVariant(True)).toBool()
-        self.LiveController.Panel.setVisible(liveVisible)
+        self.liveController.Panel.setVisible(liveVisible)
         # Create menu
         self.MenuBar = QtGui.QMenuBar(MainWindow)
         self.MenuBar.setGeometry(QtCore.QRect(0, 0, 1087, 27))
@@ -362,8 +362,8 @@
         """
         Splitter between the Preview and Live Controllers.
         """
-        self.LiveController.widthChanged()
-        self.PreviewController.widthChanged()
+        self.liveController.widthChanged()
+        self.previewController.widthChanged()
 
     def retranslateUi(self, MainWindow):
         """
@@ -548,8 +548,8 @@
         self.recentFiles = QtCore.QStringList()
         # Set up the path with plugins
         pluginpath = AppLocation.get_directory(AppLocation.PluginsDir)
-        self.plugin_manager = PluginManager(pluginpath)
-        self.plugin_helpers = {}
+        self.pluginManager = PluginManager(pluginpath)
+        self.pluginHelpers = {}
         # Set up the interface
         self.setupUi(self)
         # Load settings after setupUi so default UI sizes are overwritten
@@ -633,33 +633,33 @@
         self.mediaDockManager = MediaDockManager(self.MediaToolBox)
         log.info(u'Load Plugins')
         # make the controllers available to the plugins
-        self.plugin_helpers[u'preview'] = self.PreviewController
-        self.plugin_helpers[u'live'] = self.LiveController
-        self.plugin_helpers[u'render'] = self.renderManager
-        self.plugin_helpers[u'service'] = self.ServiceManagerContents
-        self.plugin_helpers[u'settings form'] = self.settingsForm
-        self.plugin_helpers[u'toolbox'] = self.mediaDockManager
-        self.plugin_helpers[u'pluginmanager'] = self.plugin_manager
-        self.plugin_helpers[u'formparent'] = self
-        self.plugin_manager.find_plugins(pluginpath, self.plugin_helpers)
+        self.pluginHelpers[u'preview'] = self.previewController
+        self.pluginHelpers[u'live'] = self.liveController
+        self.pluginHelpers[u'render'] = self.renderManager
+        self.pluginHelpers[u'service'] = self.ServiceManagerContents
+        self.pluginHelpers[u'settings form'] = self.settingsForm
+        self.pluginHelpers[u'toolbox'] = self.mediaDockManager
+        self.pluginHelpers[u'pluginmanager'] = self.pluginManager
+        self.pluginHelpers[u'formparent'] = self
+        self.pluginManager.find_plugins(pluginpath, self.pluginHelpers)
         # hook methods have to happen after find_plugins. Find plugins needs
         # the controllers hence the hooks have moved from setupUI() to here
         # Find and insert settings tabs
         log.info(u'hook settings')
-        self.plugin_manager.hook_settings_tabs(self.settingsForm)
+        self.pluginManager.hook_settings_tabs(self.settingsForm)
         # Find and insert media manager items
         log.info(u'hook media')
-        self.plugin_manager.hook_media_manager(self.mediaDockManager)
+        self.pluginManager.hook_media_manager(self.mediaDockManager)
         # Call the hook method to pull in import menus.
         log.info(u'hook menus')
-        self.plugin_manager.hook_import_menu(self.FileImportMenu)
+        self.pluginManager.hook_import_menu(self.FileImportMenu)
         # Call the hook method to pull in export menus.
-        self.plugin_manager.hook_export_menu(self.FileExportMenu)
+        self.pluginManager.hook_export_menu(self.FileExportMenu)
         # Call the hook method to pull in tools menus.
-        self.plugin_manager.hook_tools_menu(self.ToolsMenu)
+        self.pluginManager.hook_tools_menu(self.ToolsMenu)
         # Call the initialise method to setup plugins.
         log.info(u'initialise plugins')
-        self.plugin_manager.initialise_plugins()
+        self.pluginManager.initialise_plugins()
         # Once all components are initialised load the Themes
         log.info(u'Load Themes')
         self.ThemeManagerContents.loadThemes()
@@ -695,10 +695,10 @@
         Show the main form, as well as the display form
         """
         QtGui.QWidget.show(self)
-        self.LiveController.display.setup()
-        self.PreviewController.display.setup()
-        if self.LiveController.display.isVisible():
-            self.LiveController.display.setFocus()
+        self.liveController.display.setup()
+        self.previewController.display.setup()
+        if self.liveController.display.isVisible():
+            self.liveController.display.setFocus()
         self.activateWindow()
         if QtCore.QSettings().value(
             self.generalSettingsSection + u'/auto open',
@@ -723,7 +723,7 @@
         settings = QtCore.QSettings()
         if settings.value(u'%s/screen blank' % self.generalSettingsSection,
             QtCore.QVariant(False)).toBool():
-            self.LiveController.mainDisplaySetBackground()
+            self.liveController.mainDisplaySetBackground()
             if settings.value(u'blank warning',
                 QtCore.QVariant(False)).toBool():
                 QtGui.QMessageBox.question(self,
@@ -852,11 +852,11 @@
                 QtCore.QVariant(self.MediaToolBox.currentIndex()))
         # Call the cleanup method to shutdown plugins.
         log.info(u'cleanup plugins')
-        self.plugin_manager.finalise_plugins()
+        self.pluginManager.finalise_plugins()
         # Save settings
         self.saveSettings()
         # Close down the display
-        self.LiveController.display.close()
+        self.liveController.display.close()
 
     def serviceChanged(self, reset=False, serviceName=None):
         """
@@ -910,7 +910,7 @@
                 True - Visible
                 False - Hidden
         """
-        self.PreviewController.Panel.setVisible(visible)
+        self.previewController.Panel.setVisible(visible)
         QtCore.QSettings().setValue(u'user interface/preview panel',
             QtCore.QVariant(visible))
         self.ViewPreviewPanel.setChecked(visible)
@@ -925,7 +925,7 @@
                 True - Visible
                 False - Hidden
         """
-        self.LiveController.Panel.setVisible(visible)
+        self.liveController.Panel.setVisible(visible)
         QtCore.QSettings().setValue(u'user interface/live panel',
             QtCore.QVariant(visible))
         self.ViewLivePanel.setChecked(visible)

=== modified file 'openlp/core/ui/pluginform.py'
--- openlp/core/ui/pluginform.py	2010-11-03 18:03:28 +0000
+++ openlp/core/ui/pluginform.py	2010-12-12 08:41:34 +0000
@@ -61,7 +61,7 @@
         self.programaticChange = True
         self._clearDetails()
         self.programaticChange = True
-        for plugin in self.parent.plugin_manager.plugins:
+        for plugin in self.parent.pluginManager.plugins:
             item = QtGui.QListWidgetItem(self.pluginListWidget)
             # We do this just to make 100% sure the status is an integer as
             # sometimes when it's loaded from the config, it isn't cast to int.
@@ -110,7 +110,7 @@
         plugin_name_plural = \
             self.pluginListWidget.currentItem().text().split(u' ')[0]
         self.activePlugin = None
-        for plugin in self.parent.plugin_manager.plugins:
+        for plugin in self.parent.pluginManager.plugins:
             name_string = plugin.getString(StringContent.Name)
             if name_string[u'plural'] == plugin_name_plural:
                 self.activePlugin = plugin

=== modified file 'openlp/core/ui/servicemanager.py'
--- openlp/core/ui/servicemanager.py	2010-12-03 18:56:12 +0000
+++ openlp/core/ui/servicemanager.py	2010-12-12 08:41:34 +0000
@@ -880,7 +880,7 @@
                 newItem.merge(item[u'service_item'])
                 item[u'service_item'] = newItem
                 self.repaintServiceList(itemcount + 1, 0)
-                self.parent.LiveController.replaceServiceManagerItem(newItem)
+                self.parent.liveController.replaceServiceManagerItem(newItem)
         self.parent.serviceChanged(False, self.serviceName)
 
     def addServiceItem(self, item, rebuild=False, expand=None, replace=False):
@@ -902,7 +902,7 @@
             item.merge(self.serviceItems[sitem][u'service_item'])
             self.serviceItems[sitem][u'service_item'] = item
             self.repaintServiceList(sitem + 1, 0)
-            self.parent.LiveController.replaceServiceManagerItem(item)
+            self.parent.liveController.replaceServiceManagerItem(item)
         else:
             # nothing selected for dnd
             if self.droppos == 0:
@@ -923,7 +923,7 @@
                 self.repaintServiceList(self.droppos, 0)
             # if rebuilding list make sure live is fixed.
             if rebuild:
-                self.parent.LiveController.replaceServiceManagerItem(item)
+                self.parent.liveController.replaceServiceManagerItem(item)
         self.droppos = 0
         self.parent.serviceChanged(False, self.serviceName)
 
@@ -933,7 +933,7 @@
         """
         item, count = self.findServiceItem()
         if self.serviceItems[item][u'service_item'].is_valid:
-            self.parent.PreviewController.addServiceManagerItem(
+            self.parent.previewController.addServiceManagerItem(
                 self.serviceItems[item][u'service_item'], count)
         else:
             QtGui.QMessageBox.critical(self,
@@ -957,7 +957,7 @@
         """
         item, count = self.findServiceItem()
         if self.serviceItems[item][u'service_item'].is_valid:
-            self.parent.LiveController.addServiceManagerItem(
+            self.parent.liveController.addServiceManagerItem(
                 self.serviceItems[item][u'service_item'], count)
             if QtCore.QSettings().value(
                 self.parent.generalSettingsSection + u'/auto preview',
@@ -966,9 +966,9 @@
                 if self.serviceItems and item < len(self.serviceItems) and \
                     self.serviceItems[item][u'service_item'].is_capable(
                     ItemCapabilities.AllowsPreview):
-                    self.parent.PreviewController.addServiceManagerItem(
+                    self.parent.previewController.addServiceManagerItem(
                         self.serviceItems[item][u'service_item'], 0)
-                    self.parent.LiveController.PreviewListWidget.setFocus()
+                    self.parent.liveController.PreviewListWidget.setFocus()
         else:
             QtGui.QMessageBox.critical(self,
                 translate('OpenLP.ServiceManager', 'Missing Display Handler'),

=== modified file 'openlp/core/ui/slidecontroller.py'
--- openlp/core/ui/slidecontroller.py	2010-12-03 18:56:12 +0000
+++ openlp/core/ui/slidecontroller.py	2010-12-12 08:41:34 +0000
@@ -957,7 +957,7 @@
         """
         row = self.PreviewListWidget.currentRow()
         if row > -1 and row < self.PreviewListWidget.rowCount():
-            self.parent.LiveController.addServiceManagerItem(
+            self.parent.liveController.addServiceManagerItem(
                 self.serviceItem, row)
 
     def onMediaStart(self, item):

=== modified file 'openlp/core/ui/thememanager.py'
--- openlp/core/ui/thememanager.py	2010-12-06 23:28:01 +0000
+++ openlp/core/ui/thememanager.py	2010-12-12 08:41:34 +0000
@@ -310,7 +310,7 @@
                     translate('OpenLP.ThemeManager',
                         'You are unable to delete the default theme.'))
             else:
-                for plugin in self.parent.plugin_manager.plugins:
+                for plugin in self.parent.pluginManager.plugins:
                     if plugin.usesTheme(theme):
                         QtGui.QMessageBox.critical(self,
                             translate('OpenLP.ThemeManager', 'Error'),
@@ -663,7 +663,7 @@
                     (QtGui.QMessageBox.Yes | QtGui.QMessageBox.No),
                     QtGui.QMessageBox.No)
             if self.saveThemeName != u'':
-                for plugin in self.parent.plugin_manager.plugins:
+                for plugin in self.parent.pluginManager.plugins:
                     if plugin.usesTheme(self.saveThemeName):
                         plugin.renameTheme(self.saveThemeName, name)
                 if unicode(self.serviceComboBox.currentText()) == name:

=== modified file 'openlp/plugins/songs/forms/editsongform.py'
--- openlp/plugins/songs/forms/editsongform.py	2010-12-08 08:25:28 +0000
+++ openlp/plugins/songs/forms/editsongform.py	2010-12-12 08:41:34 +0000
@@ -120,35 +120,55 @@
             order_by_ref=Author.display_name)
         self.AuthorsSelectionComboItem.clear()
         self.AuthorsSelectionComboItem.addItem(u'')
+        self.authors = []
         for author in authors:
             row = self.AuthorsSelectionComboItem.count()
             self.AuthorsSelectionComboItem.addItem(author.display_name)
             self.AuthorsSelectionComboItem.setItemData(
                 row, QtCore.QVariant(author.id))
+            self.authors.append(author.display_name)
+        completer = QtGui.QCompleter(self.authors)
+        completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive)
+        self.AuthorsSelectionComboItem.setCompleter(completer)
 
     def loadTopics(self):
         topics = self.manager.get_all_objects(Topic, order_by_ref=Topic.name)
         self.SongTopicCombo.clear()
         self.SongTopicCombo.addItem(u'')
+        self.topics = []
         for topic in topics:
             row = self.SongTopicCombo.count()
             self.SongTopicCombo.addItem(topic.name)
+            self.topics.append(topic.name)
             self.SongTopicCombo.setItemData(row, QtCore.QVariant(topic.id))
+        completer = QtGui.QCompleter(self.topics)
+        completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive)
+        self.SongTopicCombo.setCompleter(completer)
 
     def loadBooks(self):
         books = self.manager.get_all_objects(Book, order_by_ref=Book.name)
         self.SongbookCombo.clear()
         self.SongbookCombo.addItem(u'')
+        self.books = []
         for book in books:
             row = self.SongbookCombo.count()
             self.SongbookCombo.addItem(book.name)
+            self.books.append(book.name)
             self.SongbookCombo.setItemData(row, QtCore.QVariant(book.id))
+        completer = QtGui.QCompleter(self.books)
+        completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive)
+        self.SongbookCombo.setCompleter(completer)
 
     def loadThemes(self, theme_list):
         self.ThemeSelectionComboItem.clear()
         self.ThemeSelectionComboItem.addItem(u'')
+        self.themes = []
         for theme in theme_list:
             self.ThemeSelectionComboItem.addItem(theme)
+            self.themes.append(theme)
+        completer = QtGui.QCompleter(self.themes)
+        completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive)
+        self.ThemeSelectionComboItem.setCompleter(completer)
 
     def newSong(self):
         log.debug(u'New Song')
@@ -614,12 +634,29 @@
             self.saveSong(True):
             Receiver.send_message(u'songs_preview')
 
+    def clearCaches(self):
+        """
+        Free up autocompletion memory on dialog exit
+        """
+        self.authors = []
+        self.themes = []
+        self.books = []
+        self.topics = []
+
     def closePressed(self):
+        """
+        Exit Dialog and do not save
+        """
         Receiver.send_message(u'songs_edit_clear')
+        self.clearCaches()
         self.close()
 
     def accept(self):
+        """
+        Exit Dialog and save soong if valid
+        """
         log.debug(u'accept')
+        self.clearCaches()
         if not self.song:
             self.song = Song()
         item = int(self.SongbookCombo.currentIndex())
@@ -644,7 +681,7 @@
         Get all the data from the widgets on the form, and then save it to the
         database.
 
-        ``preview`` 
+        ``preview``
             Should be ``True`` if the song is also previewed (boolean).
         """
         self.song.title = unicode(self.TitleEditItem.text())


Follow ups