def set_inspection(self, projectId, sectionId, inspectionId): self.clearContents() self.projectId = projectId self.sectionId = sectionId self.inspectionId = inspectionId for r in range(self.rowCount() - 1, -1, -1): self.removeRow(r) if self.projectId is None or self.sectionId is None or self.inspectionId is None: return for o_id, obs in self.data[self.projectId]['Sections'][self.sectionId]['Inspections'][self.inspectionId]['Observations'].iteritems(): r = self.rowCount() self.insertRow(r) for c, col in enumerate(ColumnData): item = QTableWidgetItem(u'{}'.format(obs[col] if c < 6 else '')) if c in (0,6): data_column = 'Import' if c == 0 else 'ForceImport' item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsUserCheckable) item.setCheckState(Qt.Checked if obs[data_column] else Qt.Unchecked) item.setData(Qt.UserRole, o_id) item.setData(Qt.UserRole+1, data_column) else: item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable) font = item.font() font.setPointSize(font.pointSize() - 2) item.setFont(font) self.setItem(r, c, item) self.resizeColumnsToContents()
def finish_init(self, data): self.data = data for c, col in enumerate(ColumnHeaders): self.insertColumn(c) item = QTableWidgetItem(col) font = item.font() font.setPointSize(font.pointSize() - 2) item.setFont(font) self.setHorizontalHeaderItem(c, item) self.adjustSize()
def displayColumns(self): self.clear() for c in range(self.columnCount() - 1, -1, -1): self.removeColumn(c) for r in range(self.rowCount() - 1, -1, -1): self.removeRow(r) columns = self.settings.value("columns") c = 0 for i, col in enumerate(columnVarSetting): if col in columns: if columnRowName[i] == "changedGeometryStr" and not self.geomColumn: continue self.insertColumn(c) item = QTableWidgetItem(columnFancyName[i]) item.setData(Qt.UserRole, columnRowName[i]) font = item.font() font.setPointSize(font.pointSize() - 2) item.setFont(font) self.setHorizontalHeaderItem(c, item) c += 1 self.horizontalHeader().setMinimumSectionSize(15)
def __add_record(self, ip, port, schema): count = self.__profile_table.rowCount() self.__profile_table.insertRow(count) ip_item = QTableWidgetItem(ip) ip_item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable) item_font = ip_item.font() item_font.setPointSizeF(12) ip_item.setFont(item_font) port_item = QTableWidgetItem(port) port_item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable) port_item.setFont(item_font) schema_item = QTableWidgetItem(schema) schema_item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable) schema_item.setFont(item_font) self.__profile_table.setItem(count, 0, ip_item) self.__profile_table.setItem(count, 1, port_item) self.__profile_table.setItem(count, 2, schema_item)