def __init__(self, owner, model): self._table = owner.linkTable QStyledItemDelegate.__init__(self, self._table) self._parent = owner self._model = model self._filename = '' self._dirname = ''
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 __init__(self, owner, model, diag): QStyledItemDelegate.__init__(self, owner) self._parent = owner self._model = model self._diag = diag self.orange = QColor("#FFA500") self.red = QColor("#FF0000") self.green = QColor("#008000") self.gray = QColor("#C0C0C0")
def __init__(self, presenter, parent=None): super(TableWorkspaceDisplayView, self).__init__(parent) self.presenter = presenter self.COPY_ICON = mantidqt.icons.get_icon("mdi.content-copy") self.DELETE_ROW = mantidqt.icons.get_icon("mdi.minus-box-outline") item_delegate = QStyledItemDelegate(self) item_delegate.setItemEditorFactory(PreciseDoubleFactory()) self.setItemDelegate(item_delegate) self.setAttribute(Qt.WA_DeleteOnClose, True) self.repaint_signal.connect(self._run_repaint) header = self.horizontalHeader() header.sectionDoubleClicked.connect(self.handle_double_click)
def __init__(self, presenter, parent=None): super(TableWorkspaceDisplayView, self).__init__(parent) self.presenter = presenter self.COPY_ICON = mantidqt.icons.get_icon("mdi.content-copy") self.DELETE_ROW = mantidqt.icons.get_icon("mdi.minus-box-outline") item_delegate = QStyledItemDelegate(self) item_delegate.setItemEditorFactory(PreciseDoubleFactory()) self.setItemDelegate(item_delegate) self.setAttribute(Qt.WA_DeleteOnClose, True) self.repaint_signal.connect(self._run_repaint) header = self.horizontalHeader() header.sectionDoubleClicked.connect(self.handle_double_click)
def __init__(self, presenter, parent=None, name=''): super(TableWorkspaceDisplayView, self).__init__(parent) self.presenter = presenter self.COPY_ICON = mantidqt.icons.get_icon("fa.files-o") self.DELETE_ROW = mantidqt.icons.get_icon("fa.minus-square-o") self.STATISTICS_ON_ROW = mantidqt.icons.get_icon('fa.fighter-jet') self.GRAPH_ICON = mantidqt.icons.get_icon('fa.line-chart') self.TBD = mantidqt.icons.get_icon('fa.question') item_delegate = QStyledItemDelegate(self) item_delegate.setItemEditorFactory(PreciseDoubleFactory()) self.setItemDelegate(item_delegate) self.setWindowTitle("{} - Mantid".format(name)) self.setWindowFlags(Qt.Window) self.resize(600, 400) self.show()
def __init__(self, presenter, parent=None, name=''): super(TableWorkspaceDisplayView, self).__init__(parent) self.presenter = presenter self.COPY_ICON = mantidqt.icons.get_icon("fa.files-o") self.DELETE_ROW = mantidqt.icons.get_icon("fa.minus-square-o") self.STATISTICS_ON_ROW = mantidqt.icons.get_icon('fa.fighter-jet') self.GRAPH_ICON = mantidqt.icons.get_icon('fa.line-chart') self.TBD = mantidqt.icons.get_icon('fa.question') item_delegate = QStyledItemDelegate(self) item_delegate.setItemEditorFactory(PreciseDoubleFactory()) self.setItemDelegate(item_delegate) self.setWindowTitle("{} - Mantid".format(name)) self.setWindowFlags(Qt.Window) self.resize(600, 400) self.show()
def __init__(self, presenter, parent=None): super(TableWorkspaceDisplayView, self).__init__(parent) self.presenter = presenter self.COPY_ICON = mantidqt.icons.get_icon("fa.files-o") self.DELETE_ROW = mantidqt.icons.get_icon("fa.minus-square-o") self.STATISTICS_ON_ROW = mantidqt.icons.get_icon('fa.fighter-jet') self.GRAPH_ICON = mantidqt.icons.get_icon('fa.line-chart') self.TBD = mantidqt.icons.get_icon('fa.question') item_delegate = QStyledItemDelegate(self) item_delegate.setItemEditorFactory(PreciseDoubleFactory()) self.setItemDelegate(item_delegate) self.setAttribute(Qt.WA_DeleteOnClose, True) self.repaint_signal.connect(self._run_repaint) header = self.horizontalHeader() header.sectionDoubleClicked.connect(self.handle_double_click)
def eventFilter(self, lineEdit, e): if e.type() == QEvent.KeyPress: if e.key() in [Qt.Key_Left, Qt.Key_Right]: self.commitData.emit(lineEdit) self.closeEditor.emit(lineEdit, self.NoHint) if e.key() == Qt.Key_Left: self.move.emit(0, -1) else: self.move.emit(0, 1) return True return QStyledItemDelegate.eventFilter(self, lineEdit, e)
def eventFilter(self, lineEdit, e): if e.type() == QEvent.KeyPress: if e.key() in [Qt.Key_Left, Qt.Key_Right]: self.commitData.emit(lineEdit) self.closeEditor.emit(lineEdit, self.NoHint) if e.key() == Qt.Key_Left: self.move.emit(0, -1) else: self.move.emit(0, 1) return True return QStyledItemDelegate.eventFilter(self, lineEdit, e)
def _updateModel(self, item_list=None): # get item list if not item_list: item_list = self.getCleanItems() # completer = CustomModelCompleter() # self.setCompleter(completer) # update model items self._model = CustomModel(item_list=item_list) self._model.display_item_colors = self.display_item_colors self.proxy_model = QSortFilterProxyModel() self.proxy_model.setSourceModel(self._model) # set models self.completer().setModel(self.proxy_model) # set item for popup # this makes it so that the stylesheet can be attached... # https://forum.qt.io/topic/26703/solved-stylize-using-css-and-editable-qcombobox-s-completions-list-view/7 delegate = QStyledItemDelegate() self.completer().popup().setItemDelegate(delegate)
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 __init__(self, regex): QStyledItemDelegate.__init__(self) self.__regex = regex
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 __init__(self, owner, model): QStyledItemDelegate.__init__(self, owner._tb) self._parent = owner self._mode = CELLTEXT self._model = model self._lastCol = None
def __init__(self, wtree, model): QStyledItemDelegate.__init__(self, wtree) self._parent = wtree self._mode = CELLTEXT self._model = model
def __init__(self, parent): QStyledItemDelegate.__init__(self, parent) self._margin = None
def setEditorData(self, editor, index): text = index.model().data(index, Qt.DisplayRole) #editor.setText(text) return QStyledItemDelegate.setEditorData(self, editor, index)
def __init__(self, parent): QStyledItemDelegate.__init__(self, parent)
def paint(self, painter, option, index): 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)
def __init__(self, parent): QStyledItemDelegate.__init__(self, parent)
def sizeHint(self, *args, **kwargs): return QStyledItemDelegate.sizeHint(self, *args, **kwargs)