More remote edit changes

This commit is contained in:
Tim Bentley 2009-10-29 13:44:33 +00:00
parent 0ffbc050de
commit 302d29ea85
6 changed files with 67 additions and 37 deletions

View File

@ -39,25 +39,23 @@ class ServiceManagerList(QtGui.QTreeWidget):
self.parent = parent
# def mousePressEvent(self, event):
# if type(event) == QtGui.QMouseEvent:
# if event.button() == QtCore.Qt.RightButton:
# item = self.itemAt(event.pos())
# parentitem = item.parent()
# if parentitem is None:
# pos = item.data(0, QtCore.Qt.UserRole).toInt()[0]
# else:
# pos = parentitem.data(0, QtCore.Qt.UserRole).toInt()[0]
# serviceItem = self.parent.serviceItems[pos - 1]
# if serviceItem[u'data'].editEnabled:
# self.parent.editAction.setVisible(True)
# else:
# self.parent.editAction.setVisible(False)
# event.ignore()
# if event.button() == QtCore.Qt.RightButton:
# item = self.itemAt(event.pos())
# parentitem = item.parent()
# if parentitem is None:
# pos = item.data(0, QtCore.Qt.UserRole).toInt()[0]
# else:
# event.ignore()
# pos = parentitem.data(0, QtCore.Qt.UserRole).toInt()[0]
# serviceItem = self.parent.serviceItems[pos - 1]
# if serviceItem[u'data'].editEnabled:
# self.parent.editAction.setVisible(True)
# else:
# self.parent.editAction.setVisible(False)
# event.accept()
# else:
# event.ignore()
def keyPressEvent(self, event):
if type(event) == QtGui.QKeyEvent:
#here accept the event and do something

View File

