Get format version.

--HG--
branch : feature
This commit is contained in:
dismine 2014-05-16 17:11:31 +03:00
parent 37cab897fa
commit 7b617223e9
6 changed files with 65 additions and 7 deletions

View File

@ -36,7 +36,7 @@ quint32 VContainer::_id = 0;
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VContainer::VContainer() VContainer::VContainer()
:_size(50), sizeName("Сг"), _height(176), heightName("P"), gObjects(QHash<quint32, VGObject *>()), :_size(50), sizeName(size_M), _height(176), heightName(height_M), gObjects(QHash<quint32, VGObject *>()),
measurements(QHash<QString, VMeasurement>()), increments(QHash<QString, VIncrement>()), measurements(QHash<QString, VMeasurement>()), increments(QHash<QString, VIncrement>()),
lengthLines(QHash<QString, qreal>()), lineAngles(QHash<QString, qreal>()), lengthSplines(QHash<QString, qreal>()), lengthLines(QHash<QString, qreal>()), lineAngles(QHash<QString, qreal>()), lengthSplines(QHash<QString, qreal>()),
lengthArcs(QHash<QString, qreal>()), details(QHash<quint32, VDetail>()) lengthArcs(QHash<QString, qreal>()), details(QHash<quint32, VDetail>())
@ -51,7 +51,7 @@ VContainer &VContainer::operator =(const VContainer &data)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VContainer::VContainer(const VContainer &data) VContainer::VContainer(const VContainer &data)
:_size(50), sizeName("Сг"), _height(176), heightName("P"), gObjects(QHash<quint32, VGObject *>()), :_size(50), sizeName(size_M), _height(176), heightName(height_M), gObjects(QHash<quint32, VGObject *>()),
measurements(QHash<QString, VMeasurement>()), increments(QHash<QString, VIncrement>()), measurements(QHash<QString, VMeasurement>()), increments(QHash<QString, VIncrement>()),
lengthLines(QHash<QString, qreal>()), lineAngles(QHash<QString, qreal>()), lengthSplines(QHash<QString, qreal>()), lengthLines(QHash<QString, qreal>()), lineAngles(QHash<QString, qreal>()), lengthSplines(QHash<QString, qreal>()),
lengthArcs(QHash<QString, qreal>()), details(QHash<quint32, VDetail>()) lengthArcs(QHash<QString, qreal>()), details(QHash<quint32, VDetail>())

View File

@ -88,6 +88,7 @@ const QString VDomDocument::AttrUnit = QStringLiteral("unit");
const QString VDomDocument::UnitMM = QStringLiteral("mm"); const QString VDomDocument::UnitMM = QStringLiteral("mm");
const QString VDomDocument::UnitCM = QStringLiteral("cm"); const QString VDomDocument::UnitCM = QStringLiteral("cm");
const QString VDomDocument::UnitINCH = QStringLiteral("inch"); const QString VDomDocument::UnitINCH = QStringLiteral("inch");
const QString VDomDocument::TagVersion = QStringLiteral("version");
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VDomDocument::VDomDocument(VContainer *data) VDomDocument::VDomDocument(VContainer *data)
@ -431,6 +432,30 @@ bool VDomDocument::SaveDocument(const QString &fileName)
return result; return result;
} }
//---------------------------------------------------------------------------------------------------------------------
QString VDomDocument::Major() const
{
QString version = UniqueTagText(TagVersion, "0.0.0");
QStringList v = version.split(".");
return v.at(0);
}
//---------------------------------------------------------------------------------------------------------------------
QString VDomDocument::Minor() const
{
QString version = UniqueTagText(TagVersion, "0.0.0");
QStringList v = version.split(".");
return v.at(1);
}
//---------------------------------------------------------------------------------------------------------------------
QString VDomDocument::Patch() const
{
QString version = UniqueTagText(TagVersion, "0.0.0");
QStringList v = version.split(".");
return v.at(2);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VDomDocument::setTagText(const QString &tag, const QString &text) void VDomDocument::setTagText(const QString &tag, const QString &text)
{ {

View File

@ -35,6 +35,11 @@
#include <QDebug> #include <QDebug>
#include "../options.h" #include "../options.h"
/*
can be used like #if (V_FORMAT_VERSION >= V_FORMAT_VERSION_CHECK(4, 4, 0))
*/
#define V_FORMAT_VERSION_CHECK(major, minor, patch) ((major<<16)|(minor<<8)|(patch))
#ifdef Q_CC_GNU #ifdef Q_CC_GNU
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++" #pragma GCC diagnostic ignored "-Weffc++"
@ -70,6 +75,7 @@ public:
static const QString UnitMM; static const QString UnitMM;
static const QString UnitCM; static const QString UnitCM;
static const QString UnitINCH; static const QString UnitINCH;
static const QString TagVersion;
/** /**
* @param data container with variables * @param data container with variables
* @param comboBoxDraws pointer to the ComboBox that will hold the pattern piece names * @param comboBoxDraws pointer to the ComboBox that will hold the pattern piece names
@ -146,6 +152,9 @@ public:
static Valentina::Units StrToUnits(const QString &unit); static Valentina::Units StrToUnits(const QString &unit);
static QString UnitsToStr(const Valentina::Units &unit); static QString UnitsToStr(const Valentina::Units &unit);
virtual bool SaveDocument(const QString &fileName); virtual bool SaveDocument(const QString &fileName);
QString Major() const;
QString Minor() const;
QString Patch() const;
protected: protected:
/** /**
* @brief data container with data. * @brief data container with data.

View File

@ -32,6 +32,14 @@
#include "vdomdocument.h" #include "vdomdocument.h"
#include <QDate> #include <QDate>
/*
VIT_VERSION is (major << 16) + (minor << 8) + patch.
*/
// version without patch part
#define VIT_MIN_VERSION 0x000100
// max support version of format
#define VIT_VERSION 0x000100
class VIndividualMeasurements:public VDomDocument class VIndividualMeasurements:public VDomDocument
{ {
public: public:

View File

@ -45,6 +45,14 @@ namespace Document
} }
Q_DECLARE_OPERATORS_FOR_FLAGS(Document::Documents) Q_DECLARE_OPERATORS_FOR_FLAGS(Document::Documents)
/*
VAL_VERSION is (major << 16) + (minor << 8) + patch.
*/
// version without patch part
#define VAL_MIN_VERSION 0x000100
// max support version of format
#define VAL_VERSION 0x000100
/** /**
* @brief The VPattern class working with pattern file. * @brief The VPattern class working with pattern file.
*/ */

View File

@ -31,6 +31,14 @@
#include "vdomdocument.h" #include "vdomdocument.h"
/*
VST_VERSION is (major << 16) + (minor << 8) + patch.
*/
// version without patch part
#define VST_MIN_VERSION 0x000100
// max support version of format
#define VST_VERSION 0x000100
class VStandardMeasurements:public VDomDocument class VStandardMeasurements:public VDomDocument
{ {
public: public: