Bug in undocommands. We should return to pattern piece only if in Calculation
mode. If do it in Details mode Valentina may not switch pattern piece back when a user returns to Calculation mode. This breaks a work and no new object can be added to pattern. --HG-- branch : develop
This commit is contained in:
parent
d35684a44a
commit
fe9dc90dc7
|
@ -130,7 +130,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
dialogTool(),
|
||||
dialogHistory(nullptr),
|
||||
dialogFMeasurements(nullptr),
|
||||
comboBoxDraws(nullptr), patternPieceLabel(nullptr), mode(Draw::Calculation),
|
||||
comboBoxDraws(nullptr), patternPieceLabel(nullptr),
|
||||
currentDrawIndex(0), currentToolBoxIndex(0),
|
||||
isDockToolOptionsVisible(true),
|
||||
isDockGroupsVisible(true),
|
||||
|
@ -159,7 +159,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
CreateActions();
|
||||
InitScenes();
|
||||
|
||||
doc = new VPattern(pattern, &mode, sceneDraw, sceneDetails);
|
||||
doc = new VPattern(pattern, sceneDraw, sceneDetails);
|
||||
connect(doc, &VPattern::ClearMainWindow, this, &MainWindow::Clear);
|
||||
connect(doc, &VPattern::patternChanged, this, &MainWindow::PatternChangesWereSaved);
|
||||
connect(doc, &VPattern::UndoCommand, this, &MainWindow::FullParseFile);
|
||||
|
@ -2463,7 +2463,7 @@ void MainWindow::keyPressEvent ( QKeyEvent * event )
|
|||
*/
|
||||
void MainWindow::SaveCurrentScene()
|
||||
{
|
||||
if (mode == Draw::Calculation || mode == Draw::Modeling)
|
||||
if (qApp->GetDrawMode() == Draw::Calculation || qApp->GetDrawMode() == Draw::Modeling)
|
||||
{
|
||||
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(currentScene);
|
||||
SCASSERT(scene != nullptr)
|
||||
|
@ -2520,7 +2520,7 @@ void MainWindow::ActionDraw(bool checked)
|
|||
ui->view->setScene(currentScene);
|
||||
RestoreCurrentScene();
|
||||
|
||||
mode = Draw::Calculation;
|
||||
qApp->SetDrawMode(Draw::Calculation);
|
||||
comboBoxDraws->setCurrentIndex(currentDrawIndex);//restore current pattern peace
|
||||
drawMode = true;
|
||||
|
||||
|
@ -2594,11 +2594,11 @@ void MainWindow::ActionDetails(bool checked)
|
|||
ui->view->setScene(currentScene);
|
||||
RestoreCurrentScene();
|
||||
|
||||
if (mode == Draw::Calculation)
|
||||
if (qApp->GetDrawMode() == Draw::Calculation)
|
||||
{
|
||||
currentToolBoxIndex = ui->toolBox->currentIndex();
|
||||
}
|
||||
mode = Draw::Modeling;
|
||||
qApp->SetDrawMode(Draw::Modeling);
|
||||
SetEnableTool(true);
|
||||
SetEnableWidgets(true);
|
||||
ui->toolBox->setCurrentIndex(ui->toolBox->indexOf(ui->detailPage));
|
||||
|
@ -2678,7 +2678,7 @@ void MainWindow::ActionLayout(bool checked)
|
|||
QMessageBox::information(this, tr("Layout mode"), tr("You can't use Layout mode yet. Please, "
|
||||
"include at least one detail in layout."),
|
||||
QMessageBox::Ok, QMessageBox::Ok);
|
||||
mode == Draw::Calculation ? ActionDraw(true) : ActionDetails(true);
|
||||
qApp->GetDrawMode() == Draw::Calculation ? ActionDraw(true) : ActionDetails(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -2700,7 +2700,7 @@ void MainWindow::ActionLayout(bool checked)
|
|||
QMessageBox::warning(this, tr("Layout mode"),
|
||||
tr("You can't use Layout mode yet.") + QLatin1String(" \n") + e.ErrorMessage(),
|
||||
QMessageBox::Ok, QMessageBox::Ok);
|
||||
mode == Draw::Calculation ? ActionDraw(true) : ActionDetails(true);
|
||||
qApp->GetDrawMode() == Draw::Calculation ? ActionDraw(true) : ActionDetails(true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2708,11 +2708,11 @@ void MainWindow::ActionLayout(bool checked)
|
|||
emit ui->view->itemClicked(nullptr);
|
||||
ui->view->setScene(currentScene);
|
||||
|
||||
if (mode == Draw::Calculation)
|
||||
if (qApp->GetDrawMode() == Draw::Calculation)
|
||||
{
|
||||
currentToolBoxIndex = ui->toolBox->currentIndex();
|
||||
}
|
||||
mode = Draw::Layout;
|
||||
qApp->SetDrawMode(Draw::Layout);
|
||||
SetEnableTool(true);
|
||||
SetEnableWidgets(true);
|
||||
ui->toolBox->setCurrentIndex(ui->toolBox->indexOf(ui->layoutPage));
|
||||
|
@ -3307,8 +3307,8 @@ void MainWindow::SetEnabledGUI(bool enabled)
|
|||
*/
|
||||
void MainWindow::SetEnableWidgets(bool enable)
|
||||
{
|
||||
const bool drawStage = (mode == Draw::Calculation);
|
||||
const bool designStage = (drawStage || mode == Draw::Modeling);
|
||||
const bool drawStage = (qApp->GetDrawMode() == Draw::Calculation);
|
||||
const bool designStage = (drawStage || qApp->GetDrawMode() == Draw::Modeling);
|
||||
|
||||
comboBoxDraws->setEnabled(enable && drawStage);
|
||||
ui->actionOptionDraw->setEnabled(enable && drawStage);
|
||||
|
@ -3586,7 +3586,7 @@ void MainWindow::SetEnableTool(bool enable)
|
|||
|
||||
QT_WARNING_PUSH
|
||||
QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
||||
switch (mode)
|
||||
switch (qApp->GetDrawMode())
|
||||
{
|
||||
case Draw::Calculation:
|
||||
drawTools = enable;
|
||||
|
|
|
@ -246,9 +246,6 @@ private:
|
|||
QComboBox *comboBoxDraws;
|
||||
QLabel *patternPieceLabel;
|
||||
|
||||
/** @brief mode keep current draw mode. */
|
||||
Draw mode;
|
||||
|
||||
/** @brief currentDrawIndex save current selected pattern peace. */
|
||||
qint32 currentDrawIndex;
|
||||
|
||||
|
|
|
@ -90,9 +90,8 @@ void GatherCount(int &count, const int nodes)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VPattern::VPattern(VContainer *data, Draw *mode, VMainGraphicsScene *sceneDraw,
|
||||
VMainGraphicsScene *sceneDetail, QObject *parent)
|
||||
: VAbstractPattern(parent), data(data), mode(mode), sceneDraw(sceneDraw), sceneDetail(sceneDetail)
|
||||
VPattern::VPattern(VContainer *data, VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail, QObject *parent)
|
||||
: VAbstractPattern(parent), data(data), sceneDraw(sceneDraw), sceneDetail(sceneDetail)
|
||||
{
|
||||
SCASSERT(sceneDraw != nullptr)
|
||||
SCASSERT(sceneDetail != nullptr)
|
||||
|
@ -269,7 +268,7 @@ void VPattern::Parse(const Document &parse)
|
|||
*/
|
||||
void VPattern::setCurrentData()
|
||||
{
|
||||
if (*mode == Draw::Calculation)
|
||||
if (qApp->GetDrawMode() == Draw::Calculation)
|
||||
{
|
||||
const int countPP = CountPP();
|
||||
if (countPP > 1)//don't need upadate data if we have only one pattern piece
|
||||
|
|
|
@ -46,7 +46,7 @@ class VPattern : public VAbstractPattern
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
VPattern(VContainer *data, Draw *mode, VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail,
|
||||
VPattern(VContainer *data, VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail,
|
||||
QObject *parent = nullptr);
|
||||
|
||||
virtual void CreateEmptyFile() override;
|
||||
|
@ -125,9 +125,6 @@ private:
|
|||
/** @brief data container with data. */
|
||||
VContainer *data;
|
||||
|
||||
/** @brief mode current draw mode. */
|
||||
Draw *mode;
|
||||
|
||||
VMainGraphicsScene *sceneDraw;
|
||||
VMainGraphicsScene *sceneDetail;
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
#include <QVector>
|
||||
#include <QPolygonF>
|
||||
|
||||
enum class Draw : char { Calculation, Modeling, Layout };
|
||||
enum class GOType : char
|
||||
{
|
||||
Point,
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include <QtGlobal>
|
||||
|
||||
#include "vgeometrydef.h"
|
||||
#include "../vmisc/def.h"
|
||||
|
||||
class QLineF;
|
||||
class QPoint;
|
||||
|
|
|
@ -68,6 +68,7 @@ enum class Source : char { FromGui, FromFile, FromTool };
|
|||
enum class NodeUsage : bool {NotInUse = false, InUse = true};
|
||||
enum class SelectionType : bool {ByMousePress, ByMouseRelease};
|
||||
enum class PageOrientation : bool {Portrait = true, Landscape = false};
|
||||
enum class Draw : char { Calculation, Modeling, Layout };
|
||||
|
||||
enum class PieceNodeAngle : unsigned char
|
||||
{
|
||||
|
|
|
@ -61,7 +61,8 @@ VAbstractApplication::VAbstractApplication(int &argc, char **argv)
|
|||
doc(nullptr),
|
||||
m_customerName(),
|
||||
m_userMaterials(),
|
||||
openingPattern(false)
|
||||
openingPattern(false),
|
||||
mode(Draw::Calculation)
|
||||
{
|
||||
QString rules;
|
||||
|
||||
|
@ -259,6 +260,18 @@ QString VAbstractApplication::ClearMessage(QString msg)
|
|||
return msg;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
const Draw &VAbstractApplication::GetDrawMode() const
|
||||
{
|
||||
return mode;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractApplication::SetDrawMode(const Draw &value)
|
||||
{
|
||||
mode = value;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
#if defined(Q_OS_WIN)
|
||||
void VAbstractApplication::WinAttachConsole()
|
||||
|
|
|
@ -121,6 +121,9 @@ public:
|
|||
QMap<int, QString> GetUserMaterials() const;
|
||||
void SetUserMaterials(const QMap<int, QString> &userMaterials);
|
||||
|
||||
const Draw &GetDrawMode() const;
|
||||
void SetDrawMode(const Draw &value);
|
||||
|
||||
protected:
|
||||
QUndoStack *undoStack;
|
||||
|
||||
|
@ -163,6 +166,9 @@ private:
|
|||
*/
|
||||
bool openingPattern;
|
||||
|
||||
/** @brief mode keep current draw mode. */
|
||||
Draw mode;
|
||||
|
||||
void ClearTranslation();
|
||||
};
|
||||
|
||||
|
|
|
@ -92,8 +92,11 @@ void AddGroup::undo()
|
|||
}
|
||||
|
||||
VMainGraphicsView::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView());
|
||||
if (qApp->GetDrawMode() == Draw::Calculation)
|
||||
{
|
||||
emit doc->SetCurrentPP(nameActivDraw);//Return current pattern piece after undo
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void AddGroup::redo()
|
||||
|
|
|
@ -116,5 +116,8 @@ void AddItemToGroup::performUndoRedo(bool isUndo)
|
|||
}
|
||||
|
||||
VMainGraphicsView::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView());
|
||||
if (qApp->GetDrawMode() == Draw::Calculation)
|
||||
{
|
||||
emit doc->SetCurrentPP(nameActivDraw);//Return current pattern piece after undo
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,8 +78,11 @@ void AddToCalc::undo()
|
|||
}
|
||||
emit NeedFullParsing();
|
||||
VMainGraphicsView::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView());
|
||||
if (qApp->GetDrawMode() == Draw::Calculation)
|
||||
{
|
||||
emit doc->SetCurrentPP(nameActivDraw);//Return current pattern piece after undo
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void AddToCalc::redo()
|
||||
|
@ -125,8 +128,11 @@ void AddToCalc::RedoFullParsing()
|
|||
if (redoFlag)
|
||||
{
|
||||
emit NeedFullParsing();
|
||||
if (qApp->GetDrawMode() == Draw::Calculation)
|
||||
{
|
||||
emit doc->SetCurrentPP(nameActivDraw);//Return current pattern piece after undo
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QApplication::postEvent(doc, new LiteParseEvent());
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include <QDomNodeList>
|
||||
|
||||
#include "../vmisc/logging.h"
|
||||
#include "../vmisc/vabstractapplication.h"
|
||||
#include "../ifc/xml/vabstractpattern.h"
|
||||
#include "vundocommand.h"
|
||||
|
||||
|
@ -82,15 +83,21 @@ void DeletePatternPiece::undo()
|
|||
}
|
||||
|
||||
emit NeedFullParsing();
|
||||
if (qApp->GetDrawMode() == Draw::Calculation)
|
||||
{
|
||||
emit doc->SetCurrentPP(namePP);//Without this user will not see this change
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DeletePatternPiece::redo()
|
||||
{
|
||||
qCDebug(vUndo, "Redo.");
|
||||
|
||||
if (qApp->GetDrawMode() == Draw::Calculation)
|
||||
{
|
||||
emit doc->SetCurrentPP(namePP);//Without this user will not see this change
|
||||
}
|
||||
QDomElement rootElement = doc->documentElement();
|
||||
const QDomElement patternPiece = doc->GetPPElement(namePP);
|
||||
rootElement.removeChild(patternPiece);
|
||||
|
|
|
@ -58,7 +58,10 @@ void DelGroup::undo()
|
|||
{
|
||||
qCDebug(vUndo, "Undo.");
|
||||
|
||||
if (qApp->GetDrawMode() == Draw::Calculation)
|
||||
{
|
||||
emit doc->SetCurrentPP(nameActivDraw);//Without this user will not see this change
|
||||
}
|
||||
|
||||
QDomElement groups = doc->CreateGroups();
|
||||
if (not groups.isNull())
|
||||
|
@ -81,8 +84,10 @@ void DelGroup::redo()
|
|||
{
|
||||
qCDebug(vUndo, "Redo.");
|
||||
|
||||
//Keep first!
|
||||
if (qApp->GetDrawMode() == Draw::Calculation)
|
||||
{//Keep first!
|
||||
emit doc->SetCurrentPP(nameActivDraw);//Without this user will not see this change
|
||||
}
|
||||
QDomElement groups = doc->CreateGroups();
|
||||
if (not groups.isNull())
|
||||
{
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "../ifc/ifcdef.h"
|
||||
#include "../ifc/xml/vabstractpattern.h"
|
||||
#include "../vmisc/logging.h"
|
||||
#include "../vmisc/vabstractapplication.h"
|
||||
#include "vundocommand.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -58,17 +59,22 @@ void DelTool::undo()
|
|||
|
||||
UndoDeleteAfterSibling(parentNode, siblingId);
|
||||
emit NeedFullParsing();
|
||||
//Keep last!
|
||||
|
||||
if (qApp->GetDrawMode() == Draw::Calculation)
|
||||
{//Keep last!
|
||||
emit doc->SetCurrentPP(nameActivDraw);//Without this user will not see this change
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DelTool::redo()
|
||||
{
|
||||
qCDebug(vUndo, "Redo.");
|
||||
|
||||
//Keep first!
|
||||
if (qApp->GetDrawMode() == Draw::Calculation)
|
||||
{//Keep first!
|
||||
emit doc->SetCurrentPP(nameActivDraw);//Without this user will not see this change
|
||||
}
|
||||
QDomElement domElement = doc->NodeById(nodeId);
|
||||
parentNode.removeChild(domElement);
|
||||
emit NeedFullParsing();
|
||||
|
|
|
@ -116,5 +116,9 @@ void RemoveItemFromGroup::performUndoRedo(bool isUndo)
|
|||
}
|
||||
|
||||
VMainGraphicsView::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView());
|
||||
|
||||
if (qApp->GetDrawMode() == Draw::Calculation)
|
||||
{
|
||||
emit doc->SetCurrentPP(nameActivDraw);//Return current pattern piece after undo
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user