10 from PySide
import QtCore, QtGui
15 MainWindow.setObjectName(
"MainWindow")
16 MainWindow.resize(573, 468)
18 self.centralwidget.setObjectName(
"centralwidget")
20 self.vboxlayout.setContentsMargins(0, 0, 0, 0)
21 self.vboxlayout.setSpacing(0)
22 self.vboxlayout.setObjectName(
"vboxlayout")
24 checkValues= [
'to be updated',
'2b updt']
25 self.view.setEditTriggers(QtGui.QAbstractItemView.CurrentChanged)
27 self.view.setAlternatingRowColors(
True)
28 self.view.setSelectionBehavior(QtGui.QAbstractItemView.SelectItems)
29 self.view.setHorizontalScrollMode(QtGui.QAbstractItemView.ScrollPerPixel)
30 self.view.setAnimated(
False)
31 self.view.setAllColumnsShowFocus(
True)
32 self.view.setObjectName(
"view")
33 self.view.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
34 self.view.setDragDropMode(QtGui.QAbstractItemView.DragOnly)
35 self.vboxlayout.addWidget(self.
view)
38 self.menubar.setGeometry(QtCore.QRect(0, 0, 573, 31))
39 self.menubar.setObjectName(
"menubar")
41 self.fileMenu.setObjectName(
"fileMenu")
43 self.importMenu.setObjectName(
"importMenu")
45 self.helpMenu.setObjectName(
"helpMenu")
46 MainWindow.setMenuBar(self.
menubar)
48 self.newAction.setObjectName(
"newAction")
50 self.openAction.setObjectName(
"openAction")
52 self.exitAction.setObjectName(
"exitAction")
54 self.importAction.setObjectName(
"importAction")
56 self.importFolderAction.setObjectName(
"importFolderAction")
58 self.aboutAction.setObjectName(
"aboutAction")
65 self.menubar.addAction(self.fileMenu.menuAction())
66 self.menubar.addAction(self.importMenu.menuAction())
67 self.menubar.addAction(self.helpMenu.menuAction())
70 QtCore.QMetaObject.connectSlotsByName(MainWindow)
74 MainWindow.setWindowTitle(
75 QtGui.QApplication.translate(
"MainWindow",
"PyFlex",
None, QtGui.QApplication.UnicodeUTF8))
76 MainWindow.setWindowIcon(QtGui.QIcon(
'../icons/logo_small.png'))
77 self.fileMenu.setTitle(
78 QtGui.QApplication.translate(
"MainWindow",
"&File",
None, QtGui.QApplication.UnicodeUTF8))
79 self.importMenu.setTitle(
80 QtGui.QApplication.translate(
"MainWindow",
"&Import",
None, QtGui.QApplication.UnicodeUTF8))
81 self.helpMenu.setTitle(
82 QtGui.QApplication.translate(
"MainWindow",
"&Help",
None, QtGui.QApplication.UnicodeUTF8))
83 self.newAction.setText(QtGui.QApplication.translate(
"MainWindow",
"New",
None, QtGui.QApplication.UnicodeUTF8))
84 self.newAction.setShortcut(
85 QtGui.QApplication.translate(
"MainWindow",
"Ctrl+N",
None, QtGui.QApplication.UnicodeUTF8))
86 self.openAction.setText(
87 QtGui.QApplication.translate(
"MainWindow",
"Open",
None, QtGui.QApplication.UnicodeUTF8))
88 self.openAction.setShortcut(
89 QtGui.QApplication.translate(
"MainWindow",
"Ctrl+O",
None, QtGui.QApplication.UnicodeUTF8))
90 self.exitAction.setText(
91 QtGui.QApplication.translate(
"MainWindow",
"E&xit",
None, QtGui.QApplication.UnicodeUTF8))
92 self.exitAction.setShortcut(
93 QtGui.QApplication.translate(
"MainWindow",
"Ctrl+Q",
None, QtGui.QApplication.UnicodeUTF8))
94 self.importAction.setText(
95 QtGui.QApplication.translate(
"MainWindow",
"Import time series",
None, QtGui.QApplication.UnicodeUTF8))
96 self.importAction.setShortcut(
97 QtGui.QApplication.translate(
"MainWindow",
"Ctrl+I",
None, QtGui.QApplication.UnicodeUTF8))
98 self.importFolderAction.setText(QtGui.QApplication.translate(
"MainWindow",
"Import time series folder",
None,
99 QtGui.QApplication.UnicodeUTF8))
100 self.importFolderAction.setShortcut(
101 QtGui.QApplication.translate(
"MainWindow",
"Ctrl+Shift+I",
None, QtGui.QApplication.UnicodeUTF8))
102 self.importFolderAction.setToolTip(
'Imports all tim files in folder')
104 self.aboutAction.setText(
105 QtGui.QApplication.translate(
"MainWindow",
"About",
None, QtGui.QApplication.UnicodeUTF8))
109 QtGui.QToolTip.showText(
110 QtGui.QCursor.pos(), self.importFolderAction.toolTip(), self)
114 """Superclass for all tree models in the project 116 List of methods that needs to be implemented when inherting this class: 120 super(GenericTreeModel, self).
__init__(parent)
126 return self.rootItem.columnCount()
130 Method for getting hold of the item from its index 131 :param index: the index of the item 132 :return:the pointer to the item itself 135 item = index.internalPointer()
142 """ Do not know. called by the view to get hold of the data I believe 143 :param index: the index 144 :param role: the role 145 :return:the data in display friendly mode 147 if not index.isValid():
149 if role == QtCore.Qt.DisplayRole
or role == QtCore.Qt.EditRole:
150 item = index.internalPointer()
151 return item.data(index.column())
152 elif role == QtCore.Qt.CheckStateRole:
157 def setData(self, index, value, role=QtCore.Qt.EditRole):
159 :param index: the index of the item queried 160 :param value: the new value of the data 161 :param role: which role the view queries. only EditRole relevant 162 :return: returns the result. Should be the data put into some item. 164 if role != QtCore.Qt.EditRole:
168 result = item.setData(index.column(), value)
171 self.dataChanged.emit(index, index)
177 return QtCore.Qt.CopyAction | QtCore.Qt.MoveAction
181 :param section: do not know 182 :param orientation: no idea 183 :param role: in which context the view queries info 186 if orientation == QtCore.Qt.Horizontal
and role == QtCore.Qt.DisplayRole:
187 return self.rootItem.data(section)
190 def index(self, row, column, parent):
192 :param row: the row of the tree model 193 :param column: which column of the tree model 194 :param parent: the parent of the item 195 :return:the index of the item 197 if not self.hasIndex(row, column, parent):
198 return QtCore.QModelIndex()
199 if not parent.isValid():
200 parentItem = self.rootItem
202 parentItem = parent.internalPointer()
203 childItem = parentItem.child(row)
205 return self.createIndex(row, column, childItem)
207 return QtCore.QModelIndex()
211 :param index: the index oof the item 212 :return: the index of the parent of the item 214 if not index.isValid():
215 return QtCore.QModelIndex()
216 childItem = index.internalPointer()
217 parentItem = childItem.parent()
218 if parentItem == self.rootItem:
219 return QtCore.QModelIndex()
220 return self.createIndex(parentItem.row(), 0, parentItem)
222 def removeRows(self, position, rows, parent=QtCore.QModelIndex()):
223 parentItem = self.
getItem(parent)
225 self.beginRemoveRows(parent, position, position + rows - 1)
226 success = parentItem.removeChildren(position, rows)
232 """ returns the number of children of the parent. sounds like it should return the number of rows in total... 233 :param parent: the parent of something. 236 if parent.column() > 0:
238 if not parent.isValid():
239 parentItem = self.rootItem
241 parentItem = parent.internalPointer()
242 return parentItem.childCount()
244 def insertRows(self, position, rows, parent=QtCore.QModelIndex()):
245 parentItem = self.
getItem(parent)
246 self.beginInsertRows(parent, position, position + rows - 1)
247 success = parentItem.insertChildren(position, rows,
248 self.rootItem.columnCount())
255 A delegate that places a fully functioning QComboBox in every 256 cell of the column to which it's applied 258 updateModelandDataSignal = QtCore.Signal()
260 super(ComboDelegate,self).
__init__(parent)
263 item=index.model().getItem(index)
266 if hasattr(item,
'type'):
267 if item.type==
'combo' or item.type==
'presslayer':
268 combo = QtGui.QComboBox(parent)
269 combo.addItems(item.options)
270 for i
in range(len(item.options)):
271 if item.options[i] == item.data(1):
272 combo.setCurrentIndex(i)
273 self.connect(combo, QtCore.SIGNAL(
"currentIndexChanged(int)"), self, QtCore.SLOT(
"currentIndexChanged()"))
276 return super(ComboDelegate,self).
createEditor(parent, option,index)
279 editor.blockSignals(
True)
280 item=index.model().getItem(index)
281 if hasattr(item,
'type'):
282 if item.type==
'combo' or item.type==
'presslayer':
283 for i
in range(len(item.options)):
284 if item.options[i]==item.data:
285 editor.setCurrentIndex(i)
290 item=index.model().getItem(index)
291 if hasattr(item,
'type'):
292 if item.type==
'combo' or item.type==
'presslayer':
293 model.setData(index, editor.currentText())
294 self.updateModelandDataSignal.emit()
296 super(ComboDelegate,self).
setModelData(editor, model, index)
301 self.commitData.emit(self.sender())
def setupUi(self, MainWindow)
def createEditor(self, parent, option, index)
def headerData(self, section, orientation, role)
def columnCount(self, parent)
def __init__(self, parent=None)
def removeRows(self, position, rows, parent=QtCore.QModelIndex())
def supportedDropActions(self)
def currentIndexChanged(self)
def rowCount(self, parent)
def data(self, index, role)
def setData(self, index, value, role=QtCore.Qt.EditRole)
def index(self, row, column, parent)
def __init__(self, parent)
def insertRows(self, position, rows, parent=QtCore.QModelIndex())
def setModelData(self, editor, model, index)
def retranslateUi(self, MainWindow)
def handleMenuHovered(self)
def setEditorData(self, editor, index)