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.
"""
# "Default" event - a non-event
Default = 0
Default = 0
# General application events
InitApplication = -1
ShowApplication = -2
BeforeAppClose = -3
ApplicationClose = -4
# Service events
BeforeLoadService = 1
AfterLoadService = 2
BeforeSaveService = 3
AfterSaveService = 4
LoadServiceItem = 5
LoadServiceItem = 20
# Preview events
PreviewShow = 10
LiveShow = 11
#PreviewBeforeLoad = 11
#PreviewAfterLoad = 12
#PreviewBeforeShow = 13
#PreviewAfterShow = 14
#Theme Related Events
ThemeListChanged = 15
PreviewShow = 30
LiveShow = 31
#Theme Related Events
ThemeListChanged = 40
#Plugin Related Events
LoadSongList = 50
class Event(object):

View File

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

View File

@ -56,7 +56,7 @@ class SongMediaItem(MediaManagerItem):
def __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):
# Add a toolbar
@ -207,7 +207,6 @@ class SongMediaItem(MediaManagerItem):
def onSongNewClick(self):
self.edit_song_form.newSong()
self.edit_song_form.exec_()
self.onSearchTextButtonClick()
def onSongEditClick(self):
indexes = self.SongListView.selectedIndexes()

View File

@ -134,3 +134,6 @@ class SongsPlugin(Plugin):
if event.event_type == EventType.LiveShow and event.payload == 'Song':
log.debug(u'Load Live Show Item received')
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())