def dragEnterEvent(self, event): """Re-implement drag enter event.""" if event.mimeData().hasUrls(): event.accept() QAbstractItemView.dragEnterEvent(self, event)
def on_threadSignal(self, value): self.list_widget.addItem(QListWidgetItem(value)) QAbstractItemView.scrollToBottom(self.list_widget) if "END" in value: self.thread = None self.button.setText("Send message") self.textbox.setText("")
def persistent_row_indexes(view_: QAbstractItemView) -> list: """ :@param view_: :@return: list of row indexes (selected) """ indexes = view_.selectionModel().selectedRows() model_ = view_.model() list_rows = [] for idx_ in indexes: list_rows.append(QPersistentModelIndex(model_.mapToSource(idx_))) return list_rows
def selected_db_indexes(view: QAbstractItemView) -> list: """ The DB indexes are stored in the model_ data under Qt.UserRole Method retrives these indexes for selected items :@param view: QAbstractItemView, Qt.UserRole should be implemented as need :@return: list of indexes. Type - int """ sel_model_idx = view.selectedIndexes() model = view.model() ids = [] for idx in sel_model_idx: ids.append(model.data(idx, Qt.UserRole)[0]) return ids
def setModel(self, model: QAbstractItemModel) -> None: super().setModel(model) # Derive a proxy model from the model to limit number of columns frozen_model = RearrangeColumnsProxymodel(self) frozen_model.setSourceModel(self.model()) self._frozen_table.setModel(frozen_model) link_selection_model = LinkItemSelectionModel( frozen_model, QAbstractItemView.selectionModel(self), self) self._frozen_table.setSelectionModel(link_selection_model)
def mouseReleaseEvent(self, event): if event.button() == Qt.RightButton: self.menu = self.makePopupMenu() self.menu.popup(event.globalPos()) else: QAbstractItemView.mouseReleaseEvent(self, event)
def bind_to_ui(self, view: QAbstractItemView, late=True): if self.cached_data is None and late: self.late_bindings.append(view) else: view.setModel(self) view.show()
def dropEvent(self, event): if event.source() == self: QAbstractItemView.dropEvent(self, event)
def on_combo_Mode_currentIndexChanged(self, index): mode = QAbstractItemView.DragDropMode(index) self.__itemView.setAcceptDrops(mode)