src/misc.cpp

changeset 20
a5457405cc9b
parent 13
9bdddd2ccde6
child 21
99225eac33ba
--- a/src/misc.cpp	Sun Aug 11 16:08:13 2013 +0300
+++ b/src/misc.cpp	Sun Sep 08 16:14:58 2013 +0300
@@ -18,46 +18,37 @@
 
 #include "misc.h"
 
+EXTERN_CONFIG (List, devBuildNames)
+EXTERN_CONFIG (List, releaseNames)
+EXTERN_CONFIG (Map, binaryPaths)
+
 uint32 makeByteID (uint8 a, uint8 b, uint8 c, uint8 d) {
 	return a | (b << 8) | (c << 16) | (d << 24);
 }
 
 // =============================================================================
 // -----------------------------------------------------------------------------
+QList<QVariant> getVersions() {
+	return cfg::devBuildNames + cfg::releaseNames;
+}
+
+// =============================================================================
+// -----------------------------------------------------------------------------
 str binaryConfigName (str ver) {
 	return fmt ("binaries/%1", ver);
 }
 
 // =============================================================================
 // -----------------------------------------------------------------------------
-list<var> getVersionsList() {
-	QSettings cfg;
-	return cfg.value ("binarynames", list<var>()).toList();
-}
-
-// =============================================================================
-// -----------------------------------------------------------------------------
-list<var> getReleasesList() {
-	QSettings cfg;
-	return cfg.value ("releasenames", list<var>()).toList();
-}
-
-// =============================================================================
-// -----------------------------------------------------------------------------
 void addVersion (str name, bool isRelease, str binaryPath) {
-	QSettings cfg;
-	list<var> versions = getVersionsList();
-	versions << var (name);
-	cfg.setValue ("binarynames", versions);
-	cfg.setValue (binaryConfigName (name), binaryPath);
+	cfg::binaryPaths[name] = binaryPath;
 	
-	if (isRelease) {
-		versions = getReleasesList();
-		versions << var (name);
-		cfg.setValue ("releasenames", versions);
-	}
+	if (isRelease)
+		cfg::releaseNames << var (name);
+	else
+		cfg::devBuildNames << var (name);
 	
-	cfg.sync();
+	cfg::save();
 }
 
 // =============================================================================
@@ -69,4 +60,4 @@
 		return path.mid (lastpos + 1);
 	
 	return path;
-}
+}
\ No newline at end of file

mercurial