Switch individual quirks on and off
This commit is contained in:
parent
fd0375f14f
commit
63fe5fc612
2 changed files with 22 additions and 1 deletions
|
@ -49,8 +49,13 @@ class pesterQuirk(object):
|
|||
raise ValueError("Quirks must be given a dictionary")
|
||||
self.quirk = quirk
|
||||
self.type = self.quirk["type"]
|
||||
if "on" not in self.quirk:
|
||||
self.quirk["on"] = True
|
||||
self.on = self.quirk["on"]
|
||||
def apply(self, string, first=False, last=False):
|
||||
if self.type == "prefix":
|
||||
if not self.on:
|
||||
return string
|
||||
elif self.type == "prefix":
|
||||
return self.quirk["value"] + string
|
||||
elif self.type == "suffix":
|
||||
return string + self.quirk["value"]
|
||||
|
|
16
menus.py
16
menus.py
|
@ -37,6 +37,22 @@ class PesterQuirkList(QtGui.QListWidget):
|
|||
self.setDragEnabled(True)
|
||||
self.setDragDropMode(QtGui.QAbstractItemView.InternalMove)
|
||||
|
||||
def addItem(self, item):
|
||||
self.connect(self, QtCore.SIGNAL('itemChanged(QListWidgetItem *)'),
|
||||
self, QtCore.SLOT('changeCheckState()'))
|
||||
item.setFlags(item.flags() | QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsEnabled)
|
||||
if item.quirk.on:
|
||||
item.setCheckState(2)
|
||||
else:
|
||||
item.setCheckState(0)
|
||||
QtGui.QListWidget.addItem(self, item)
|
||||
|
||||
@QtCore.pyqtSlot()
|
||||
def changeCheckState(self):
|
||||
item = self.currentItem()
|
||||
if not item: return
|
||||
item.quirk.quirk["on"] = item.quirk.on = (item.checkState() == QtCore.Qt.Checked)
|
||||
|
||||
def currentQuirk(self):
|
||||
return self.item(self.currentRow())
|
||||
|
||||
|
|
Loading…
Reference in a new issue