From 206ee04db69f0cc7259713fa35c6fbfa964d5f32 Mon Sep 17 00:00:00 2001 From: Stevan Pettit Date: Thu, 19 May 2011 18:20:00 -0400 Subject: [PATCH] modified: openlp/plugins/custom/forms/editcustomform.py openlp/plugins/custom/lib/mediaitem.py openlp/plugins/songs/forms/editsongform.py openlp/plugins/songs/lib/mediaitem.py --- openlp/plugins/custom/forms/editcustomform.py | 2 ++ openlp/plugins/custom/lib/mediaitem.py | 12 +++++++++++- openlp/plugins/songs/forms/editsongform.py | 2 ++ openlp/plugins/songs/lib/mediaitem.py | 10 ++++++++++ 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index 774789fa0..1d0e0427d 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -114,6 +114,8 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): def accept(self): log.debug(u'accept') if self.saveCustom(): + Receiver.send_message(u'custom_set_autoselect_item', + self.customSlide.title) Receiver.send_message(u'custom_load_list') QtGui.QDialog.accept(self) diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index 66b1c3675..7e1298bd8 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -62,6 +62,7 @@ class CustomMediaItem(MediaManagerItem): # which Custom is required. self.remoteCustom = -1 self.manager = parent.manager + self.setAutoSelectItem() def addEndHeaderBar(self): self.addToolbarSeparator() @@ -105,6 +106,9 @@ class CustomMediaItem(MediaManagerItem): QtCore.SIGNAL(u'custom_edit_clear'), self.onRemoteEditClear) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'custom_load_list'), self.initialise) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'custom_set_autoselect_item'), + self.setAutoSelectItem) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'custom_preview'), self.onPreviewClick) @@ -140,10 +144,16 @@ class CustomMediaItem(MediaManagerItem): custom_name.setData( QtCore.Qt.UserRole, QtCore.QVariant(customSlide.id)) self.listView.addItem(custom_name) + # Auto-select the item if name has been set + if customSlide.title == self.autoSelectItem : + self.listView.setCurrentItem(custom_name) + + def setAutoSelectItem(self,itemToSelect="*"): + self.autoSelectItem = itemToSelect def onNewClick(self): self.parent.edit_custom_form.loadCustom(0) - self.parent.edit_custom_form.exec_() + self.parent.edit_custom_fom.exec_() self.initialise() def onRemoteEditClear(self): diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 297318d53..6155145f8 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -695,6 +695,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.clearCaches() if self._validate_song(): self.saveSong() + Receiver.send_message(u'songs_set_autoselect_item', + unicode(self.titleEdit.text())) Receiver.send_message(u'songs_load_list') QtGui.QDialog.accept(self) diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 5f961b2f2..1f7987569 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -73,6 +73,7 @@ class SongMediaItem(MediaManagerItem): self.editItem = None self.quickPreviewAllowed = True self.hasSearch = True + self.setAutoSelectItem() def addEndHeaderBar(self): self.addToolbarSeparator() @@ -123,6 +124,9 @@ class SongMediaItem(MediaManagerItem): QtCore.QObject.connect(self.searchTextEdit, QtCore.SIGNAL(u'searchTypeChanged(int)'), self.onSearchTextButtonClick) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'songs_set_autoselect_item'), + self.setAutoSelectItem) def configUpdated(self): self.searchAsYouType = QtCore.QSettings().value( @@ -159,6 +163,9 @@ class SongMediaItem(MediaManagerItem): QtCore.QVariant(SongSearch.Entire)).toInt()[0]) self.configUpdated() + def setAutoSelectItem(self,itemToSelect="*"): + self.autoSelectItem = itemToSelect + def onSearchTextButtonClick(self): # Save the current search type to the configuration. QtCore.QSettings().setValue(u'%s/last search type' % @@ -237,6 +244,9 @@ class SongMediaItem(MediaManagerItem): song_name = QtGui.QListWidgetItem(song_detail) song_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(song.id)) self.listView.addItem(song_name) + # Auto-select the item if name has been set + if song.title == self.autoSelectItem : + self.listView.setCurrentItem(song_name) def displayResultsAuthor(self, searchresults): log.debug(u'display results Author')