issue 826 - workind on undo redo command
--HG-- branch : feature
This commit is contained in:
parent
2ee19af497
commit
1526d77612
|
@ -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);
|
||||
|
|
|
@ -68,7 +68,7 @@ public:
|
|||
|
||||
public slots:
|
||||
void ProcessCMD();
|
||||
|
||||
void UpdateGroups();
|
||||
virtual void ShowToolTip(const QString &toolTip) Q_DECL_OVERRIDE;
|
||||
|
||||
signals:
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -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 T> 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<MainWindow *>(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)
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "removeitemfromgroup.h"
|
||||
|
||||
RemoveItemFromGroup::RemoveItemFromGroup()
|
||||
{
|
||||
//RemoveItemFromGroup::RemoveItemFromGroup()
|
||||
//{
|
||||
|
||||
}
|
||||
//}
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
#define REMOVEITEMFROMGROUP_H
|
||||
|
||||
|
||||
class RemoveItemFromGroup : public VUndoCommand
|
||||
{
|
||||
public:
|
||||
RemoveItemFromGroup();
|
||||
};
|
||||
//class RemoveItemFromGroup : public VUndoCommand
|
||||
//{
|
||||
//public:
|
||||
// RemoveItemFromGroup();
|
||||
//};
|
||||
|
||||
#endif // REMOVEITEMFROMGROUP_H
|
||||
#endif // REMOVEITEMFROMGROUP_H
|
||||
|
|
Loading…
Reference in New Issue
Block a user