From cd11ae92a7ae1e8490b51dec676edd4f4bddbb12 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Sun, 21 Jun 2009 21:41:01 +0200 Subject: [PATCH 1/6] Changed key events to up/down = up/down slides, pgup = first, pgdn = last --- openlp/core/ui/slidecontroller.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index d6fa68cba..e6897a56b 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -104,12 +104,18 @@ class SlideList(QtGui.QListView): def keyPressEvent(self, event): if type(event) == QtGui.QKeyEvent: #here accept the event and do something - if event.key() == QtCore.Qt.Key_PageUp: + if event.key() == QtCore.Qt.Key_Up: self.parent.onSlideSelectedPrevious() event.accept() - elif event.key() == QtCore.Qt.Key_PageDown: + elif event.key() == QtCore.Qt.Key_Down: self.parent.onSlideSelectedNext() event.accept() + elif event.key() == QtCore.Qt.Key_PageUp: + self.parent.onSlideSelectedFirst() + event.accept() + elif event.key() == QtCore.Qt.Key_PageDown: + self.parent.onSlideSelectedLast() + event.accept() event.ignore() else: event.ignore() From a1b60e034ea8898cf683f669efa244f353ee0d57 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 23 Jun 2009 16:48:31 +0100 Subject: [PATCH 2/6] Fix error on song saving --- openlp/plugins/songs/songsplugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index eb3d2588f..f18f85e0d 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -136,4 +136,4 @@ class SongsPlugin(Plugin): 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()) + self.media_item.displayResultsSong(self.songmanager.get_songs()) From d1b9b5b21879008b0a55cca77142295a36350974 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 24 Jun 2009 06:17:41 +0100 Subject: [PATCH 3/6] Fix bugs from unicode migration in theme Correct errors in Theme handling More code style fixes on route --- openlp/core/lib/themexmlhandler.py | 4 +- openlp/core/theme/theme.py | 88 +++++++++++++++++++----------- openlp/core/ui/thememanager.py | 19 ++++--- 3 files changed, 68 insertions(+), 43 deletions(-) diff --git a/openlp/core/lib/themexmlhandler.py b/openlp/core/lib/themexmlhandler.py index 74e150369..12880bfa6 100644 --- a/openlp/core/lib/themexmlhandler.py +++ b/openlp/core/lib/themexmlhandler.py @@ -16,8 +16,6 @@ PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -from xml.dom.minidom import Document -from xml.etree.ElementTree import ElementTree, XML, dump For XML Schema see wiki.openlp.org """ @@ -256,5 +254,5 @@ class ThemeXML(): s = u'' for k in dir(self): if k[0:1] != u'_': - s += u'%30s : %s\n' %(k,getattr(self,k)) + s += u'%30s : %s\n' %(k, getattr(self, k)) return s diff --git a/openlp/core/theme/theme.py b/openlp/core/theme/theme.py index 84b1d8ae2..3c154f117 100644 --- a/openlp/core/theme/theme.py +++ b/openlp/core/theme/theme.py @@ -1,9 +1,26 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +""" +OpenLP - Open Source Lyrics Projection +Copyright (c) 2008 Raoul Snyman +Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Carsten Tinggaard + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place, Suite 330, Boston, MA 02111-1307 USA + +""" import platform -ver = platform.python_version() -if ver >= '2.5': - from xml.etree.ElementTree import ElementTree, XML -else: - from elementtree import ElementTree, XML +import types +from xml.etree.ElementTree import ElementTree, XML from PyQt4 import QtGui @@ -59,7 +76,7 @@ class Theme: FontName : name of font to use FontColor : color for main font FontProportion : size of font - FontUnits : whether size of font is in or + FontUnits : whether size of font is in or Shadow : 0 - no shadow, non-zero use shadow ShadowColor : color for drop shadow @@ -78,52 +95,57 @@ class Theme: # init to defaults self._set_from_XML(blankstylexml) self._set_from_XML(xml) +# print self.__str__() def _get_as_string(self): - s="" + s = u'' keys=dir(self) keys.sort() for k in keys: - if k[0:1] != "_": - s+= "_%s_" %(getattr(self,k)) + if k[0:1] != u'_': + s += u'_%s_' %(getattr(self,k)) return s + def _set_from_XML(self, xml): - root=ElementTree(element=XML(xml)) - iter=root.getiterator() + root = ElementTree(element=XML(xml)) + iter = root.getiterator() for element in iter: - if element.tag != "Theme": - t=element.text -# print element.tag, t, type(t) - if type(t) == type(None): # easy! - val=t - if type(t) == type(u' '): # strings need special handling to sort the colours out -# print "str", - if t[0] == "$": # might be a hex number -# print "hex", + if element.tag != u'Theme': + t = element.text +# print element.tag, t, type(t) + val = 0 + # easy! + if type(t) == type(None): + val = t + # strings need special handling to sort the colours out + if type(t) is types.StringType or type(t) is types.UnicodeType: +# print u'str', + if t[0] == u'$': # might be a hex number +# print u'hex', try: - val=int(t[1:], 16) + val = int(t[1:], 16) except ValueError: # nope -# print "nope", +# print u'nope' pass elif DelphiColors.has_key(t): -# print "colour", - val=DelphiColors[t] +# print u'colour ', t + val = DelphiColors[t] else: try: - val=int(t) + val = int(t) except ValueError: - val=t + val = t if (element.tag.find(u'Color') > 0 or (element.tag.find(u'BackgroundParameter') == 0 and type(val) == type(0))): # convert to a wx.Colour val= QtGui.QColor((val>>16) & 0xFF, (val>>8)&0xFF, val&0xFF) - # print [val] - setattr(self,element.tag, val) - +# print [val] +# print u'>> ', element.tag, val + setattr(self, element.tag, val) def __str__(self): - s="" + s = u'' for k in dir(self): - if k[0:1] != "_": - s+= "%30s : %s\n" %(k,getattr(self,k)) - return s \ No newline at end of file + if k[0:1] != u'_': + s += u'%30s : %s\n' %(k, getattr(self, k)) + return s diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index d292f6fe5..49400f97f 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -57,9 +57,9 @@ class ThemeData(QtCore.QAbstractListModel): def insertRow(self, row, filename): self.beginInsertRows(QtCore.QModelIndex(), row, row) - log.info(u'insert row %d:%s' % (row, filename)) + log.debug(u'insert row %d:%s' % (row, filename)) (prefix, shortfilename) = os.path.split(unicode(filename)) - log.info(u'shortfilename = %s' % shortfilename) + log.debug(u'shortfilename = %s' % shortfilename) theme = shortfilename.split(u'.') # create a preview image if os.path.exists(filename): @@ -81,7 +81,7 @@ class ThemeData(QtCore.QAbstractListModel): pixmap.fill(QtCore.Qt.black) # finally create the row self.items.insert(row, (filename, pixmap, shortfilename, theme[0])) - log.info(u'Items: %s' % self.items) + log.debug(u'Items: %s' % self.items) self.endInsertRows() def removeRow(self, row): @@ -190,8 +190,13 @@ class ThemeManager(QtGui.QWidget): try: os.remove(os.path.join(self.path, th)) except: - pass #if not present do not worry - shutil.rmtree(os.path.join(self.path, theme)) + #if not present do not worry + pass + try: + shutil.rmtree(os.path.join(self.path, theme)) + except: + #if not present do not worry + pass self.themeData.clearItems() self.loadThemes() @@ -201,7 +206,7 @@ class ThemeManager(QtGui.QWidget): def onImportTheme(self): files = QtGui.QFileDialog.getOpenFileNames(None, translate(u'ThemeManager', u'Select Theme Import File'), - self.path, u'Theme (*.theme)') + self.path, u'Theme (*.*)') log.info(u'New Themes %s', unicode(files)) if len(files) > 0: for file in files: @@ -335,7 +340,7 @@ class ThemeManager(QtGui.QWidget): outfile = open(theme_file, u'w') outfile.write(theme_xml) outfile.close() - if image_from is not None and image_from is not image_to: + if image_from is not None and image_from != image_to: shutil.copyfile(image_from, image_to) self.generateAndSaveImage(self.path, name, theme_xml) self.themeData.clearItems() From c77cbb0aa1c38cd84e19da72025dbf150641207e Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 24 Jun 2009 07:10:13 +0100 Subject: [PATCH 4/6] Clean up migration database tables --- openlp/migration/migratesongs.py | 13 +++++++++++-- openlp/plugins/songs/lib/tables.py | 2 -- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/openlp/migration/migratesongs.py b/openlp/migration/migratesongs.py index 144c1a9ed..400789a57 100644 --- a/openlp/migration/migratesongs.py +++ b/openlp/migration/migratesongs.py @@ -117,8 +117,8 @@ class MigrateSongs(): def v_1_9_0(self, database): self.display.output(u'Migration 1.9.0 Started for ' + database) - self._v1_9_0_old(database) - self._v1_9_0_new(database) + #self._v1_9_0_old(database) + #self._v1_9_0_new(database) self._v1_9_0_cleanup(database) self.display.output(u'Migration 1.9.0 Finished for ' + database) @@ -175,3 +175,12 @@ class MigrateSongs(): '(u', ''), ')', ''), '{', ''), '}',''),'?','') ;""") conn.commit() + conn.execute(u'drop table authors_temp;') + conn.commit() + conn.execute(u'drop table songs_temp;') + conn.commit() + conn.execute(u'drop table songauthors_temp;') + conn.commit() + conn.execute(u'drop table settings;') + + conn.commit() diff --git a/openlp/plugins/songs/lib/tables.py b/openlp/plugins/songs/lib/tables.py index dea61861f..617c53b7d 100644 --- a/openlp/plugins/songs/lib/tables.py +++ b/openlp/plugins/songs/lib/tables.py @@ -73,8 +73,6 @@ Index(u'authors_id',authors_table.c.id) Index(u'authors_display_name_id',authors_table.c.display_name, authors_table.c.id) Index(u'song_books_id',song_books_table.c.id) Index(u'songs_id',songs_table.c.id) -Index(u'songs_lyrics_id',songs_table.c.search_lyrics, songs_table.c.id) -Index(u'songs_title_id',songs_table.c.search_title, songs_table.c.id) Index(u'topics_id',topics_table.c.id) Index(u'authors_songs_author',authors_songs_table.c.author_id, authors_songs_table.c.song_id) Index(u'authors_songs_song',authors_songs_table.c.song_id, authors_songs_table.c.author_id) From ec81608fe0fe7ea8bd9b2a3a890aa5e0c169def7 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 24 Jun 2009 07:11:04 +0100 Subject: [PATCH 5/6] Add options back in again --- openlp/migration/migratesongs.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/migration/migratesongs.py b/openlp/migration/migratesongs.py index 400789a57..2465c8b9d 100644 --- a/openlp/migration/migratesongs.py +++ b/openlp/migration/migratesongs.py @@ -117,8 +117,8 @@ class MigrateSongs(): def v_1_9_0(self, database): self.display.output(u'Migration 1.9.0 Started for ' + database) - #self._v1_9_0_old(database) - #self._v1_9_0_new(database) + self._v1_9_0_old(database) + self._v1_9_0_new(database) self._v1_9_0_cleanup(database) self.display.output(u'Migration 1.9.0 Finished for ' + database) From 69df159f176ad3177e36695d2bd028d9ffd08ea0 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 24 Jun 2009 07:15:04 +0100 Subject: [PATCH 6/6] Change Topics Form handling to allow save button to be enabled. --- openlp/plugins/songs/forms/topicsform.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/openlp/plugins/songs/forms/topicsform.py b/openlp/plugins/songs/forms/topicsform.py index d5aaafe9d..d18547638 100644 --- a/openlp/plugins/songs/forms/topicsform.py +++ b/openlp/plugins/songs/forms/topicsform.py @@ -51,7 +51,8 @@ class TopicsForm(QtGui.QDialog, Ui_TopicsDialog): Refresh the screen and rest fields """ self.TopicsListWidget.clear() - self.onClearButtonClick() # tidy up screen + # tidy up screen + self.onClearButtonClick() topics = self.songmanager.get_topics() for topic in topics: topic_name = QtGui.QListWidgetItem(topic.name) @@ -77,12 +78,13 @@ class TopicsForm(QtGui.QDialog, Ui_TopicsDialog): """ Sent New or update details to the database """ - if self.topic == None: - self.topic = Topic() - self.topic.name = unicode(self.TopicNameEdit.displayText()) - self.songmanager.save_topic(self.topic) - self.onClearButtonClick() - self.load_form() + if self._validate_form(): + if self.topic == None: + self.topic = Topic() + self.topic.name = unicode(self.TopicNameEdit.displayText()) + self.songmanager.save_topic(self.topic) + self.onClearButtonClick() + self.load_form() def onClearButtonClick(self): """ @@ -91,7 +93,6 @@ class TopicsForm(QtGui.QDialog, Ui_TopicsDialog): self.TopicNameEdit.setText(u'') self.MessageLabel.setText(u'') self.DeleteButton.setEnabled(False) - self.AddUpdateButton.setEnabled(True) self.topic = None self._validate_form() @@ -115,7 +116,10 @@ class TopicsForm(QtGui.QDialog, Ui_TopicsDialog): def _validate_form(self): # We need at lease a display name + valid = True if len(self.TopicNameEdit.displayText()) == 0: - self.AddUpdateButton.setEnabled(False) + valid = False + self.TopicNameEdit.setStyleSheet(u'background-color: red; color: white') else: - self.AddUpdateButton.setEnabled(True) + self.TopicNameEdit.setStyleSheet(u'') + return valid