diff -r e7f6bcdf5f6c -r 1ad892c1a709 version.cpp --- a/version.cpp Mon Jul 23 12:42:02 2007 +0000 +++ b/version.cpp Tue Mar 02 13:59:19 2010 +0000 @@ -1,71 +1,56 @@ #include "version.h" +#include + bool checkVersion (const QString &v) { // returns true, if vym is able to read file regarding // the version set with setVersion return checkVersion (v,__VYM_VERSION); - /* - QString s1=v.section (".",0,0); - QString s2=v.section (".",1,1); - QString s3=v.section (".",2,2); - bool ok; - int vv1 =QString(__VYM_VERSION).section (".",0,0).toInt(&ok,10); - int vv2 =QString(__VYM_VERSION).section (".",1,1).toInt(&ok,10); - int vv3 =QString(__VYM_VERSION).section (".",2,2).toInt(&ok,10); - int mv1=0; - int mv2=0; - int mv3=0; - if (!s1.isEmpty() ) mv1=s1.toInt(&ok,10); - if (!s2.isEmpty() ) mv2=s2.toInt(&ok,10); - if (!s3.isEmpty() ) mv3=s3.toInt(&ok,10); - - if (vv1 > mv1) - return true; - if (vv1 < mv1) - return false; - if (vv2 > mv2) - return true; - if (vv2 < mv2) - return false; - if (vv3 > mv3) - return true; - if (vv3 < mv3) - return false; - return true; -*/ } + bool checkVersion (const QString &v, const QString &d) { - QString v1=v.section (".",0,0); - QString v2=v.section (".",1,1); - QString v3=v.section (".",2,2); - QString d1=d.section (".",0,0); - QString d2=d.section (".",1,1); - QString d3=d.section (".",2,2); bool ok; - int d1i=d1.toInt(&ok,10); - int d2i=d2.toInt(&ok,10); - int d3i=d3.toInt(&ok,10); - int v1i=0; - int v2i=0; - int v3i=0; - if (!v1.isEmpty() ) v1i=v1.toInt(&ok,10); - if (!v2.isEmpty() ) v2i=v2.toInt(&ok,10); - if (!v3.isEmpty() ) v3i=v3.toInt(&ok,10); + int v1; + int v2; + int v3; + int d1; + int d2; + int d3; + + QRegExp rx("(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})"); + int pos=rx.indexIn (v); + if (pos>-1) + { + v1=rx.cap(1).toInt(&ok); + v2=rx.cap(2).toInt(&ok); + v3=rx.cap(3).toInt(&ok); + } else + qWarning (QString ("Warning: Checking version failed for v=%1").arg(v)); + + pos=rx.indexIn (d); + if (pos>-1) + { + d1=rx.cap(1).toInt(&ok); + d2=rx.cap(2).toInt(&ok); + d3=rx.cap(3).toInt(&ok); + } else + qWarning (QString ("Warning: Checking version failed for d=%1").arg(d)); + - if (d1i > v1i) + if (d1 > v1) return true; - if (d1i < v1i) + if (d1 < v1) return false; - if (d2i > v2i) + if (d2 > v2) return true; - if (d2i < v2i) + if (d2 < v2) return false; - if (d3i > v3i) + if (d3 > v3) return true; - if (d3i < v3i) + if (d3 < v3) return false; return true;