[education/rkward] /: Do not destroy and recreate data editor for each preview update. Also, keep previews from stealing focus.

Thomas Friedrichsmeier null at kde.org
Thu Jun 16 18:53:54 BST 2022


Git commit 84d2b0bc0fe16fcf78de2fc513a6d6cc0436f709 by Thomas Friedrichsmeier.
Committed on 16/06/2022 at 17:53.
Pushed by tfry into branch 'master'.

Do not destroy and recreate data editor for each preview update. Also, keep previews from stealing focus.

M  +1    -0    ChangeLog
M  +6    -3    rkward/windows/rkworkplace.cpp

https://invent.kde.org/education/rkward/commit/84d2b0bc0fe16fcf78de2fc513a6d6cc0436f709

diff --git a/ChangeLog b/ChangeLog
index d57615eb..1df0f524 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,4 @@
+- Fix focus problems, and better efficiency for data previews (as used in data import dialogs)
 - Fixed: Excel import plugin failed to accept file name
 - Add option to offer code completion/hinting in all file types not just R scripts (e.g. in .Rmd files)
 - Fix zooming help/output pages with Ctrl+scroll wheel, when compiled with QWebEngine
diff --git a/rkward/windows/rkworkplace.cpp b/rkward/windows/rkworkplace.cpp
index 3990b65c..260c00fd 100644
--- a/rkward/windows/rkworkplace.cpp
+++ b/rkward/windows/rkworkplace.cpp
@@ -623,13 +623,16 @@ RKEditor *RKWorkplace::editObject (RObject *object) {
 		}
 	}
 
+	bool activate = window_style_override != "preview";
 	RKEditor *ed = 0;
 	QList<RKEditor*> existing_editors = object->editors ();
+	RKMDIWindow *nw = getNamedWindow(window_name_override);
 	for (int i = 0; i < existing_editors.size (); ++i) {
 		RObject *eobj = existing_editors[i]->getObject ();
 		if (eobj == iobj) {
-			if (view ()->windowInActivePane (existing_editors[i])) {
-				ed = existing_editors[i];
+			auto candidate = existing_editors[i];
+			if (view()->windowInActivePane(candidate) || (nw == candidate)) {
+				ed = candidate;
 				break;
 			}
 		}
@@ -650,7 +653,7 @@ RKEditor *RKWorkplace::editObject (RObject *object) {
 		addWindow (ed);
 	}
 
-	ed->activate ();
+	if (activate) ed->activate ();
 	return ed;
 }
 


More information about the rkward-tracker mailing list