Resolved issue #265. Add 'Read only' attribute.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2016-01-22 12:45:18 +02:00
parent e000486633
commit 8b050eee31
13 changed files with 576 additions and 8 deletions

View File

@ -41,7 +41,7 @@ DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *pat
QDialog(parent), ui(new Ui::DialogPatternProperties), doc(doc), pattern(pattern), heightsChecked(MAX_HEIGHTS), QDialog(parent), ui(new Ui::DialogPatternProperties), doc(doc), pattern(pattern), heightsChecked(MAX_HEIGHTS),
sizesChecked(MAX_SIZES), heights (QMap<GHeights, bool>()), sizes(QMap<GSizes, bool>()), sizesChecked(MAX_SIZES), heights (QMap<GHeights, bool>()), sizes(QMap<GSizes, bool>()),
data(QMap<QCheckBox *, int>()), descriptionChanged(false), gradationChanged(false), defaultChanged(false), data(QMap<QCheckBox *, int>()), descriptionChanged(false), gradationChanged(false), defaultChanged(false),
isInitialized(false) securityChanged(false), isInitialized(false)
{ {
ui->setupUi(this); ui->setupUi(this);
@ -104,9 +104,22 @@ DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *pat
connect(ui->comboBoxSize, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, connect(ui->comboBoxSize, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&DialogPatternProperties::DefValueChanged); &DialogPatternProperties::DefValueChanged);
const bool readOnly = doc->IsReadOnly();
ui->checkBoxPatternReadOnly->setChecked(readOnly);
if (not readOnly)
{
connect(ui->checkBoxPatternReadOnly, &QRadioButton::toggled, this,
&DialogPatternProperties::SecurityValueChanged);
}
else
{
ui->checkBoxPatternReadOnly->setDisabled(true);
}
//Initialization change value. Set to default value after initialization //Initialization change value. Set to default value after initialization
gradationChanged = false; gradationChanged = false;
defaultChanged = false; defaultChanged = false;
securityChanged = false;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -132,6 +145,11 @@ void DialogPatternProperties::Apply()
defaultChanged = false; defaultChanged = false;
emit doc->patternChanged(false); emit doc->patternChanged(false);
break; break;
case 2:
doc->SetReadOnly(ui->checkBoxPatternReadOnly->isChecked());
securityChanged = false;
emit doc->patternChanged(false);
break;
default: default:
break; break;
} }
@ -161,6 +179,13 @@ void DialogPatternProperties::Ok()
emit doc->patternChanged(false); emit doc->patternChanged(false);
} }
if (securityChanged)
{
doc->SetReadOnly(ui->checkBoxPatternReadOnly->isChecked());
securityChanged = false;
emit doc->patternChanged(false);
}
close(); close();
} }
@ -329,6 +354,12 @@ void DialogPatternProperties::DefValueChanged()
defaultChanged = true; defaultChanged = true;
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::SecurityValueChanged()
{
securityChanged = true;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::SetHeightsChecked(bool enabled) void DialogPatternProperties::SetHeightsChecked(bool enabled)
{ {

View File

@ -62,6 +62,7 @@ protected:
private slots: private slots:
void ToggleComboBox(); void ToggleComboBox();
void DefValueChanged(); void DefValueChanged();
void SecurityValueChanged();
private: private:
Q_DISABLE_COPY(DialogPatternProperties) Q_DISABLE_COPY(DialogPatternProperties)
Ui::DialogPatternProperties *ui; Ui::DialogPatternProperties *ui;
@ -75,6 +76,7 @@ private:
bool descriptionChanged; bool descriptionChanged;
bool gradationChanged; bool gradationChanged;
bool defaultChanged; bool defaultChanged;
bool securityChanged;
bool isInitialized; bool isInitialized;
void SetHeightsChecked(bool enabled); void SetHeightsChecked(bool enabled);

View File

@ -21,7 +21,7 @@
<item> <item>
<widget class="QTabWidget" name="tabWidget"> <widget class="QTabWidget" name="tabWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>1</number> <number>0</number>
</property> </property>
<widget class="QWidget" name="tab"> <widget class="QWidget" name="tab">
<attribute name="title"> <attribute name="title">
@ -911,6 +911,20 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="tab_3">
<attribute name="title">
<string>Security</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_10">
<item alignment="Qt::AlignTop">
<widget class="QCheckBox" name="checkBoxPatternReadOnly">
<property name="text">
<string>Open only for read</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget> </widget>
</item> </item>
<item> <item>

View File

@ -98,7 +98,8 @@ const QString autosavePrefix = QStringLiteral(".autosave");
MainWindow::MainWindow(QWidget *parent) MainWindow::MainWindow(QWidget *parent)
:MainWindowsNoGUI(parent), ui(new Ui::MainWindow), watcher(new QFileSystemWatcher(this)), currentTool(Tool::Arrow), :MainWindowsNoGUI(parent), ui(new Ui::MainWindow), watcher(new QFileSystemWatcher(this)), currentTool(Tool::Arrow),
lastUsedTool(Tool::Arrow), sceneDraw(nullptr), sceneDetails(nullptr), lastUsedTool(Tool::Arrow), sceneDraw(nullptr), sceneDetails(nullptr),
mouseCoordinate(nullptr), helpLabel(nullptr), isInitialized(false), mChanges(false), dialogTable(nullptr), mouseCoordinate(nullptr), helpLabel(nullptr), isInitialized(false), mChanges(false), patternReadOnly(false),
dialogTable(nullptr),
dialogTool(nullptr), dialogTool(nullptr),
dialogHistory(nullptr), comboBoxDraws(nullptr), patternPieceLabel(nullptr), mode(Draw::Calculation), dialogHistory(nullptr), comboBoxDraws(nullptr), patternPieceLabel(nullptr), mode(Draw::Calculation),
currentDrawIndex(0), currentToolBoxIndex(0), drawMode(true), recentFileActs(), currentDrawIndex(0), currentToolBoxIndex(0), drawMode(true), recentFileActs(),
@ -2099,6 +2100,25 @@ bool MainWindow::SaveAs()
} }
} }
if (curFile == fileName && patternReadOnly)
{
const QString message = QString("Failed to save the pattern '%1'. Error writing. The document is read-only.")
.arg(fileName);
QMessageBox messageBox;
messageBox.setIcon(QMessageBox::Critical);
messageBox.setInformativeText(message);
messageBox.setDefaultButton(QMessageBox::Ok);
messageBox.setStandardButtons(QMessageBox::Ok);
messageBox.exec();
return false;
}
// Need for restoring previous state in case of failure
const bool wasModified = doc->IsModified(); // Need because SetReadOnly() will change internal state
const bool readOnly = doc->IsReadOnly();
doc->SetReadOnly(false);// Save as... disable read only state
QString error; QString error;
const bool result = SavePattern(fileName, error); const bool result = SavePattern(fileName, error);
if (result == false) if (result == false)
@ -2111,9 +2131,15 @@ bool MainWindow::SaveAs()
messageBox.setStandardButtons(QMessageBox::Ok); messageBox.setStandardButtons(QMessageBox::Ok);
messageBox.exec(); messageBox.exec();
// Restoring previous state
doc->SetReadOnly(readOnly);
doc->SetModified(wasModified);
return result; return result;
} }
patternReadOnly = false;
qCDebug(vMainWindow, "Locking file"); qCDebug(vMainWindow, "Locking file");
VlpCreateLock(lock, fileName); VlpCreateLock(lock, fileName);
@ -2416,6 +2442,7 @@ void MainWindow::FullParseFile()
GlobalChangePP(patternPiece); GlobalChangePP(patternPiece);
SetEnableTool(comboBoxDraws->count() > 0); SetEnableTool(comboBoxDraws->count() > 0);
patternReadOnly = doc->IsReadOnly();
SetEnableWidgets(true); SetEnableWidgets(true);
} }
@ -2489,10 +2516,14 @@ void MainWindow::SetEnableWidgets(bool enable)
{ {
comboBoxDraws->setEnabled(enable); comboBoxDraws->setEnabled(enable);
ui->actionOptionDraw->setEnabled(enable); ui->actionOptionDraw->setEnabled(enable);
if (enable && not curFile.isEmpty()) if (enable && not curFile.isEmpty() && not patternReadOnly)
{ {
ui->actionSave->setEnabled(enable); ui->actionSave->setEnabled(enable);
} }
else
{
ui->actionSave->setEnabled(false);
}
ui->actionSaveAs->setEnabled(enable); ui->actionSaveAs->setEnabled(enable);
ui->actionPattern_properties->setEnabled(enable); ui->actionPattern_properties->setEnabled(enable);
ui->actionEdit_pattern_code->setEnabled(enable); ui->actionEdit_pattern_code->setEnabled(enable);
@ -2654,7 +2685,7 @@ void MainWindow::PatternWasModified(bool saved)
{ {
const bool state = doc->IsModified() || !saved; const bool state = doc->IsModified() || !saved;
setWindowModified(state); setWindowModified(state);
ui->actionSave->setEnabled(state); not patternReadOnly ? ui->actionSave->setEnabled(state): ui->actionSave->setEnabled(false);
isLayoutStale = true; isLayoutStale = true;
} }
} }

