Reload list only if title changes.

This commit is contained in:
Tim Bentley 2009-06-14 08:25:39 +01:00
parent dc40e79ee7
commit d96267934c
4 changed files with 22 additions and 25 deletions

View File

@ -24,28 +24,17 @@ class EventType(object):
Types of events are stored in this class. Types of events are stored in this class.
""" """
# "Default" event - a non-event # "Default" event - a non-event
Default = 0 Default = 0
# General application events # General application events
InitApplication = -1
ShowApplication = -2
BeforeAppClose = -3
ApplicationClose = -4
# Service events # Service events
BeforeLoadService = 1 LoadServiceItem = 20
AfterLoadService = 2
BeforeSaveService = 3
AfterSaveService = 4
LoadServiceItem = 5
# Preview events # Preview events
PreviewShow = 10 PreviewShow = 30
LiveShow = 11 LiveShow = 31
#PreviewBeforeLoad = 11 #Theme Related Events
#PreviewAfterLoad = 12 ThemeListChanged = 40
#PreviewBeforeShow = 13 #Plugin Related Events
#PreviewAfterShow = 14 LoadSongList = 50
#Theme Related Events
ThemeListChanged = 15
class Event(object): class Event(object):

View File

@ -19,7 +19,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
""" """
import logging import logging
from PyQt4 import Qt, QtCore, QtGui from PyQt4 import Qt, QtCore, QtGui
from openlp.core.lib import SongXMLBuilder, SongXMLParser from openlp.core.lib import SongXMLBuilder, SongXMLParser, Event, EventType, EventManager
from openlp.plugins.songs.forms import AuthorsForm, TopicsForm, SongBookForm, \ from openlp.plugins.songs.forms import AuthorsForm, TopicsForm, SongBookForm, \
EditVerseForm EditVerseForm
from openlp.plugins.songs.lib.models import Song from openlp.plugins.songs.lib.models import Song
@ -33,7 +33,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
global log global log
log = logging.getLogger(u'EditSongForm') log = logging.getLogger(u'EditSongForm')
log.info(u'Song Editor loaded') log.info(u'Song Editor loaded')
def __init__(self, songmanager, parent=None): def __init__(self, songmanager, eventmanager, parent=None):
""" """
Constructor Constructor
""" """
@ -74,6 +74,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
QtCore.SIGNAL(u'activated(int)'), self.onThemeComboChanged) QtCore.SIGNAL(u'activated(int)'), self.onThemeComboChanged)
# Create other objects and forms # Create other objects and forms
self.songmanager = songmanager self.songmanager = songmanager
self.eventmanager = eventmanager
self.authors_form = AuthorsForm(self.songmanager) self.authors_form = AuthorsForm(self.songmanager)
self.topics_form = TopicsForm(self.songmanager) self.topics_form = TopicsForm(self.songmanager)
self.song_book_form = SongBookForm(self.songmanager) self.song_book_form = SongBookForm(self.songmanager)
@ -92,6 +93,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
self.DeleteButton.setEnabled(False) self.DeleteButton.setEnabled(False)
self.AuthorRemoveItem.setEnabled(False) self.AuthorRemoveItem.setEnabled(False)
self.TopicRemoveItem.setEnabled(False) self.TopicRemoveItem.setEnabled(False)
self.title_change = False
def loadAuthors(self): def loadAuthors(self):
authors = self.songmanager.get_authors() authors = self.songmanager.get_authors()
@ -127,6 +129,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
self.VerseListWidget.clear() self.VerseListWidget.clear()
self.AuthorsListView.clear() self.AuthorsListView.clear()
self.TopicsListView.clear() self.TopicsListView.clear()
self.title_change = False
def loadSong(self, id): def loadSong(self, id):
log.debug(u'Load Song') log.debug(u'Load Song')
@ -174,6 +177,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
topic_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(topic.id)) topic_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(topic.id))
self.TopicsListView.addItem(topic_name) self.TopicsListView.addItem(topic_name)
self._validate_song() self._validate_song()
self.title_change = False
def onAuthorAddtoSongItemClicked(self): def onAuthorAddtoSongItemClicked(self):
author_name = unicode(self.AuthorsSelectionComboItem.currentText()) author_name = unicode(self.AuthorsSelectionComboItem.currentText())
@ -307,8 +311,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
slot.setAutoFillBackground(True) slot.setAutoFillBackground(True)
def on_TitleEditItem_lostFocus(self): def on_TitleEditItem_lostFocus(self):
#self._validate_song() self.song.title = self.TitleEditItem.text()
pass self.title_change = True
def onCopyrightInsertItemTriggered(self): def onCopyrightInsertItemTriggered(self):
text = self.CopyrightEditItem.displayText() text = self.CopyrightEditItem.displayText()
@ -330,6 +334,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
self.processTitle() self.processTitle()
self.song.song_book_id = 0 self.song.song_book_id = 0
self.songmanager.save_song(self.song) self.songmanager.save_song(self.song)
if self.title_change:
self.eventmanager.post_event(Event(EventType.LoadSongList))
self.close() self.close()
def processLyrics(self): def processLyrics(self):

View File

@ -56,7 +56,7 @@ class SongMediaItem(MediaManagerItem):
def __init__(self, parent, icon, title): def __init__(self, parent, icon, title):
MediaManagerItem.__init__(self, parent, icon, title) MediaManagerItem.__init__(self, parent, icon, title)
self.edit_song_form = EditSongForm(self.parent.songmanager) self.edit_song_form = EditSongForm(self.parent.songmanager, self.parent.event_manager)
def setupUi(self): def setupUi(self):
# Add a toolbar # Add a toolbar
@ -207,7 +207,6 @@ class SongMediaItem(MediaManagerItem):
def onSongNewClick(self): def onSongNewClick(self):
self.edit_song_form.newSong() self.edit_song_form.newSong()
self.edit_song_form.exec_() self.edit_song_form.exec_()
self.onSearchTextButtonClick()
def onSongEditClick(self): def onSongEditClick(self):
indexes = self.SongListView.selectedIndexes() indexes = self.SongListView.selectedIndexes()

View File

@ -134,3 +134,6 @@ class SongsPlugin(Plugin):
if event.event_type == EventType.LiveShow and event.payload == 'Song': if event.event_type == EventType.LiveShow and event.payload == 'Song':
log.debug(u'Load Live Show Item received') log.debug(u'Load Live Show Item received')
self.media_item.onSongLiveClick() self.media_item.onSongLiveClick()
if event.event_type == EventType.LoadSongList :
log.debug(u'Load Load Song List Item received')
self.media_item.displayResults(self.songmanager.get_songs())