def paint(self, painter, option, index): """ Overrides the selection highlight color. https://www.qtcentre.org/threads/41299-How-to-Change-QTreeView-highlight-color Note: this can actually do alot more than that with the QPalette... which is something I should learn how to use apparently... """ from qtpy.QtGui import QPalette item = index.internalPointer() new_option = QStyleOptionViewItem(option) brush = QBrush() if item.isEnabled(): color = QColor(*iColor["rgba_text"]) else: color = QColor(*iColor["rgba_text_disabled"]) # TODO highlight selection color??? # why did I move this here? brush.setColor(color) # brush2 = QBrush(QColor(0, 255, 0, 128)) new_option.palette.setBrush(QPalette.Normal, QPalette.HighlightedText, brush) # new_option.palette.setBrush(QPalette.Normal, QPalette.Highlight, brush2) QStyledItemDelegate.paint(self, painter, new_option, index) # if option.state == QStyle.State_Selected: # brush2 = QBrush(QColor(0, 255, 255, 128)) return
def paint(self, painter, option, index): if (self._parent.modelIndex(index).column() == NMT.COLUMN_NAME): if (self._parent.modelData(index).sidsName() not in OCTXT._ReservedNames): option.font.setWeight(QFont.Bold) uf = self._parent.modelData(index).userState() if (uf in NMT.USERSTATES): if (self._model.hasUserColor(uf)): cl = self._model.getUserColor(uf) option.palette.brush(QPalette.Text).setColor(cl) QStyledItemDelegate.paint(self, painter, option, index) option.font.setWeight(QFont.Light) elif (index.column() in [NMT.COLUMN_VALUE, NMT.COLUMN_DATATYPE]): option.font.setFamily(OCTXT.Table_Family) if (index.column() == NMT.COLUMN_DATATYPE): # option.font.setPointSize(8) pass QStyledItemDelegate.paint(self, painter, option, index) elif (index.column() in NMT.COLUMN_FLAGS): option.decorationPosition = QStyleOptionViewItem.Top QStyledItemDelegate.paint(self, painter, option, index) option.decorationPosition = QStyleOptionViewItem.Left else: QStyledItemDelegate.paint(self, painter, option, index)
def paint(self, painter, option, index): QStyledItemDelegate.paint(self, painter, option, index)
def paint(self, painter, option, index): idx = self._parent.modelIndex(index) col = idx.column() nnm = self._parent.modelData(index).sidsName() pth = CGU.getPathNoRoot(self._parent.modelData(index).sidsPath()) if col == NMT.COLUMN_NAME: if nnm not in OCTXT._ReservedNames: option.font.setWeight(QFont.Bold) QStyledItemDelegate.paint(self, painter, option, index) option.font.setWeight(QFont.Light) if (self._diag is not None) and (pth in self._diag): color = self.gray if self._diag[pth] == DIFF_NX: color = self.gray if self._diag[pth] == DIFF_NA: color = self.green if self._diag[pth] == DIFF_ND: color = self.red painter.save() painter.setBrush(Qt.NoBrush) painter.setPen(color) painter.drawRect(option.rect) painter.restore() elif col == NMT.COLUMN_VALUE: option.font.setFamily(OCTXT.Table_Family) QStyledItemDelegate.paint(self, painter, option, index) if (self._diag is not None) and (pth in self._diag): if self._diag[pth] == DIFF_CV: painter.save() painter.setBrush(Qt.NoBrush) painter.setPen(self.orange) painter.drawRect(option.rect) painter.restore() elif col == NMT.COLUMN_DATATYPE: option.font.setFamily(OCTXT.Table_Family) option.font.setPointSize(8) QStyledItemDelegate.paint(self, painter, option, index) if (self._diag is not None) and (pth in self._diag): if self._diag[pth] == DIFF_CQ: painter.save() painter.setBrush(Qt.NoBrush) painter.setPen(self.orange) painter.drawRect(option.rect) painter.restore() elif col == NMT.COLUMN_SHAPE: QStyledItemDelegate.paint(self, painter, option, index) if (self._diag is not None) and (pth in self._diag): if self._diag[pth] == DIFF_CS: painter.save() painter.setBrush(Qt.NoBrush) painter.setPen(self.orange) painter.drawRect(option.rect) painter.restore() elif col == NMT.COLUMN_SIDS: QStyledItemDelegate.paint(self, painter, option, index) if (self._diag is not None) and (pth in self._diag): if self._diag[pth] == DIFF_CT: painter.save() painter.setBrush(Qt.NoBrush) painter.setPen(self.orange) painter.drawRect(option.rect) painter.restore() else: QStyledItemDelegate.paint(self, painter, option, index)
def paint(self, painter, option, index): if index.column() in [0, 1]: option.decorationPosition = QStyleOptionViewItem.Top QStyledItemDelegate.paint(self, painter, option, index) else: QStyledItemDelegate.paint(self, painter, option, index)