def headerData(self, section, orientation, role): """ Public method to get header data from the model. @param section section number (integer) @param orientation orientation (Qt.Orientation) @param role role of the data to retrieve (integer) @return requested data """ if role == Qt.SizeHintRole: fm = QFontMetrics(QFont()) height = fm.height() + fm.height() // 3 width = \ fm.width(self.headerData(section, orientation, Qt.DisplayRole)) return QSize(width, height) if orientation == Qt.Horizontal: if role == Qt.DisplayRole: try: return self.__headers[section] except IndexError: return None return None return QAbstractTableModel.headerData(self, section, orientation, role)
def headerData(self, section, orientation, role = Qt.DisplayRole): if role == Qt.DisplayRole: if orientation == Qt.Horizontal: return str(self.h_header[section]) elif orientation == Qt.Vertical: return str(self.v_header[section]) return QAbstractTableModel.headerData(self, section, orientation, role)
def __init__(self, *args, model: QAbstractTableModel = None, selected_columns: List[int] = None, **kwargs): super().__init__(*args, **kwargs) for i in range(self.layoutBins.count()): w = self.layoutBins.itemAt(i).widget() if w is not None and not isinstance(w, QLabel): w.hide() if model is not None: for col in range(model.columnCount()): text = model.headerData(col, Qt.Horizontal, Qt.DisplayRole) color = model.headerData(col, Qt.Horizontal, ColorMarkRole) item = ColumnListWidgetItem(text, column=col) if color is not None: item.setBackground(color) if selected_columns is not None and col in selected_columns: self.lstUsedColumns.addItem(item) else: self.lstColumns.addItem(item) colors = QSettings().value('NetworkView/pie_colors', [c.name() for c in generate_colors(8)], type=str) self.set_colors(colors) self.btUseSelectedColumns.clicked.connect(lambda: self.move_selected_columns(MOVE_COLUMNS_SELECT)) self.btRemoveSelectedColumns.clicked.connect(lambda: self.move_selected_columns(MOVE_COLUMNS_UNSELECT))
def headerData(self, col, orientation, role): """ Overrided function for getting headerData from certain column """ if orientation == Qt.Horizontal and role == Qt.DisplayRole: return QVariant(self.header_data[col]) return QAbstractTableModel.headerData(self, col, orientation, role)
def headerData(self, section, orientation, role=Qt.DisplayRole): ''' Set the Headers of the table ''' if role == Qt.DisplayRole and orientation == Qt.Horizontal: return self.header[section] return QAbstractTableModel.headerData(self, section, orientation, role)
def headerData(self, section, orientation, role): if Qt is None: return if orientation == Qt.Horizontal and role == Qt.DisplayRole: headers = T2G_Vertex.HEADERS return headers[section] return QAbstractTableModel.headerData(self, section, orientation, role)
def headerData(self, section: int, orientation: Qt.Orientation, role: int = ...): if orientation == Qt.Horizontal: # 水平表头 if role == Qt.DisplayRole: # 角色为显示 return self.m_dataList['head'][section]['label'] # 返回指定位置表头 return QAbstractTableModel.headerData(self, section, orientation, role)
def headerData(self, section, orientation, role=Qt.DisplayRole): if role == Qt.DisplayRole: if orientation == Qt.Horizontal: if section == 0: return "Property" if section == 1: return "Value" return QAbstractTableModel.headerData(self, section, orientation, role)
def headerData(self, section, orientation, role=Qt.DisplayRole): if orientation == Qt.Vertical: if role == Qt.DecorationRole and self.arraydata[section][0] != "": # icon and button won't display correctly in this use case; just make the entire header item clickable return self.printIconPixmap if role == Qt.DisplayRole: return "" if role == Qt.DisplayRole and orientation == Qt.Horizontal: return self.header_labels[section] return QAbstractTableModel.headerData(self, section, orientation, role)
def headerData(self,sec,orientation,role=Qt.DisplayRole): if orientation==Qt.Horizontal: #print(role) if role==Qt.DisplayRole: return self.itemClass.header[sec] elif role==Qt.BackgroundRole: return QColor(100,100,100) elif role==Qt.TextAlignmentRole: return Qt.AlignCenter else: return QAbstractTableModel.headerData(self,sec,orientation,role) else: return None
def headerData(self, section, orientation, role=Qt.DisplayRole): """ Public method to get header data from the model. @param section section number (integer) @param orientation orientation (Qt.Orientation) @param role role of the data to retrieve (integer) @return requested data """ if orientation == Qt.Horizontal and role == Qt.DisplayRole: return self.__headerData[section] return QAbstractTableModel.headerData(self, section, orientation, role)
def __init__(self, *args, model: QAbstractTableModel = None, column_id: int = None, mapping: dict = None, **kwargs): self._model = model self._column_id = column_id super().__init__(*args, **kwargs) self.lstUsedColumns.setItemDelegate(ItemDelegate()) self.lstColors.setItemDelegate(ItemDelegate()) data = self._model.headerData(self._column_id, Qt.Horizontal, role=ColumnDataRole) if data is not None and not isinstance(data, pd.Series): data = pd.Series(data) self._data = data if model is not None and column_id is not None: for i in range(model.columnCount()): index = model.index(0, i) text = model.headerData(i, Qt.Horizontal, Qt.DisplayRole) color = model.headerData(i, Qt.Horizontal, ColorMarkRole) item = ColumnListWidgetItem(text, column=index.column()) if color is not None: item.setBackground(color) if index.column() != column_id: self.lstColumns.addItem(item) self.lstUsedColumns.setSelectionMode(QAbstractItemView.ContiguousSelection) self.lstColumns.setSelectionMode(QAbstractItemView.SingleSelection) self.populate_bins(mapping) colors = QSettings().value('NetworkView/node_colors', [c.name() for c in generate_colors(8)], type=str) self.set_colors(colors) self.btUseSelectedColumns.clicked.connect(self.on_use_selected_column) self.btRemoveSelectedColumns.clicked.connect(self.on_unuse_selected_column)
def headerData(self, section, orientation, role=Qt.DisplayRole): """ Public method to get the header data. @param section section number (integer) @param orientation header orientation (Qt.Orientation) @param role data role (integer) @return header data """ if orientation == Qt.Horizontal and role == Qt.DisplayRole: try: return self.__headers[section] except IndexError: pass return QAbstractTableModel.headerData(self, section, orientation, role)
def __init__(self, *args, model: QAbstractTableModel, column_id: int, func: 'SizeMappingFunc' = None, **kwargs): super().__init__(*args, **kwargs) self._model = model self._column_id = column_id self._func = func self.setupUi(self) self.setWindowFlags(Qt.Tool | Qt.CustomizeWindowHint | Qt.WindowCloseButtonHint) self.setFixedSize(self.geometry().size()) self.spinMaxValue.valueChanged.connect( lambda x: self.on_range_changed('max-value', x)) self.spinMinValue.valueChanged.connect( lambda x: self.on_range_changed('min-value', x)) self.spinMaxSize.valueChanged.connect( lambda x: self.on_range_changed('max-size', x)) self.spinMinSize.valueChanged.connect( lambda x: self.on_range_changed('min-size', x)) self.btAddHandle.clicked.connect(self.on_add_handle) self.btRemoveHandle.clicked.connect(self.on_remove_handle) self.gvMapping.setRenderHints(QPainter.Antialiasing | QPainter.TextAntialiasing) self.gvMapping.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.gvMapping.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.cbMode.addItems(["Linear", "Log"]) self.cbMode.activated[int].connect(self.on_mode_changed) self._current_mode = MODE_LINEAR self.cbMode.setCurrentIndex(MODE_LINEAR) self.lstColumns.selectionModel().currentChanged.connect( self.on_column_changed) for col in range(model.columnCount()): text = model.headerData(col, Qt.Horizontal, Qt.DisplayRole) item = ColumnListWidgetItem(text, column=col) self.lstColumns.addItem(item)
def headerData(self, p_int, Qt_Orientation, role=None): if role == Qt.DisplayRole and Qt_Orientation == Qt.Horizontal: return self.labels[p_int] return QAbstractTableModel.headerData(self, p_int, Qt_Orientation, role)
def headerData(self, section, orientation, role=Qt.DisplayRole): if role == Qt.DisplayRole and orientation == Qt.Horizontal: return QVariant(self.headerdata[section]) else: return QAbstractTableModel.headerData(self, section, orientation, role)
def headerData(self, section, orientation, role=Qt.DisplayRole): """Set header.""" if role == Qt.DisplayRole and orientation == Qt.Horizontal: return self._header[section] return QAbstractTableModel.headerData(self, section, orientation, role)
def headerData(self, column, orientation, role=None): if orientation == Qt.Horizontal and role == Qt.DisplayRole: return self._header_data[column] # return "" return QAbstractTableModel.headerData(self, column, orientation, role)
def headerData(self, section, orientation, role=Qt.DisplayRole): if role == Qt.DisplayRole and orientation == 1: return self.grades_data[section][0] # return self.header_data[section] return QAbstractTableModel.headerData(self, section, orientation, role)
def headerData(self, section, orientation, role=None): if role == QtCore.Qt.DisplayRole: if orientation == Qt.Horizontal: return self._header[section] return QAbstractTableModel.headerData(self, section, orientation, role)
def headerData(self, section, orientation, role=Qt.DisplayRole): if role == Qt.DisplayRole and orientation == Qt.Horizontal: if section < self.columnCount(): return self.__h_headers_data.get( section, role) # @fixme: empty, call parent return QAbstractTableModel.headerData(self, section, orientation, role)
def headerData(self, section, orientation, role=Qt.DisplayRole): if role == Qt.DisplayRole and orientation == Qt.Horizontal: return self.HEADER[section] return QAbstractTableModel.headerData(self, section, orientation, role)
def headerData(self, section, orientation, role=Qt.DisplayRole): if orientation == Qt.Horizontal and role == Qt.DisplayRole: return self.info_keys[section] return QAbstractTableModel.headerData(self, section, orientation, role)
def headerData(self, section, orientation, role=Qt.DisplayRole): if orientation == Qt.Horizontal and role==Qt.DisplayRole: return self.infoKeys[section] return QAbstractTableModel.headerData(self, section, orientation, role)
def headerData( self, section, orientation, role=QtCore.Qt.DisplayRole ): if role == QtCore.Qt.DisplayRole and orientation == QtCore.Qt.Horizontal: return self.COLUMNS[section] return QAbstractTableModel.headerData( self, section, orientation, role )