Python PyQt5.QtCore.Qt.AscendingOrder() Examples
The following are 16
code examples of PyQt5.QtCore.Qt.AscendingOrder().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
PyQt5.QtCore.Qt
, or try the search function
.
Example #1
Source File: CustomWidgetSortItem.py From PyQt with GNU General Public License v3.0 | 7 votes |
def lessThan(self, source_left, source_right): if not source_left.isValid() or not source_right.isValid(): return False # 获取数据 leftData = self.sourceModel().data(source_left) rightData = self.sourceModel().data(source_right) if self.sortOrder() == Qt.DescendingOrder: # 按照时间倒序排序 leftData = leftData.split('-')[-1] rightData = rightData.split('-')[-1] return leftData < rightData # elif self.sortOrder() == Qt.AscendingOrder: # #按照名字升序排序 # leftData = leftData.split('-')[0] # rightData = rightData.split('-')[0] # return leftData < rightData return super(SortFilterProxyModel, self).lessThan(source_left, source_right)
Example #2
Source File: parameter_tree.py From Grabber with GNU General Public License v3.0 | 6 votes |
def load_profile(self, profile: dict): self.blockSignals(True) self.setSortingEnabled(False) self.clear() for name, settings in profile.items(): parent = self.make_option(name, self, settings['state'], 0, settings['tooltip'], settings['dependency']) if settings['options']: for number, choice in enumerate(settings['options']): if settings['active option'] == number: option = self.make_option(str(choice), parent, True, 1, subindex=number) option.setFlags(option.flags() ^ Qt.ItemIsUserCheckable) else: option = self.make_option(str(choice), parent, False, 1, subindex=number) self.make_exclusive(parent) self.hock_dependency() self.update_size() self.setSortingEnabled(True) self.sortByColumn(0, Qt.AscendingOrder) self.blockSignals(False)
Example #3
Source File: centralwidget.py From autokey with GNU General Public License v3.0 | 6 votes |
def on_treeWidget_itemChanged(self, item, column): if item is self._get_current_treewidget_item() and column == 0: newText = str(item.text(0)) if ui_common.validate( not ui_common.EMPTY_FIELD_REGEX.match(newText), "The name can't be empty.", None, self.window()): self.window().app.monitor.suspend() self.stack.currentWidget().set_item_title(newText) self.stack.currentWidget().rebuild_item_path() persistGlobal = self.stack.currentWidget().save() self.window().app.monitor.unsuspend() self.window().app.config_altered(persistGlobal) self.treeWidget.sortItems(0, Qt.AscendingOrder) else: item.update()
Example #4
Source File: centralwidget.py From autokey with GNU General Public License v3.0 | 6 votes |
def __createFolder(self, parent_item): folder = model.Folder("New Folder") new_item = ak_tree.FolderWidgetItem(parent_item, folder) self.window().app.monitor.suspend() if parent_item is not None: parentFolder = self.__extractData(parent_item) parentFolder.add_folder(folder) else: self.treeWidget.addTopLevelItem(new_item) self.configManager.folders.append(folder) folder.persist() self.window().app.monitor.unsuspend() self.treeWidget.sortItems(0, Qt.AscendingOrder) self.treeWidget.setCurrentItem(new_item) self.on_treeWidget_itemSelectionChanged() self.on_rename()
Example #5
Source File: centralwidget.py From autokey with GNU General Public License v3.0 | 6 votes |
def on_new_phrase(self): self.window().app.monitor.suspend() tree_widget = self.treeWidget # type: ak_tree.AkTreeWidget parent_item = tree_widget.selectedItems()[0] # type: ak_tree.ItemWidgetType parent = self.__extractData(parent_item) phrase = model.Phrase("New Phrase", "Enter phrase contents") new_item = ak_tree.PhraseWidgetItem(parent_item, phrase) parent.add_item(phrase) phrase.persist() self.window().app.monitor.unsuspend() tree_widget.sortItems(0, Qt.AscendingOrder) tree_widget.setCurrentItem(new_item) parent_item.setSelected(False) self.on_treeWidget_itemSelectionChanged() self.on_rename()
Example #6
Source File: centralwidget.py From autokey with GNU General Public License v3.0 | 6 votes |
def on_new_script(self): self.window().app.monitor.suspend() tree_widget = self.treeWidget # type: ak_tree.AkTreeWidget parent_item = tree_widget.selectedItems()[0] # type: ak_tree.ItemWidgetType parent = self.__extractData(parent_item) script = model.Script("New Script", "#Enter script code") new_item = ak_tree.ScriptWidgetItem(parent_item, script) parent.add_item(script) script.persist() self.window().app.monitor.unsuspend() tree_widget.sortItems(0, Qt.AscendingOrder) tree_widget.setCurrentItem(new_item) parent_item.setSelected(False) self.on_treeWidget_itemSelectionChanged() self.on_rename()
Example #7
Source File: centralwidget.py From autokey with GNU General Public License v3.0 | 6 votes |
def move_items(self, sourceItems, target): target_model_item = self.__extractData(target) # Filter out any child objects that belong to a parent already in the list result = [f for f in sourceItems if f.parent() not in sourceItems] self.window().app.monitor.suspend() for source in result: self.__removeItem(source) source_model_item = self.__extractData(source) if isinstance(source_model_item, model.Folder): target_model_item.add_folder(source_model_item) self.__moveRecurseUpdate(source_model_item) else: target_model_item.add_item(source_model_item) source_model_item.path = None source_model_item.persist() target.addChild(source) self.window().app.monitor.unsuspend() self.treeWidget.sortItems(0, Qt.AscendingOrder) self.window().app.config_altered(True)
Example #8
Source File: SortItemByRole.py From PyQt with GNU General Public License v3.0 | 6 votes |
def lessThan(self, source_left, source_right): if not source_left.isValid() or not source_right.isValid(): return False if self.sortRole() == ClassifyRole and \ source_left.column() == self.sortColumn() and \ source_right.column() == self.sortColumn(): # 获取左右两个的分类 leftIndex = source_left.data(ClassifyRole) rightIndex = source_right.data(ClassifyRole) # 升序 if self.sortOrder() == Qt.AscendingOrder: # 保持在最前面 if leftIndex == self._topIndex: leftIndex = -1 if rightIndex == self._topIndex: rightIndex = -1 return leftIndex < rightIndex return super(SortFilterProxyModel, self).lessThan(source_left, source_right)
Example #9
Source File: ext_item_model.py From dash-masternode-tool with MIT License | 5 votes |
def __init__(self, parent, columns: List[TableModelColumn], columns_movable): object.__init__(self) self.parent_widget = parent self._columns = columns self._col_idx_by_name: Dict[str, int] = {} self._rebuild_column_index() self.view: QAbstractItemView = None self.columns_movable = columns_movable self.sorting_column_name = '' self.sorting_order = Qt.AscendingOrder self.proxy_model: ColumnedSortFilterProxyModel = None
Example #10
Source File: cuelistdialog.py From linux-show-player with GNU General Public License v3.0 | 5 votes |
def __init__(self, cues=None, properties=('index', 'name'), selection_mode=QTreeWidget.SingleSelection, **kwargs): super().__init__(**kwargs) self.setMinimumSize(600, 400) self._properties = list(properties) self._cues = {} self.list = QTreeWidget(self) self.list.setSelectionMode(selection_mode) self.list.setSelectionBehavior(QTreeWidget.SelectRows) self.list.setAlternatingRowColors(True) self.list.setIndentation(0) self.list.setHeaderLabels([prop.title() for prop in properties]) self.list.header().setSectionResizeMode(QHeaderView.Fixed) self.list.header().setSectionResizeMode(1, QHeaderView.Stretch) self.list.header().setStretchLastSection(False) self.list.sortByColumn(0, Qt.AscendingOrder) self.list.setSortingEnabled(True) if cues is not None: self.add_cues(cues) self.setLayout(QVBoxLayout()) self.layout().addWidget(self.list) self.buttons = QDialogButtonBox(self) self.buttons.addButton(QDialogButtonBox.Cancel) self.buttons.addButton(QDialogButtonBox.Ok) self.layout().addWidget(self.buttons) self.buttons.accepted.connect(self.accept) self.buttons.rejected.connect(self.reject)
Example #11
Source File: parameter_tree.py From Grabber with GNU General Public License v3.0 | 5 votes |
def __init__(self, profile: dict, parent=None): """ Data table: All data is in column 0. -- 0 - Visual name. 32 - main data entry, name of parents, full data for children 33 - 0 for parent, 1 for children, 3 for custom option. 34 - Name of item that needs to be checked 35 - index for children used for active option 37 - List of QModelIndex to items that this depends on. """ super().__init__(parent=parent) self.favorite = False self.setExpandsOnDoubleClick(False) # self.setHeaderHidden(True) self.setRootIsDecorated(False) self.setHeaderHidden(True) # self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setContextMenuPolicy(Qt.CustomContextMenu) self.customContextMenuRequested.connect(self.contextMenu) # self.header().setSectionResizeMode(0,QHeaderView.ResizeToContents) # self.headerItem().setResizeMode(QHeaderView.ResizeToContents) # self.setItemWidget() if isinstance(profile, dict): self.load_profile(profile) else: raise TypeError(f'Expected dict, not type {type(profile)}') self.setSortingEnabled(True) self.sortByColumn(0, Qt.AscendingOrder) self.itemChanged.connect(self.make_exclusive) self.itemChanged.connect(self.check_dependency)
Example #12
Source File: centralwidget.py From autokey with GNU General Public License v3.0 | 5 votes |
def populate_tree(self, config): self.factory = ak_tree.WidgetItemFactory(config.folders) root_folders = self.factory.get_root_folder_list() for item in root_folders: self.treeWidget.addTopLevelItem(item) self.treeWidget.sortItems(0, Qt.AscendingOrder) self.treeWidget.setCurrentItem(self.treeWidget.topLevelItem(0)) self.on_treeWidget_itemSelectionChanged()
Example #13
Source File: centralwidget.py From autokey with GNU General Public License v3.0 | 5 votes |
def on_paste(self): parent_item = self._get_current_treewidget_item() parent = self.__extractData(parent_item) self.window().app.monitor.suspend() new_items = [] for item in self.cutCopiedItems: if isinstance(item, model.Folder): new_item = ak_tree.FolderWidgetItem(parent_item, item) ak_tree.WidgetItemFactory.process_folder(new_item, item) parent.add_folder(item) elif isinstance(item, model.Phrase): new_item = ak_tree.PhraseWidgetItem(parent_item, item) parent.add_item(item) else: new_item = ak_tree.ScriptWidgetItem(parent_item, item) parent.add_item(item) item.persist() new_items.append(new_item) self.treeWidget.sortItems(0, Qt.AscendingOrder) self.treeWidget.setCurrentItem(new_items[-1]) self.on_treeWidget_itemSelectionChanged() self.cutCopiedItems = [] for item in new_items: item.setSelected(True) self.window().app.monitor.unsuspend() self.window().app.config_altered(False)
Example #14
Source File: centralwidget.py From autokey with GNU General Public License v3.0 | 5 votes |
def on_save(self): logger.info("User requested file save.") if self.stack.currentWidget().validate(): self.window().app.monitor.suspend() persist_global = self.stack.currentWidget().save() self.window().save_completed(persist_global) self.set_dirty(False) item = self._get_current_treewidget_item() item.update() self.treeWidget.update() self.treeWidget.sortItems(0, Qt.AscendingOrder) self.window().app.monitor.unsuspend() return False return True
Example #15
Source File: centralwidget.py From autokey with GNU General Public License v3.0 | 5 votes |
def __removeItem(self, widgetItem): parent = widgetItem.parent() item = self.__extractData(widgetItem) self.__deleteHotkeys(item) if parent is None: removed_index = self.treeWidget.indexOfTopLevelItem(widgetItem) self.treeWidget.takeTopLevelItem(removed_index) self.configManager.folders.remove(item) else: removed_index = parent.indexOfChild(widgetItem) parent.removeChild(widgetItem) if isinstance(item, model.Folder): item.parent.remove_folder(item) else: item.parent.remove_item(item) item.remove_data() self.treeWidget.sortItems(0, Qt.AscendingOrder) if parent is not None: if parent.childCount() > 0: new_index = min((removed_index, parent.childCount() - 1)) self.treeWidget.setCurrentItem(parent.child(new_index)) else: self.treeWidget.setCurrentItem(parent) else: new_index = min((removed_index, self.treeWidget.topLevelItemCount() - 1)) self.treeWidget.setCurrentItem(self.treeWidget.topLevelItem(new_index))
Example #16
Source File: CustomWidgetSortItem.py From PyQt with GNU General Public License v3.0 | 5 votes |
def sortByName(self): # 按照名字升序排序 self.fmodel.sort(0, Qt.AscendingOrder)