Esempio n. 1
0
    def __init__(self, parent, project, rpc, actioncode, cursor=None):
        QtGui.QDialog.__init__(self)
        self.project = project
        self.parent = parent
        self.prjconn = rpc
        self.action = self.project.action_index[actioncode]
        self.table = self.project.table_index[self.action.table]
        self.cursor = cursor

        print "Loading", self.action.name
        self.setWindowTitle("(SqlCursor) %s -> %s" %
                            (self.action.name, self.table.name))
        self.layout = QtGui.QVBoxLayout(self)
        self.title = QtGui.QLabel(self.action.name)
        self.title.setAlignment(QtCore.Qt.AlignCenter)
        font = self.title.font()
        font.setBold(True)
        self.title.setFont(font)

        self.table = QtGui.QTableView(self)
        self.table.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)
        self.table.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)
        self.table.setSortingEnabled(True)
        tableheader = self.table.horizontalHeader()
        tableheader.setSortIndicator(0, 0)
        self.connect(tableheader,
                     QtCore.SIGNAL("sortIndicatorChanged(int,Qt::SortOrder)"),
                     self.table_sortIndicatorChanged)

        self.layout.addWidget(self.title)
        self.buttonLayout = QtGui.QHBoxLayout()
        self.tbInsert = self.tbutton("Insert")
        self.tbDelete = self.tbutton("Delete")
        self.tbCommit = self.tbutton("Commit",
                                     action=self.buttonCommit_clicked)
        self.tbRevert = self.tbutton("Revert",
                                     action=self.buttonRevert_clicked)
        self.buttonLayout.addStretch()
        self.tbNewView = self.tbutton("New View",
                                      action=self.buttonNewView_clicked)
        self.layout.addLayout(self.buttonLayout)
        self.layout.addWidget(self.table)
        if self.cursor is None:
            self.cursor = SqlCursor(self.project, self.prjconn,
                                    self.action.code)
            self.cursor.select()
        self.cursor.configureViewWidget(self.table)
        self.resize(600, 400)

        self.child_views = []