[rkward/frameworks] /: Don't show status bar on R Console, and handle drag-and-drop, gracefully.
Thomas Friedrichsmeier
thomas.friedrichsmeier at ruhr-uni-bochum.de
Wed Nov 25 10:13:55 UTC 2015
Git commit 2b2d9c70a6ccb8f5835073c245d4aa9a1c3cd265 by Thomas Friedrichsmeier.
Committed on 25/11/2015 at 10:13.
Pushed by tfry into branch 'frameworks'.
Don't show status bar on R Console, and handle drag-and-drop, gracefully.
M +5 -0 ChangeLog
M +29 -0 rkward/rkconsole.cpp
http://commits.kde.org/rkward/2b2d9c70a6ccb8f5835073c245d4aa9a1c3cd265
diff --git a/ChangeLog b/ChangeLog
index a892c1e..270b5ec 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+- Better handling of text drag-and-drop inside the R console window
+
+--- Version 0.6.4 - XXXXXXXXXXXXXXX
+
+
- Fixed: RKWard package repository would be listed twice on fresh installations
- Switch to bugs.kde.org as primary issue tracker
- Workspace browser gains functionality to search / filter objects by name
diff --git a/rkward/rkconsole.cpp b/rkward/rkconsole.cpp
index 4cb311e..634b638 100644
--- a/rkward/rkconsole.cpp
+++ b/rkward/rkconsole.cpp
@@ -80,6 +80,7 @@ RKConsole::RKConsole (QWidget *parent, bool tool_window, const char *name) : RKM
doc = editor->createDocument (this);
view = doc->createView (this);
layout->addWidget (view);
+ view->setStatusBarEnabled (false);
KTextEditor::ConfigInterface *confint = qobject_cast<KTextEditor::ConfigInterface*> (view);
RK_ASSERT (view);
@@ -509,6 +510,34 @@ bool RKConsole::eventFilter (QObject *o, QEvent *e) {
view->scroll (0, y - y2);
}
} */ // not good, yet: always jumps to bottom of view
+ } else if (e->type () == QEvent::DragMove || e->type () == QEvent::Drop) {
+ QDropEvent* me = static_cast<QDropEvent*> (e); // NOTE: QDragMoveEvent inherits from QDropEvent
+
+ // WTF? the position seems to be off by around two chars. Icon border?
+ // Hack it to be correct.
+ QWidget *rec = dynamic_cast<QWidget*> (o);
+ if (!o) rec = view;
+ KTextEditor::Cursor pos = view->coordinatesToCursor (rec->mapTo (view, me->pos ()));
+
+ bool in_last_line = (pos.line () == doc->lines () - 1) && (pos.column () >= prefix.length ());
+ if (!in_last_line) {
+ e->ignore ();
+ return true;
+ } else {
+ if (e->type () == QEvent::DragMove) {
+ // Not sure why this is needed, here, but without this, the move will remain permanently inacceptable,
+ // once it has been ignored, below, once. KF5 5.9.0
+ e->accept ();
+ // But also _not_ filtering it.
+ } else {
+ // We have prevent the katepart from _moving_ the text in question. Thus, instead we fake a paste.
+ // This does mean, we don't support movements within the last line, either, but so what.
+ view->setCursorPosition (pos);
+ submitBatch (me->mimeData ()->text ());
+ me->ignore ();
+ return true;
+ }
+ }
}
if (acceptsEventsFor (o)) return RKMDIWindow::eventFilter (o, e);
More information about the rkward-tracker
mailing list