Event clean ups and fixes

This commit is contained in:
Tim Bentley 2010-03-04 22:03:43 +00:00
parent 9ada2f00b0
commit 181c7c9946
2 changed files with 39 additions and 30 deletions

View File

@ -60,7 +60,6 @@ QToolBar
padding: 0; padding: 0;
} }
""" """
log = logging.getLogger(__name__)
class OpenLP(QtGui.QApplication): class OpenLP(QtGui.QApplication):
""" """

View File

@ -42,15 +42,15 @@ class ServiceManagerList(QtGui.QTreeWidget):
def __init__(self, parent=None, name=None): def __init__(self, parent=None, name=None):
QtGui.QTreeWidget.__init__(self,parent) QtGui.QTreeWidget.__init__(self,parent)
self.parent = parent self.parent = parent
self.setExpandsOnDoubleClick(False)
def mouseDoubleClickEvent(self, event):
self.parent.makeLive()
event.ignore()
def mousePressEvent(self, event): def mousePressEvent(self, event):
if event.button() == QtCore.Qt.RightButton: #Implement item selection
item = self.itemAt(event.pos()) item = self.itemAt(event.pos())
if item is not None:
self.setCurrentItem(item)
parentitem = item.parent() parentitem = item.parent()
if event.button() == QtCore.Qt.RightButton:
self.parent.noteAction.setVisible(False) self.parent.noteAction.setVisible(False)
if parentitem is None: if parentitem is None:
pos = item.data(0, QtCore.Qt.UserRole).toInt()[0] pos = item.data(0, QtCore.Qt.UserRole).toInt()[0]
@ -58,7 +58,6 @@ class ServiceManagerList(QtGui.QTreeWidget):
else: else:
pos = parentitem.data(0, QtCore.Qt.UserRole).toInt()[0] pos = parentitem.data(0, QtCore.Qt.UserRole).toInt()[0]
serviceItem = self.parent.serviceItems[pos - 1] serviceItem = self.parent.serviceItems[pos - 1]
self.parent.menuServiceItem = serviceItem
if serviceItem[u'service_item'].is_text(): if serviceItem[u'service_item'].is_text():
self.parent.themeMenu.menuAction().setVisible(True) self.parent.themeMenu.menuAction().setVisible(True)
else: else:
@ -68,11 +67,22 @@ class ServiceManagerList(QtGui.QTreeWidget):
else: else:
self.parent.editAction.setVisible(False) self.parent.editAction.setVisible(False)
event.accept() event.accept()
elif event.button() == QtCore.Qt.LeftButton:
if parentitem is None:
if self.isItemExpanded(item):
self.collapseItem(item)
else: else:
event.ignore() self.expandItem(item)
else:
event.accept()
else:
event.accept()
def mouseDoubleClickEvent(self, event):
self.parent.makeLive()
event.accept()
def keyPressEvent(self, event): def keyPressEvent(self, event):
print event.isAutoRepeat()
if type(event) == QtGui.QKeyEvent: if type(event) == QtGui.QKeyEvent:
#here accept the event and do something #here accept the event and do something
if event.key() == QtCore.Qt.Key_Enter: if event.key() == QtCore.Qt.Key_Enter:
@ -256,10 +266,11 @@ class ServiceManager(QtGui.QWidget):
self.presentation_types = presentation_types self.presentation_types = presentation_types
def onServiceItemNoteForm(self): def onServiceItemNoteForm(self):
item, count = self.findServiceItem()
self.serviceItemNoteForm.textEdit.setPlainText( self.serviceItemNoteForm.textEdit.setPlainText(
self.menuServiceItem[u'service_item'].notes) self.serviceItems[item][u'service_item'].notes)
if self.serviceItemNoteForm.exec_(): if self.serviceItemNoteForm.exec_():
self.menuServiceItem[u'service_item'].notes = \ self.serviceItems[item][u'service_item'].notes = \
self.serviceItemNoteForm.textEdit.toPlainText() self.serviceItemNoteForm.textEdit.toPlainText()
def nextItem(self): def nextItem(self):
@ -650,7 +661,6 @@ class ServiceManager(QtGui.QWidget):
""" """
Send the current item to the Live slide controller Send the current item to the Live slide controller
""" """
print "ml"
item, count = self.findServiceItem() item, count = self.findServiceItem()
self.parent.LiveController.addServiceManagerItem( self.parent.LiveController.addServiceManagerItem(
self.serviceItems[item][u'service_item'], count) self.serviceItems[item][u'service_item'], count)