예제 #1
0
    def data(self, index, role):
        """ Retrieve the data for the item at the given index
        """
        item = self.itemAt(index)
        if not item:
            return None
        d = item.declaration
        if role == Qt.DisplayRole:
            return d.text
        elif role == Qt.ToolTipRole:
            return d.tool_tip
        elif role == Qt.CheckStateRole and d.checkable:
            return d.checked and Qt.Checked or Qt.Unchecked
        elif role == Qt.DecorationRole and d.icon:
            return get_cached_qicon(d.icon)
        elif role == Qt.EditRole and d.editable:
            return d.text
        elif role == Qt.StatusTipRole:
            return d.status_tip
        elif role == Qt.TextAlignmentRole:
            h, v = d.text_alignment
            return TEXT_H_ALIGNMENTS[h] | TEXT_V_ALIGNMENTS[v]
        elif role == Qt.ForegroundRole and d.foreground:
            return get_cached_qcolor(d.foreground)
        elif role == Qt.BackgroundRole and d.background:
            return get_cached_qcolor(d.background)
        #elif role == Qt.SizeHintRole and d.minimum_size:
        #    return d.minimum_size

        return None
예제 #2
0
 def data(self, index, role):
     """ @see http://doc.qt.io/qt-4.8/qt.html#ItemDataRole-enum
     """
     item = self.itemAt(index)
     if not item:
         return None
     d = item.declaration
     
     if role == Qt.DisplayRole:
         return d.text
     elif role == Qt.ToolTipRole:
         return d.tool_tip
     elif role == Qt.CheckStateRole and d.checkable:
         return d.checked and Qt.Checked or Qt.Unchecked
     elif role == Qt.DecorationRole and d.icon:
         return get_cached_qicon(d.icon)
     elif role == Qt.EditRole and d.editable:
         return d.text
     elif role == Qt.StatusTipRole:
         return d.status_tip
     elif role == Qt.TextAlignmentRole:
         h,v = d.text_alignment
         return TEXT_H_ALIGNMENTS[h] | TEXT_V_ALIGNMENTS[v]
     elif role == Qt.ForegroundRole and d.foreground:
         return get_cached_qcolor(d.foreground)
     elif role == Qt.BackgroundRole and d.background:
         return get_cached_qcolor(d.background)
     #elif role == Qt.SizeHintRole and (d.minimum_size):
     #    return d.minimum_size
     return None
예제 #3
0
    def data(self, index, role):
        """ @see http://doc.qt.io/qt-4.8/qt.html#ItemDataRole-enum
        """
        item = self.itemAt(index)
        if not item:
            return None
        d = item.declaration

        if role == Qt.DisplayRole:
            return d.text
        elif role == Qt.ToolTipRole:
            return d.tool_tip
        elif role == Qt.CheckStateRole and d.checkable:
            return d.checked and Qt.Checked or Qt.Unchecked
        elif role == Qt.DecorationRole and d.icon:
            return get_cached_qicon(d.icon)
        elif role == Qt.EditRole and d.editable:
            return d.text
        elif role == Qt.StatusTipRole:
            return d.status_tip
        elif role == Qt.TextAlignmentRole:
            h, v = d.text_alignment
            return TEXT_H_ALIGNMENTS[h] | TEXT_V_ALIGNMENTS[v]
        elif role == Qt.ForegroundRole and d.foreground:
            return get_cached_qcolor(d.foreground)
        elif role == Qt.BackgroundRole and d.background:
            return get_cached_qcolor(d.background)
        #elif role == Qt.SizeHintRole and (d.minimum_size):
        #    return d.minimum_size
        return None
예제 #4
0
파일: plugin.py 프로젝트: frmdstryr/Inkcut
    def set_window_icon(self):
        """ Set the main application window icon

        """
        ui = self.workbench.get_plugin('enaml.workbench.ui')
        try:
            icon = get_cached_qicon(load_icon('logo'))
            ui.window.proxy.widget.setWindowIcon(icon)
        except Exception as e:
            log.error('Failed to set window icon: {}'.format(e))
예제 #5
0
    def set_window_icon(self):
        """ Set the main application window icon

        """
        ui = self.workbench.get_plugin('enaml.workbench.ui')
        try:
            icon = get_cached_qicon(load_icon('logo'))
            ui.window.proxy.widget.setWindowIcon(icon)
        except Exception as e:
            log.error('Failed to set window icon: {}'.format(e))
예제 #6
0
    def data(self, index, role=Qt.DisplayRole):
        if not (index.isValid() and (0 <= index.row() < self.rowCount())):
            return None

        if role == Qt.TextAlignmentRole:
            return int(Qt.AlignRight | Qt.AlignVCenter)
        elif role == Qt.DecorationRole:
            row = self.map_to_row(index.row())
            col = self.map_to_col(index.column())
            value = self.get_value(index.row(), index.column())
            data = self.decoration(row, col, value)
            if isinstance(data, Color):
                return get_cached_qcolor(data)
            elif isinstance(data, Icon):
                return get_cached_qicon(data)
            else:
                return None
        elif role == Qt.DisplayRole:
            return self.format_value(
                self.get_value(index.row(), index.column()))

        return None