@ -54,7 +54,8 @@ class Ui_customEditDialog(object):
self.UpButton.setIcon(icon1)
self.UpButton.setObjectName(u'UpButton')
self.verticalLayout.addWidget(self.UpButton)
spacerItem = QtGui.QSpacerItem(20, 128, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
spacerItem = QtGui.QSpacerItem(20, 128,
QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.verticalLayout.addItem(spacerItem)
self.DownButton = QtGui.QPushButton(customEditDialog)
icon2 = buildIcon(u':/services/service_down.png')
@ -94,7 +95,8 @@ class Ui_customEditDialog(object):
self.ClearButton = QtGui.QPushButton(self.ButtonWidge)
self.ClearButton.setObjectName(u'ClearButton')
self.verticalLayout_2.addWidget(self.ClearButton)
spacerItem1 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
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)
@ -117,11 +119,16 @@ class Ui_customEditDialog(object):
self.horizontalLayout_2.addWidget(self.CreditEdit)
self.gridLayout.addLayout(self.horizontalLayout_2, 4, 0, 1, 1)
self.buttonBox = QtGui.QDialogButtonBox(customEditDialog)
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
self.buttonBox.setStandardButtons(
QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
self.buttonBox.setObjectName(u'buttonBox')
self.gridLayout.addWidget(self.buttonBox, 5, 0, 1, 1)
self.retranslateUi(customEditDialog)
QtCore.QObject.connect(self.buttonBox,
QtCore.SIGNAL(u'rejected()'), customEditDialog.closePressed)
QtCore.QObject.connect(self.buttonBox,
QtCore.SIGNAL(u'accepted()'), customEditDialog.accept)
QtCore.QMetaObject.connectSlotsByName(customEditDialog)
customEditDialog.setTabOrder(self.TitleEdit, self.VerseTextEdit)
customEditDialog.setTabOrder(self.VerseTextEdit, self.AddButton)

View File

@ -40,10 +40,6 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
#self.parent = parent
self.setupUi(self)
# Connecting signals and slots
QtCore.QObject.connect(self.buttonBox,
QtCore.SIGNAL(u'rejected()'), self.rejected)
QtCore.QObject.connect(self.buttonBox,
QtCore.SIGNAL(u'accepted()'), self.accept)
QtCore.QObject.connect(self.AddButton,
QtCore.SIGNAL(u'pressed()'), self.onAddButtonPressed)
QtCore.QObject.connect(self.EditButton,
@ -113,6 +109,10 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
else:
self.ThemeComboBox.setCurrentIndex(0)
def closePressed(self):
Receiver().send_message(u'remote_edit_clear')
self.close()
def accept(self):
valid, message = self._validate()
if not valid:
@ -132,9 +132,7 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
self.customSlide.credits = unicode(self.CreditEdit.displayText())
self.customSlide.theme_name = unicode(self.ThemeComboBox.currentText())
self.custommanager.save_slide(self.customSlide)
self.close()
def rejected(self):
Receiver().send_message(u'load_custom_list')
self.close()
def onUpButtonPressed(self):

View File

@ -26,7 +26,7 @@ import logging
from PyQt4 import QtCore, QtGui
from openlp.core.lib import MediaManagerItem, SongXMLParser, BaseListWithDnD
from openlp.core.lib import MediaManagerItem, SongXMLParser, BaseListWithDnD, Receiver
class CustomListView(BaseListWithDnD):
def __init__(self, parent=None):
@ -53,6 +53,15 @@ class CustomMediaItem(MediaManagerItem):
self.servicePath = None
MediaManagerItem.__init__(self, parent, icon, title)
self.parent = parent
self.fromServiceManager = -1
def addEndHeaderBar(self):
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'%s_edit' % self.parent.name), self.onRemoteEdit)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'remote_edit_clear' ), self.onRemoteEditClear)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'load_custom_list'), self.initialise)
def requiredIcons(self):
MediaManagerItem.requiredIcons(self)
@ -68,12 +77,24 @@ class CustomMediaItem(MediaManagerItem):
custom_name.setData(
QtCore.Qt.UserRole, QtCore.QVariant(CustomSlide.id))
self.ListView.addItem(custom_name)
if CustomSlide.id == self.fromServiceManager:
self.onAddClick()
def onNewClick(self):
self.parent.edit_custom_form.loadCustom(0)
self.parent.edit_custom_form.exec_()
self.initialise()
def onRemoteEditClear(self):
self.fromServiceManager = -1
def onRemoteEdit(self, item_id):
valid = self.parent.custommanager.get_custom(item_id)
if valid is not None:
self.fromServiceManager = item_id
self.parent.edit_custom_form.loadCustom(item_id)
self.parent.edit_custom_form.exec_()
def onEditClick(self):
item = self.ListView.currentItem()
if item is not None:
@ -95,13 +116,19 @@ class CustomMediaItem(MediaManagerItem):
raw_footer = []
slide = None
theme = None
item = self.ListView.currentItem()
if item is None:
return False
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
if self.fromServiceManager == -1:
item = self.ListView.currentItem()
if item is None:
return False
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
else:
item_id = self.fromServiceManager
self.fromServiceManager = -1
customSlide = self.parent.custommanager.get_custom(item_id)
title = customSlide.title
credit = customSlide.credits
service_item.editEnabled = True
service_item.editId = item_id
theme = customSlide.theme_name
if len(theme) is not 0 :
service_item.theme = theme

View File

@ -400,7 +400,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
def onPreview(self, button):
log.debug(u'onPreview')
if button.text() == self.trUtf8(u'Save & Preview') and self.saveSong():
if button.text() == unicode(self.trUtf8(u'Save && Preview')) \
and self.saveSong():
Receiver().send_message(u'preview_song')
def closePressed(self):
@ -410,9 +411,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
def accept(self):
log.debug(u'accept')
if self.saveSong():
if self.title_change:
Receiver().send_message(u'load_song_list')
Receiver().send_message(u'preview_song')
Receiver().send_message(u'load_song_list')
self.close()
def saveSong(self):

View File

@ -55,7 +55,7 @@ class SongMediaItem(MediaManagerItem):
self.edit_song_form = EditSongForm(self.parent.songmanager, self)
self.song_maintenance_form = SongMaintenanceForm(
self.parent.songmanager, self)
self.fromPreview = None
self.fromPreview = -1
self.fromServiceManager = -1
def requiredIcons(self):
@ -184,8 +184,9 @@ class SongMediaItem(MediaManagerItem):
song_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(song.id))
self.ListView.addItem(song_name)
if song.id == self.fromPreview:
self.fromPreview = 0
self.ListView.setCurrentItem(song_name)
self.onPreviewClick()
self.fromPreview = -1
if song.id == self.fromServiceManager:
self.onAddClick()
@ -247,7 +248,7 @@ class SongMediaItem(MediaManagerItem):
item = self.ListView.currentItem()
if item is not None:
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
self.fromPreview = 0
self.fromPreview = -1
if preview:
self.fromPreview = item_id
self.edit_song_form.loadSong(item_id)