当前位置: 首页>>代码示例>>Python>>正文


Python QtGui.QDropEvent方法代码示例

本文整理汇总了Python中PyQt5.QtGui.QDropEvent方法的典型用法代码示例。如果您正苦于以下问题:Python QtGui.QDropEvent方法的具体用法?Python QtGui.QDropEvent怎么用?Python QtGui.QDropEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt5.QtGui的用法示例。


在下文中一共展示了QtGui.QDropEvent方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: dropEvent

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QDropEvent [as 别名]
def dropEvent(self, event: QtGui.QDropEvent) -> None:
        """Identifies source/target row of a finished drag&drop and runs moveRow() on the model"""
        if (event.source() is not self or
                (event.dropAction() != QtCore.Qt.MoveAction and
                 self.dragDropMode() != QtWidgets.QAbstractItemView.InternalMove)):
            super().dropEvent(event)

        selection = self.selectedIndexes()
        from_index = selection[0].row() if selection else -1
        to_index = self.indexAt(event.pos()).row()
        if (0 <= from_index < self.model().rowCount() and
                0 <= to_index < self.model().rowCount() and
                from_index != to_index):
            self.model().moveRow(QtCore.QModelIndex(), from_index, QtCore.QModelIndex(), to_index)
            event.accept()
        super().dropEvent(event) 
开发者ID:frans-fuerst,项目名称:track,代码行数:18,代码来源:qreordertableview.py

示例2: test_EditorPane_drop_event

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QDropEvent [as 别名]
def test_EditorPane_drop_event(qtapp):
    """
    If there's a drop event associated with files, cause them to be passed into
    Mu's existing file loading code.
    """
    ep = mu.interface.editor.EditorPane(None, "baz")
    m = mock.MagicMock()
    ep.open_file = mock.MagicMock()
    ep.open_file.emit = m
    data = QMimeData()
    data.setUrls(
        [
            QUrl("file://test/path.py"),
            QUrl("file://test/path.hex"),
            QUrl("file://test/path.txt"),
        ]
    )
    evt = QDropEvent(
        QPointF(0, 0), Qt.CopyAction, data, Qt.LeftButton, Qt.NoModifier
    )
    ep.dropEvent(evt)
    # Upstream _load will handle invalid file type (.txt).
    assert m.call_count == 3 
开发者ID:mu-editor,项目名称:mu,代码行数:25,代码来源:test_editor.py

示例3: dropEvent

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QDropEvent [as 别名]
def dropEvent(self, event: QDropEvent):
        target = self.itemAt(event.pos())
        sources = self.selectedItems()
        self.window().central_widget.move_items(sources, target) 
开发者ID:autokey,项目名称:autokey,代码行数:6,代码来源:autokey_treewidget.py

示例4: dropEvent

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QDropEvent [as 别名]
def dropEvent(self, event: QtGui.QDropEvent) -> None:
        valid_files = []
        files = [u.toLocalFile() for u in event.mimeData().urls()]
        for f in files:
            if os.path.isfile(f):
                mime_type, encoding = mimetypes.guess_type(f)  # magic.from_file(f,mime=True)
                if mime_type.find("video") != -1 and self.content_type == "Videos":
                    valid_files.append(f)
                elif mime_type.find("image") != -1 and self.content_type == "Images":
                    valid_files.append(f)
        valid_files = sorted(valid_files, key=lambda v: os.path.basename(v))
        self.filesDropped.emit(valid_files) 
开发者ID:haruiz,项目名称:CvStudio,代码行数:14,代码来源:gallery.py

示例5: dropEvent

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QDropEvent [as 别名]
def dropEvent(self, event: QDropEvent):
        # if not self.ui.decoderchain.geometry().contains(self.mapToGlobal(event.pos())):
        if self.ui.decoderchain.currentItem() is not None:
            self.chainoptions.pop(self.ui.decoderchain.currentItem().text(), None)
            self.ui.decoderchain.takeItem(self.ui.decoderchain.currentRow())
            self.decoderchainUpdate() 
