[rkward-cvs] [rkward] /: Try to cope with moving RKWard installations (particularly on Windows).

Thomas Friedrichsmeier thomas.friedrichsmeier at ruhr-uni-bochum.de
Mon Dec 1 09:58:03 UTC 2014


Git commit 75322d4012a34fb5dbf801c6fb7fff7057811b32 by Thomas Friedrichsmeier.
Committed on 01/12/2014 at 09:56.
Pushed by tfry into branch 'master'.

Try to cope with moving RKWard installations (particularly on Windows).

M  +2    -0    ChangeLog
M  +18   -3    rkward/settings/rksettingsmodulegeneral.cpp
M  +7    -1    rkward/settings/rksettingsmodulegeneral.h
M  +4    -4    rkward/settings/rksettingsmoduleplugins.cpp
M  +3    -1    rkward/settings/rksettingsmoduler.cpp

http://commits.kde.org/rkward/75322d4012a34fb5dbf801c6fb7fff7057811b32

diff --git a/ChangeLog b/ChangeLog
index bb8bbb0..9eaa4a6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,5 @@
+- When the RKWard installation has moved on disk, try to adjust stored .pluginmaps paths, accordingly
+  - TODO: Actually test this on Windows
 - Fixed: Freezes when using RKWard-functionality (such as the RK()-device) from tcl/tk (e.g. Rcmdr)
 - Allow opening RKWard's plugin files (with correct highlighting), and other text files
 - More robust control over placement of plugins within a menu
diff --git a/rkward/settings/rksettingsmodulegeneral.cpp b/rkward/settings/rksettingsmodulegeneral.cpp
index 704054b..51bc61e 100644
--- a/rkward/settings/rksettingsmodulegeneral.cpp
+++ b/rkward/settings/rksettingsmodulegeneral.cpp
@@ -2,7 +2,7 @@
                           rksettingsmodulegeneral  -  description
                              -------------------
     begin                : Fri Jul 30 2004
-    copyright            : (C) 2004-2013 by Thomas Friedrichsmeier
+    copyright            : (C) 2004-2014 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -52,6 +52,8 @@ bool RKSettingsModuleGeneral::config_exists;
 RKSettingsModuleGeneral::InitialDirectory RKSettingsModuleGeneral::initial_dir;
 QString RKSettingsModuleGeneral::initial_dir_specification;
 bool RKSettingsModuleGeneral::rkward_version_changed;
