EditCustom & SongUsage naming

This commit is contained in:
Jon Tibble 2010-07-27 12:21:11 +01:00
parent 7f6920e220
commit 9482b40b8c
6 changed files with 262 additions and 263 deletions

View File

@ -28,7 +28,7 @@ from PyQt4 import QtCore, QtGui
from openlp.core.lib import build_icon, translate
class Ui_customEditDialog(object):
class Ui_CustomEditDialog(object):
def setupUi(self, customEditDialog):
customEditDialog.setObjectName(u'customEditDialog')
customEditDialog.resize(590, 541)
@ -38,94 +38,94 @@ class Ui_customEditDialog(object):
self.gridLayout.setObjectName(u'gridLayout')
self.horizontalLayout = QtGui.QHBoxLayout()
self.horizontalLayout.setObjectName(u'horizontalLayout')
self.TitleLabel = QtGui.QLabel(customEditDialog)
self.TitleLabel.setObjectName(u'TitleLabel')
self.horizontalLayout.addWidget(self.TitleLabel)
self.TitleEdit = QtGui.QLineEdit(customEditDialog)
self.TitleLabel.setBuddy(self.TitleEdit)
self.TitleEdit.setObjectName(u'TitleEdit')
self.horizontalLayout.addWidget(self.TitleEdit)
self.titleLabel = QtGui.QLabel(customEditDialog)
self.titleLabel.setObjectName(u'titleLabel')
self.horizontalLayout.addWidget(self.titleLabel)
self.titleEdit = QtGui.QLineEdit(customEditDialog)
self.titleLabel.setBuddy(self.titleEdit)
self.titleEdit.setObjectName(u'titleEdit')
self.horizontalLayout.addWidget(self.titleEdit)
self.gridLayout.addLayout(self.horizontalLayout, 0, 0, 1, 1)
self.horizontalLayout_4 = QtGui.QHBoxLayout()
self.horizontalLayout_4.setObjectName(u'horizontalLayout_4')
self.VerseListView = QtGui.QListWidget(customEditDialog)
self.VerseListView.setAlternatingRowColors(True)
self.VerseListView.setObjectName(u'VerseListView')
self.horizontalLayout_4.addWidget(self.VerseListView)
self.horizontalLayout4 = QtGui.QHBoxLayout()
self.horizontalLayout4.setObjectName(u'horizontalLayout4')
self.verseListView = QtGui.QListWidget(customEditDialog)
self.verseListView.setAlternatingRowColors(True)
self.verseListView.setObjectName(u'verseListView')
self.horizontalLayout4.addWidget(self.verseListView)
self.verticalLayout = QtGui.QVBoxLayout()
self.verticalLayout.setObjectName(u'verticalLayout')
self.UpButton = QtGui.QPushButton(customEditDialog)
self.UpButton.setIcon(build_icon(u':/services/service_up.png'))
self.UpButton.setObjectName(u'UpButton')
self.verticalLayout.addWidget(self.UpButton)
self.upButton = QtGui.QPushButton(customEditDialog)
self.upButton.setIcon(build_icon(u':/services/service_up.png'))
self.upButton.setObjectName(u'upButton')
self.verticalLayout.addWidget(self.upButton)
spacerItem = QtGui.QSpacerItem(20, 128, QtGui.QSizePolicy.Minimum,
QtGui.QSizePolicy.Expanding)
self.verticalLayout.addItem(spacerItem)
self.DownButton = QtGui.QPushButton(customEditDialog)
self.DownButton.setIcon(build_icon(u':/services/service_down.png'))
self.DownButton.setObjectName(u'DownButton')
self.verticalLayout.addWidget(self.DownButton)
self.horizontalLayout_4.addLayout(self.verticalLayout)
self.gridLayout.addLayout(self.horizontalLayout_4, 1, 0, 1, 1)
self.EditWidget = QtGui.QWidget(customEditDialog)
self.EditWidget.setObjectName(u'EditWidget')
self.EditLayout_3 = QtGui.QHBoxLayout(self.EditWidget)
self.EditLayout_3.setSpacing(8)
self.EditLayout_3.setMargin(0)
self.EditLayout_3.setObjectName(u'EditLayout_3')
self.VerseTextEdit = QtGui.QTextEdit(self.EditWidget)
self.downButton = QtGui.QPushButton(customEditDialog)
self.downButton.setIcon(build_icon(u':/services/service_down.png'))
self.downButton.setObjectName(u'downButton')
self.verticalLayout.addWidget(self.downButton)
self.horizontalLayout4.addLayout(self.verticalLayout)
self.gridLayout.addLayout(self.horizontalLayout4, 1, 0, 1, 1)
self.editWidget = QtGui.QWidget(customEditDialog)
self.editWidget.setObjectName(u'editWidget')
self.editLayout3 = QtGui.QHBoxLayout(self.editWidget)
self.editLayout3.setSpacing(8)
self.editLayout3.setMargin(0)
self.editLayout3.setObjectName(u'editLayout3')
self.VerseTextEdit = QtGui.QTextEdit(self.editWidget)
self.VerseTextEdit.setObjectName(u'VerseTextEdit')
self.EditLayout_3.addWidget(self.VerseTextEdit)
self.ButtonWidge = QtGui.QWidget(self.EditWidget)
self.editLayout3.addWidget(self.VerseTextEdit)
self.ButtonWidge = QtGui.QWidget(self.editWidget)
self.ButtonWidge.setObjectName(u'ButtonWidge')
self.verticalLayout_2 = QtGui.QVBoxLayout(self.ButtonWidge)
self.verticalLayout_2.setObjectName(u'verticalLayout_2')
self.AddButton = QtGui.QPushButton(self.ButtonWidge)
self.AddButton.setObjectName(u'AddButton')
self.verticalLayout_2.addWidget(self.AddButton)
self.EditButton = QtGui.QPushButton(self.ButtonWidge)
self.EditButton.setObjectName(u'EditButton')
self.verticalLayout_2.addWidget(self.EditButton)
self.EditAllButton = QtGui.QPushButton(self.ButtonWidge)
self.EditAllButton.setObjectName(u'EditAllButton')
self.verticalLayout_2.addWidget(self.EditAllButton)
self.SaveButton = QtGui.QPushButton(self.ButtonWidge)
self.SaveButton.setObjectName(u'SaveButton')
self.verticalLayout_2.addWidget(self.SaveButton)
self.DeleteButton = QtGui.QPushButton(self.ButtonWidge)
self.DeleteButton.setObjectName(u'DeleteButton')
self.verticalLayout_2.addWidget(self.DeleteButton)
self.ClearButton = QtGui.QPushButton(self.ButtonWidge)
self.ClearButton.setObjectName(u'ClearButton')
self.verticalLayout_2.addWidget(self.ClearButton)
self.SplitButton = QtGui.QPushButton(self.ButtonWidge)
self.SplitButton.setObjectName(u'SplitButton')
self.verticalLayout_2.addWidget(self.SplitButton)
self.verticalLayout2 = QtGui.QVBoxLayout(self.ButtonWidge)
self.verticalLayout2.setObjectName(u'verticalLayout2')
self.addButton = QtGui.QPushButton(self.ButtonWidge)
self.addButton.setObjectName(u'addButton')
self.verticalLayout2.addWidget(self.addButton)
self.editButton = QtGui.QPushButton(self.ButtonWidge)
self.editButton.setObjectName(u'editButton')
self.verticalLayout2.addWidget(self.editButton)
self.editAllButton = QtGui.QPushButton(self.ButtonWidge)
self.editAllButton.setObjectName(u'editAllButton')
self.verticalLayout2.addWidget(self.editAllButton)
self.saveButton = QtGui.QPushButton(self.ButtonWidge)
self.saveButton.setObjectName(u'saveButton')
self.verticalLayout2.addWidget(self.saveButton)
self.deleteButton = QtGui.QPushButton(self.ButtonWidge)
self.deleteButton.setObjectName(u'deleteButton')
self.verticalLayout2.addWidget(self.deleteButton)
self.clearButton = QtGui.QPushButton(self.ButtonWidge)
self.clearButton.setObjectName(u'clearButton')
self.verticalLayout2.addWidget(self.clearButton)
self.splitButton = QtGui.QPushButton(self.ButtonWidge)
self.splitButton.setObjectName(u'splitButton')
self.verticalLayout2.addWidget(self.splitButton)
spacerItem1 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum,
QtGui.QSizePolicy.Expanding)
self.verticalLayout_2.addItem(spacerItem1)
self.EditLayout_3.addWidget(self.ButtonWidge)
self.gridLayout.addWidget(self.EditWidget, 2, 0, 1, 1)
self.horizontalLayout_3 = QtGui.QHBoxLayout()
self.horizontalLayout_3.setObjectName(u'horizontalLayout_3')
self.ThemeLabel = QtGui.QLabel(customEditDialog)
self.ThemeLabel.setObjectName(u'ThemeLabel')
self.horizontalLayout_3.addWidget(self.ThemeLabel)
self.ThemeComboBox = QtGui.QComboBox(customEditDialog)
self.ThemeLabel.setBuddy(self.ThemeComboBox)
self.ThemeComboBox.setObjectName(u'ThemeComboBox')
self.horizontalLayout_3.addWidget(self.ThemeComboBox)
self.gridLayout.addLayout(self.horizontalLayout_3, 3, 0, 1, 1)
self.horizontalLayout_2 = QtGui.QHBoxLayout()
self.horizontalLayout_2.setObjectName(u'horizontalLayout_2')
self.CreditLabel = QtGui.QLabel(customEditDialog)
self.CreditLabel.setObjectName(u'CreditLabel')
self.horizontalLayout_2.addWidget(self.CreditLabel)
self.CreditEdit = QtGui.QLineEdit(customEditDialog)
self.CreditLabel.setBuddy(self.CreditEdit)
self.CreditEdit.setObjectName(u'CreditEdit')
self.horizontalLayout_2.addWidget(self.CreditEdit)
self.gridLayout.addLayout(self.horizontalLayout_2, 4, 0, 1, 1)
self.verticalLayout2.addItem(spacerItem1)
self.editLayout3.addWidget(self.ButtonWidge)
self.gridLayout.addWidget(self.editWidget, 2, 0, 1, 1)
self.horizontalLayout3 = QtGui.QHBoxLayout()
self.horizontalLayout3.setObjectName(u'horizontalLayout3')
self.themeLabel = QtGui.QLabel(customEditDialog)
self.themeLabel.setObjectName(u'themeLabel')
self.horizontalLayout3.addWidget(self.themeLabel)
self.themeComboBox = QtGui.QComboBox(customEditDialog)
self.themeLabel.setBuddy(self.themeComboBox)
self.themeComboBox.setObjectName(u'themeComboBox')
self.horizontalLayout3.addWidget(self.themeComboBox)
self.gridLayout.addLayout(self.horizontalLayout3, 3, 0, 1, 1)
self.horizontalLayout2 = QtGui.QHBoxLayout()
self.horizontalLayout2.setObjectName(u'horizontalLayout2')
self.creditLabel = QtGui.QLabel(customEditDialog)
self.creditLabel.setObjectName(u'creditLabel')
self.horizontalLayout2.addWidget(self.creditLabel)
self.creditEdit = QtGui.QLineEdit(customEditDialog)
self.creditLabel.setBuddy(self.creditEdit)
self.creditEdit.setObjectName(u'creditEdit')
self.horizontalLayout2.addWidget(self.creditEdit)
self.gridLayout.addLayout(self.horizontalLayout2, 4, 0, 1, 1)
self.buttonBox = QtGui.QDialogButtonBox(customEditDialog)
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel |
QtGui.QDialogButtonBox.Save)
@ -141,49 +141,49 @@ class Ui_customEditDialog(object):
def retranslateUi(self, customEditDialog):
customEditDialog.setWindowTitle(
translate('CustomPlugin.EditCustomForm', 'Edit Custom Slides'))
self.UpButton.setToolTip(
self.upButton.setToolTip(
translate('CustomPlugin.EditCustomForm', 'Move slide up once '
'position.'))
self.DownButton.setToolTip(
self.downButton.setToolTip(
translate('CustomPlugin.EditCustomForm', 'Move slide down one '
'position.'))
self.TitleLabel.setText(
self.titleLabel.setText(
translate('CustomPlugin.EditCustomForm', '&Title:'))
self.AddButton.setText(
self.addButton.setText(
translate('CustomPlugin.EditCustomForm', 'Add New'))
self.AddButton.setToolTip(
self.addButton.setToolTip(
translate('CustomPlugin.EditCustomForm', 'Add a new slide at '
'bottom.'))
self.EditButton.setText(
self.editButton.setText(
translate('CustomPlugin.EditCustomForm', 'Edit'))
self.EditButton.setToolTip(
self.editButton.setToolTip(
translate('CustomPlugin.EditCustomForm', 'Edit the selected '
'slide.'))
self.EditAllButton.setText(
self.editAllButton.setText(
translate('CustomPlugin.EditCustomForm', 'Edit All'))
self.EditAllButton.setToolTip(
self.editAllButton.setToolTip(
translate('CustomPlugin.EditCustomForm', 'Edit all the slides at '
'once.'))
self.SaveButton.setText(
self.saveButton.setText(
translate('CustomPlugin.EditCustomForm', 'Save'))
self.SaveButton.setToolTip(
self.saveButton.setToolTip(
translate('CustomPlugin.EditCustomForm', 'Save the slide currently '
'being edited.'))
self.DeleteButton.setText(
self.deleteButton.setText(
translate('CustomPlugin.EditCustomForm', 'Delete'))
self.DeleteButton.setToolTip(
self.deleteButton.setToolTip(
translate('CustomPlugin.EditCustomForm', 'Delete the selected '
'slide.'))
self.ClearButton.setText(
self.clearButton.setText(
translate('CustomPlugin.EditCustomForm', 'Clear'))
self.ClearButton.setToolTip(
self.clearButton.setToolTip(
translate('CustomPlugin.EditCustomForm', 'Clear edit area'))
self.SplitButton.setText(
self.splitButton.setText(
translate('CustomPlugin.EditCustomForm', 'Split Slide'))
self.SplitButton.setToolTip(
self.splitButton.setToolTip(
translate('CustomPlugin.EditCustomForm', 'Split a slide into two '
'by inserting a slide splitter.'))
self.ThemeLabel.setText(
self.themeLabel.setText(
translate('CustomPlugin.EditCustomForm', 'The&me:'))
self.CreditLabel.setText(
self.creditLabel.setText(
translate('CustomPlugin.EditCustomForm', '&Credits:'))

View File

@ -28,14 +28,14 @@ import logging
from PyQt4 import QtCore, QtGui
from editcustomdialog import Ui_customEditDialog
from openlp.core.lib import Receiver, translate
from openlp.plugins.custom.lib import CustomXMLBuilder, CustomXMLParser
from openlp.plugins.custom.lib.db import CustomSlide
from editcustomdialog import Ui_CustomEditDialog
log = logging.getLogger(__name__)
class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog):
"""
Class documentation goes here.
"""
@ -55,28 +55,28 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
self.previewButton, QtGui.QDialogButtonBox.ActionRole)
QtCore.QObject.connect(self.buttonBox,
QtCore.SIGNAL(u'clicked(QAbstractButton*)'), self.onPreview)
QtCore.QObject.connect(self.AddButton,
QtCore.QObject.connect(self.addButton,
QtCore.SIGNAL(u'pressed()'), self.onAddButtonPressed)
QtCore.QObject.connect(self.EditButton,
QtCore.QObject.connect(self.editButton,
QtCore.SIGNAL(u'pressed()'), self.onEditButtonPressed)
QtCore.QObject.connect(self.EditAllButton,
QtCore.QObject.connect(self.editAllButton,
QtCore.SIGNAL(u'pressed()'), self.onEditAllButtonPressed)
QtCore.QObject.connect(self.SaveButton,
QtCore.QObject.connect(self.saveButton,
QtCore.SIGNAL(u'pressed()'), self.onSaveButtonPressed)
QtCore.QObject.connect(self.DeleteButton,
QtCore.QObject.connect(self.deleteButton,
QtCore.SIGNAL(u'pressed()'), self.onDeleteButtonPressed)
QtCore.QObject.connect(self.ClearButton,
QtCore.QObject.connect(self.clearButton,
QtCore.SIGNAL(u'pressed()'), self.onClearButtonPressed)
QtCore.QObject.connect(self.UpButton,
QtCore.QObject.connect(self.upButton,
QtCore.SIGNAL(u'pressed()'), self.onUpButtonPressed)
QtCore.QObject.connect(self.DownButton,
QtCore.QObject.connect(self.downButton,
QtCore.SIGNAL(u'pressed()'), self.onDownButtonPressed)
QtCore.QObject.connect(self.SplitButton,
QtCore.QObject.connect(self.splitButton,
QtCore.SIGNAL(u'pressed()'), self.onSplitButtonPressed)
QtCore.QObject.connect(self.VerseListView,
QtCore.QObject.connect(self.verseListView,
QtCore.SIGNAL(u'itemDoubleClicked(QListWidgetItem*)'),
self.onVerseListViewSelected)
QtCore.QObject.connect(self.VerseListView,
QtCore.QObject.connect(self.verseListView,
QtCore.SIGNAL(u'itemClicked(QListWidgetItem*)'),
self.onVerseListViewPressed)
QtCore.QObject.connect(Receiver.get_receiver(),
@ -93,45 +93,45 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
def initialise(self):
self.editAll = False
self.AddButton.setEnabled(True)
self.DeleteButton.setEnabled(False)
self.EditButton.setEnabled(False)
self.EditAllButton.setEnabled(True)
self.SaveButton.setEnabled(False)
self.ClearButton.setEnabled(False)
self.SplitButton.setEnabled(False)
self.TitleEdit.setText(u'')
self.CreditEdit.setText(u'')
self.VerseTextEdit.clear()
self.VerseListView.clear()
self.addButton.setEnabled(True)
self.deleteButton.setEnabled(False)
self.editButton.setEnabled(False)
self.editAllButton.setEnabled(True)
self.saveButton.setEnabled(False)
self.clearButton.setEnabled(False)
self.splitButton.setEnabled(False)
self.titleEdit.setText(u'')
self.creditEdit.setText(u'')
self.verseTextEdit.clear()
self.verseListView.clear()
#make sure we have a new item
self.customSlide = CustomSlide()
self.ThemeComboBox.addItem(u'')
self.themeComboBox.addItem(u'')
def loadThemes(self, themelist):
self.ThemeComboBox.clear()
self.ThemeComboBox.addItem(u'')
self.themeComboBox.clear()
self.themeComboBox.addItem(u'')
for themename in themelist:
self.ThemeComboBox.addItem(themename)
self.themeComboBox.addItem(themename)
def loadCustom(self, id, preview=False):
self.customSlide = CustomSlide()
self.initialise()
if id != 0:
self.customSlide = self.custommanager.get_object(CustomSlide, id)
self.TitleEdit.setText(self.customSlide.title)
self.CreditEdit.setText(self.customSlide.credits)
self.titleEdit.setText(self.customSlide.title)
self.creditEdit.setText(self.customSlide.credits)
customXML = CustomXMLParser(self.customSlide.text)
verseList = customXML.get_verses()
for verse in verseList:
self.VerseListView.addItem(verse[1])
self.verseListView.addItem(verse[1])
theme = self.customSlide.theme_name
id = self.ThemeComboBox.findText(theme, QtCore.Qt.MatchExactly)
id = self.themeComboBox.findText(theme, QtCore.Qt.MatchExactly)
if id == -1:
id = 0 # Not Found
self.ThemeComboBox.setCurrentIndex(id)
self.themeComboBox.setCurrentIndex(id)
else:
self.ThemeComboBox.setCurrentIndex(0)
self.themeComboBox.setCurrentIndex(0)
#if not preview hide the preview button
self.previewButton.setVisible(False)
if preview:
@ -158,126 +158,126 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
sxml.new_document()
sxml.add_lyrics_to_song()
count = 1
for i in range (0, self.VerseListView.count()):
for i in range (0, self.verseListView.count()):
sxml.add_verse_to_lyrics(u'custom', unicode(count),
unicode(self.VerseListView.item(i).text()))
unicode(self.verseListView.item(i).text()))
count += 1
self.customSlide.title = unicode(self.TitleEdit.displayText(), u'utf-8')
self.customSlide.title = unicode(self.titleEdit.displayText(), u'utf-8')
self.customSlide.text = unicode(sxml.extract_xml(), u'utf-8')
self.customSlide.credits = unicode(self.CreditEdit.displayText(),
self.customSlide.credits = unicode(self.creditEdit.displayText(),
u'utf-8')
self.customSlide.theme_name = unicode(self.ThemeComboBox.currentText(),
self.customSlide.theme_name = unicode(self.themeComboBox.currentText(),
u'utf-8')
return self.custommanager.save_object(self.customSlide)
def onUpButtonPressed(self):
selectedRow = self.VerseListView.currentRow()
selectedRow = self.verseListView.currentRow()
if selectedRow != 0:
qw = self.VerseListView.takeItem(selectedRow)
self.VerseListView.insertItem(selectedRow - 1, qw)
self.VerseListView.setCurrentRow(selectedRow - 1)
qw = self.verseListView.takeItem(selectedRow)
self.verseListView.insertItem(selectedRow - 1, qw)
self.verseListView.setCurrentRow(selectedRow - 1)
def onDownButtonPressed(self):
selectedRow = self.VerseListView.currentRow()
selectedRow = self.verseListView.currentRow()
# zero base arrays
if selectedRow != self.VerseListView.count() - 1:
qw = self.VerseListView.takeItem(selectedRow)
self.VerseListView.insertItem(selectedRow + 1, qw)
self.VerseListView.setCurrentRow(selectedRow + 1)
if selectedRow != self.verseListView.count() - 1:
qw = self.verseListView.takeItem(selectedRow)
self.verseListView.insertItem(selectedRow + 1, qw)
self.verseListView.setCurrentRow(selectedRow + 1)
def onClearButtonPressed(self):
self.VerseTextEdit.clear()
self.verseTextEdit.clear()
self.editAll = False
self.AddButton.setEnabled(True)
self.EditAllButton.setEnabled(True)
self.SaveButton.setEnabled(False)
self.addButton.setEnabled(True)
self.editAllButton.setEnabled(True)
self.saveButton.setEnabled(False)
def onVerseListViewPressed(self, item):
self.DeleteButton.setEnabled(True)
self.EditButton.setEnabled(True)
self.deleteButton.setEnabled(True)
self.editButton.setEnabled(True)
def onVerseListViewSelected(self, item):
self.editText(item.text())
def onAddButtonPressed(self):
self.VerseListView.addItem(self.VerseTextEdit.toPlainText())
self.DeleteButton.setEnabled(False)
self.VerseTextEdit.clear()
self.verseListView.addItem(self.verseTextEdit.toPlainText())
self.deleteButton.setEnabled(False)
self.verseTextEdit.clear()
def onEditButtonPressed(self):
self.editText(self.VerseListView.currentItem().text())
self.editText(self.verseListView.currentItem().text())
def onEditAllButtonPressed(self):
self.editAll = True
self.AddButton.setEnabled(False)
self.SplitButton.setEnabled(True)
if self.VerseListView.count() > 0:
self.addButton.setEnabled(False)
self.splitButton.setEnabled(True)
if self.verseListView.count() > 0:
verse_list = u''
for row in range(0, self.VerseListView.count()):
item = self.VerseListView.item(row)
for row in range(0, self.verseListView.count()):
item = self.verseListView.item(row)
verse_list += item.text()
if row != self.VerseListView.count() - 1:
if row != self.verseListView.count() - 1:
verse_list += u'\n[---]\n'
self.editText(verse_list)
def editText(self, text):
self.beforeText = text
self.VerseTextEdit.setPlainText(text)
self.DeleteButton.setEnabled(False)
self.EditButton.setEnabled(False)
self.EditAllButton.setEnabled(False)
self.SaveButton.setEnabled(True)
self.ClearButton.setEnabled(True)
self.verseTextEdit.setPlainText(text)
self.deleteButton.setEnabled(False)
self.editButton.setEnabled(False)
self.editAllButton.setEnabled(False)
self.saveButton.setEnabled(True)
self.clearButton.setEnabled(True)
def onSaveButtonPressed(self):
if self.editAll:
self.VerseListView.clear()
for row in unicode(self.VerseTextEdit.toPlainText()).split(
self.verseListView.clear()
for row in unicode(self.verseTextEdit.toPlainText()).split(
u'\n[---]\n'):
self.VerseListView.addItem(row)
self.verseListView.addItem(row)
else:
self.VerseListView.currentItem().setText(
self.VerseTextEdit.toPlainText())
self.verseListView.currentItem().setText(
self.verseTextEdit.toPlainText())
#number of lines has change
if len(self.beforeText.split(u'\n')) != \
len(self.VerseTextEdit.toPlainText().split(u'\n')):
len(self.verseTextEdit.toPlainText().split(u'\n')):
tempList = {}
for row in range(0, self.VerseListView.count()):
tempList[row] = self.VerseListView.item(row).text()
self.VerseListView.clear()
for row in range(0, self.verseListView.count()):
tempList[row] = self.verseListView.item(row).text()
self.verseListView.clear()
for row in range (0, len(tempList)):
self.VerseListView.addItem(tempList[row])
self.VerseListView.repaint()
self.AddButton.setEnabled(True)
self.SaveButton.setEnabled(False)
self.EditButton.setEnabled(False)
self.EditAllButton.setEnabled(True)
self.SplitButton.setEnabled(False)
self.VerseTextEdit.clear()
self.verseListView.addItem(tempList[row])
self.verseListView.repaint()
self.addButton.setEnabled(True)
self.saveButton.setEnabled(False)
self.editButton.setEnabled(False)
self.editAllButton.setEnabled(True)
self.splitButton.setEnabled(False)
self.verseTextEdit.clear()
def onSplitButtonPressed(self):
if self.VerseTextEdit.textCursor().columnNumber() != 0:
self.VerseTextEdit.insertPlainText(u'\n')
self.VerseTextEdit.insertPlainText(u'[---]\n' )
self.VerseTextEdit.setFocus()
if self.verseTextEdit.textCursor().columnNumber() != 0:
self.verseTextEdit.insertPlainText(u'\n')
self.verseTextEdit.insertPlainText(u'[---]\n' )
self.verseTextEdit.setFocus()
def onDeleteButtonPressed(self):
self.VerseListView.takeItem(self.VerseListView.currentRow())
self.EditButton.setEnabled(False)
self.EditAllButton.setEnabled(True)
self.verseListView.takeItem(self.verseListView.currentRow())
self.editButton.setEnabled(False)
self.editAllButton.setEnabled(True)
def _validate(self):
if len(self.TitleEdit.displayText()) == 0:
self.TitleEdit.setFocus()
if len(self.titleEdit.displayText()) == 0:
self.titleEdit.setFocus()
return False, translate('CustomPlugin.EditCustomForm',
'You need to type in a title.')
# must have 1 slide
if self.VerseListView.count() == 0:
self.VerseTextEdit.setFocus()
if self.verseListView.count() == 0:
self.verseTextEdit.setFocus()
return False, translate('CustomPlugin.EditCustomForm',
'You need to add at least one slide')
if self.VerseTextEdit.toPlainText():
self.VerseTextEdit.setFocus()
if self.verseTextEdit.toPlainText():
self.verseTextEdit.setFocus()
return False, translate('CustomPlugin.EditCustomForm',
'You have one or more unsaved slides, please either save your '
'slide(s) or clear your changes.')

View File

@ -28,37 +28,37 @@ from PyQt4 import QtCore, QtGui
from openlp.core.lib import translate
class Ui_SongUsageDeleteDialog(object):
def setupUi(self, SongUsageDeleteDialog):
SongUsageDeleteDialog.setObjectName(u'SongUsageDeleteDialog')
SongUsageDeleteDialog.resize(291, 243)
self.layoutWidget = QtGui.QWidget(SongUsageDeleteDialog)
def setupUi(self, songUsageDeleteDialog):
songUsageDeleteDialog.setObjectName(u'songUsageDeleteDialog')
songUsageDeleteDialog.resize(291, 243)
self.layoutWidget = QtGui.QWidget(songUsageDeleteDialog)
self.layoutWidget.setGeometry(QtCore.QRect(20, 10, 247, 181))
self.layoutWidget.setObjectName(u'layoutWidget')
self.verticalLayout = QtGui.QVBoxLayout(self.layoutWidget)
self.verticalLayout.setObjectName(u'verticalLayout')
self.DeleteCalendar = QtGui.QCalendarWidget(self.layoutWidget)
self.DeleteCalendar.setFirstDayOfWeek(QtCore.Qt.Sunday)
self.DeleteCalendar.setGridVisible(True)
self.DeleteCalendar.setVerticalHeaderFormat(
self.deleteCalendar = QtGui.QCalendarWidget(self.layoutWidget)
self.deleteCalendar.setFirstDayOfWeek(QtCore.Qt.Sunday)
self.deleteCalendar.setGridVisible(True)
self.deleteCalendar.setVerticalHeaderFormat(
QtGui.QCalendarWidget.NoVerticalHeader)
self.DeleteCalendar.setObjectName(u'DeleteCalendar')
self.verticalLayout.addWidget(self.DeleteCalendar)
self.buttonBox = QtGui.QDialogButtonBox(SongUsageDeleteDialog)
self.deleteCalendar.setObjectName(u'deleteCalendar')
self.verticalLayout.addWidget(self.deleteCalendar)
self.buttonBox = QtGui.QDialogButtonBox(songUsageDeleteDialog)
self.buttonBox.setGeometry(QtCore.QRect(30, 210, 245, 25))
self.buttonBox.setStandardButtons(
QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
self.buttonBox.setObjectName(u'buttonBox')
self.retranslateUi(SongUsageDeleteDialog)
self.retranslateUi(songUsageDeleteDialog)
QtCore.QObject.connect(
self.buttonBox, QtCore.SIGNAL(u'accepted()'),
SongUsageDeleteDialog.accept)
songUsageDeleteDialog.accept)
QtCore.QObject.connect(
self.buttonBox, QtCore.SIGNAL(u'rejected()'),
SongUsageDeleteDialog.close)
QtCore.QMetaObject.connectSlotsByName(SongUsageDeleteDialog)
songUsageDeleteDialog.close)
QtCore.QMetaObject.connectSlotsByName(songUsageDeleteDialog)
def retranslateUi(self, SongUsageDeleteDialog):
SongUsageDeleteDialog.setWindowTitle(
def retranslateUi(self, songUsageDeleteDialog):
songUsageDeleteDialog.setWindowTitle(
translate('SongUsagePlugin.SongUsageDeleteForm',
'Delete Song Usage Data'))

View File

@ -48,12 +48,11 @@ class SongUsageDeleteForm(QtGui.QDialog, Ui_SongUsageDeleteDialog):
'Delete Selected Song Usage Events?'),
translate('SongUsagePlugin.SongUsageDeleteForm',
'Are you sure you want to delete selected Song Usage data?'),
QtGui.QMessageBox.StandardButtons(
QtGui.QMessageBox.Ok |
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok |
QtGui.QMessageBox.Cancel),
QtGui.QMessageBox.Cancel)
if ret == QtGui.QMessageBox.Ok:
deleteDate = self.DeleteCalendar.selectedDate().toPyDate()
deleteDate = self.deleteCalendar.selectedDate().toPyDate()
self.songusagemanager.delete_all_objects(SongUsageItem,
SongUsageItem.usagedate <= deleteDate)
self.close()

View File

@ -34,41 +34,41 @@ class Ui_SongUsageDetailDialog(object):
SongUsageDetailDialog.resize(609, 413)
self.verticalLayout = QtGui.QVBoxLayout(SongUsageDetailDialog)
self.verticalLayout.setObjectName(u'verticalLayout')
self.DateRangeGroupBox = QtGui.QGroupBox(SongUsageDetailDialog)
self.DateRangeGroupBox.setObjectName(u'DateRangeGroupBox')
self.verticalLayout_2 = QtGui.QVBoxLayout(self.DateRangeGroupBox)
self.verticalLayout_2.setObjectName(u'verticalLayout_2')
self.DateHorizontalLayout = QtGui.QHBoxLayout()
self.DateHorizontalLayout.setObjectName(u'DateHorizontalLayout')
self.FromDate = QtGui.QCalendarWidget(self.DateRangeGroupBox)
self.FromDate.setObjectName(u'FromDate')
self.DateHorizontalLayout.addWidget(self.FromDate)
self.ToLabel = QtGui.QLabel(self.DateRangeGroupBox)
self.ToLabel.setScaledContents(False)
self.ToLabel.setAlignment(QtCore.Qt.AlignCenter)
self.ToLabel.setObjectName(u'ToLabel')
self.DateHorizontalLayout.addWidget(self.ToLabel)
self.ToDate = QtGui.QCalendarWidget(self.DateRangeGroupBox)
self.ToDate.setObjectName(u'ToDate')
self.DateHorizontalLayout.addWidget(self.ToDate)
self.verticalLayout_2.addLayout(self.DateHorizontalLayout)
self.FileGroupBox = QtGui.QGroupBox(self.DateRangeGroupBox)
self.FileGroupBox.setObjectName(u'FileGroupBox')
self.verticalLayout_4 = QtGui.QVBoxLayout(self.FileGroupBox)
self.verticalLayout_4.setObjectName(u'verticalLayout_4')
self.dateRangeGroupBox = QtGui.QGroupBox(SongUsageDetailDialog)
self.dateRangeGroupBox.setObjectName(u'dateRangeGroupBox')
self.verticalLayout2 = QtGui.QVBoxLayout(self.dateRangeGroupBox)
self.verticalLayout2.setObjectName(u'verticalLayout2')
self.dateHorizontalLayout = QtGui.QHBoxLayout()
self.dateHorizontalLayout.setObjectName(u'dateHorizontalLayout')
self.fromDate = QtGui.QCalendarWidget(self.dateRangeGroupBox)
self.fromDate.setObjectName(u'fromDate')
self.dateHorizontalLayout.addWidget(self.fromDate)
self.toLabel = QtGui.QLabel(self.dateRangeGroupBox)
self.toLabel.setScaledContents(False)
self.toLabel.setAlignment(QtCore.Qt.AlignCenter)
self.toLabel.setObjectName(u'toLabel')
self.dateHorizontalLayout.addWidget(self.toLabel)
self.toDate = QtGui.QCalendarWidget(self.dateRangeGroupBox)
self.toDate.setObjectName(u'toDate')
self.dateHorizontalLayout.addWidget(self.toDate)
self.verticalLayout2.addLayout(self.dateHorizontalLayout)
self.fileGroupBox = QtGui.QGroupBox(self.dateRangeGroupBox)
self.fileGroupBox.setObjectName(u'fileGroupBox')
self.verticalLayout4 = QtGui.QVBoxLayout(self.fileGroupBox)
self.verticalLayout4.setObjectName(u'verticalLayout4')
self.horizontalLayout = QtGui.QHBoxLayout()
self.horizontalLayout.setObjectName(u'horizontalLayout')
self.FileLineEdit = QtGui.QLineEdit(self.FileGroupBox)
self.FileLineEdit.setObjectName(u'FileLineEdit')
self.horizontalLayout.addWidget(self.FileLineEdit)
self.SaveFilePushButton = QtGui.QPushButton(self.FileGroupBox)
self.SaveFilePushButton.setIcon(
self.fileLineEdit = QtGui.QLineEdit(self.fileGroupBox)
self.fileLineEdit.setObjectName(u'fileLineEdit')
self.horizontalLayout.addWidget(self.fileLineEdit)
self.saveFilePushButton = QtGui.QPushButton(self.fileGroupBox)
self.saveFilePushButton.setIcon(
build_icon(u':/general/general_load.png'))
self.SaveFilePushButton.setObjectName(u'SaveFilePushButton')
self.horizontalLayout.addWidget(self.SaveFilePushButton)
self.verticalLayout_4.addLayout(self.horizontalLayout)
self.verticalLayout_2.addWidget(self.FileGroupBox)
self.verticalLayout.addWidget(self.DateRangeGroupBox)
self.saveFilePushButton.setObjectName(u'saveFilePushButton')
self.horizontalLayout.addWidget(self.saveFilePushButton)
self.verticalLayout4.addLayout(self.horizontalLayout)
self.verticalLayout2.addWidget(self.fileGroupBox)
self.verticalLayout.addWidget(self.dateRangeGroupBox)
self.buttonBox = QtGui.QDialogButtonBox(SongUsageDetailDialog)
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel |
QtGui.QDialogButtonBox.Ok)
@ -80,7 +80,7 @@ class Ui_SongUsageDetailDialog(object):
SongUsageDetailDialog.accept)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'rejected()'),
SongUsageDetailDialog.close)
QtCore.QObject.connect(self.SaveFilePushButton,
QtCore.QObject.connect(self.saveFilePushButton,
QtCore.SIGNAL(u'pressed()'),
SongUsageDetailDialog.defineOutputLocation)
QtCore.QMetaObject.connectSlotsByName(SongUsageDetailDialog)
@ -89,11 +89,11 @@ class Ui_SongUsageDetailDialog(object):
SongUsageDetailDialog.setWindowTitle(
translate('SongUsagePlugin.SongUsageDetailForm',
'Song Usage Extraction'))
self.DateRangeGroupBox.setTitle(
self.dateRangeGroupBox.setTitle(
translate('SongUsagePlugin.SongUsageDetailForm',
'Select Date Range'))
self.ToLabel.setText(
self.toLabel.setText(
translate('SongUsagePlugin.SongUsageDetailForm', 'to'))
self.FileGroupBox.setTitle(
self.fileGroupBox.setTitle(
translate('SongUsagePlugin.SongUsageDetailForm',
'Report Location'))

View File

@ -56,9 +56,9 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog):
year -= 1
toDate = QtCore.QDate(year, 8, 31)
fromDate = QtCore.QDate(year - 1, 9, 1)
self.FromDate.setSelectedDate(fromDate)
self.ToDate.setSelectedDate(toDate)
self.FileLineEdit.setText(
self.fromDate.setSelectedDate(fromDate)
self.toDate.setSelectedDate(toDate)
self.fileLineEdit.setText(
SettingsManager.get_last_dir(self.parent.settingsSection, 1))
def defineOutputLocation(self):
@ -69,19 +69,19 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog):
path = unicode(path)
if path != u'':
SettingsManager.set_last_dir(self.parent.settingsSection, path, 1)
self.FileLineEdit.setText(path)
self.fileLineEdit.setText(path)
def accept(self):
log.debug(u'Detailed report generated')
filename = u'usage_detail_%s_%s.txt' % (
self.FromDate.selectedDate().toString(u'ddMMyyyy'),
self.ToDate.selectedDate().toString(u'ddMMyyyy'))
self.fromDate.selectedDate().toString(u'ddMMyyyy'),
self.toDate.selectedDate().toString(u'ddMMyyyy'))
usage = self.parent.songusagemanager.get_all_objects(
SongUsageItem, and_(
SongUsageItem.usagedate >= self.FromDate.selectedDate().toPyDate(),
SongUsageItem.usagedate < self.ToDate.selectedDate().toPyDate()),
SongUsageItem.usagedate >= self.fromDate.selectedDate().toPyDate(),
SongUsageItem.usagedate < self.toDate.selectedDate().toPyDate()),
[SongUsageItem.usagedate, SongUsageItem.usagetime])
outname = os.path.join(unicode(self.FileLineEdit.text()), filename)
outname = os.path.join(unicode(self.fileLineEdit.text()), filename)
file = None
try:
file = open(outname, u'w')