Пример #1
0
    def paint(self, painter, option, index):
        QItemDelegate.paint(self, painter, option, index)
        column = index.column()
        row = index.row()
        rect = option.rect

        # Draw borders
        pen = QPen()
        pen.setWidth(1)
        pen.setColor(QColor('#cdcdcd'))
        painter.setPen(pen)
        painter.drawLine(rect.topLeft(), rect.topRight())

        if (row == self.current_hover_row() or row == self.current_row() and
                (self.has_focus_or_context())):
            brush = QBrush(Qt.SolidPattern)
            brush.setColor(QColor(255, 255, 255, 100))
            painter.fillRect(rect, brush)
            if row == self.current_row() and column in [const.COL_START]:
                pen = QPen()
                pen.setWidth(10)
                pen.setColor(QColor('#7cbb4c'))
                painter.setPen(pen)
                dyt = QPoint(0, 5)
                dyb = QPoint(0, 4)
                painter.drawLine(rect.bottomLeft()-dyb, rect.topLeft()+dyt)
Пример #2
0
 def setEditorData(self, editor, index):
     text = index.model().data(index, Qt.DisplayRole)
     column = index.column()
     if column == 0:
         editor.setText(text)
     elif column == 1:
         editor.setText(text)
     else:
         QItemDelegate.setEditorData(self, editor, index)
Пример #3
0
    def paint(self, painter, option, index):
        """Paint."""
        logtype = self.parent().model().data(
            index.sibling(index.row(), 2))
        if logtype.upper() == 'WARN':
            painter.fillRect(option.rect, PyDMLed.Yellow)
        elif logtype.upper() == 'ERR':
            painter.fillRect(option.rect, PyDMLed.Red)
        elif logtype.upper() == 'DISCONN':
            painter.fillRect(option.rect, PyDMLed.Gray)

        QItemDelegate.paint(self, painter, option, index)
Пример #4
0
 def sizeHint(self, style, model_index):
     """Override Qt method."""
     column = model_index.column()
     if column in [C.ACTION_COLUMNS, C.COL_PACKAGE_TYPE]:
         return QSize(32, 32)
     else:
         return QItemDelegate.sizeHint(self, style, model_index)
Пример #5
0
 def sizeHint(self, style, model_index):
     column = model_index.column()
     if column in [const.COL_PACKAGE_TYPE] + [const.ACTION_COLUMNS,
                                              const.COL_PACKAGE_TYPE]:
         return QSize(24, 24)
     else:
         return QItemDelegate.sizeHint(self, style, model_index)
Пример #6
0
 def setModelData(self, editor, model, index):
     column = index.column()
     if column == 0:
         model.setData(index, editor.selection())
     elif column == 1:
         model.setData(index, editor.text())
     else:
         return QItemDelegate.setModelData(self, editor, model, index)
Пример #7
0
 def createEditor(self, parent, option, index):
     column = index.column()
     if column == 0:
         return TextAttributeLineEdit(WindowLayer.material, parent)
     elif column == 1:
         return NumericalAttributeLineEdit(WindowLayer.thickness, parent)
     else:
         return QItemDelegate.createEditor(self, parent, option, index)
Пример #8
0
    def __init__(self,
                 dtype,
                 parent=None,
                 font=None,
                 minvalue=None,
                 maxvalue=None):
        QItemDelegate.__init__(self, parent)
        self.dtype = dtype
        if font is None:
            font = get_font('arrayeditor')
        self.font = font
        self.minvalue = minvalue
        self.maxvalue = maxvalue

        # We must keep a count instead of the "current" one, because when
        # switching from one cell to the next, the new editor is created
        # before the old one is destroyed, which means it would be set to None
        # when the old one is destroyed.
        self.editor_count = 0
