author | insilmaril |
Wed, 22 Jul 2009 19:56:29 +0000 | |
branch | release-1-12-maintained |
changeset 71 | 0da9dd0b3911 |
parent 55 | 79b0656dbe7d |
permissions | -rw-r--r-- |
insilmaril@55 | 1 |
#include "version.h" |
insilmaril@55 | 2 |
|
insilmaril@55 | 3 |
#include <QRegExp> |
insilmaril@55 | 4 |
|
insilmaril@55 | 5 |
bool checkVersion (const QString &v) |
insilmaril@55 | 6 |
{ |
insilmaril@55 | 7 |
// returns true, if vym is able to read file regarding |
insilmaril@55 | 8 |
// the version set with setVersion |
insilmaril@55 | 9 |
return checkVersion (v,__VYM_VERSION); |
insilmaril@55 | 10 |
} |
insilmaril@55 | 11 |
|
insilmaril@55 | 12 |
|
insilmaril@55 | 13 |
bool checkVersion (const QString &v, const QString &d) |
insilmaril@55 | 14 |
{ |
insilmaril@55 | 15 |
bool ok; |
insilmaril@55 | 16 |
int v1; |
insilmaril@55 | 17 |
int v2; |
insilmaril@55 | 18 |
int v3; |
insilmaril@55 | 19 |
int d1; |
insilmaril@55 | 20 |
int d2; |
insilmaril@55 | 21 |
int d3; |
insilmaril@55 | 22 |
|
insilmaril@55 | 23 |
QRegExp rx("(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})"); |
insilmaril@55 | 24 |
int pos=rx.indexIn (v); |
insilmaril@55 | 25 |
if (pos>-1) |
insilmaril@55 | 26 |
{ |
insilmaril@55 | 27 |
v1=rx.cap(1).toInt(&ok); |
insilmaril@55 | 28 |
v2=rx.cap(2).toInt(&ok); |
insilmaril@55 | 29 |
v3=rx.cap(3).toInt(&ok); |
insilmaril@55 | 30 |
} else |
insilmaril@55 | 31 |
qWarning (QString ("Warning: Checking version failed for v=%1").arg(v)); |
insilmaril@55 | 32 |
|
insilmaril@55 | 33 |
pos=rx.indexIn (d); |
insilmaril@55 | 34 |
if (pos>-1) |
insilmaril@55 | 35 |
{ |
insilmaril@55 | 36 |
d1=rx.cap(1).toInt(&ok); |
insilmaril@55 | 37 |
d2=rx.cap(2).toInt(&ok); |
insilmaril@55 | 38 |
d3=rx.cap(3).toInt(&ok); |
insilmaril@55 | 39 |
} else |
insilmaril@55 | 40 |
qWarning (QString ("Warning: Checking version failed for d=%1").arg(d)); |
insilmaril@55 | 41 |
|
insilmaril@55 | 42 |
|
insilmaril@55 | 43 |
if (d1 > v1) |
insilmaril@55 | 44 |
return true; |
insilmaril@55 | 45 |
if (d1 < v1) |
insilmaril@55 | 46 |
return false; |
insilmaril@55 | 47 |
if (d2 > v2) |
insilmaril@55 | 48 |
return true; |
insilmaril@55 | 49 |
if (d2 < v2) |
insilmaril@55 | 50 |
return false; |
insilmaril@55 | 51 |
if (d3 > v3) |
insilmaril@55 | 52 |
return true; |
insilmaril@55 | 53 |
if (d3 < v3) |
insilmaril@55 | 54 |
return false; |
insilmaril@55 | 55 |
return true; |
insilmaril@55 | 56 |
|
insilmaril@55 | 57 |
} |