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