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 = []
Esempio n. 2
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 = []
Esempio n. 3
0
class TestSqlCursorDialog(QtGui.QDialog):
    def tbutton(self, title, action=None):
        button = QtGui.QToolButton(self)
        button.setText(title)
        self.buttonLayout.addWidget(button)
        if action:
            if type(action) is list or type(action) is tuple:
                self.connect(button, QtCore.SIGNAL("clicked()"), *action)
            else:
                self.connect(button, QtCore.SIGNAL("clicked()"), action)
        return button

    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 = []

    def table_sortIndicatorChanged(self, column, order):
        print "Sorting", column, order
        self.table.model().setSort(column, order)
        self.table.model().refresh()

    def closeEvent(self, event):
        del self.parent.dialogs[self.action.code]
        event.accept()

    def buttonNewView_clicked(self):
        child = TestSqlCursorDialog(self.parent, self.project, self.prjconn,
                                    self.action.code, self.cursor)
        self.child_views.append(child)
        child.show()

    def buttonCommit_clicked(self):
        self.cursor.commitBuffer()

    def buttonRevert_clicked(self):
        self.cursor.refreshBuffer()
Esempio n. 4
0
class TestSqlCursorDialog(QtGui.QDialog):
    def tbutton(self, title, action = None):
        button = QtGui.QToolButton(self)
        button.setText(title)
        self.buttonLayout.addWidget(button)
        if action:
            if type(action) is list or type(action) is tuple: 
                self.connect(button, QtCore.SIGNAL("clicked()"), *action)
            else:
                self.connect(button, QtCore.SIGNAL("clicked()"), action)
        return button
        
    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 = []
        
        
    def table_sortIndicatorChanged(self, column, order):
        print "Sorting", column, order
        self.table.model().setSort(column,order)
        self.table.model().refresh()
        
    def closeEvent(self,event):
        del self.parent.dialogs[self.action.code]
        event.accept()
        
    def buttonNewView_clicked(self):
        child = TestSqlCursorDialog(self.parent, self.project, self.prjconn, self.action.code, self.cursor)
        self.child_views.append(child)
        child.show()
    
    def buttonCommit_clicked(self):
        self.cursor.commitBuffer()
        
    def buttonRevert_clicked(self):
        self.cursor.refreshBuffer()