Esempio n. 1
0
    def tableRecords(self):
        if self.tableRecords_:
            print("ERROR: tableRecords - llamada doble")
            return

        self.tabDataLayout = QtGui.QVBoxLayout()
        self.comboBoxFieldToSearch = QtGui.QComboBox()
        self.comboBoxFieldToSearch2 = QtGui.QComboBox()
        self.lineEditSearch = QtGui.QLineEdit()
        label1 = QtGui.QLabel()
        label2 = QtGui.QLabel()

        label1.setText("Buscar")
        label2.setText("en")

        self.tabControlLayout = QtGui.QHBoxLayout()

        self.tabControlLayout.addWidget(label1)
        self.tabControlLayout.addWidget(self.lineEditSearch)
        self.tabControlLayout.addWidget(label2)
        self.tabControlLayout.addWidget(self.comboBoxFieldToSearch)
        self.tabControlLayout.addWidget(self.comboBoxFieldToSearch2)

        self.tabDataLayout.addLayout(self.tabControlLayout)


        if not self.tableRecords_:
            self.tableRecords_ = FLDataTable(self, "tableRecords")
            self.tableRecords_.setFocusPolicy(QtCore.Qt.StrongFocus)
            self.setFocusProxy(self.tableRecords_)
            self.tabDataLayout.addWidget(self.tableRecords_)
            self.lineEditSearch.installEventFilter(self)
            self.tableRecords_.installEventFilter(self)

            self.setLayout(self.tabDataLayout)
            self.setTabOrder(self.tableRecords_, self.lineEditSearch)
            self.setTabOrder(self.lineEditSearch, self.comboBoxFieldToSearch)
            self.setTabOrder(self.comboBoxFieldToSearch, self.comboBoxFieldToSearch2)
            self.tableRecords_.recordChoosed.connect(self.currentChanged)

        self.lineEditSearch.textChanged.connect(self.filterRecords)
        model = self.cursor_.model()

        if model:
            for column in range(model.columnCount()):
                field = model.metadata().indexFieldObject(column)
                if not field.visibleGrid():
                    self.tableRecords_.setColumnHidden(column, True)
                else:
                    self.comboBoxFieldToSearch.addItem(model.headerData(column, QtCore.Qt.Horizontal, QtCore.Qt.DisplayRole))
                    self.comboBoxFieldToSearch2.addItem(model.headerData(column, QtCore.Qt.Horizontal, QtCore.Qt.DisplayRole))
            self.comboBoxFieldToSearch.addItem("*")
            self.comboBoxFieldToSearch2.addItem("*")
            self.comboBoxFieldToSearch.setCurrentIndex(0)
            self.comboBoxFieldToSearch2.setCurrentIndex(1)
            self.comboBoxFieldToSearch.currentIndexChanged.connect(self.putFirstCol)
            self.comboBoxFieldToSearch2.currentIndexChanged.connect(self.putSecondCol)
            self._controlsInit = True

        else:
            self.comboBoxFieldToSearch.addItem("*")
            self.comboBoxFieldToSearch2.addItem("*")

        return self.tableRecords_