diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 562a834af..5c06fb535 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -3485,6 +3485,12 @@ void MainWindow::ShowProgress() } } +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::UpdateGroups() +{ + groupsWidget->UpdateGroups(); +} + //--------------------------------------------------------------------------------------------------------------------- void MainWindow::SetDefaultHeight() { @@ -4123,7 +4129,7 @@ void MainWindow::InitDocksContain() qCDebug(vMainWindow, "Initialization groups dock."); groupsWidget = new VWidgetGroups(doc, this); ui->dockWidgetGroups->setWidget(groupsWidget); - connect(doc,&VAbstractPattern::UpdateGroups , groupsWidget, &VWidgetGroups::UpdateGroups); + connect(doc,&VAbstractPattern::UpdateGroups , this, &MainWindow::UpdateGroups); detailsWidget = new VWidgetDetails(pattern, doc, this); connect(doc, &VPattern::FullUpdateFromFile, detailsWidget, &VWidgetDetails::UpdateList); diff --git a/src/app/valentina/mainwindow.h b/src/app/valentina/mainwindow.h index bb34cf391..def642090 100644 --- a/src/app/valentina/mainwindow.h +++ b/src/app/valentina/mainwindow.h @@ -68,7 +68,7 @@ public: public slots: void ProcessCMD(); - + void UpdateGroups(); virtual void ShowToolTip(const QString &toolTip) Q_DECL_OVERRIDE; signals: diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index a02657907..9968a652f 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -2506,6 +2506,8 @@ QDomElement VAbstractPattern::AddItemToGroup(quint32 toolId, quint32 objectId, q { qDebug() << "The group of id " << groupId << " doesn't exist"; } + + return QDomElement(); } //--------------------------------------------------------------------------------------------------------------------- @@ -2555,7 +2557,7 @@ QDomElement VAbstractPattern::RemoveItemFromGroup(quint32 toolId, quint32 object ParseGroups(groups); } - return itemNode; + return item; } } } @@ -2566,6 +2568,8 @@ QDomElement VAbstractPattern::RemoveItemFromGroup(quint32 toolId, quint32 object { qDebug() << "The group of id " << groupId << " doesn't exist"; } + + return QDomElement(); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/vdrawtool.h b/src/libs/vtools/tools/drawTools/vdrawtool.h index 5e5c1c7bc..3a120eede 100644 --- a/src/libs/vtools/tools/drawTools/vdrawtool.h +++ b/src/libs/vtools/tools/drawTools/vdrawtool.h @@ -51,6 +51,8 @@ #include "../vdatatool.h" #include "../vgeometry/vpointf.h" #include "../vtools/undocommands/addgroup.h" +#include "../vtools/undocommands/additemtogroup.h" +#include "../../../../app/valentina/mainwindow.h" template class QSharedPointer; @@ -282,11 +284,14 @@ void VDrawTool::ContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 itemI quint32 groupId = selectedAction->data().toUInt(); QDomElement item = doc->AddItemToGroup(this->getId(), itemId, groupId); - AddItemToGroup *addItemToGroup = new AddItemToGroup(item, doc); + MainWindow *window = qobject_cast(qApp->getMainWindow()); - // where should the signal be connected to? should we have a central "UpdateGroup" slot, like in the mainWindow? - // connect(addItemToGroup, &AddItemToGroup::UpdateGroups, , &VWidgetGroups::UpdateGroups); - qApp->getUndoStack()->push(addGroup); + SCASSERT(window != nullptr) + { + AddItemToGroup *addItemToGroup = new AddItemToGroup(item, doc); + connect(addItemToGroup, &AddItemToGroup::UpdateGroups, window, &MainWindow::UpdateGroups); + qApp->getUndoStack()->push(addItemToGroup); + } } else if (selectedAction->actionGroup() == actionsRemoveFromGroup) diff --git a/src/libs/vtools/undocommands/additemtogroup.cpp b/src/libs/vtools/undocommands/additemtogroup.cpp index 3ed6ccbd1..054412184 100644 --- a/src/libs/vtools/undocommands/additemtogroup.cpp +++ b/src/libs/vtools/undocommands/additemtogroup.cpp @@ -40,13 +40,18 @@ //--------------------------------------------------------------------------------------------------------------------- AddItemToGroup::AddItemToGroup(const QDomElement &xml, VAbstractPattern *doc, QUndoCommand *parent) - : VUndoCommand(xml, doc, parent), nameActivDraw(doc->GetNameActivPP()) + : VUndoCommand(xml, doc, parent), nameActivDraw(doc->GetNameActivPP()), toolId(0), objectId(0) { setText(tr("add item to group")); objectId = doc->GetParametrUInt(xml,QString("object"),NULL_ID_STR); toolId = doc->GetParametrUInt(xml,QString("tool"),NULL_ID_STR); - nodeId = doc->GetParametrId(xml.parentNode()); // nodeId is the groupId + QDomNode parentNode = xml.parentNode(); + + if (parentNode.isElement()) + { + nodeId = doc->GetParametrId(parentNode.toElement()); // nodeId is the groupId + } } //--------------------------------------------------------------------------------------------------------------------- @@ -73,7 +78,11 @@ void AddItemToGroup::undo() return; } + doc->SetModified(true); + emit qApp->getCurrentDocument()->patternChanged(false); + doc->ParseGroups(groups); + emit UpdateGroups(); } else @@ -91,3 +100,8 @@ void AddItemToGroup::undo() VMainGraphicsView::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView()); emit doc->SetCurrentPP(nameActivDraw);//Return current pattern piece after undo } + +void AddItemToGroup::redo() +{ + +} diff --git a/src/libs/vtools/undocommands/additemtogroup.h b/src/libs/vtools/undocommands/additemtogroup.h index 5b9fe9143..2d005ada6 100644 --- a/src/libs/vtools/undocommands/additemtogroup.h +++ b/src/libs/vtools/undocommands/additemtogroup.h @@ -43,7 +43,7 @@ class AddItemToGroup : public VUndoCommand Q_OBJECT public: AddItemToGroup(const QDomElement &xml, VAbstractPattern *doc, QUndoCommand *parent = nullptr); - virtual ~AddGroup(); + virtual ~AddItemToGroup(); virtual void undo() Q_DECL_OVERRIDE; virtual void redo() Q_DECL_OVERRIDE; protected: diff --git a/src/libs/vtools/undocommands/removeitemfromgroup.cpp b/src/libs/vtools/undocommands/removeitemfromgroup.cpp index 370767fd7..97875f6c1 100644 --- a/src/libs/vtools/undocommands/removeitemfromgroup.cpp +++ b/src/libs/vtools/undocommands/removeitemfromgroup.cpp @@ -1,6 +1,6 @@ #include "removeitemfromgroup.h" -RemoveItemFromGroup::RemoveItemFromGroup() -{ +//RemoveItemFromGroup::RemoveItemFromGroup() +//{ -} +//} diff --git a/src/libs/vtools/undocommands/removeitemfromgroup.h b/src/libs/vtools/undocommands/removeitemfromgroup.h index 5d6fb42fb..fc76a92e5 100644 --- a/src/libs/vtools/undocommands/removeitemfromgroup.h +++ b/src/libs/vtools/undocommands/removeitemfromgroup.h @@ -2,10 +2,10 @@ #define REMOVEITEMFROMGROUP_H -class RemoveItemFromGroup : public VUndoCommand -{ -public: - RemoveItemFromGroup(); -}; +//class RemoveItemFromGroup : public VUndoCommand +//{ +//public: +// RemoveItemFromGroup(); +//}; -#endif // REMOVEITEMFROMGROUP_H \ No newline at end of file +#endif // REMOVEITEMFROMGROUP_H