Пример #1
0
    def _load_table(self, assignments):
        from PyQt5.QtCore import Qt
        self.tbl.clear()
        if not assignments:
            return
        self.tbl.setRowCount(len(assignments))
        self.tbl.setColumnCount(4)
        self.tbl.setHorizontalHeaderLabels([
            'Employee' if type(self.owner) is Project else 'Project',
            'FM', 'LM', '%'
        ])
        self.tbl.verticalHeader().hide()
        self.tbl.setColumnWidth(0, 180)
        self.tbl.setColumnWidth(1, 50)
        self.tbl.setColumnWidth(2, 50)
        self.tbl.setColumnWidth(3, 30)

        for row, asn in enumerate(assignments):
            if type(self.owner) is Project:
                item = QTableWidgetItem(asn.employee_name)
            else:
                item = QTableWidgetItem(asn.project_name)
            self.tbl.setItem(row, 0, item)
            item = QTableWidgetItem(Monkey.prettify(asn.first_month))
            item.setTextAlignment(Qt.AlignRight)
            self.tbl.setItem(row, 1, item)
            item = QTableWidgetItem(Monkey.prettify(asn.last_month))
            item.setTextAlignment(Qt.AlignRight)
            self.tbl.setItem(row, 2, item)
            item = QTableWidgetItem(str(asn.effort))
            item.setTextAlignment(Qt.AlignRight)
            self.tbl.setItem(row, 3, item)
        self.tbl.setCurrentItem(self.tbl.item(0, 0))
        self._item_selected()
Пример #2
0
 def _item_selected(self):
     asn = self.owner.assignments[self.tbl.currentIndex().row()]
     self.ui.firstMonthEdit.setText(Monkey.prettify(asn.first_month))
     self.ui.lastMonthEdit.setText(Monkey.prettify(asn.last_month))
     self.ui.effortEdit.setText(str(asn.effort))
     self.ui.notesEdit.setPlainText(asn.notes)