16 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 */ |
17 */ |
18 |
18 |
19 #include "misc.h" |
19 #include "misc.h" |
20 |
20 |
|
21 EXTERN_CONFIG (List, devBuildNames) |
|
22 EXTERN_CONFIG (List, releaseNames) |
|
23 EXTERN_CONFIG (Map, binaryPaths) |
|
24 |
21 uint32 makeByteID (uint8 a, uint8 b, uint8 c, uint8 d) { |
25 uint32 makeByteID (uint8 a, uint8 b, uint8 c, uint8 d) { |
22 return a | (b << 8) | (c << 16) | (d << 24); |
26 return a | (b << 8) | (c << 16) | (d << 24); |
|
27 } |
|
28 |
|
29 // ============================================================================= |
|
30 // ----------------------------------------------------------------------------- |
|
31 QList<QVariant> getVersions() { |
|
32 return cfg::devBuildNames + cfg::releaseNames; |
23 } |
33 } |
24 |
34 |
25 // ============================================================================= |
35 // ============================================================================= |
26 // ----------------------------------------------------------------------------- |
36 // ----------------------------------------------------------------------------- |
27 str binaryConfigName (str ver) { |
37 str binaryConfigName (str ver) { |
28 return fmt ("binaries/%1", ver); |
38 return fmt ("binaries/%1", ver); |
29 } |
39 } |
30 |
40 |
31 // ============================================================================= |
41 // ============================================================================= |
32 // ----------------------------------------------------------------------------- |
42 // ----------------------------------------------------------------------------- |
33 list<var> getVersionsList() { |
|
34 QSettings cfg; |
|
35 return cfg.value ("binarynames", list<var>()).toList(); |
|
36 } |
|
37 |
|
38 // ============================================================================= |
|
39 // ----------------------------------------------------------------------------- |
|
40 list<var> getReleasesList() { |
|
41 QSettings cfg; |
|
42 return cfg.value ("releasenames", list<var>()).toList(); |
|
43 } |
|
44 |
|
45 // ============================================================================= |
|
46 // ----------------------------------------------------------------------------- |
|
47 void addVersion (str name, bool isRelease, str binaryPath) { |
43 void addVersion (str name, bool isRelease, str binaryPath) { |
48 QSettings cfg; |
44 cfg::binaryPaths[name] = binaryPath; |
49 list<var> versions = getVersionsList(); |
|
50 versions << var (name); |
|
51 cfg.setValue ("binarynames", versions); |
|
52 cfg.setValue (binaryConfigName (name), binaryPath); |
|
53 |
45 |
54 if (isRelease) { |
46 if (isRelease) |
55 versions = getReleasesList(); |
47 cfg::releaseNames << var (name); |
56 versions << var (name); |
48 else |
57 cfg.setValue ("releasenames", versions); |
49 cfg::devBuildNames << var (name); |
58 } |
|
59 |
50 |
60 cfg.sync(); |
51 cfg::save(); |
61 } |
52 } |
62 |
53 |
63 // ============================================================================= |
54 // ============================================================================= |
64 // ----------------------------------------------------------------------------- |
55 // ----------------------------------------------------------------------------- |
65 str basename (str path) { |
56 str basename (str path) { |