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
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
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
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))
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