From bc0ca88af5e2e2e880b69bba6f1946d5d6ffc69b Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 11 Dec 2010 20:31:47 +0000 Subject: [PATCH 1/4] Add Autocompletion for Authors and Themes --- openlp/plugins/songs/forms/editsongform.py | 34 ++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 247e5e837..778046d0d 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -61,6 +61,14 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): QtCore.QObject.connect(self.AuthorsListView, QtCore.SIGNAL(u'itemClicked(QListWidgetItem*)'), self.onAuthorsListViewPressed) + QtCore.QObject.connect(self.AuthorsSelectionComboItem, + QtCore.SIGNAL(u'activated(int)'), self.updateAuthorAutoCompleter) + QtCore.QObject.connect(self.AuthorsSelectionComboItem, + QtCore.SIGNAL(u'activated(int)'), self.updateAuthorAutoCompleter)# + QtCore.QObject.connect(self.ThemeSelectionComboItem, + QtCore.SIGNAL(u'activated(int)'), self.updateAuthorAutoCompleter) + QtCore.QObject.connect(self.ThemeSelectionComboItem, + QtCore.SIGNAL(u'activated(int)'), self.updateThemeAutoCompleter) QtCore.QObject.connect(self.TopicAddButton, QtCore.SIGNAL(u'clicked()'), self.onTopicAddButtonClicked) QtCore.QObject.connect(self.TopicRemoveButton, @@ -119,12 +127,23 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): authors = self.manager.get_all_objects(Author, order_by_ref=Author.display_name) self.AuthorsSelectionComboItem.clear() - self.AuthorsSelectionComboItem.addItem(u'') + 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) + self.updateAuthorAutoCompleter() + + def updateAuthorAutoCompleter(self): + """ + This updates the author completion list for the search field. + """ + 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) @@ -147,8 +166,19 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): 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) + self.updateThemeAutoCompleter() + + def updateThemeAutoCompleter(self): + """ + This updates the theme completion list for the search field. + """ + completer = QtGui.QCompleter(self.themes) + completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive) + self.ThemeSelectionComboItem.setCompleter(completer) def newSong(self): log.debug(u'New Song') @@ -644,7 +674,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): 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()) From a25ce9d3cf2d735538315b03a21d490a972da96a Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 11 Dec 2010 20:49:50 +0000 Subject: [PATCH 2/4] Sort out Camels --- openlp/core/lib/plugin.py | 20 +++++----- openlp/core/ui/mainwindow.py | 64 +++++++++++++++---------------- openlp/core/ui/pluginform.py | 4 +- openlp/core/ui/servicemanager.py | 14 +++---- openlp/core/ui/slidecontroller.py | 2 +- openlp/core/ui/thememanager.py | 4 +- 6 files changed, 54 insertions(+), 54 deletions(-) diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index 37ac3d74a..f73b58735 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -108,7 +108,7 @@ class Plugin(QtCore.QObject): """ 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 @@ class Plugin(QtCore.QObject): ``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 @@ class Plugin(QtCore.QObject): 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) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 3833f1697..a319e005f 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -97,16 +97,16 @@ class Ui_MainWindow(object): 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 @@ class Ui_MainWindow(object): """ 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 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): 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 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): 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 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): 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 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): 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 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): 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 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): 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 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): 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) diff --git a/openlp/core/ui/pluginform.py b/openlp/core/ui/pluginform.py index a857caee7..3d3a814a0 100644 --- a/openlp/core/ui/pluginform.py +++ b/openlp/core/ui/pluginform.py @@ -61,7 +61,7 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog): 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 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog): 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 diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 85dff6b91..32e46dffb 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -880,7 +880,7 @@ class ServiceManager(QtGui.QWidget): 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 @@ class ServiceManager(QtGui.QWidget): 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 @@ class ServiceManager(QtGui.QWidget): 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 @@ class ServiceManager(QtGui.QWidget): """ 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 @@ class ServiceManager(QtGui.QWidget): """ 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 @@ class ServiceManager(QtGui.QWidget): 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'), diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index f667c6d3c..6c7fb8538 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -957,7 +957,7 @@ class SlideController(QtGui.QWidget): """ 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): diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index da8597cc0..b6e8c3d7a 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -310,7 +310,7 @@ class ThemeManager(QtGui.QWidget): 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 @@ class ThemeManager(QtGui.QWidget): (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: From 031b23ccda8900f0025794498dab1778fc51433d Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 11 Dec 2010 20:57:45 +0000 Subject: [PATCH 3/4] Format errors --- openlp/plugins/songs/forms/editsongform.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 778046d0d..59eae1160 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -64,7 +64,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): QtCore.QObject.connect(self.AuthorsSelectionComboItem, QtCore.SIGNAL(u'activated(int)'), self.updateAuthorAutoCompleter) QtCore.QObject.connect(self.AuthorsSelectionComboItem, - QtCore.SIGNAL(u'activated(int)'), self.updateAuthorAutoCompleter)# + QtCore.SIGNAL(u'activated(int)'), self.updateAuthorAutoCompleter) QtCore.QObject.connect(self.ThemeSelectionComboItem, QtCore.SIGNAL(u'activated(int)'), self.updateAuthorAutoCompleter) QtCore.QObject.connect(self.ThemeSelectionComboItem, @@ -127,7 +127,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): authors = self.manager.get_all_objects(Author, order_by_ref=Author.display_name) self.AuthorsSelectionComboItem.clear() - self.AuthorsSelectionComboItem.addItem(u'')# + self.AuthorsSelectionComboItem.addItem(u'') self.authors = [] for author in authors: row = self.AuthorsSelectionComboItem.count() From 4a7300c6c08738de7aa54fe08f5be6efc6c2860c Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 12 Dec 2010 08:35:02 +0000 Subject: [PATCH 4/4] Topic and Book Auto completion --- openlp/plugins/songs/forms/editsongform.py | 47 +++++++++++++--------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 59eae1160..b7f4a3f0b 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -61,14 +61,6 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): QtCore.QObject.connect(self.AuthorsListView, QtCore.SIGNAL(u'itemClicked(QListWidgetItem*)'), self.onAuthorsListViewPressed) - QtCore.QObject.connect(self.AuthorsSelectionComboItem, - QtCore.SIGNAL(u'activated(int)'), self.updateAuthorAutoCompleter) - QtCore.QObject.connect(self.AuthorsSelectionComboItem, - QtCore.SIGNAL(u'activated(int)'), self.updateAuthorAutoCompleter) - QtCore.QObject.connect(self.ThemeSelectionComboItem, - QtCore.SIGNAL(u'activated(int)'), self.updateAuthorAutoCompleter) - QtCore.QObject.connect(self.ThemeSelectionComboItem, - QtCore.SIGNAL(u'activated(int)'), self.updateThemeAutoCompleter) QtCore.QObject.connect(self.TopicAddButton, QtCore.SIGNAL(u'clicked()'), self.onTopicAddButtonClicked) QtCore.QObject.connect(self.TopicRemoveButton, @@ -135,12 +127,6 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.AuthorsSelectionComboItem.setItemData( row, QtCore.QVariant(author.id)) self.authors.append(author.display_name) - self.updateAuthorAutoCompleter() - - def updateAuthorAutoCompleter(self): - """ - This updates the author completion list for the search field. - """ completer = QtGui.QCompleter(self.authors) completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive) self.AuthorsSelectionComboItem.setCompleter(completer) @@ -149,19 +135,29 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): 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() @@ -170,12 +166,6 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): for theme in theme_list: self.ThemeSelectionComboItem.addItem(theme) self.themes.append(theme) - self.updateThemeAutoCompleter() - - def updateThemeAutoCompleter(self): - """ - This updates the theme completion list for the search field. - """ completer = QtGui.QCompleter(self.themes) completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive) self.ThemeSelectionComboItem.setCompleter(completer) @@ -644,12 +634,29 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): 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())