View File

@ -209,6 +209,8 @@ private:
/** @brief mChanges true if measurement file was changed. */ /** @brief mChanges true if measurement file was changed. */
bool mChanges; bool mChanges;
bool patternReadOnly;
DialogIncrements *dialogTable; DialogIncrements *dialogTable;
DialogTool *dialogTool; DialogTool *dialogTool;
DialogHistory *dialogHistory; DialogHistory *dialogHistory;

View File

@ -49,6 +49,8 @@
#include <QUndoStack> #include <QUndoStack>
#include <QtCore/qmath.h> #include <QtCore/qmath.h>
const QString VPattern::AttrReadOnly = QStringLiteral("readOnly");
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPattern::VPattern(VContainer *data, Draw *mode, VMainGraphicsScene *sceneDraw, VPattern::VPattern(VContainer *data, Draw *mode, VMainGraphicsScene *sceneDraw,
VMainGraphicsScene *sceneDetail, QObject *parent) VMainGraphicsScene *sceneDetail, QObject *parent)
@ -2683,6 +2685,38 @@ void VPattern::SetDefCustomSize(int value)
} }
} }
//---------------------------------------------------------------------------------------------------------------------
bool VPattern::IsReadOnly() const
{
const QDomElement pattern = documentElement();
if (pattern.isNull())
{
return false;
}
return GetParametrBool(pattern, AttrReadOnly, QStringLiteral("false"));
}
//---------------------------------------------------------------------------------------------------------------------
void VPattern::SetReadOnly(bool rOnly)
{
QDomElement pattern = documentElement();
if (not pattern.isNull())
{
if (rOnly)
{
SetAttribute(pattern, AttrReadOnly, rOnly);
}
else
{// For better backward compatibility
pattern.removeAttribute(AttrReadOnly);
}
modified = true;
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPattern::PrepareForParse(const Document &parse) void VPattern::PrepareForParse(const Document &parse)
{ {

View File

@ -87,6 +87,11 @@ public:
int GetDefCustomSize() const; int GetDefCustomSize() const;
void SetDefCustomSize(int value); void SetDefCustomSize(int value);
bool IsReadOnly() const;
void SetReadOnly(bool rOnly);
static const QString AttrReadOnly;
public slots: public slots:
void LiteParseTree(const Document &parse); void LiteParseTree(const Document &parse);

View File

@ -9,6 +9,8 @@
<file>schema/pattern/v0.2.1.xsd</file> <file>schema/pattern/v0.2.1.xsd</file>
<file>schema/pattern/v0.2.2.xsd</file> <file>schema/pattern/v0.2.2.xsd</file>
<file>schema/pattern/v0.2.3.xsd</file> <file>schema/pattern/v0.2.3.xsd</file>
<file>schema/pattern/v0.2.4.xsd</file>
<file>schema/pattern/v0.2.5.xsd</file>
<file>schema/standard_measurements/v0.3.0.xsd</file> <file>schema/standard_measurements/v0.3.0.xsd</file>
<file>schema/standard_measurements/v0.4.0.xsd</file> <file>schema/standard_measurements/v0.4.0.xsd</file>
<file>schema/standard_measurements/v0.4.1.xsd</file> <file>schema/standard_measurements/v0.4.1.xsd</file>
@ -18,6 +20,5 @@
<file>schema/individual_measurements/v0.3.1.xsd</file> <file>schema/individual_measurements/v0.3.1.xsd</file>
<file>schema/individual_measurements/v0.3.2.xsd</file> <file>schema/individual_measurements/v0.3.2.xsd</file>
<file>schema/individual_measurements/v0.3.3.xsd</file> <file>schema/individual_measurements/v0.3.3.xsd</file>
<file>schema/pattern/v0.2.4.xsd</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@ -0,0 +1,424 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<!-- XML Schema Generated from XML Document-->
<xs:element name="pattern">
<xs:complexType>
<xs:sequence minOccurs="1" maxOccurs="unbounded">
<xs:element name="version" type="formatVersion"></xs:element>
<xs:element name="unit" type="units"></xs:element>
<xs:element name="author" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element>
<xs:element name="description" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element>
<xs:element name="notes" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element>
<xs:element name="gradation" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="heights">
<xs:complexType>
<xs:attribute name="all" type="xs:boolean" use="required"></xs:attribute>
<xs:attribute name="h92" type="xs:boolean"></xs:attribute>
<xs:attribute name="h98" type="xs:boolean"></xs:attribute>
<xs:attribute name="h104" type="xs:boolean"></xs:attribute>
<xs:attribute name="h110" type="xs:boolean"></xs:attribute>
<xs:attribute name="h116" type="xs:boolean"></xs:attribute>
<xs:attribute name="h122" type="xs:boolean"></xs:attribute>
<xs:attribute name="h128" type="xs:boolean"></xs:attribute>
<xs:attribute name="h134" type="xs:boolean"></xs:attribute>
<xs:attribute name="h140" type="xs:boolean"></xs:attribute>
<xs:attribute name="h146" type="xs:boolean"></xs:attribute>
<xs:attribute name="h152" type="xs:boolean"></xs:attribute>
<xs:attribute name="h158" type="xs:boolean"></xs:attribute>
<xs:attribute name="h164" type="xs:boolean"></xs:attribute>
<xs:attribute name="h170" type="xs:boolean"></xs:attribute>
<xs:attribute name="h176" type="xs:boolean"></xs:attribute>
<xs:attribute name="h182" type="xs:boolean"></xs:attribute>
<xs:attribute name="h188" type="xs:boolean"></xs:attribute>
<xs:attribute name="h194" type="xs:boolean"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="sizes">
<xs:complexType>
<xs:attribute name="all" type="xs:boolean" use="required"></xs:attribute>
<xs:attribute name="s22" type="xs:boolean"></xs:attribute>
<xs:attribute name="s24" type="xs:boolean"></xs:attribute>
<xs:attribute name="s26" type="xs:boolean"></xs:attribute>
<xs:attribute name="s28" type="xs:boolean"></xs:attribute>
<xs:attribute name="s30" type="xs:boolean"></xs:attribute>
<xs:attribute name="s32" type="xs:boolean"></xs:attribute>
<xs:attribute name="s34" type="xs:boolean"></xs:attribute>
<xs:attribute name="s36" type="xs:boolean"></xs:attribute>
<xs:attribute name="s38" type="xs:boolean"></xs:attribute>
<xs:attribute name="s40" type="xs:boolean"></xs:attribute>
<xs:attribute name="s42" type="xs:boolean"></xs:attribute>
<xs:attribute name="s44" type="xs:boolean"></xs:attribute>
<xs:attribute name="s46" type="xs:boolean"></xs:attribute>
<xs:attribute name="s48" type="xs:boolean"></xs:attribute>
<xs:attribute name="s50" type="xs:boolean"></xs:attribute>
<xs:attribute name="s52" type="xs:boolean"></xs:attribute>
<xs:attribute name="s54" type="xs:boolean"></xs:attribute>
<xs:attribute name="s56" type="xs:boolean"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="custom" type="xs:boolean"></xs:attribute>
<xs:attribute name="defHeight" type="baseHeight"></xs:attribute>
<xs:attribute name="defSize" type="baseSize"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="measurements" type="xs:string"></xs:element>
<xs:element name="increments" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element name="increment" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="description" type="xs:string" use="required"></xs:attribute>
<xs:attribute name="name" type="shortName" use="required"></xs:attribute>
<xs:attribute name="formula" type="xs:string" use="required"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:unique name="incrementName">
<xs:selector xpath="increment"/>
<xs:field xpath="@name"/>
</xs:unique>
</xs:element>
<xs:element name="draw" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="calculation" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="point" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="x" type="xs:double"></xs:attribute>
<xs:attribute name="y" type="xs:double"></xs:attribute>
<xs:attribute name="mx" type="xs:double"></xs:attribute>
<xs:attribute name="my" type="xs:double"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="name" type="shortName"></xs:attribute>
<xs:attribute name="firstPoint" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="secondPoint" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="thirdPoint" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="basePoint" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="pShoulder" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="p1Line" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="p2Line" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="length" type="xs:string"></xs:attribute>
<xs:attribute name="angle" type="xs:string"></xs:attribute>
<xs:attribute name="typeLine" type="xs:string"></xs:attribute>
<xs:attribute name="splinePath" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="spline" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="p1Line1" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="p1Line2" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="p2Line1" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="p2Line2" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="center" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="radius" type="xs:string"></xs:attribute>
<xs:attribute name="axisP1" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="axisP2" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="arc" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="curve" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="lineColor" type="colors"></xs:attribute>
<xs:attribute name="color" type="colors"></xs:attribute>
<xs:attribute name="firstArc" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="secondArc" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="crossPoint" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="c1Center" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="c2Center" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="c1Radius" type="xs:string"></xs:attribute>
<xs:attribute name="c2Radius" type="xs:string"></xs:attribute>
<xs:attribute name="cRadius" type="xs:string"></xs:attribute>
<xs:attribute name="tangent" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="cCenter" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="name1" type="shortName"></xs:attribute>
<xs:attribute name="mx1" type="xs:double"></xs:attribute>
<xs:attribute name="my1" type="xs:double"></xs:attribute>
<xs:attribute name="name2" type="shortName"></xs:attribute>
<xs:attribute name="mx2" type="xs:double"></xs:attribute>
<xs:attribute name="my2" type="xs:double"></xs:attribute>
<xs:attribute name="point1" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="point2" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="dartP1" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="dartP2" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="dartP3" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="baseLineP1" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="baseLineP2" type="xs:unsignedInt"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="line" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="firstPoint" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="secondPoint" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="typeLine" type="xs:string"></xs:attribute>
<xs:attribute name="lineColor" type="colors"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="arc" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="angle1" type="xs:string"></xs:attribute>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="angle2" type="xs:string"></xs:attribute>
<xs:attribute name="radius" type="xs:string"></xs:attribute>
<xs:attribute name="center" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="color" type="colors"></xs:attribute>
<xs:attribute name="length" type="xs:string"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="spline" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="pathPoint" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="kAsm2" type="xs:string"></xs:attribute>
<xs:attribute name="pSpline" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="angle" type="xs:string"></xs:attribute>
<xs:attribute name="kAsm1" type="xs:string"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="kCurve" type="xs:double"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="kAsm1" type="xs:double"></xs:attribute>
<xs:attribute name="kAsm2" type="xs:double"></xs:attribute>
<xs:attribute name="angle1" type="xs:double"></xs:attribute>
<xs:attribute name="angle2" type="xs:double"></xs:attribute>
<xs:attribute name="point1" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="point4" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="color" type="colors"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="modeling" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="point" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="idObject" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="mx" type="xs:double"></xs:attribute>
<xs:attribute name="typeObject" type="xs:string"></xs:attribute>
<xs:attribute name="my" type="xs:double"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="idTool" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="inUse" type="xs:boolean"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="arc" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="idObject" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="typeObject" type="xs:string"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="idTool" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="inUse" type="xs:boolean"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="spline" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="idObject" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="typeObject" type="xs:string"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="idTool" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="inUse" type="xs:boolean"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="tools" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="det" minOccurs="2" maxOccurs="2">
<xs:complexType>
<xs:sequence>
<xs:element name="node" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="nodeType" type="xs:string"></xs:attribute>
<xs:attribute name="idObject" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="mx" type="xs:double"></xs:attribute>
<xs:attribute name="my" type="xs:double"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="reverse" type="xs:unsignedInt"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="children" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="child" type="xs:unsignedInt" minOccurs="1" maxOccurs="unbounded"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="indexD1" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="indexD2" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="inUse" type="xs:boolean"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="details" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="detail" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="node" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="nodeType" type="xs:string"></xs:attribute>
<xs:attribute name="idObject" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="mx" type="xs:double"></xs:attribute>
<xs:attribute name="my" type="xs:double"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="reverse" type="xs:unsignedInt"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="supplement" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="mx" type="xs:double"></xs:attribute>
<xs:attribute name="my" type="xs:double"></xs:attribute>
<xs:attribute name="width" type="xs:double"></xs:attribute>
<xs:attribute name="name" type="xs:string"></xs:attribute>
<xs:attribute name="closed" type="xs:unsignedInt"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="name" type="xs:string"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="readOnly" type="xs:boolean"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:simpleType name="shortName">
<xs:restriction base="xs:string">
<xs:pattern value="^([^0-9*/^+\-=\s()?%:;!.,`'\&quot;]){1,1}([^*/^+\-=\s()?%:;!.,`'\&quot;]){0,}$"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="units">
<xs:restriction base="xs:string">
<xs:enumeration value="mm"/>
<xs:enumeration value="cm"/>
<xs:enumeration value="inch"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="measurementsTypes">
<xs:restriction base="xs:string">
<xs:enumeration value="standard"/>
<xs:enumeration value="individual"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="formatVersion">
<xs:restriction base="xs:string">
<xs:pattern value="^(0|([1-9][0-9]*))\.(0|([1-9][0-9]*))\.(0|([1-9][0-9]*))$"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="colors">
<xs:restriction base="xs:string">
<xs:enumeration value="black"/>
<xs:enumeration value="green"/>
<xs:enumeration value="blue"/>
<xs:enumeration value="darkRed"/>
<xs:enumeration value="darkGreen"/>
<xs:enumeration value="darkBlue"/>
<xs:enumeration value="yellow"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="baseHeight">
<xs:restriction base="xs:unsignedInt">
<xs:enumeration value="92"/>
<xs:enumeration value="98"/>
<xs:enumeration value="104"/>
<xs:enumeration value="110"/>
<xs:enumeration value="116"/>
<xs:enumeration value="122"/>
<xs:enumeration value="128"/>
<xs:enumeration value="134"/>
<xs:enumeration value="140"/>
<xs:enumeration value="146"/>
<xs:enumeration value="152"/>
<xs:enumeration value="158"/>
<xs:enumeration value="164"/>
<xs:enumeration value="170"/>
<xs:enumeration value="176"/>
<xs:enumeration value="182"/>
<xs:enumeration value="188"/>
<xs:enumeration value="194"/>
<xs:enumeration value="920"/>
<xs:enumeration value="980"/>
<xs:enumeration value="1040"/>
<xs:enumeration value="1100"/>
<xs:enumeration value="1160"/>
<xs:enumeration value="1220"/>
<xs:enumeration value="1280"/>
<xs:enumeration value="1340"/>
<xs:enumeration value="1400"/>
<xs:enumeration value="1460"/>
<xs:enumeration value="1520"/>
<xs:enumeration value="1580"/>
<xs:enumeration value="1640"/>
<xs:enumeration value="1700"/>
<xs:enumeration value="1760"/>
<xs:enumeration value="1820"/>
<xs:enumeration value="1880"/>
<xs:enumeration value="1940"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="baseSize">
<xs:restriction base="xs:unsignedInt">
<xs:enumeration value="22"/>
<xs:enumeration value="24"/>
<xs:enumeration value="26"/>
<xs:enumeration value="28"/>
<xs:enumeration value="30"/>
<xs:enumeration value="32"/>
<xs:enumeration value="34"/>
<xs:enumeration value="36"/>
<xs:enumeration value="38"/>
<xs:enumeration value="40"/>
<xs:enumeration value="42"/>
<xs:enumeration value="44"/>
<xs:enumeration value="46"/>
<xs:enumeration value="48"/>
<xs:enumeration value="50"/>
<xs:enumeration value="52"/>
<xs:enumeration value="54"/>
<xs:enumeration value="56"/>
<xs:enumeration value="220"/>
<xs:enumeration value="240"/>
<xs:enumeration value="260"/>
<xs:enumeration value="280"/>
<xs:enumeration value="300"/>
<xs:enumeration value="320"/>
<xs:enumeration value="340"/>
<xs:enumeration value="360"/>
<xs:enumeration value="380"/>
<xs:enumeration value="400"/>
<xs:enumeration value="420"/>
<xs:enumeration value="440"/>
<xs:enumeration value="460"/>
<xs:enumeration value="480"/>
<xs:enumeration value="500"/>
<xs:enumeration value="520"/>
<xs:enumeration value="540"/>
<xs:enumeration value="560"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>

View File

@ -1322,6 +1322,12 @@ bool VAbstractPattern::IsModified() const
return modified; return modified;
} }
//---------------------------------------------------------------------------------------------------------------------
void VAbstractPattern::SetModified(bool modified)
{
this->modified = modified;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QDomElement VAbstractPattern::GetDraw(const QString &name) const QDomElement VAbstractPattern::GetDraw(const QString &name) const
{ {

View File

@ -104,6 +104,7 @@ public:
void SetVersion(); void SetVersion();
bool IsModified() const; bool IsModified() const;
void SetModified(bool modified);
QDomElement GetDraw(const QString &name) const; QDomElement GetDraw(const QString &name) const;

View File

@ -43,8 +43,8 @@
*/ */
const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.0"); const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.0");
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.2.4"); const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.2.5");
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.2.4.xsd"); const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.2.5.xsd");
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPatternConverter::VPatternConverter(const QString &fileName) VPatternConverter::VPatternConverter(const QString &fileName)
@ -105,6 +105,8 @@ QString VPatternConverter::XSDSchema(int ver) const
case (0x000203): case (0x000203):
return QStringLiteral("://schema/pattern/v0.2.3.xsd"); return QStringLiteral("://schema/pattern/v0.2.3.xsd");
case (0x000204): case (0x000204):
return QStringLiteral("://schema/pattern/v0.2.4.xsd");
case (0x000205):
return CurrentSchema; return CurrentSchema;
default: default:
InvalidVersion(ver); InvalidVersion(ver);
@ -183,6 +185,13 @@ void VPatternConverter::ApplyPatches()
V_FALLTHROUGH V_FALLTHROUGH
} }
case (0x000204): case (0x000204):
{
ToV0_2_5();
const QString schema = XSDSchema(0x000205);
ValidateXML(schema, fileName);
V_FALLTHROUGH
}
case (0x000205):
break; break;
default: default:
break; break;
@ -283,6 +292,13 @@ void VPatternConverter::ToV0_2_4()
Save(); Save();
} }
//---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::ToV0_2_5()
{
SetVersion(QStringLiteral("0.2.5"));
Save();
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::TagUnitToV0_2_0() void VPatternConverter::TagUnitToV0_2_0()
{ {

View File

@ -65,6 +65,7 @@ private:
void ToV0_2_2(); void ToV0_2_2();
void ToV0_2_3(); void ToV0_2_3();
void ToV0_2_4(); void ToV0_2_4();
void ToV0_2_5();
void TagUnitToV0_2_0(); void TagUnitToV0_2_0();
void TagIncrementToV0_2_0(); void TagIncrementToV0_2_0();