--- a/src/misc.cpp Mon Jun 01 17:06:13 2015 +0300 +++ b/src/misc.cpp Fri Jun 05 18:33:51 2015 +0300 @@ -1,6 +1,6 @@ /* * ZCinema: Zandronum demo launcher - * Copyright (C) 2013 Santeri Piippo + * Copyright (C) 2013-2015 Teemu Piippo * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,53 +19,53 @@ #include "misc.h" #include <QMessageBox> -EXTERN_CONFIG (List, devBuildNames) -EXTERN_CONFIG (List, releaseNames) -EXTERN_CONFIG (Map, binaryPaths) - -uint32 makeByteID (uint8 a, uint8 b, uint8 c, uint8 d) { +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); +QList<QVariant> getVersions() +{ + return Config::get ("versions").toList(); } -// ============================================================================= +// // ----------------------------------------------------------------------------- -void addVersion (str name, bool isRelease, str binaryPath) { - cfg::binaryPaths[name] = binaryPath; - - if (isRelease) - cfg::releaseNames << QVariant (name); - else - cfg::devBuildNames << QVariant (name); - - cfg::save(); +// + +void addVersion (const ZandronumVersion& version) +{ + QList<QVariant> versions = getVersions(); + QVariant var; + var.setValue (version); + versions.append (var); + Config::set ("versions", versions); } -// ============================================================================= +// // ----------------------------------------------------------------------------- -str basename (str path) { - long lastpos = path.lastIndexOf ("/"); - +// + +QString basename (const QString& path) +{ + int lastpos = path.lastIndexOf ("/"); + if (lastpos != -1) return path.mid (lastpos + 1); - + return path; } -// ============================================================================= +// // ----------------------------------------------------------------------------- -bool confirm (str text) { - return QMessageBox::question (null, QObject::tr ("Confirm"), text, +// + +bool confirm (const QString& text) +{ + return QMessageBox::question (NULL, QObject::tr ("Confirm"), text, QMessageBox::Yes | QMessageBox::No, QMessageBox::No) != QMessageBox::No; } \ No newline at end of file