#include "version.h"

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);
	
	if (d1i > v1i)
		return true;
	if (d1i < v1i)
		return false;
	if (d2i > v2i)
		return true;
	if (d2i < v2i)
		return false;
	if (d3i > v3i)
		return true;
	if (d3i < v3i)
		return false;
	return true;	

}
