def getCrafterList(self): self.CrafterTable.setRowCount(0) for root, dirs, files in os.walk(self.getCrafterPath()): for file in (x for x in files if self.reini.search(x)): with open(root + '\\' + file, 'r') as document: if self.rectl.search(document.read()) is not None: character = self.reini.search(file).group(1) server_code = self.reini.search(file).group(2) server = ServerCodes[ server_code] if server_code in ServerCodes else 'Unknown' self.TableModel.insertRows(self.TableModel.rowCount(), 1) index = self.TableModel.index( self.TableModel.rowCount() - 1, 0, QModelIndex()) self.TableModel.setData(index, QVariant(' ' + server), Qt.DisplayRole) self.TableModel.setData(index, QVariant(root + '\\' + file), Qt.UserRole) index = self.TableModel.index( self.TableModel.rowCount() - 1, 1, QModelIndex()) self.TableModel.setData(index, QVariant(' ' + character), Qt.DisplayRole) self.CrafterTable.resizeRowsToContents() if self.TableModel.rowCount() == 1: self.CrafterTable.selectRow(0)
def data(self, index, role=Qt.DisplayRole): # noqa C901 ''' @param: index QModelIndex @return: QVariant ''' row = index.row() if row < 0 or row > len(self._tabs): return QVariant() tab = self.tab(index) if not tab: return QVariant() if role == self.WebTabRole: return QVariant(tab) elif role in (self.TitleRole, Qt.DisplayRole): return tab.title() elif role in (self.IconRole, Qt.DecorationRole): return tab.icon() elif role == self.PinnedRole: return tab.isPinned() elif role == self.RestoredRole: return tab.isRestored() elif role == self.CurrentTabRole: return tab.isCurrentTab() elif role == self.LoadingRole: return tab.isLoading() elif role == self.AudioPlayingRole: return tab.isPlaying() elif role == self.AudioMutedRole: return tab.isMuted() elif role == self.BackgroundActivityRole: return tab.backgroundActivity() else: return QVariant()
def __init__(self): QWidget.__init__(self) self.ui = Ui_KeyboardWidget() self.ui.setupUi(self) index = 0 # comboBox.addItem doesn't increase the currentIndex self.default_layout_index = None locales = sorted([(country, data) for country, data in yali.localedata.locales.items() ]) for country, data in locales: if data["xkbvariant"]: i = 0 for variant in data["xkbvariant"]: _d = dict(data) _d["xkbvariant"] = variant[0] _d["name"] = variant[1] _d["consolekeymap"] = data["consolekeymap"][i] self.ui.keyboard_list.addItem(_d["name"], QVariant(_d)) i += 1 else: self.ui.keyboard_list.addItem(data["name"], QVariant(data)) if ctx.consts.lang == country: if ctx.consts.lang == "tr": self.default_layout_index = index + 1 else: self.default_layout_index = index index += 1 self.ui.keyboard_list.setCurrentIndex(self.default_layout_index) self.ui.keyboard_list.currentIndexChanged[int].connect( self.slotLayoutChanged)
def data(self, index, role): try: if index.isValid() and role == Qt.DisplayRole: return QVariant(self.list_data[index.row()]) else: return QVariant() #return QVariant(self.list_data[index.row()]) except: traceback.print_exc()
def data(self, index, role): if not index.isValid(): return QVariant() elif role not in (Qt.DisplayRole, Qt.EditRole): return QVariant() row = self.results[index.row()] name = self.fields[index.column()][2] return getattr(row, name)
def headerData( self, section, orientation, # noqa: N802 role=Qt.DisplayRole): """Override built-in method.""" if role != Qt.DisplayRole: return QVariant() if orientation == Qt.Horizontal: return QVariant(self.headers[section]) return QVariant(int(section + 1))
def data(self, index: QModelIndex = None, role=None) -> QVariant: if not self._is_index_valid(index=index): return QVariant() environment = self._data[index.row()] # Data is 1-dimensional array if role == self.ID_ROLE: return environment.id elif role in (Qt.DisplayRole, self.NAME_ROLE): return environment.name elif role is self.DATA_ROLE: return environment else: return QVariant()
def headerData(self, col, orientation, role): if orientation == Qt.Horizontal and role == Qt.DisplayRole: tmp_horizontal_headers = [ header.split(sep) for header in self._horizontal_headers ] headers = [] for c in tmp_horizontal_headers: result = list( filter( lambda x: all(x in l for l in tmp_horizontal_headers) == False, c)) headers.append(" ".join(result)) return QVariant(headers[col]) elif orientation == Qt.Vertical and role == Qt.DisplayRole: return QVariant(self._vertical_headers[col]) return QVariant()
def headerData(self, section, orientation, role=None): role = role or Qt.DisplayRole if role in [Qt.DisplayRole, Qt.EditRole ] and orientation in [Qt.Horizontal]: return self.tr('Property Name') if section == 0 else self.tr( 'Property Value') return QVariant()
def headerData(self, section, orientation, role=QtCore.Qt.DisplayRole): if orientation == QtCore.Qt.Horizontal: if role == QtCore.Qt.DisplayRole: return SequenceComponentCustomPropsQtModel._COLUMN_HEADERS[ section] # Return an invalid QVariant if the data could not be found. return QVariant()
def Update_List(self, Item_list): self.PenJobList.clear() for item in Item_list: List_Item = QtWidgets.QListWidgetItem(item.name) List_Item.setData(Qt.UserRole, QVariant(item.id)) self.PenJobList.addItem(List_Item)
def data(self, column, role=Qt.DisplayRole): if role == Qt.DisplayRole: if column == 0: return self.name elif column == 1: return len(self.children) elif column == 2: return self.size / FSTreeItem.SIZE_DIVISOR elif column == 3: return self.path else: return str("n/a") elif role == Qt.DecorationRole: if column == 0: if self.extension_type == FSExtensionType.TYPE_EXT: return QVariant(QIcon("res/list.svg")) else: return QVariant(QIcon("res/office-material.svg"))
def Delete_Button_Clicked(): Items = MyUI.PenJobList.selectedItems() joblist = sched.get_jobs() for item in Items: job_id = QVariant(item.data(Qt.UserRole)).value() sched.remove_job(job_id) MyUI.Update_List(sched.get_jobs())
def data(self, index: QModelIndex, role=None) -> QVariant: """ Overridden from QAbstractItemModel This function is used to get a specific piece of info about the data to display :param index: :param role: :return: """ if not self._is_index_valid(index): return QVariant() album = self._data[index.row()] # Data is 1-dimensional array if role == self.id_role: return album.id elif role in (Qt.DisplayRole, self.name_role): return album.name else: return QVariant()
def __init__(self, *args, **kwargs): super(QQuickView, self).__init__() self._rotation = self.get_rotation() self.engine().rootContext().setContextProperty('screenRotation', QVariant(self.rotation)) self.setSource(QUrl('main.qml')) self.setHeight(self.screen().size().height()) self.setWidth(self.screen().size().width()) self.setResizeMode(QQuickView.SizeRootObjectToView) self.setFlags(Qt.WindowFullscreenButtonHint)
def data(self, index, role): row = index.row() col = index.column() if not index.isValid(): return QVariant() node = self.nodeFromIndex(index) if (role == Qt.DisplayRole or role == Qt.EditRole) and col == 0: return node.title # properties : if role == Qt.UserRole: return node.properties # sheet_id : if role == 37: return node.sheet_id return QVariant()
def set_value(self): try: meta_object = self.target.metaObject() index = meta_object.indexOfProperty(self.property) if index < 0: raise Exception("could not set property {}".format( self.property)) meta_object.property(index).write(self.target, QVariant(self.value)) except Exception as ex: logger.error("could not enter text into input item: {}".format(ex))
def value(self, key, defaultValue=QVariant(), **kwargs): type_ = kwargs.get('type', None) if type_ is None: if type(defaultValue) != QVariant: # guess defaultValue type as type type_ = type(defaultValue) if type_ == bytes: from PyQt5.Qt import QByteArray type_ = QByteArray return self.s_settings.value(key, defaultValue, type_) else: return self.s_settings.value(key, defaultValue) else: return self.s_settings.value(key, defaultValue, type=type_) self.s_settings.value()
def data(self, index, role): if index.isValid(): node = self.qt_index_to_node(index) if node is not None and index.column() == 0: if role == QtCore.Qt.DisplayRole: return node.name if role == QtCore.Qt.EditRole: return node.name if role == QtCore.Qt.DecorationRole: return node.component_type.get_icon() # Return an invalid QVariant if the data could not be found. return QVariant()
def data(self, index, role=QtCore.Qt.DisplayRole): if index.isValid( ) and self._seq_component_tree_controller.active_node is not None: if role == QtCore.Qt.DisplayRole: prop_name = self._seq_component_tree_controller.active_node.custom_prop_names[ index.row()] prop_value = self._seq_component_tree_controller.active_node.get_custom_prop( prop_name) if index.column( ) == SequenceComponentCustomPropsQtModel._NAME_COLUMN: return prop_name elif index.column( ) == SequenceComponentCustomPropsQtModel._VALUE_COLUMN: return prop_value.value_str elif index.column( ) == SequenceComponentCustomPropsQtModel._EVAL_COLUMN: return prop_value.is_expr # Return an invalid QVariant if the data could not be found. return QVariant()
def data(self, q_parent_index, q_role): if q_parent_index.isValid() and q_role == Qt.DisplayRole: siblings = q_parent_index.internalPointer().parent.children if len(siblings) > 1: sibling_identifiers = [] sibling_identifiers += [ sibling.identifier.split(sep) for sibling in siblings ] unique_part = [] for c in sibling_identifiers: result = list( filter( lambda x: all(x in l for l in sibling_identifiers) == False, c)) unique_part.append(" ".join(result)) return unique_part[q_parent_index.row()] else: path = str(q_parent_index.internalPointer()) return path return QVariant()
def setValue(self, key, defaultValue=QVariant()): self.s_settings.setValue(key, defaultValue)
def dbus_as(value): var = QVariant(value) ret = var.convert(QVariant.StringList) assert ret, "QVariant conversion failure: {}".format(value) return var
def getBoolValue(self, option): default = self._initValue(option, False) return self.config.value(option, QVariant(default)) == "true"
def dbus_uint(value): var = QVariant(value) ret = var.convert(QVariant.UInt) assert ret, "QVariant conversion failure: {}".format(value) return var
def headerData(self, col, orientation, role): if orientation == Qt.Horizontal and role == Qt.DisplayRole: return QVariant(self.fields[col][0]) return QVariant()
def data(self, index, role=Qt.DisplayRole): if role in [Qt.DisplayRole, Qt.EditRole, Qt.ToolTipRole]: column = self._data.columns[index.column()] return str(self._data[column].iloc[index.row()]) return QVariant()
def setValue(self, option, value): self.config.setValue(option, QVariant(value)) self.config.sync()
def headerData(self, section, orientation, role): if orientation == Qt.Horizontal and role == Qt.DisplayRole: return QVariant(self.headers[section]) return QVariant()
def getNumValue(self, option): default = self._initValue(option, 0) return int(self.config.value(option, QVariant(default)))#[0]