コード例 #1
0
    def __update(self):
        """Update the current description.
        """
        if self.__currentIndex != -1:
            index = self.model().index(self.__currentIndex, 0)
        else:
            index = QModelIndex()

        if not index.isValid():
            description = ""
            name = ""
            path = ""
            svg = NO_PREVIEW_SVG
        else:
            description = qtcompat.qunwrap(index.data(Qt.WhatsThisRole))
            if description:
                description = six.text_type(description)
            else:
                description = u"No description."

            description = escape(description)
            description = description.replace("\n", "<br/>")

            name = qtcompat.qunwrap(index.data(Qt.DisplayRole))
            if name:
                name = six.text_type(name)
            else:
                name = "Untitled"

            name = escape(name)
            path = qtcompat.qunwrap(index.data(Qt.StatusTipRole))
            path = six.text_type(path)

            svg = qtcompat.qunwrap(index.data(previewmodel.ThumbnailSVGRole))
            svg = six.text_type(svg)

        desc_text = self.__template.format(description=description, name=name)

        self.__label.setText(desc_text)

        self.__path.setText(path)

        if not svg:
            svg = NO_PREVIEW_SVG

        if svg:
            self.__image.load(QByteArray(svg.encode("utf-8")))
コード例 #2
0
    def __update(self):
        # type: () -> None
        """Update the current description.
        """
        if self.__currentIndex != -1 and self.__model is not None:
            index = self.__model.index(self.__currentIndex, 0)
        else:
            index = QModelIndex()

        if not index.isValid():
            description = ""
            name = ""
            path = ""
            svg = NO_PREVIEW_SVG
        else:
            description = index.data(Qt.WhatsThisRole)
            if description:
                description = description
            else:
                description = "没有说明。"

            description = escape(description)
            description = description.replace("\n", "<br/>")

            name = index.data(Qt.DisplayRole)
            if name:
                name = name
            else:
                name = "Untitled"

            name = escape(name)
            path = str(index.data(Qt.StatusTipRole))
            svg = str(index.data(previewmodel.ThumbnailSVGRole))

        desc_text = self.__template.format(description=description, name=name)

        self.__label.setText(desc_text)

        self.__path.setText(contractuser(path))

        if not svg:
            svg = NO_PREVIEW_SVG

        if svg:
            self.__image.load(QByteArray(svg.encode("utf-8")))
コード例 #3
0
ファイル: owwordlist.py プロジェクト: larazupan/orange3-text
 def paint(self, painter: QPainter, option: QStyleOptionViewItem,
           index: QModelIndex):
     word_list = index.data(Qt.DisplayRole)
     if word_list.flags & WordList.Modified:
         option = QStyleOptionViewItem(option)
         option.palette.setColor(QPalette.Text, QColor(Qt.red))
         option.palette.setColor(QPalette.Highlight, QColor(Qt.darkRed))
         option.palette.setColor(QPalette.HighlightedText, QColor(Qt.white))
     super().paint(painter, option, index)
コード例 #4
0
    def __update(self):
        """Update the current description.
        """
        if self.__currentIndex != -1:
            index = self.model().index(self.__currentIndex, 0)
        else:
            index = QModelIndex()

        if not index.isValid():
            description = ""
            name = ""
            path = ""
            svg = NO_PREVIEW_SVG
        else:
            description = index.data(Qt.WhatsThisRole)
            if description:
                description = description
            else:
                description = "No description."

            description = escape(description)
            description = description.replace("\n", "<br/>")

            name = index.data(Qt.DisplayRole)
            if name:
                name = name
            else:
                name = "Untitled"

            name = escape(name)
            path = str(index.data(Qt.StatusTipRole))
            svg = str(index.data(previewmodel.ThumbnailSVGRole))

        desc_text = self.__template.format(description=description, name=name)

        self.__label.setText(desc_text)

        self.__path.setText(contractuser(path))

        if not svg:
            svg = NO_PREVIEW_SVG

        if svg:
            self.__image.load(QByteArray(svg.encode("utf-8")))
コード例 #5
0
ファイル: owwordlist.py プロジェクト: larazupan/orange3-text
 def setEditorData(self, editor: QLineEdit, index: QModelIndex):
     word_list = index.data(Qt.DisplayRole)
     editor.setText(word_list.name)
コード例 #6
0
 def sizeHint(self, _: QStyleOptionViewItem, index: QModelIndex) -> QSize:
     return _create_editor(index.data(role=VariableRole), np.array([0]),
                           None, lambda: 1).sizeHint()
コード例 #7
0
 def createEditor(self, parent: QWidget, _: QStyleOptionViewItem,
                  index: QModelIndex) -> VariableEditor:
     variable = index.data(VariableRole)
     values = index.data(ValuesRole)
     return _create_editor(variable, values, parent, self._commit_data)