Пример #9
0
    def paint(self, painter, option, index):
        """Override Qt method."""
        QItemDelegate.paint(self, painter, option, index)
        column = index.column()
        row = index.row()
        rect = option.rect

        # Draw borders
        # pen = QPen()
        # pen.setWidth(1)
        # pen.setColor(QColor('#cdcdcd'))
        # painter.setPen(pen)
        # painter.drawLine(rect.topLeft(), rect.topRight())

        if column in [C.COL_NAME, C.COL_DESCRIPTION, C.COL_VERSION]:
            pen = QPen()
            pen.setWidth(1)
            pen.setColor(QColor('#ddd'))
            painter.setPen(pen)
            painter.drawLine(rect.topRight(), rect.bottomRight())

        if (row == self.current_hover_row()
                or row == self.current_row() and self.has_focus_or_context()):
            pen = QPen()
            pen.setWidth(1)
            if row == self.current_row():
                pen.setColor(QColor('#007041'))
            else:
                pen.setColor(QColor('#43b02a'))
            painter.setPen(pen)
            painter.drawLine(rect.topLeft(), rect.topRight())
            painter.drawLine(rect.bottomLeft(), rect.bottomRight())

        if (row == self.current_row() and self.has_focus_or_context()
                and column in [C.COL_START]):
            pen = QPen()
            pen.setWidth(10)
            pen.setColor(QColor('#007041'))
            painter.setPen(pen)
            dyt = QPoint(0, 5)
            dyb = QPoint(0, 4)
            painter.drawLine(rect.bottomLeft() - dyb, rect.topLeft() + dyt)
Пример #10
0
 def createEditor(self, parent, option, index):
     column = index.column()
     if column == 0:
         editor = PeriodicTableDialog(parent)
         editor.setMultipleSelection(False)
         editor.setRequiresSelection(True)
         return editor
     elif column == 1:
         editor = QLineEdit(parent)
         editor.setValidator(QDoubleValidator())
         return editor
     else:
         return QItemDelegate.createEditor(self, parent, option, index)
Пример #11
0
 def createEditor(self, parent, option, index):
     column = index.column()
     if column == 0:
         return NumericalAttributeLineEdit(SpecimenPosition.x, parent)
     elif column == 1:
         return NumericalAttributeLineEdit(SpecimenPosition.y, parent)
     elif column == 2:
         return NumericalAttributeLineEdit(SpecimenPosition.y, parent)
     elif column == 3:
         return NumericalAttributeLineEdit(SpecimenPosition.y, parent)
     elif column == 4:
         return NumericalAttributeLineEdit(SpecimenPosition.y, parent)
     else:
         return QItemDelegate.createEditor(self, parent, option, index)
Пример #12
0
    def paint(self, painter, option, index):
        """Override paint function.

        Responsible for painting dirt columns and cells.
        """
        col = index.column()
        pvname = index.model()._vertical_header[index.row()]['name']
        if pvname in index.model().configurations[col]._dirty_pvs.keys():
            color = QColor(200, 0, 0)
            painter.fillRect(option.rect, color)
            QItemDelegate.paint(self, painter, option, index)
        elif index.model().configurations[col].dirty:
            color = QColor(230, 230, 230)
            painter.fillRect(option.rect, color)
            QItemDelegate.paint(self, painter, option, index)
        else:
            QItemDelegate.paint(self, painter, option, index)
Пример #13
0
 def __init__(self, parent=None):
     QItemDelegate.__init__(self, parent)
Пример #14
0
 def __init__(self, dtype, parent=None):
     QItemDelegate.__init__(self, parent)
     self.dtype = dtype
Пример #15
0
 def __init__(self):
     QItemDelegate.__init__(self)
Пример #16
0
 def __init__(self, parent=None):
     QItemDelegate.__init__(self, parent)
Пример #17
0
 def __init__(self, parent=None):
     QItemDelegate.__init__(self, parent)
     self._editors = {}  # keep references on opened editors
Пример #18
0
 def __init__(self, dtype, parent=None):
     QItemDelegate.__init__(self, parent)
     self.dtype = dtype