From 44224b0c73adeed6eab6eb07c4e790720ceb0792 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Thu, 18 Mar 2010 21:50:20 +0000 Subject: [PATCH] Fix up maintenance dialog --- openlp/core/lib/serviceitem.py | 13 +++-- openlp/core/ui/serviceitemeditdialog.py | 28 +++++++-- openlp/core/ui/serviceitemeditform.py | 76 +++++++++++++++++++++++++ openlp/core/ui/servicemanager.py | 11 ++-- openlp/plugins/bibles/lib/mediaitem.py | 5 +- 5 files changed, 116 insertions(+), 17 deletions(-) diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index 9164f3235..09c5ac8b9 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -66,7 +66,6 @@ class ServiceItem(object): self.iconic_representation = None self.raw_footer = None self.theme = None - self.service_item_path = None self.service_item_type = None self.edit_enabled = False self.maintain_allowed = False @@ -157,9 +156,8 @@ class ServiceItem(object): The actual image file name. """ self.service_item_type = ServiceItemType.Image - self.service_item_path = path self._raw_frames.append( - {u'title': title, u'image': image}) + {u'title': title, u'image': image, u'path': path}) def add_from_text(self, title, raw_slide, verseTag=None): """ @@ -190,9 +188,8 @@ class ServiceItem(object): The command of/for the slide. """ self.service_item_type = ServiceItemType.Command - self.service_item_path = path self._raw_frames.append( - {u'title': file_name, u'image': image}) + {u'title': file_name, u'image': image, u'path': path}) def get_service_repr(self): """ @@ -209,7 +206,9 @@ class ServiceItem(object): u'type':self.service_item_type, u'audit':self.audit, u'notes':self.notes, - u'preview':self.autoPreviewAllowed + u'preview':self.autoPreviewAllowed, + u'edit':self.edit_enabled, + u'maintain':self.maintain_allowed } service_data = [] if self.service_item_type == ServiceItemType.Text: @@ -245,6 +244,8 @@ class ServiceItem(object): self.audit = header[u'audit'] self.autoPreviewAllowed = header[u'preview'] self.notes = header[u'notes'] + self.edit_enabled = header[u'edit'] + self.maintain_allowed = header[u'maintain'] if self.service_item_type == ServiceItemType.Text: for slide in serviceitem[u'serviceitem'][u'data']: self._raw_frames.append(slide) diff --git a/openlp/core/ui/serviceitemeditdialog.py b/openlp/core/ui/serviceitemeditdialog.py index f8d643a94..b0ca3bf30 100644 --- a/openlp/core/ui/serviceitemeditdialog.py +++ b/openlp/core/ui/serviceitemeditdialog.py @@ -1,11 +1,27 @@ # -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 -# Form implementation generated from reading ui file 'serviceitemeditdialog.ui' -# -# Created: Wed Mar 17 20:55:46 2010 -# by: PyQt4 UI code generator 4.7 -# -# WARNING! All changes made in this file will be lost! +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2010 Raoul Snyman # +# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael # +# Gorven, Scott Guerrieri, Maikel Stuivenberg, Martin Thompson, Jon Tibble, # +# 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 # +############################################################################### from PyQt4 import QtCore, QtGui diff --git a/openlp/core/ui/serviceitemeditform.py b/openlp/core/ui/serviceitemeditform.py index f251140a5..cbe530d80 100644 --- a/openlp/core/ui/serviceitemeditform.py +++ b/openlp/core/ui/serviceitemeditform.py @@ -36,9 +36,85 @@ class ServiceItemEditForm(QtGui.QDialog, Ui_ServiceItemEditDialog): """ QtGui.QDialog.__init__(self, parent) self.setupUi(self) + self.itemList = [] + # enable drop + QtCore.QObject.connect(self.upButton, + QtCore.SIGNAL(u'clicked()'), + self.onItemUp) + QtCore.QObject.connect(self.downButton, + QtCore.SIGNAL(u'clicked()'), + self.onItemDown) + QtCore.QObject.connect(self.deleteButton, + QtCore.SIGNAL(u'clicked()'), + self.onItemDelete) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'accepted()'), self.accept) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'rejected()'), self.reject) + + def setServiceItem(self, item): + self.item = item + self.itemList = [] + if self.item.is_image(): + self.data = True + for frame in self.item._raw_frames: + self.itemList.append(frame) + self.loadData() + + def getServiceItem(self): + if self.data: + self.item._raw_frames = [] + if self.item.is_image(): + for item in self.itemList: + self.item.add_from_image(item[u'path'], + item[u'title'], item[u'image']) + self.item.render() + return self.item + + def loadData(self): + self.listWidget.clear() + for frame in self.itemList: + item_name = QtGui.QListWidgetItem(frame[u'title']) + self.listWidget.addItem(item_name) + + def onItemDelete(self): + """ + Move the current ServiceItem up in the list + Note move up means move to top of area ie 0. + """ + items = self.listWidget.selectedItems() + for item in items: + row = self.listWidget.row(item) + if row > 0: + self.itemList.remove(self.itemList[row]) + self.loadData() + + def onItemUp(self): + """ + Move the current ServiceItem up in the list + Note move up means move to top of area ie 0. + """ + items = self.listWidget.selectedItems() + for item in items: + row = self.listWidget.row(item) + if row > 0: + temp = self.itemList[row] + self.itemList.remove(self.itemList[row]) + self.itemList.insert(row - 1, temp) + self.loadData() + + def onItemDown(self): + """ + Move the current ServiceItem down in the list + Note move down means move to bottom of area i.e len(). + """ + items = self.listWidget.selectedItems() + for item in items: + row = self.listWidget.row(item) + if row < len(self.itemList) and row is not -1: + temp = self.itemList[row] + self.itemList.remove(self.itemList[row]) + self.itemList.insert(row + 1, temp) + self.loadData() diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 386d7af8d..3225d9237 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -269,9 +269,12 @@ class ServiceManager(QtGui.QWidget): def onServiceItemEditForm(self): item, count = self.findServiceItem() + self.serviceItemEditForm.setServiceItem( + self.serviceItems[item][u'service_item']) if self.serviceItemEditForm.exec_(): - pass - + self.serviceItems[item][u'service_item'] = \ + self.serviceItemEditForm.getServiceItem() + self.repaintServiceList(item, 0) def nextItem(self): """ @@ -367,7 +370,7 @@ class ServiceManager(QtGui.QWidget): def onServiceUp(self): """ Move the current ServiceItem up in the list - Note move up means move to top of area ie 0. + Note move up means move to top of area ie 0. """ item, count = self.findServiceItem() if item > 0: @@ -513,7 +516,7 @@ class ServiceManager(QtGui.QWidget): if item[u'service_item'].uses_file(): for frame in item[u'service_item'].get_frames(): path_from = unicode(os.path.join( - item[u'service_item'].service_item_path, + frame[u'path'], frame[u'title'])) zip.write(path_from) file = open(servicefile, u'wb') diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 861289682..c2aaf0d64 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -492,7 +492,10 @@ class BibleMediaItem(MediaManagerItem): if self.parent.settings_tab.layout_style == 0: raw_slides.append(bible_text) bible_text = u'' - service_item.title = u'%s %s' % (book, verse_text) + if not service_item.title: + service_item.title = u'%s %s' % (book, verse_text) + elif service_item.title.find(self.trUtf8(u'etc')) == -1: + service_item.title = u'%s, %s' % (service_item.title, self.trUtf8(u'etc')) if len(self.parent.settings_tab.bible_theme) == 0: service_item.theme = None else: