1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/version.cpp Thu Mar 05 09:33:30 2009 +0000
1.3 @@ -0,0 +1,57 @@
1.4 +#include "version.h"
1.5 +
1.6 +#include <QRegExp>
1.7 +
1.8 +bool checkVersion (const QString &v)
1.9 +{
1.10 + // returns true, if vym is able to read file regarding
1.11 + // the version set with setVersion
1.12 + return checkVersion (v,__VYM_VERSION);
1.13 +}
1.14 +
1.15 +
1.16 +bool checkVersion (const QString &v, const QString &d)
1.17 +{
1.18 + bool ok;
1.19 + int v1;
1.20 + int v2;
1.21 + int v3;
1.22 + int d1;
1.23 + int d2;
1.24 + int d3;
1.25 +
1.26 + QRegExp rx("(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})");
1.27 + int pos=rx.indexIn (v);
1.28 + if (pos>-1)
1.29 + {
1.30 + v1=rx.cap(1).toInt(&ok);
1.31 + v2=rx.cap(2).toInt(&ok);
1.32 + v3=rx.cap(3).toInt(&ok);
1.33 + } else
1.34 + qWarning (QString ("Warning: Checking version failed for v=%1").arg(v));
1.35 +
1.36 + pos=rx.indexIn (d);
1.37 + if (pos>-1)
1.38 + {
1.39 + d1=rx.cap(1).toInt(&ok);
1.40 + d2=rx.cap(2).toInt(&ok);
1.41 + d3=rx.cap(3).toInt(&ok);
1.42 + } else
1.43 + qWarning (QString ("Warning: Checking version failed for d=%1").arg(d));
1.44 +
1.45 +
1.46 + if (d1 > v1)
1.47 + return true;
1.48 + if (d1 < v1)
1.49 + return false;
1.50 + if (d2 > v2)
1.51 + return true;
1.52 + if (d2 < v2)
1.53 + return false;
1.54 + if (d3 > v3)
1.55 + return true;
1.56 + if (d3 < v3)
1.57 + return false;
1.58 + return true;
1.59 +
1.60 +}