开发者ID:jopohl,项目名称:urh,代码行数:8,代码来源:DecoderDialog.py

示例6: dropEvent

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QDropEvent [as 别名]
def dropEvent(self, event: QDropEvent):
        mime_data = event.mimeData()
        data_str = str(mime_data.text())
        indexes = list(data_str.split("/")[:-1])

        signal = None
        proto_analyzer = None
        for index in indexes:
            row, column, parent = map(int, index.split(","))
            if parent == -1:
                parent = self.signal_tree_root
            else:
                parent = self.signal_tree_root.child(parent)
            node = parent.child(row)
            if node.protocol is not None and node.protocol.signal is not None:
                signal = node.protocol.signal
                proto_analyzer = node.protocol
                break

        if signal is None:
            return

        if signal is None:
            return

        self.signal = signal  # type: Signal
        self.proto_analyzer = proto_analyzer  # type: ProtocolAnalyzer

        self.scene_manager = SignalSceneManager(signal, self)
        self.plot_data(self.signal.real_plot_data)
        self.show_full_scene()
        self.auto_fit_view()

        self.signal_loaded.emit(self.proto_analyzer) 
开发者ID:jopohl,项目名称:urh,代码行数:36,代码来源:ZoomAndDropableGraphicView.py

示例7: dropEvent

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QDropEvent [as 别名]
def dropEvent(self, event: QDropEvent):
        if len(event.mimeData().urls()) > 0:
            group_id = self.model().get_group_id_for_index(self.indexAt(event.pos()))
            self.files_dropped_on_group.emit(event.mimeData().urls(), group_id)
        else:
            super().dropEvent(event) 
开发者ID:jopohl,项目名称:urh,代码行数:8,代码来源:ProtocolTreeView.py

示例8: dropEvent

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QDropEvent [as 别名]
def dropEvent(self, event: QDropEvent):
        if len(event.mimeData().urls()) > 0:
            self.files_dropped.emit(event.mimeData().urls()) 
开发者ID:jopohl,项目名称:urh,代码行数:5,代码来源:ProtocolTableView.py

示例9: dropEvent

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QDropEvent [as 别名]
def dropEvent(self, event: QDropEvent):
        super().dropEvent(event)
        if self.count() > 0:
            item = self.itemAt(event.pos())
            if item is not None:
                index = self.indexFromItem(item).row()
                self.setCurrentRow(index)
            else:
                self.setCurrentRow(self.count()-1) 
开发者ID:jopohl,项目名称:urh,代码行数:11,代码来源:ListWidget.py

示例10: dropEvent

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QDropEvent [as 别名]
def dropEvent(self, event: QDropEvent):
        items = [item for item in self.items(event.scenePos()) if isinstance(item, GraphicsItem) and item.acceptDrops()]
        item = None if len(items) == 0 else items[0]
        if len(event.mimeData().urls()) > 0:
            self.files_dropped.emit(event.mimeData().urls())

        indexes = list(event.mimeData().text().split("/")[:-1])

        group_nodes = []
        file_nodes = []
        for index in indexes:
            try:
                row, column, parent = map(int, index.split(","))
                if parent == -1:
                    parent = self.tree_root_item
                else:
                    parent = self.tree_root_item.child(parent)
                node = parent.child(row)
                if node.is_group:
                    group_nodes.append(node)
                else:
                    file_nodes.append(node)
            except ValueError:
                continue

        # Which Nodes to add?
        nodes_to_add = []
        """:type: list of ProtocolTreeItem """
        for group_node in group_nodes:
            nodes_to_add.extend(group_node.children)
        nodes_to_add.extend([file_node for file_node in file_nodes if file_node not in nodes_to_add])
        protocols_to_add = [node.protocol for node in nodes_to_add]

        ref_item = item
        position = None if ref_item is None else item.drop_indicator_position
        self.add_protocols(ref_item, position, protocols_to_add)
        super().dropEvent(event) 
