First test for apply on creation

--HG--
branch : DialogTools
This commit is contained in:
Patrick Proy 2014-05-26 09:03:51 +02:00
parent 2913e55024
commit e645e671de
5 changed files with 25 additions and 10 deletions

View File

@ -45,7 +45,7 @@ DialogTool::DialogTool(const VContainer *data, QWidget *parent)
labelResultCalculation(nullptr), labelDescription(nullptr), labelEditNamePoint(nullptr),
labelEditFormula(nullptr), radioButtonSizeGrowth(nullptr), radioButtonStandardTable(nullptr),
radioButtonIncrements(nullptr), radioButtonLengthLine(nullptr), radioButtonLengthArc(nullptr),
radioButtonLengthCurve(nullptr), lineStyles(QStringList())
radioButtonLengthCurve(nullptr), lineStyles(QStringList()), associatedTool(nullptr)
{
Q_CHECK_PTR(data);
timerFormula = new QTimer(this);

View File

@ -40,6 +40,7 @@
#include <QPlainTextEdit>
#include "../../container/vcontainer.h"
#include "../../widgets/vapplication.h"
#include "../../tools/vabstracttool.h"
namespace ComboMode
{
@ -69,6 +70,8 @@ public:
*/
DialogTool(const VContainer *data, QWidget *parent = nullptr);
virtual ~DialogTool() {}
inline VAbstractTool* GetAssociatedTool() { return this->associatedTool;}
inline void SetAssociatedTool(VAbstractTool* tool) { this->associatedTool=tool;}
signals:
/**
* @brief DialogClosed signal dialog closed
@ -475,6 +478,7 @@ protected:
Q_CHECK_PTR(bApply);
connect(bApply, &QPushButton::clicked, this, &DialogTool::DialogApply);
}
VAbstractTool* associatedTool;
private:
/**
* @brief FillList fill combobox list

View File

@ -268,7 +268,10 @@ void MainWindow::ClosedDialog(int result)
Q_CHECK_PTR(dialogTool);
if (result == QDialog::Accepted)
{
DrawTool::Create(dialogTool, currentScene, doc, pattern);
if (dialogTool->GetAssociatedTool() == nullptr)
{
DrawTool::Create(dialogTool, currentScene, doc, pattern);
}
}
ArrowTool();
}
@ -280,10 +283,14 @@ void MainWindow::ApplyDialog()
Q_CHECK_PTR(dialogTool);
// TODO ISSUE 79 : Only create on first apply for now,
// for updating : VDataTool * stored in DialogTool ?
DrawTool::Create(dialogTool, currentScene, doc, pattern);
// need function for updating in dialogtools or drawtool
ArrowTool();
if (dialogTool->GetAssociatedTool() == nullptr)
{
dialogTool->SetAssociatedTool(
dynamic_cast<VAbstractTool * > (DrawTool::Create(dialogTool, currentScene, doc, pattern)));
}
//ArrowTool();
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -65,7 +65,7 @@ void VToolEndLine::setDialog()
}
//---------------------------------------------------------------------------------------------------------------------
void VToolEndLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc,
VToolEndLine* VToolEndLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data)
{
Q_CHECK_PTR(dialog);
@ -76,12 +76,12 @@ void VToolEndLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPatter
QString formula = dialogTool->getFormula();
qreal angle = dialogTool->getAngle();
quint32 basePointId = dialogTool->getBasePointId();
Create(0, pointName, typeLine, formula, angle, basePointId, 5, 10, scene, doc, data, Document::FullParse,
return Create(0, pointName, typeLine, formula, angle, basePointId, 5, 10, scene, doc, data, Document::FullParse,
Valentina::FromGui);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolEndLine::Create(const quint32 _id, const QString &pointName, const QString &typeLine,
VToolEndLine* VToolEndLine::Create(const quint32 _id, const QString &pointName, const QString &typeLine,
const QString &formula, const qreal &angle, const quint32 &basePointId,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data, const Document::Documents &parse, const Valentina::Sources &typeCreation)
@ -120,8 +120,10 @@ void VToolEndLine::Create(const quint32 _id, const QString &pointName, const QSt
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPoint::SetFactor);
doc->AddTool(id, point);
doc->IncrementReferens(basePointId);
return point;
}
}
return nullptr;
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -63,8 +63,9 @@ public:
* @param scene pointer to scene.
* @param doc dom document container.
* @param data container with variables.
* @return the created tool
*/
static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
static VToolEndLine *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
/**
* @brief Create help create tool.
* @param _id tool id, 0 if tool doesn't exist yet.
@ -80,8 +81,9 @@ public:
* @param data container with variables.
* @param parse parser file mode.
* @param typeCreation way we create this tool.
* @return the created tool
*/
static void Create(const quint32 _id, const QString &pointName, const QString &typeLine,
static VToolEndLine *Create(const quint32 _id, const QString &pointName, const QString &typeLine,
const QString &formula, const qreal &angle, const quint32 &basePointId, const qreal &mx,
const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
const Document::Documents &parse, const Valentina::Sources &typeCreation);