[rkward-cvs] SF.net SVN: rkward:[3743] trunk/rkward/rkward/settings

tfry at users.sourceforge.net tfry at users.sourceforge.net
Sun Sep 11 11:24:11 UTC 2011


Revision: 3743
          http://rkward.svn.sourceforge.net/rkward/?rev=3743&view=rev
Author:   tfry
Date:     2011-09-11 11:24:11 +0000 (Sun, 11 Sep 2011)
Log Message:
-----------
Add support for versioned config. Not used, yet, but will probably be used very soon.

Modified Paths:
--------------
    trunk/rkward/rkward/settings/rksettingsmodulegeneral.cpp
    trunk/rkward/rkward/settings/rksettingsmodulegeneral.h

Modified: trunk/rkward/rkward/settings/rksettingsmodulegeneral.cpp
===================================================================
--- trunk/rkward/rkward/settings/rksettingsmodulegeneral.cpp	2011-09-10 12:00:31 UTC (rev 3742)
+++ trunk/rkward/rkward/settings/rksettingsmodulegeneral.cpp	2011-09-11 11:24:11 UTC (rev 3743)
@@ -45,6 +45,8 @@
 bool RKSettingsModuleGeneral::show_help_on_startup;
 int RKSettingsModuleGeneral::warn_size_object_edit;
 RKSettingsModuleGeneral::RKMDIFocusPolicy RKSettingsModuleGeneral::mdi_focus_policy;
+RKSettingsModuleGeneral::RKWardConfigVersion RKSettingsModuleGeneral::stored_config_version;
+bool RKSettingsModuleGeneral::config_exists;
 
 RKSettingsModuleGeneral::RKSettingsModuleGeneral (RKSettings *gui, QWidget *parent) : RKSettingsModule (gui, parent) {
 	RK_TRACE (SETTINGS);
@@ -195,11 +197,16 @@
 
 	cg = config->group ("MDI");
 	cg.writeEntry ("focus policy", (int) mdi_focus_policy);
+
+	cg = config->group ("Internal");
+	cg.writeEntry ("config file version", (int) RKWardConfig_Latest);
 }
 
 void RKSettingsModuleGeneral::loadSettings (KConfig *config) {
 	RK_TRACE (SETTINGS);
 
+	config_exists = config->hasGroup ("General");	// one of the very oldest groups in the config
+
 	KConfigGroup cg;
 	cg = config->group ("Logfiles");
 	files_path = new_files_path = cg.readEntry ("logfile dir", QDir ().homePath () + "/.rkward/");
@@ -217,6 +224,9 @@
 
 	cg = config->group ("MDI");
 	mdi_focus_policy = (RKMDIFocusPolicy) cg.readEntry ("focus policy", (int) RKMDIClickFocus);
+
+	cg = config->group ("Internal");
+	stored_config_version = (RKWardConfigVersion) cg.readEntry ("config file version", (int) RKWardConfig_Pre0_5_7);
 }
 
 QString RKSettingsModuleGeneral::getSavedWorkplace (KConfig *config) {

Modified: trunk/rkward/rkward/settings/rksettingsmodulegeneral.h
===================================================================
--- trunk/rkward/rkward/settings/rksettingsmodulegeneral.h	2011-09-10 12:00:31 UTC (rev 3742)
+++ trunk/rkward/rkward/settings/rksettingsmodulegeneral.h	2011-09-11 11:24:11 UTC (rev 3743)
@@ -69,6 +69,19 @@
 	static bool cdToWorkspaceOnLoad () { return cd_to_workspace_dir_on_load; };
 	static unsigned long warnLargeObjectThreshold () { return warn_size_object_edit; };
 	static RKMDIFocusPolicy mdiFocusPolicy () { return mdi_focus_policy; }
+
+	enum RKWardConfigVersion {
+		RKWardConfig_Pre0_5_7,
+//		RKWardConfig_0_5_7,
+		RKWardConfig_Next,		/**< add new configuration versions above / before this entry */
+		RKWardConfig_Latest = RKWardConfig_Next - 1
+	};
+	/** Which version did an existing config file appear to have?
+	 * @return RKWardConfig_Pre0_5_7, if no config file could be read. See anyExistingConfig()
+	 * @note Not all versions of RKWard have a config file version of their own, not even necessarily when new entries were added. Only when not-quite-compatible changes are needed, new config versions will be added. */
+	static RKWardConfigVersion storedConfigVersion () { return stored_config_version; };
+	/** Did a config file already exist? */
+	static bool anyExistingConfig () { return config_exists; };
 public slots:
 	void pathChanged ();
 	void boxChanged (int);
@@ -90,6 +103,8 @@
 	static bool show_help_on_startup;
 	static int warn_size_object_edit;
 	static RKMDIFocusPolicy mdi_focus_policy;
+	static RKWardConfigVersion stored_config_version;
+	static bool config_exists;
 };
 
 #endif

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.





More information about the rkward-tracker mailing list