version.cpp
author insilmaril
Sun, 26 Aug 2007 12:16:26 +0000
changeset 587 83d00d979f16
parent 565 e7f6bcdf5f6c
child 729 7ddbe3fa34a1
permissions -rw-r--r--
changed searchpath for documentation SUSE Linux
     1 #include "version.h"
     2 
     3 bool checkVersion (const QString &v)
     4 {
     5 	// returns true, if vym is able to read file regarding 
     6 	// the version set with setVersion
     7 	return checkVersion (v,__VYM_VERSION);
     8 	/*
     9 	QString s1=v.section (".",0,0);
    10 	QString s2=v.section (".",1,1);
    11 	QString s3=v.section (".",2,2);
    12 	bool ok;
    13 	int vv1 =QString(__VYM_VERSION).section (".",0,0).toInt(&ok,10);
    14 	int vv2 =QString(__VYM_VERSION).section (".",1,1).toInt(&ok,10);
    15 	int vv3 =QString(__VYM_VERSION).section (".",2,2).toInt(&ok,10);
    16 	int mv1=0;
    17 	int mv2=0;
    18 	int mv3=0;
    19 	if (!s1.isEmpty() ) mv1=s1.toInt(&ok,10);
    20 	if (!s2.isEmpty() ) mv2=s2.toInt(&ok,10);
    21 	if (!s3.isEmpty() ) mv3=s3.toInt(&ok,10);
    22 	
    23 	if (vv1 > mv1)
    24 		return true;
    25 	if (vv1 < mv1)
    26 		return false;
    27 	if (vv2 > mv2)
    28 		return true;
    29 	if (vv2 < mv2)
    30 		return false;
    31 	if (vv3 > mv3)
    32 		return true;
    33 	if (vv3 < mv3)
    34 		return false;
    35 	return true;	
    36 */
    37 }
    38 
    39 bool checkVersion (const QString &v, const QString &d)
    40 {
    41 	QString v1=v.section (".",0,0);
    42 	QString v2=v.section (".",1,1);
    43 	QString v3=v.section (".",2,2);
    44 	QString d1=d.section (".",0,0);
    45 	QString d2=d.section (".",1,1);
    46 	QString d3=d.section (".",2,2);
    47 	bool ok;
    48 	int d1i=d1.toInt(&ok,10);
    49 	int d2i=d2.toInt(&ok,10);
    50 	int d3i=d3.toInt(&ok,10);
    51 	int v1i=0;
    52 	int v2i=0;
    53 	int v3i=0;
    54 	if (!v1.isEmpty() ) v1i=v1.toInt(&ok,10);
    55 	if (!v2.isEmpty() ) v2i=v2.toInt(&ok,10);
    56 	if (!v3.isEmpty() ) v3i=v3.toInt(&ok,10);
    57 	
    58 	if (d1i > v1i)
    59 		return true;
    60 	if (d1i < v1i)
    61 		return false;
    62 	if (d2i > v2i)
    63 		return true;
    64 	if (d2i < v2i)
    65 		return false;
    66 	if (d3i > v3i)
    67 		return true;
    68 	if (d3i < v3i)
    69 		return false;
    70 	return true;	
    71 
    72 }