5 from PyQt5
import QtCore
6 from .preset
import Preset
9 def __init__(self, preset, parent=None, *args):
10 QtCore.QAbstractListModel.__init__(self, parent, *args)
15 self.
insertRowinsertRow(row, QtCore.QModelIndex(),op)
16 model_index = self.createIndex(row,0)
17 end_index = self.createIndex(self.
rowCountrowCount(),0)
18 self.emit(QtCore.SIGNAL(
"dataChanged"),model_index, end_index)
22 self.
removeRowremoveRow(row, QtCore.QModelIndex())
23 model_index = self.createIndex(row,0)
24 self.emit(QtCore.SIGNAL(
"dataChanged"),model_index, model_index)
28 if model_index.isValid():
32 self.
preset_preset_.SetOp(model_index.row(), op)
38 def rowCount(self, parent=QtCore.QModelIndex()):
39 return self.
preset_preset_.GetOpCount()
41 def data(self, index, role):
42 if index.isValid()
and index.row()< self.
rowCountrowCount():
44 if role == QtCore.Qt.DisplayRole:
46 selection=str(data.GetSelection())
48 return QtCore.QVariant(str(
"%s (%s)"%(name,selection.replace(os.linesep,
" "))))
50 return QtCore.QVariant(str(
"%s (all)"%name))
51 return QtCore.QVariant()
57 if role == QtCore.Qt.EditRole:
59 elif role == QtCore.Qt.DisplayRole:
61 elif role == QtCore.Qt.DecorationRole:
67 flags = QtCore.QAbstractItemModel.flags(self,index)
68 return flags | QtCore.Qt.ItemIsEditable
69 return QtCore.Qt.ItemIsEnabled
72 self.beginInsertRows(index, position, position)
73 self.
preset_preset_.InsertOp(position, op)
78 self.beginRemoveRows(index, position, position)
79 self.
preset_preset_.RemoveOpAt(position)
def RemoveItem(self, row)
def SetItem(self, model_index, op)
def data(self, index, role)
def GetOp(self, model_index)
def __init__(self, preset, parent=None, *args)
def insertRow(self, position, index, op)
def setData(self, index, value, role)
def removeRow(self, position, index)
def AddItem(self, op, row)
def rowCount(self, parent=QtCore.QModelIndex())