开发者ID:jopohl,项目名称:urh,代码行数:39,代码来源:SimulatorScene.py

示例11: dropEvent

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QDropEvent [as 别名]
def dropEvent(self, event: QDropEvent):
        self.drag_over = False
        self.update() 
开发者ID:jopohl,项目名称:urh,代码行数:5,代码来源:GraphicsItem.py

示例12: dragMoveEvent

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QDropEvent [as 别名]
def dragMoveEvent(self, event: QDropEvent):
        self.update_drop_indicator(event.pos()) 
开发者ID:jopohl,项目名称:urh,代码行数:4,代码来源:GraphicsItem.py

示例13: add_all_signals_to_simulator

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QDropEvent [as 别名]
def add_all_signals_to_simulator(self):
        assert isinstance(self.form, MainController)
        sim_frame = self.form.simulator_tab_controller
        sim_frame.ui.treeProtocols.selectAll()
        self.assertGreater(len(sim_frame.ui.treeProtocols.selectedIndexes()), 0)
        mimedata = sim_frame.tree_model.mimeData(sim_frame.ui.treeProtocols.selectedIndexes())
        drop_event = QDropEvent(sim_frame.ui.gvSimulator.rect().center(), Qt.CopyAction | Qt.MoveAction,
                                mimedata, Qt.LeftButton, Qt.NoModifier)
        drop_event.acceptProposedAction()
        sim_frame.ui.gvSimulator.dropEvent(drop_event) 
开发者ID:jopohl,项目名称:urh,代码行数:12,代码来源:QtTestCase.py

示例14: test_signal_view

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QDropEvent [as 别名]
def test_signal_view(self):
        self.add_signal_to_form("esaver.complex16s")
        signal = self.form.signal_tab_controller.signal_frames[0].signal

        tree_view = self.dialog.ui.treeViewSignals
        tree_model = tree_view.model()
        item = tree_model.rootItem.children[0].children[0]
        index = tree_model.createIndex(0, 0, item)
        rect = tree_view.visualRect(index)
        QTest.mousePress(tree_view.viewport(), Qt.LeftButton, pos=rect.center())
        mime_data = tree_model.mimeData([index])
        drag_drop = QDropEvent(rect.center(), Qt.CopyAction | Qt.MoveAction, mime_data, Qt.LeftButton, Qt.NoModifier)
        drag_drop.acceptProposedAction()
        self.dialog.ui.gVOriginalSignal.dropEvent(drag_drop)
        self.assertEqual(self.dialog.ui.gVOriginalSignal.sceneRect().width(), signal.num_samples)

        self.dialog.ui.cbShowDataBitsOnly.click()
        self.dialog.ui.chkBoxLockSIV.click()

        self.assertEqual(int(self.dialog.ui.gVOriginalSignal.view_rect().width()),
                         int(self.dialog.ui.gVModulated.view_rect().width()))

        freq = self.dialog.ui.doubleSpinBoxCarrierFreq.value()
        self.dialog.ui.btnAutoDetect.click()
        self.assertNotEqual(freq, self.dialog.ui.doubleSpinBoxCarrierFreq.value())

        self.dialog.ui.comboBoxModulationType.setCurrentText("Frequency Shift Keying (FSK)")
        self.dialog.ui.btnAutoDetect.click()

        self.assertEqual(self.dialog.ui.lCurrentSearchResult.text(), "1")
        self.dialog.ui.btnSearchNext.click()
        self.assertEqual(self.dialog.ui.lCurrentSearchResult.text(), "2")
        self.dialog.ui.btnSearchPrev.click()
        self.assertEqual(self.dialog.ui.lCurrentSearchResult.text(), "1") 
开发者ID:jopohl,项目名称:urh,代码行数:36,代码来源:test_modulator_gui.py


注:本文中的PyQt5.QtGui.QDropEvent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。