Undo add pattern piece now work.

--HG--
branch : feature
This commit is contained in:
dismine 2014-06-06 18:06:41 +03:00
parent d914f359c1
commit fc3c8acc46
9 changed files with 157 additions and 63 deletions

View File

@ -58,7 +58,7 @@ DialogHistory::DialogHistory(VContainer *data, VPattern *doc, QWidget *parent)
connect(this, &DialogHistory::ShowHistoryTool, doc, &VPattern::ShowHistoryTool); connect(this, &DialogHistory::ShowHistoryTool, doc, &VPattern::ShowHistoryTool);
connect(doc, &VPattern::ChangedCursor, this, &DialogHistory::ChangedCursor); connect(doc, &VPattern::ChangedCursor, this, &DialogHistory::ChangedCursor);
connect(doc, &VPattern::patternChanged, this, &DialogHistory::UpdateHistory); connect(doc, &VPattern::patternChanged, this, &DialogHistory::UpdateHistory);
connect(doc, &VPattern::ChangedActivDraw, this, &DialogHistory::UpdateHistory); connect(doc, &VPattern::ChangedActivPP, this, &DialogHistory::UpdateHistory);
ShowPoint(); ShowPoint();
} }

View File

@ -111,9 +111,9 @@ MainWindow::MainWindow(QWidget *parent)
void MainWindow::ActionNewPP() void MainWindow::ActionNewPP()
{ {
QString patternPieceName = QString(tr("Pattern piece %1")).arg(comboBoxDraws->count()+1); QString patternPieceName = QString(tr("Pattern piece %1")).arg(comboBoxDraws->count()+1);
QString path;
if (comboBoxDraws->count() == 0) if (comboBoxDraws->count() == 0)
{ {
QString path;
DialogMeasurements measurements(this); DialogMeasurements measurements(this);
if (measurements.exec() == QDialog::Rejected) if (measurements.exec() == QDialog::Rejected)
{ {
@ -155,7 +155,6 @@ void MainWindow::ActionNewPP()
return; return;
} }
} }
doc->CreateEmptyFile(path);
} }
else else
{ {
@ -165,9 +164,9 @@ void MainWindow::ActionNewPP()
return; return;
} }
} }
if (doc->appendDraw(patternPieceName) == false) if (doc->appendPP(patternPieceName) == false)
{ {
qDebug()<<"Error creating pattern with the name "<<patternPieceName<<"."; qDebug()<<"Error creating pattern piece with the name "<<patternPieceName<<".";
return; return;
} }
disconnect(comboBoxDraws, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), disconnect(comboBoxDraws, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
@ -178,7 +177,7 @@ void MainWindow::ActionNewPP()
//Create single point //Create single point
const quint32 id = pattern->AddGObject(new VPointF(qApp->toPixel((10+comboBoxDraws->count()*5)), qApp->toPixel(10), const quint32 id = pattern->AddGObject(new VPointF(qApp->toPixel((10+comboBoxDraws->count()*5)), qApp->toPixel(10),
"А", 5, 10)); "А", 5, 10));
VToolSinglePoint *spoint = new VToolSinglePoint(doc, pattern, id, Valentina::FromGui); VToolSinglePoint *spoint = new VToolSinglePoint(doc, pattern, id, Valentina::FromGui, patternPieceName, path);
sceneDraw->addItem(spoint); sceneDraw->addItem(spoint);
connect(spoint, &VToolPoint::ChoosedTool, sceneDraw, &VMainGraphicsScene::ChoosedItem); connect(spoint, &VToolPoint::ChoosedTool, sceneDraw, &VMainGraphicsScene::ChoosedItem);
connect(sceneDraw, &VMainGraphicsScene::NewFactor, spoint, &VToolSinglePoint::SetFactor); connect(sceneDraw, &VMainGraphicsScene::NewFactor, spoint, &VToolSinglePoint::SetFactor);
@ -902,7 +901,7 @@ void MainWindow::currentDrawChanged( int index )
{ {
if (index != -1) if (index != -1)
{ {
doc->ChangeActivDraw(comboBoxDraws->itemText(index)); doc->ChangeActivPP(comboBoxDraws->itemText(index));
doc->setCurrentData(); doc->setCurrentData();
if (drawMode) if (drawMode)
{ {
@ -1644,6 +1643,7 @@ bool MainWindow::SavePattern(const QString &fileName)
{ {
setCurrentFile(fileName); setCurrentFile(fileName);
helpLabel->setText(tr("File saved")); helpLabel->setText(tr("File saved"));
qApp->getUndoStack()->setClean();
} }
} }
return result; return result;

View File

@ -46,7 +46,7 @@ VDrawTool::VDrawTool(VPattern *doc, VContainer *data, quint32 id)
:VAbstractTool(doc, data, id), ignoreContextMenuEvent(false), ignoreFullUpdate(false), :VAbstractTool(doc, data, id), ignoreContextMenuEvent(false), ignoreFullUpdate(false),
nameActivDraw(doc->GetNameActivDraw()), dialog(nullptr) nameActivDraw(doc->GetNameActivDraw()), dialog(nullptr)
{ {
connect(this->doc, &VPattern::ChangedActivDraw, this, &VDrawTool::ChangedActivDraw); connect(this->doc, &VPattern::ChangedActivPP, this, &VDrawTool::ChangedActivDraw);
connect(this->doc, &VPattern::ChangedNameDraw, this, &VDrawTool::ChangedNameDraw); connect(this->doc, &VPattern::ChangedNameDraw, this, &VDrawTool::ChangedNameDraw);
connect(this->doc, &VPattern::ShowTool, this, &VDrawTool::ShowTool); connect(this->doc, &VPattern::ShowTool, this, &VDrawTool::ShowTool);
} }

View File

@ -29,12 +29,14 @@
#include "vtoolsinglepoint.h" #include "vtoolsinglepoint.h"
#include "../../dialogs/tools/dialogsinglepoint.h" #include "../../dialogs/tools/dialogsinglepoint.h"
#include <xml/vundocommands.h>
const QString VToolSinglePoint::ToolType = QStringLiteral("single"); const QString VToolSinglePoint::ToolType = QStringLiteral("single");
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VToolSinglePoint::VToolSinglePoint (VPattern *doc, VContainer *data, quint32 id, const Valentina::Sources &typeCreation, VToolSinglePoint::VToolSinglePoint (VPattern *doc, VContainer *data, quint32 id, const Valentina::Sources &typeCreation,
QGraphicsItem * parent ) const QString &namePP, const QString &mPath, QGraphicsItem * parent )
:VToolPoint(doc, data, id, parent) :VToolPoint(doc, data, id, parent), namePP(namePP), mPath(mPath)
{ {
baseColor = Qt::red; baseColor = Qt::red;
currentColor = baseColor; currentColor = baseColor;
@ -67,18 +69,35 @@ void VToolSinglePoint::setDialog()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolSinglePoint::AddToFile() void VToolSinglePoint::AddToFile()
{ {
Q_ASSERT_X(namePP.isEmpty() == false, "AddToFile", "name pattern piece is empty");
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id); const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
QDomElement domElement = doc->createElement(TagName); QDomElement sPoint = doc->createElement(TagName);
doc->SetAttribute(domElement, VDomDocument::AttrId, id); // Create SPoint tag
doc->SetAttribute(domElement, AttrType, ToolType); doc->SetAttribute(sPoint, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrName, point->name()); doc->SetAttribute(sPoint, AttrType, ToolType);
doc->SetAttribute(domElement, AttrX, qApp->fromPixel(point->x())); doc->SetAttribute(sPoint, AttrName, point->name());
doc->SetAttribute(domElement, AttrY, qApp->fromPixel(point->y())); doc->SetAttribute(sPoint, AttrX, qApp->fromPixel(point->x()));
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx())); doc->SetAttribute(sPoint, AttrY, qApp->fromPixel(point->y()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my())); doc->SetAttribute(sPoint, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(sPoint, AttrMy, qApp->fromPixel(point->my()));
AddToCalculation(domElement); //Create pattern piece structure
QDomElement patternPiece = doc->createElement(VPattern::TagDraw);
doc->SetAttribute(patternPiece, AttrName, namePP);
QDomElement calcElement = doc->createElement(VPattern::TagCalculation);
calcElement.appendChild(sPoint);
patternPiece.appendChild(calcElement);
patternPiece.appendChild(doc->createElement(VPattern::TagModeling));
patternPiece.appendChild(doc->createElement(VPattern::TagDetails));
AddPatternPiece *addPP = new AddPatternPiece(patternPiece, doc, namePP, mPath);
connect(addPP, &AddPatternPiece::ClearScene, doc, &VPattern::ClearScene);
connect(addPP, &AddPatternPiece::NeedFullParsing, doc, &VPattern::NeedFullParsing);
qApp->getUndoStack()->push(addPP);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -48,6 +48,7 @@ public:
* @param parent parent object. * @param parent parent object.
*/ */
VToolSinglePoint (VPattern *doc, VContainer *data, quint32 id, const Valentina::Sources &typeCreation, VToolSinglePoint (VPattern *doc, VContainer *data, quint32 id, const Valentina::Sources &typeCreation,
const QString &namePP = QString(), const QString &mPath = QString(),
QGraphicsItem * parent = nullptr ); QGraphicsItem * parent = nullptr );
/** /**
* @brief setDialog set dialog when user want change tool option. * @brief setDialog set dialog when user want change tool option.
@ -114,6 +115,8 @@ protected:
*/ */
virtual void SaveDialog(QDomElement &domElement); virtual void SaveDialog(QDomElement &domElement);
private: private:
QString namePP;
QString mPath;
/** /**
* @brief setColorLabel change color for label and label line. * @brief setColorLabel change color for label and label line.
* @param color new color. * @param color new color.

View File

@ -91,6 +91,7 @@ void VPattern::CreateEmptyFile(const QString &tablePath)
{ {
throw VException("Path to measurement table empty."); throw VException("Path to measurement table empty.");
} }
this->clear();
QDomElement patternElement = this->createElement(TagPattern); QDomElement patternElement = this->createElement(TagPattern);
patternElement.appendChild(createComment("Valentina pattern format.")); patternElement.appendChild(createComment("Valentina pattern format."));
@ -117,21 +118,21 @@ void VPattern::CreateEmptyFile(const QString &tablePath)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief ChangeActivDraw set new pattern peace name. * @brief ChangeActivPP set new active pattern piece name.
* @param name new name. * @param name new name.
* @param parse parser file mode. * @param parse parser file mode.
*/ */
void VPattern::ChangeActivDraw(const QString &name, const Document::Documents &parse) void VPattern::ChangeActivPP(const QString &name, const Document::Documents &parse)
{ {
Q_ASSERT_X(name.isEmpty() == false, "ChangeActivDraw", "name draw is empty"); Q_ASSERT_X(name.isEmpty() == false, "ChangeActivPP", "name pattern piece is empty");
if (this->nameActivDraw != name) if (this->nameActivDraw != name)
{ {
if (CheckNameDraw(name)) if (CheckNamePP(name))
{ {
this->nameActivDraw = name; this->nameActivDraw = name;
if (parse == Document::FullParse) if (parse == Document::FullParse)
{ {
emit ChangedActivDraw(name); emit ChangedActivPP(name);
} }
} }
} }
@ -170,37 +171,29 @@ bool VPattern::GetActivDrawElement(QDomElement &element) const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief appendDraw add new pattern peace structure to the file. * @brief appendPP add new pattern piece.
*
* Method check if not exist pattern piece with the same name and change name active pattern piece name, send signal
* about change pattern piece. Doen't add pattern piece to file structure. This task make SPoint tool.
* @param name pattern peace name. * @param name pattern peace name.
* @return true if success. * @return true if success.
*/ */
bool VPattern::appendDraw(const QString &name) bool VPattern::appendPP(const QString &name)
{ {
Q_ASSERT_X(name.isEmpty() == false, "appendDraw", "name draw is empty"); Q_ASSERT_X(name.isEmpty() == false, "appendPP", "name pattern piece is empty");
if (name.isEmpty()) if (name.isEmpty())
{ {
return false; return false;
} }
if (CheckNameDraw(name) == false) if (CheckNamePP(name) == false)
{ {
QDomElement rootElement = this->documentElement();
QDomElement drawElement = this->createElement(TagDraw);
SetAttribute(drawElement, AttrName, name);
drawElement.appendChild(createElement(TagCalculation));
drawElement.appendChild(createElement(TagModeling));
drawElement.appendChild(createElement(TagDetails));
rootElement.appendChild(drawElement);
if (nameActivDraw.isEmpty()) if (nameActivDraw.isEmpty())
{ {
SetActivDraw(name); SetActivPP(name);
} }
else else
{ {
ChangeActivDraw(name); ChangeActivPP(name);
} }
return true; return true;
} }
@ -268,17 +261,17 @@ void VPattern::Parse(const Document::Documents &parse)
{ {
if (nameActivDraw.isEmpty()) if (nameActivDraw.isEmpty())
{ {
SetActivDraw(GetParametrString(domElement, AttrName)); SetActivPP(GetParametrString(domElement, AttrName));
} }
else else
{ {
ChangeActivDraw(GetParametrString(domElement, AttrName)); ChangeActivPP(GetParametrString(domElement, AttrName));
} }
patternPieces << GetParametrString(domElement, AttrName); patternPieces << GetParametrString(domElement, AttrName);
} }
else else
{ {
ChangeActivDraw(GetParametrString(domElement, AttrName), Document::LiteParse); ChangeActivPP(GetParametrString(domElement, AttrName), Document::LiteParse);
} }
ParseDrawElement(sceneDraw, sceneDetail, domElement, parse); ParseDrawElement(sceneDraw, sceneDetail, domElement, parse);
break; break;
@ -487,7 +480,7 @@ quint32 VPattern::SPointActiveDraw()
* @param name pattern peace name. * @param name pattern peace name.
* @return true if exist. * @return true if exist.
*/ */
bool VPattern::CheckNameDraw(const QString &name) const bool VPattern::CheckNamePP(const QString &name) const
{ {
Q_ASSERT_X(name.isEmpty() == false, "CheckNameDraw", "name draw is empty"); Q_ASSERT_X(name.isEmpty() == false, "CheckNameDraw", "name draw is empty");
const QDomNodeList elements = this->documentElement().elementsByTagName( TagDraw ); const QDomNodeList elements = this->documentElement().elementsByTagName( TagDraw );
@ -511,12 +504,12 @@ bool VPattern::CheckNameDraw(const QString &name) const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief SetActivDraw set current pattern peace. * @brief SetActivPP set current pattern piece.
* @param name pattern peace name. * @param name pattern peace name.
*/ */
void VPattern::SetActivDraw(const QString &name) void VPattern::SetActivPP(const QString &name)
{ {
Q_ASSERT_X(name.isEmpty() == false, "SetActivDraw", "name draw is empty"); Q_ASSERT_X(name.isEmpty() == false, "SetActivPP", "name pattern piece is empty");
this->nameActivDraw = name; this->nameActivDraw = name;
} }
@ -747,11 +740,17 @@ void VPattern::ShowHistoryTool(quint32 id, Qt::GlobalColor color, bool enable)
emit ShowTool(id, color, enable); emit ShowTool(id, color, enable);
} }
//---------------------------------------------------------------------------------------------------------------------
void VPattern::NeedFullParsing() void VPattern::NeedFullParsing()
{ {
emit UndoCommand(); emit UndoCommand();
} }
//---------------------------------------------------------------------------------------------------------------------
void VPattern::ClearScene()
{
emit ClearMainWindow();
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
@ -1877,3 +1876,28 @@ void VPattern::UpdateMeasurements()
m.Measurements(); m.Measurements();
} }
} }
QDomElement VPattern::GetPPElement(const QString &name)
{
if (name.isEmpty() == false)
{
const QDomNodeList elements = this->documentElement().elementsByTagName( TagDraw );
if (elements.size() == 0)
{
return QDomElement();
}
for ( qint32 i = 0; i < elements.count(); i++ )
{
QDomElement element = elements.at( i ).toElement();
if (element.isNull() == false)
{
if ( element.attribute( AttrName ) == name )
{
return element;
}
}
}
}
return QDomElement();
}

View File

@ -65,10 +65,10 @@ public:
VPattern(VContainer *data, Valentina::Draws *mode, VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail, VPattern(VContainer *data, Valentina::Draws *mode, VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail,
QObject *parent = nullptr); QObject *parent = nullptr);
void CreateEmptyFile(const QString &tablePath); void CreateEmptyFile(const QString &tablePath);
void ChangeActivDraw(const QString& name, const Document::Documents &parse = Document::FullParse); void ChangeActivPP(const QString& name, const Document::Documents &parse = Document::FullParse);
QString GetNameActivDraw() const; QString GetNameActivDraw() const;
bool GetActivDrawElement(QDomElement &element) const; bool GetActivDrawElement(QDomElement &element) const;
bool appendDraw(const QString& name); bool appendPP(const QString& name);
bool SetNameDraw(const QString& name); bool SetNameDraw(const QString& name);
void Parse(const Document::Documents &parse); void Parse(const Document::Documents &parse);
QHash<quint32, VDataTool*>* getTools(); QHash<quint32, VDataTool*>* getTools();
@ -116,12 +116,13 @@ public:
static const QString IncrementDescription; static const QString IncrementDescription;
virtual bool SaveDocument(const QString &fileName); virtual bool SaveDocument(const QString &fileName);
QStringList getPatternPieces() const; QStringList getPatternPieces() const;
QDomElement GetPPElement(const QString &name);
signals: signals:
/** /**
* @brief ChangedActivDraw change active pattern peace. * @brief ChangedActivDraw change active pattern peace.
* @param newName new pattern peace name. * @param newName new pattern peace name.
*/ */
void ChangedActivDraw(const QString &newName); void ChangedActivPP(const QString &newName);
/** /**
* @brief ChangedNameDraw save new name active pattern peace. * @brief ChangedNameDraw save new name active pattern peace.
* @param oldName old name. * @param oldName old name.
@ -155,6 +156,7 @@ public slots:
void haveLiteChange(); void haveLiteChange();
void ShowHistoryTool(quint32 id, Qt::GlobalColor color, bool enable); void ShowHistoryTool(quint32 id, Qt::GlobalColor color, bool enable);
void NeedFullParsing(); void NeedFullParsing();
void ClearScene();
private: private:
Q_DISABLE_COPY(VPattern) Q_DISABLE_COPY(VPattern)
@ -181,8 +183,8 @@ private:
VMainGraphicsScene *sceneDraw; VMainGraphicsScene *sceneDraw;
VMainGraphicsScene *sceneDetail; VMainGraphicsScene *sceneDetail;
bool CheckNameDraw(const QString& name) const; bool CheckNamePP(const QString& name) const;
void SetActivDraw(const QString& name); void SetActivPP(const QString& name);
void ParseDrawElement(VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail, void ParseDrawElement(VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail,
const QDomNode& node, const Document::Documents &parse); const QDomNode& node, const Document::Documents &parse);
void ParseDrawMode(VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail, void ParseDrawMode(VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail,
@ -266,4 +268,6 @@ inline QStringList VPattern::getPatternPieces() const
return patternPieces; return patternPieces;
} }
#endif // VPATTERN_H #endif // VPATTERN_H

View File

@ -31,9 +31,10 @@
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
AddToCal::AddToCal(const QDomElement &xml, VPattern *doc, QUndoCommand *parent) AddToCal::AddToCal(const QDomElement &xml, VPattern *doc, QUndoCommand *parent)
: QObject(), QUndoCommand(parent), xml(xml), doc(doc), nameActivDraw(doc->GetNameActivDraw()), cursor(doc->getCursor()) : QObject(), QUndoCommand(parent), xml(xml), doc(doc), nameActivDraw(doc->GetNameActivDraw()),
cursor(doc->getCursor()), redoFlag(false)
{ {
setText(tr("Add to section %1").arg(VPattern::TagCalculation)); setText(tr("Add object"));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -43,7 +44,7 @@ AddToCal::~AddToCal()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void AddToCal::undo() void AddToCal::undo()
{ {
doc->ChangeActivDraw(nameActivDraw); doc->ChangeActivPP(nameActivDraw);
doc->setCursor(cursor); doc->setCursor(cursor);
QDomElement calcElement; QDomElement calcElement;
@ -65,7 +66,7 @@ void AddToCal::undo()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void AddToCal::redo() void AddToCal::redo()
{ {
doc->ChangeActivDraw(nameActivDraw); doc->ChangeActivPP(nameActivDraw);
doc->setCursor(cursor); doc->setCursor(cursor);
QDomElement calcElement; QDomElement calcElement;
@ -93,28 +94,66 @@ void AddToCal::redo()
{ {
qDebug()<<"Can't find tag Calculation"<< Q_FUNC_INFO; qDebug()<<"Can't find tag Calculation"<< Q_FUNC_INFO;
} }
emit UnsavedChange(); if (redoFlag == false)
{
emit UnsavedChange();
}
else
{
emit NeedFullParsing();
}
redoFlag = true;
} }
//--------------------------------------------AddPatternPiece---------------------------------------------------------- //--------------------------------------------AddPatternPiece----------------------------------------------------------
int AddPatternPiece::countPP = 0; int AddPatternPiece::countPP = 0;
AddPatternPiece::AddPatternPiece(const QDomElement &xml, VPattern *doc, QUndoCommand *parent) AddPatternPiece::AddPatternPiece(const QDomElement &xml, VPattern *doc, const QString &namePP, const QString &mPath,
: QObject(), QUndoCommand(parent), xml(xml), doc(doc) QUndoCommand *parent)
: QObject(), QUndoCommand(parent), xml(xml), doc(doc), namePP(namePP), redoFlag(false), mPath(mPath)
{ {
setText(tr("Add to new pattern piece")); setText(tr("Add pattern piece %1").arg(namePP));
} }
//---------------------------------------------------------------------------------------------------------------------
AddPatternPiece::~AddPatternPiece() AddPatternPiece::~AddPatternPiece()
{} {}
//---------------------------------------------------------------------------------------------------------------------
void AddPatternPiece::undo() void AddPatternPiece::undo()
{ {
if (countPP <= 1)
{
emit ClearScene();
}
else
{
QDomElement rootElement = doc->documentElement();
QDomElement patternPiece = doc->GetPPElement(namePP);
rootElement.removeChild(patternPiece);
emit NeedFullParsing();
}
--countPP; --countPP;
} }
//---------------------------------------------------------------------------------------------------------------------
void AddPatternPiece::redo() void AddPatternPiece::redo()
{ {
++countPP; ++countPP;
if (countPP == 1 && mPath.isEmpty() == false)
{
doc->CreateEmptyFile(mPath);
}
QDomElement rootElement = doc->documentElement();
rootElement.appendChild(xml);
doc->haveLiteChange();
if (redoFlag)
{
emit NeedFullParsing();
}
redoFlag = true;
} }

View File

@ -51,24 +51,29 @@ private:
VPattern *doc; VPattern *doc;
const QString nameActivDraw; const QString nameActivDraw;
quint32 cursor; quint32 cursor;
bool redoFlag;
}; };
class AddPatternPiece : public QObject, public QUndoCommand class AddPatternPiece : public QObject, public QUndoCommand
{ {
Q_OBJECT Q_OBJECT
public: public:
AddPatternPiece(const QDomElement &xml, VPattern *doc, QUndoCommand *parent = 0); AddPatternPiece(const QDomElement &xml, VPattern *doc, const QString &namePP, const QString &mPath,
QUndoCommand *parent = 0);
virtual ~AddPatternPiece(); virtual ~AddPatternPiece();
virtual void undo(); virtual void undo();
virtual void redo(); virtual void redo();
signals: signals:
void UnsavedChange(); void ClearScene();
void NeedFullParsing(); void NeedFullParsing();
private: private:
Q_DISABLE_COPY(AddPatternPiece) Q_DISABLE_COPY(AddPatternPiece)
const QDomElement xml; const QDomElement xml;
VPattern *doc; VPattern *doc;
static int countPP; static int countPP;
QString namePP;
bool redoFlag;
QString mPath;
}; };
#endif // VUNDOCOMMANDS_H #endif // VUNDOCOMMANDS_H