示例#1
0
    def dragEnterEvent(self, event):
        """Re-implement drag enter event."""

        if event.mimeData().hasUrls():
            event.accept()

        QAbstractItemView.dragEnterEvent(self, event)
示例#2
0
    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("")
示例#3
0
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
示例#4
0
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
示例#5
0
    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)
示例#6
0
 def mouseReleaseEvent(self, event):
     if event.button() == Qt.RightButton:
         self.menu = self.makePopupMenu()
         self.menu.popup(event.globalPos())
     else:
         QAbstractItemView.mouseReleaseEvent(self, event)
示例#7
0
文件: models.py 项目: chstan/daquiri
 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()
示例#8
0
 def mouseReleaseEvent(self, event):
     if event.button() == Qt.RightButton:
         self.menu = self.makePopupMenu()
         self.menu.popup(event.globalPos())
     else:
         QAbstractItemView.mouseReleaseEvent(self, event)
示例#9
0
 def dropEvent(self, event):
     if event.source() == self:
         QAbstractItemView.dropEvent(self, event)
示例#10
0
 def on_combo_Mode_currentIndexChanged(self, index):
     mode = QAbstractItemView.DragDropMode(index)
     self.__itemView.setAcceptDrops(mode)