Skip to content

Commit

Permalink
owpythonscript: Remove obsolete dropEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
irgolic committed Jan 24, 2021
1 parent a308fa9 commit 24c53a6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 27 deletions.
7 changes: 0 additions & 7 deletions Orange/widgets/data/owpythonscript.py
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,6 @@ def _(color, text):
self.consoleBox.setAlignment(Qt.AlignBottom)
self.console.setTabStopWidth(4)
self.splitCanvas.setSizes([2, 1])
self.setAcceptDrops(True)
self.controlArea.layout().addStretch(10)

self._restoreState()
Expand Down Expand Up @@ -903,12 +902,6 @@ def dragEnterEvent(self, event): # pylint: disable=no-self-use
if c is not None:
event.acceptProposedAction()

def dropEvent(self, event):
"""Handle file drops"""
urls = event.mimeData().urls()
if urls:
self.text.pasteFile(urls[0])

@classmethod
def migrate_settings(cls, settings, version):
if version is not None and version < 2:
Expand Down
24 changes: 4 additions & 20 deletions Orange/widgets/data/tests/test_owpythonscript.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,10 @@ def test_script_insert_mime_file(self):
url = QUrl.fromLocalFile(fn)
mime.setUrls([url])
self.widget.text.insertFromMimeData(mime)
self.assertEqual("test", self.widget.text.toPlainText())
self.assertEqual(
"'" + fn + "'" + previous,
self.widget.text.toPlainText()
)
self.widget.text.undo()
self.assertEqual(previous, self.widget.text.toPlainText())

Expand All @@ -201,25 +204,6 @@ def _drag_enter_event(self, url):
QPoint(0, 0), Qt.MoveAction, data,
Qt.NoButton, Qt.NoModifier)

def test_dropEvent_replaces_file(self):
with named_file("test", suffix=".42") as fn:
previous = self.widget.text.toPlainText()
event = self._drop_event(QUrl.fromLocalFile(fn))
self.widget.dropEvent(event)
self.assertEqual("test", self.widget.text.toPlainText())
self.widget.text.undo()
self.assertEqual(previous, self.widget.text.toPlainText())

def _drop_event(self, url):
# make sure data does not get garbage collected before it used
# pylint: disable=attribute-defined-outside-init
self.event_data = data = QMimeData()
data.setUrls([QUrl(url)])

return QDropEvent(
QPoint(0, 0), Qt.MoveAction, data,
Qt.NoButton, Qt.NoModifier, QDropEvent.Drop)

def test_shared_namespaces(self):
widget1 = self.create_widget(OWPythonScript)
widget2 = self.create_widget(OWPythonScript)
Expand Down

0 comments on commit 24c53a6

Please sign in to comment.