1.1 --- a/mapeditor.cpp Mon Dec 01 16:44:35 2008 +0000
1.2 +++ b/mapeditor.cpp Thu Dec 04 13:47:47 2008 +0000
1.3 @@ -1806,6 +1806,7 @@
1.4 return aborted;
1.5 }
1.6
1.7 +// cout <<"ME::save filePath="<<filePath.toStdString()<<endl;
1.8 safeFilePath=filePath;
1.9 setFilePath (tmpZipDir+"/"+ mapName+ ".xml", safeFilePath);
1.10 } // zipped
1.11 @@ -1813,6 +1814,15 @@
1.12 // Create mapName and fileDir
1.13 makeSubDirs (fileDir);
1.14
1.15 +/*
1.16 + // FIXME testing
1.17 + cout <<"ME::save filePath="<<filePath.toStdString()<<endl;
1.18 + cout <<"ME::save saveFilePath="<<safeFilePath.toStdString()<<endl;
1.19 + cout <<"ME::save destPath="<<destPath.toStdString()<<endl;
1.20 + cout <<"ME::save mapName="<<mapName.toStdString()<<endl;
1.21 + cout <<"ME::save mapFileName="<<mapFileName.toStdString()<<endl;
1.22 +*/
1.23 +
1.24 QString saveFile;
1.25 if (savemode==CompleteMap || xelection.isEmpty())
1.26 {
1.27 @@ -1821,13 +1831,6 @@
1.28 mapChanged=false;
1.29 mapUnsaved=false;
1.30 autosaveTimer->stop();
1.31 - /*
1.32 - cout <<"ME::save filePath="<<filePath.toStdString()<<endl;
1.33 - cout <<"ME::save saveFilePath="<<safeFilePath.toStdString()<<endl;
1.34 - cout <<"ME::save destPath="<<destPath.toStdString()<<endl;
1.35 - cout <<"ME::save mapName="<<mapName.toStdString()<<endl;
1.36 - cout <<"ME::save mapFileName="<<mapFileName.toStdString()<<endl;
1.37 - */
1.38 }
1.39 else
1.40 {
2.1 --- a/settings.cpp Mon Dec 01 16:44:35 2008 +0000
2.2 +++ b/settings.cpp Thu Dec 04 13:47:47 2008 +0000
2.3 @@ -1,8 +1,153 @@
2.4 #include <iostream>
2.5 +#include <qregexp.h>
2.6 #include "settings.h"
2.7 -#include "misc.h"
2.8 +#include "file.h"
2.9
2.10 -using namespace std;
2.11 +/////////////////////////////////////////////////////////////////
2.12 +// SimpleSettings
2.13 +/////////////////////////////////////////////////////////////////
2.14 +SimpleSettings::SimpleSettings()
2.15 +{
2.16 + clear();
2.17 +}
2.18 +
2.19 +SimpleSettings::~SimpleSettings()
2.20 +{
2.21 +}
2.22 +
2.23 +void SimpleSettings::clear()
2.24 +{
2.25 + keylist.clear();
2.26 + valuelist.clear();
2.27 +}
2.28 +
2.29 +void SimpleSettings::readSettings (const QString &path)
2.30 +{
2.31 + QString s;
2.32 + if (!loadStringFromDisk(path,s))
2.33 + {
2.34 + qWarning ("SimpleSettings::readSettings() Couldn't read "+path);
2.35 + return;
2.36 + }
2.37 + QStringList lines;
2.38 + lines=QStringList::split (QRegExp("\n"),s,false);
2.39 + int i;
2.40 + QStringList::Iterator it=lines.begin();
2.41 + while (it !=lines.end() )
2.42 + {
2.43 + i=(*it).find("=",0);
2.44 + keylist.append((*it).left(i));
2.45 + valuelist.append((*it).right((*it).length()-i-1));
2.46 + it++;
2.47 + }
2.48 +}
2.49 +
2.50 +void SimpleSettings::writeSettings (const QString &path)
2.51 +{
2.52 + QString s;
2.53 + QStringList::Iterator itk=keylist.begin();
2.54 + QStringList::Iterator itv=valuelist.begin();
2.55 +
2.56 + // First search for value in settings saved in map
2.57 + while (itk !=keylist.end() )
2.58 + {
2.59 + s+=*itk+"="+*itv+"\n";
2.60 + itk++;
2.61 + itv++;
2.62 + }
2.63 + if (!saveStringToDisk(path,s))
2.64 + qWarning ("SimpleSettings::writeSettings() Couldn't write "+path);
2.65 +}
2.66 +
2.67 +/*
2.68 +QString SimpleSettings::readEntry (const QString &key)
2.69 +{
2.70 + QStringList::Iterator itk=keylist.begin();
2.71 + QStringList::Iterator itv=valuelist.begin();
2.72 +
2.73 + // First search for value in settings saved in map
2.74 + while (itk !=keylist.end() )
2.75 + {
2.76 + if (*itk == key)
2.77 + return *itv;
2.78 + itk++;
2.79 + itv++;
2.80 + }
2.81 + qWarning ("SimpleSettings::readEntry() Couldn't find key "+key);
2.82 + return "";
2.83 +}
2.84 +*/
2.85 +
2.86 +QString SimpleSettings::readEntry (const QString &key, const QString &def)
2.87 +{
2.88 + QStringList::Iterator itk=keylist.begin();
2.89 + QStringList::Iterator itv=valuelist.begin();
2.90 +
2.91 + // First search for value in settings saved in map
2.92 + while (itk !=keylist.end() )
2.93 + {
2.94 + if (*itk == key)
2.95 + return *itv;
2.96 + itk++;
2.97 + itv++;
2.98 + }
2.99 + return def;
2.100 +}
2.101 +
2.102 +int SimpleSettings::readNumEntry (const QString &key, const int &def)
2.103 +{
2.104 + QStringList::Iterator itk=keylist.begin();
2.105 + QStringList::Iterator itv=valuelist.begin();
2.106 +
2.107 + // First search for value in settings saved in map
2.108 + while (itk !=keylist.end() )
2.109 + {
2.110 + if (*itk == key)
2.111 + {
2.112 + bool ok;
2.113 + int i=(*itv).toInt(&ok,10);
2.114 + if (ok)
2.115 + return i;
2.116 + else
2.117 + return def;
2.118 + }
2.119 + itk++;
2.120 + itv++;
2.121 + }
2.122 + return def;
2.123 +}
2.124 +
2.125 +void SimpleSettings::setEntry (const QString &key, const QString &value)
2.126 +{
2.127 + QStringList::Iterator itk=keylist.begin();
2.128 + QStringList::Iterator itv=valuelist.begin();
2.129 +
2.130 + if (!key.isEmpty() )
2.131 + {
2.132 + // Search for existing entry first
2.133 + while (itk !=keylist.end() )
2.134 + {
2.135 + if (*itk == key)
2.136 + {
2.137 + if (!value.isEmpty())
2.138 + *itv=value;
2.139 + else
2.140 + *itv="";
2.141 + *itv=value;
2.142 + return;
2.143 + }
2.144 + itk++;
2.145 + itv++;
2.146 + }
2.147 +
2.148 + // If no entry exists, append a new one
2.149 + keylist.append (key);
2.150 + valuelist.append (value);
2.151 + }
2.152 +}
2.153 +
2.154 +
2.155 +
2.156 /////////////////////////////////////////////////////////////////
2.157 // Settings
2.158 /////////////////////////////////////////////////////////////////
2.159 @@ -11,6 +156,11 @@
2.160 clear();
2.161 }
2.162
2.163 +Settings::Settings(const QString & organization, const QString & application ):QSettings (organization,application)
2.164 +{
2.165 + clear();
2.166 +}
2.167 +
2.168 Settings::~Settings()
2.169 {
2.170 }
2.171 @@ -93,7 +243,7 @@
2.172 }
2.173 }
2.174
2.175 -QString Settings::getXMLData (const QString &fpath)
2.176 +QString Settings::getDataXML (const QString &fpath)
2.177 {
2.178 QString s;
2.179 QStringList::Iterator itp=pathlist.begin();
2.180 @@ -116,17 +266,3 @@
2.181 return s;
2.182 }
2.183
2.184 -void Settings::write()
2.185 -{
2.186 - QStringList::Iterator itp=pathlist.begin();
2.187 - QStringList::Iterator itk=keylist.begin();
2.188 - QStringList::Iterator itv=valuelist.begin();
2.189 -
2.190 - while (itp !=pathlist.end() )
2.191 - {
2.192 - itp++;
2.193 - itk++;
2.194 - itv++;
2.195 - }
2.196 -}
2.197 -
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/version.cpp Thu Dec 04 13:47:47 2008 +0000
3.3 @@ -0,0 +1,57 @@
3.4 +#include "version.h"
3.5 +
3.6 +#include <QRegExp>
3.7 +
3.8 +bool checkVersion (const QString &v)
3.9 +{
3.10 + // returns true, if vym is able to read file regarding
3.11 + // the version set with setVersion
3.12 + return checkVersion (v,__VYM_VERSION);
3.13 +}
3.14 +
3.15 +
3.16 +bool checkVersion (const QString &v, const QString &d)
3.17 +{
3.18 + bool ok;
3.19 + int v1;
3.20 + int v2;
3.21 + int v3;
3.22 + int d1;
3.23 + int d2;
3.24 + int d3;
3.25 +
3.26 + QRegExp rx("(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})");
3.27 + int pos=rx.indexIn (v);
3.28 + if (pos>-1)
3.29 + {
3.30 + v1=rx.cap(1).toInt(&ok);
3.31 + v2=rx.cap(2).toInt(&ok);
3.32 + v3=rx.cap(3).toInt(&ok);
3.33 + } else
3.34 + qWarning (QString ("Warning: Checking version failed for v=%1").arg(v));
3.35 +
3.36 + pos=rx.indexIn (d);
3.37 + if (pos>-1)
3.38 + {
3.39 + d1=rx.cap(1).toInt(&ok);
3.40 + d2=rx.cap(2).toInt(&ok);
3.41 + d3=rx.cap(3).toInt(&ok);
3.42 + } else
3.43 + qWarning (QString ("Warning: Checking version failed for d=%1").arg(d));
3.44 +
3.45 +
3.46 + if (d1 > v1)
3.47 + return true;
3.48 + if (d1 < v1)
3.49 + return false;
3.50 + if (d2 > v2)
3.51 + return true;
3.52 + if (d2 < v2)
3.53 + return false;
3.54 + if (d3 > v3)
3.55 + return true;
3.56 + if (d3 < v3)
3.57 + return false;
3.58 + return true;
3.59 +
3.60 +}
4.1 --- a/version.h Mon Dec 01 16:44:35 2008 +0000
4.2 +++ b/version.h Thu Dec 04 13:47:47 2008 +0000
4.3 @@ -4,10 +4,10 @@
4.4 #include <QString>
4.5
4.6 #define __VYM_NAME "VYM"
4.7 -#define __VYM_VERSION "1.12.2"
4.8 -#define __VYM_CODENAME "Maintenance Update a"
4.9 +#define __VYM_VERSION "1.12.2b"
4.10 +#define __VYM_CODENAME "Maintenance Update "
4.11 //#define __VYM_CODENAME "Codename: development version"
4.12 -#define __VYM_BUILD_DATE "2008-12-01"
4.13 +#define __VYM_BUILD_DATE "2008-12-04"
4.14
4.15
4.16 bool checkVersion(const QString &);