All pastes #404962 Raw Edit

Mine

public python v1 · immutable
·published 2007-03-21 11:58 UTC
rendered paste body
"""Handling orders."""from PyQt4 import QtCore, QtGuifrom PyQt4.uic import loadUiclass ComboBoxDelegate(QtGui.QItemDelegate):    def __init__(self, parent = None):        QtGui.QItemDelegate.__init__(self, parent)    def createEditor(self, parent, styleOptionViewItem, modelIndex):        combo = QtGui.QComboBox(parent)        combo.setEditable(True)        combo.addItem("test 1")        combo.addItem("test 2")        combo.addItem("test 3")            def setEditorData(self, editor, modelIndex):        editor.setEditText("%s"%modelIndex.data())    def setModelData(self, editor, model, modelIndex):        model.setData(modelIndex, editor.getEditText())        class OrderListModel(QtCore.QAbstractTableModel):    def __init__(self, orderRows, parent = None):        QtCore.QAbstractTableModel.__init__(self, parent)        self.orderRows = orderRows or []    def headerData(self, section, orientation, role = QtCore.Qt.DisplayRole):        return QtCore.QVariant(1)    def columnCount(self, parent=QtCore.QModelIndex()):        return 4class OrderRowItem(object):        def __init__(self, orderRow, _parent):        self.orderRow = orderRow        self._parent = parent    def appendChild(self, child):        pass            def child(self, row):        return None        def childCount(self):        return 0        def columnCount(self):        return 4        def data(self, column):        return (orderRow.description,                orderRow.quantity,                orderRow.price,                orderRow.getTotalPrice())[column]        def parent(self):        return self._parent    def row(self):        if self._parent:            return self._parent.childItems.index(self)        return 0class NewOrderForm(QtGui.QMainWindow):    def __init__(self, app, **kwargs):        QtGui.QMainWindow.__init__(self)        self.app = app        loadUi("%s/order.ui"%app.uiPath, self)        model = OrderListModel(None)        self.orderRowsTable.setModel(model)