Ejemplo n.º 1
0
    def init_ui(self):
        model = QtGui.QStandardItemModel()
        model.setHorizontalHeaderItem(0, QtGui.QStandardItem("Last Name"))
        model.setHorizontalHeaderItem(1, QtGui.QStandardItem("First Name"))
        model.setHorizontalHeaderItem(2, QtGui.QStandardItem("Email"))

        profs = Database.get_all_professors()
        count = 0
        for prof in profs:
            model.setItem(count, 0, QtGui.QStandardItem(prof["last_name"]))
            model.setItem(count, 1, QtGui.QStandardItem(prof["first_name"]))
            model.setItem(count, 2, QtGui.QStandardItem(prof["email"]))
            count += 1

        completer = QtWidgets.QCompleter()
        completer.setFilterMode(QtCore.Qt.MatchContains)
        completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive)
        completer.setModel(model)
        popup = QtWidgets.QTableView()
        popup.setModel(model)
        popup.setMinimumSize(320, 250)
        completer.setPopup(popup)
        self.newProfessorDropDown.setCompleter(completer)
        self.newProfessorDropDown.setModel(model)
        self.newProfessorDropDown.setView(QtWidgets.QTableView())

        self.cancelButton.clicked.connect(self.cancel_button_clicked)
        self.okButton.clicked.connect(self.ok_button_clicked)
        self.newProfessorDropDown.activated.connect(self.dropdown_activated)
        self.newProfessorDropDown.completer().activated[
            QtCore.QModelIndex].connect(self.completer_activated)
        self.newSubjectInput.textEdited.connect(self.edit_subject_text)
        self.newCatalogInput.textEdited.connect(self.edit_catalog_text)
        self.newSectionInput.textEdited.connect(self.edit_section_text)
Ejemplo n.º 2
0
    def fill_table(self):
        model = QtGui.QStandardItemModel()
        model.setHorizontalHeaderItem(0, QtGui.QStandardItem("Last Name"))
        model.setHorizontalHeaderItem(1, QtGui.QStandardItem("First Name"))
        model.setHorizontalHeaderItem(2, QtGui.QStandardItem("Email"))

        profs = Database.get_all_professors()
        count = 0
        for prof in profs:
            self.professorsTable.setRowCount(count + 1)
            self.professorsTable.setItem(
                count, 0, QtWidgets.QTableWidgetItem(prof["last_name"]))
            self.professorsTable.setItem(
                count, 1, QtWidgets.QTableWidgetItem(prof["first_name"]))
            self.professorsTable.setItem(
                count, 2, QtWidgets.QTableWidgetItem(prof["email"]))

            model.setItem(count, 0, QtGui.QStandardItem(prof["last_name"]))
            model.setItem(count, 1, QtGui.QStandardItem(prof["first_name"]))
            model.setItem(count, 2, QtGui.QStandardItem(prof["email"]))
            count += 1

        self.numProfessorsLabel.setText(str(self.professorsTable.rowCount()))

        completer = QtWidgets.QCompleter()
        completer.setFilterMode(QtCore.Qt.MatchContains)
        completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive)
        completer.setModel(model)
        popup = QtWidgets.QTableView()
        popup.setModel(model)
        popup.setMinimumWidth(530)
        popup.setMinimumHeight(250)
        popup.setColumnWidth(0, 150)
        popup.setColumnWidth(1, 150)
        popup.setColumnWidth(2, 215)
        completer.setPopup(popup)
        self.searchbar.setCompleter(completer)