+bool RKSettingsModuleGeneral::installation_moved = false;
+QString RKSettingsModuleGeneral::previous_rkward_data_dir;
 
 RKSettingsModuleGeneral::RKSettingsModuleGeneral (RKSettings *gui, QWidget *parent) : RKSettingsModule (gui, parent) {
 	RK_TRACE (SETTINGS);
@@ -214,6 +216,7 @@ void RKSettingsModuleGeneral::saveSettings (KConfig *config) {
 	cg.writeEntry ("show help on startup", show_help_on_startup);
 	cg.writeEntry ("initial dir mode", (int) initial_dir);
 	cg.writeEntry ("initial dir spec", (initial_dir == LastUsedDirectory) ? QDir::currentPath() : initial_dir_specification);
+	cg.writeEntry ("last known data dir", RKCommonFunctions::getRKWardDataDir ());
 
 	cg = config->group ("Workplace");
 	cg.writeEntry ("save mode", (int) workplace_save_mode);
@@ -237,7 +240,7 @@ void RKSettingsModuleGeneral::loadSettings (KConfig *config) {
 
 	KConfigGroup cg;
 	cg = config->group ("Logfiles");
-	files_path = new_files_path = cg.readEntry ("logfile dir", QDir ().homePath () + "/.rkward/");
+	files_path = new_files_path = checkAdjustLoadedPath (cg.readEntry ("logfile dir", QDir ().homePath () + "/.rkward/"));
 
 	cg = config->group ("General");
 	startup_action = (StartupDialog::Result) cg.readEntry ("startup action", (int) StartupDialog::NoSavedSetting);
@@ -249,7 +252,9 @@ void RKSettingsModuleGeneral::loadSettings (KConfig *config) {
 		(int) RKWardDirectory
 #endif
 	);
-	initial_dir_specification = cg.readEntry ("initial dir spec", QString ());
+	initial_dir_specification = checkAdjustLoadedPath (cg.readEntry ("initial dir spec", QString ()));
+	previous_rkward_data_dir = cg.readEntry ("last known data dir", RKCommonFunctions::getRKWardDataDir ());
+	installation_moved = (previous_rkward_data_dir != RKCommonFunctions::getRKWardDataDir ()) && !previous_rkward_data_dir.isEmpty ();
 
 	cg = config->group ("Workplace");
 	workplace_save_mode = (WorkplaceSaveMode) cg.readEntry ("save mode", (int) SaveWorkplaceWithWorkspace);
@@ -280,4 +285,14 @@ void RKSettingsModuleGeneral::setSavedWorkplace (const QString &description, KCo
 	cg.writeEntry ("last saved layout", description);
 }
 
+QString RKSettingsModuleGeneral::checkAdjustLoadedPath (const QString& localpath) {
+	RK_TRACE (SETTINGS);
+
+	if (!installation_moved) return localpath;
+	bool is_parent;	// old data path is parent of given path
+	QString adjusted = KUrl::relativePath (previous_rkward_data_dir, localpath, &is_parent);
+	if (is_parent) return adjusted;
+	return localpath;
+}
+
 #include "rksettingsmodulegeneral.moc"
diff --git a/rkward/settings/rksettingsmodulegeneral.h b/rkward/settings/rksettingsmodulegeneral.h
index ff9de3b..65d1e01 100644
--- a/rkward/settings/rksettingsmodulegeneral.h
+++ b/rkward/settings/rksettingsmodulegeneral.h
@@ -2,7 +2,7 @@
                           rksettingsmodulegeneral  -  description
                              -------------------
     begin                : Fri Jul 30 2004
-    copyright            : (C) 2004-2013 by Thomas Friedrichsmeier
+    copyright            : (C) 2004-2014 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -78,6 +78,10 @@ public:
 	static RKMDIFocusPolicy mdiFocusPolicy () { return mdi_focus_policy; }
 	static QString workspaceFilenameFilter () { return ("*.RData *.RDA"); };
 	static QString initialWorkingDirectory ();
+/** if the installation-path of KDE seems to have moved since the last startup, *and* the given path is relative to the
+ *  KDE data path, adjust the given path (probably loaded from config), accordingly. @See RKCommonFunctions::getRKWardDataDir()
+ *  TODO: similar, but not quite identical functionality in rkworkplace.cpp checkAdjustRestoredUrl(). Might be mergeable. */
+	static QString checkAdjustLoadedPath (const QString &localpath);
 
 	enum RKWardConfigVersion {
 		RKWardConfig_Pre0_5_7,
@@ -121,6 +125,8 @@ private:
 	static InitialDirectory initial_dir;
 	static QString initial_dir_specification;
 	static bool rkward_version_changed;
+	static QString previous_rkward_data_dir;
+	static bool installation_moved;
 };
 
 #endif
diff --git a/rkward/settings/rksettingsmoduleplugins.cpp b/rkward/settings/rksettingsmoduleplugins.cpp
index 98b5272..f0b48ee 100644
--- a/rkward/settings/rksettingsmoduleplugins.cpp
+++ b/rkward/settings/rksettingsmoduleplugins.cpp
@@ -186,8 +186,8 @@ void RKSettingsModulePlugins::loadSettings (KConfig *config) {
 		QStringList plugin_maps = cg.readEntry ("Plugin Maps", QStringList ());
 		QStringList kplugin_maps = cg.readEntry ("All known plugin maps", QStringList ());
 		for (int i = 0; i < kplugin_maps.size (); ++i) {
-			PluginMapStoredInfo inf (kplugin_maps[i]);
-			inf.active = plugin_maps.contains (kplugin_maps[i]);
+			PluginMapStoredInfo inf (RKSettingsModuleGeneral::checkAdjustLoadedPath (kplugin_maps[i]));
+			inf.active = plugin_maps.contains (kplugin_maps[i]);	// comparing unadjusted path on purpose!
 			// state info will be properly initialized in fixPluginMapLists()
 			known_plugin_maps.append (inf);
 		}
@@ -195,8 +195,8 @@ void RKSettingsModulePlugins::loadSettings (KConfig *config) {
 		KConfigGroup pmg = cg.group ("Known Plugin maps");
 		QStringList kplugin_maps = cg.readEntry ("All known plugin maps", QStringList ());
 		for (int i = 0; i < kplugin_maps.size (); ++i) {
-			KConfigGroup ppmg = pmg.group (kplugin_maps[i]);
-			PluginMapStoredInfo inf (kplugin_maps[i]);
+			KConfigGroup ppmg = pmg.group (kplugin_maps[i]);	// unadjusted path on purpose!
+			PluginMapStoredInfo inf (RKSettingsModuleGeneral::checkAdjustLoadedPath (kplugin_maps[i]));
 			inf.active = ppmg.readEntry ("Active", false);
 			// Pluginmaps which are broken with one version of RKWard may be alright with other versions. So reset flags, if version has changed.
 			inf.broken_in_this_version = ppmg.readEntry ("Broken", false) && !RKSettingsModuleGeneral::rkwardVersionChanged ();
diff --git a/rkward/settings/rksettingsmoduler.cpp b/rkward/settings/rksettingsmoduler.cpp
index e6256c5..7eeb9f4 100644
--- a/rkward/settings/rksettingsmoduler.cpp
+++ b/rkward/settings/rksettingsmoduler.cpp
@@ -269,7 +269,9 @@ QStringList RKSettingsModuleR::makeRRunTimeOptionCommands () {
 	list.append (QString ("setInternet2 (") + (options_internet2 ? "TRUE)\n" : "FALSE)\n"));
 #endif
 
-#warning TODO make the following options configurable
+#ifdef __GNUC__
+#	warning TODO make the following options configurable
+#endif
 	list.append ("options (help_type=\"html\")\n");		// for R 2.10.0 and above
 	list.append ("try ({options (htmlhelp=TRUE); options (chmhelp=FALSE)})\n");	// COMPAT: for R 2.9.x and below
 	list.append ("options (browser=rk.show.html)\n");




More information about the rkward-tracker mailing list