Fixed issue #307. Valentina enables wrong pattern piece after deleting curve.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2015-05-25 09:24:16 +03:00
parent 8e3ef70859
commit 8980db725d
15 changed files with 41 additions and 25 deletions

View File

@ -1798,8 +1798,8 @@ void MainWindow::SetEnableWidgets(bool enable)
ui->actionLayout->setEnabled(enable); ui->actionLayout->setEnabled(enable);
} }
//Now we want allow user call context menu //Now we don't want allow user call context menu
sceneDraw->SetDisable(!enable); sceneDraw->SetDisableTools(!enable, doc->GetNameActivPP());
ui->view->setEnabled(enable); ui->view->setEnabled(enable);
} }

View File

@ -71,9 +71,9 @@ void VAbstractSpline::FullUpdateFromFile()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VAbstractSpline::Disable(bool disable) void VAbstractSpline::Disable(bool disable, const QString &namePP)
{ {
enabled = !disable; enabled = !CorrectDisable(disable, namePP);
this->setEnabled(enabled); this->setEnabled(enabled);
this->setPen(QPen(CorrectColor(lineColor), qApp->toPixel(qApp->widthHairLine())/factor, Qt::SolidLine, this->setPen(QPen(CorrectColor(lineColor), qApp->toPixel(qApp->widthHairLine())/factor, Qt::SolidLine,
Qt::RoundCap)); Qt::RoundCap));

View File

@ -51,7 +51,7 @@ public:
public slots: public slots:
virtual void FullUpdateFromFile (); virtual void FullUpdateFromFile ();
virtual void Disable(bool disable); virtual void Disable(bool disable, const QString &namePP);
void DetailsMode(bool mode); void DetailsMode(bool mode);
signals: signals:
/** /**

View File

@ -79,7 +79,7 @@ void VDrawTool::ShowTool(quint32 id, bool enable)
*/ */
void VDrawTool::ChangedActivDraw(const QString &newName) void VDrawTool::ChangedActivDraw(const QString &newName)
{ {
Disable(!(nameActivDraw == newName)); Disable(!(nameActivDraw == newName), newName);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -183,6 +183,19 @@ QColor VDrawTool::CorrectColor(const QColor &color) const
} }
} }
//---------------------------------------------------------------------------------------------------------------------
bool VDrawTool::CorrectDisable(bool disable, const QString &namePP) const
{
if (disable)
{
return disable;
}
else
{
return !(nameActivDraw == namePP);
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VDrawTool::ReadAttributes() void VDrawTool::ReadAttributes()
{ {

View File

@ -70,7 +70,7 @@ public slots:
virtual void FullUpdateFromGuiApply(); virtual void FullUpdateFromGuiApply();
virtual void SetFactor(qreal factor); virtual void SetFactor(qreal factor);
virtual void EnableToolMove(bool move); virtual void EnableToolMove(bool move);
virtual void Disable(bool disable)=0; virtual void Disable(bool disable, const QString &namePP)=0;
protected: protected:
/** @brief nameActivDraw name of tool's pattern peace. */ /** @brief nameActivDraw name of tool's pattern peace. */
@ -94,7 +94,9 @@ protected:
void SaveDialogChange(); void SaveDialogChange();
virtual void AddToFile(); virtual void AddToFile();
virtual void RefreshDataInFile(); virtual void RefreshDataInFile();
QColor CorrectColor(const QColor &color) const; QColor CorrectColor(const QColor &color) const;
bool CorrectDisable(bool disable, const QString &namePP) const;
void ReadAttributes(); void ReadAttributes();
virtual void ReadToolAttributes(const QDomElement &domElement)=0; virtual void ReadToolAttributes(const QDomElement &domElement)=0;

View File

@ -68,9 +68,9 @@ void VToolCut::HoverPath(quint32 id, SimpleCurvePoint curvePosition, PathDirecti
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolCut::Disable(bool disable) void VToolCut::Disable(bool disable, const QString &namePP)
{ {
VToolPoint::Disable(disable); VToolPoint::Disable(disable, namePP);
firstCurve->ChangedActivDraw(enabled); firstCurve->ChangedActivDraw(enabled);
secondCurve->ChangedActivDraw(enabled); secondCurve->ChangedActivDraw(enabled);
} }

View File

@ -53,7 +53,7 @@ public:
public slots: public slots:
virtual void CurveChoosed(quint32 id)=0; virtual void CurveChoosed(quint32 id)=0;
void HoverPath(quint32 id, SimpleCurvePoint curvePosition, PathDirection direction); void HoverPath(quint32 id, SimpleCurvePoint curvePosition, PathDirection direction);
virtual void Disable(bool disable); virtual void Disable(bool disable, const QString &namePP);
void DetailsMode(bool mode); void DetailsMode(bool mode);
protected: protected:
/** @brief formula keep formula of length */ /** @brief formula keep formula of length */

View File

@ -221,11 +221,12 @@ void VToolLine::SetFactor(qreal factor)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolLine::Disable(bool disable) void VToolLine::Disable(bool disable, const QString &namePP)
{ {
enabled = !disable; enabled = !CorrectDisable(disable, namePP);
this->setEnabled(enabled); this->setEnabled(enabled);
this->setPen(QPen(QColor(baseColor), qApp->toPixel(qApp->widthHairLine())/factor, LineStyleToPenStyle(typeLine))); this->setPen(QPen(CorrectColor(baseColor), qApp->toPixel(qApp->widthHairLine())/factor,
LineStyleToPenStyle(typeLine)));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -66,7 +66,7 @@ public slots:
virtual void FullUpdateFromFile(); virtual void FullUpdateFromFile();
virtual void ShowTool(quint32 id, bool enable); virtual void ShowTool(quint32 id, bool enable);
virtual void SetFactor(qreal factor); virtual void SetFactor(qreal factor);
virtual void Disable(bool disable); virtual void Disable(bool disable, const QString &namePP);
protected: protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile(); virtual void AddToFile();

View File

@ -99,10 +99,10 @@ void VToolLinePoint::SetFactor(qreal factor)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolLinePoint::Disable(bool disable) void VToolLinePoint::Disable(bool disable, const QString &namePP)
{ {
VToolPoint::Disable(disable); VToolPoint::Disable(disable, namePP);
mainLine->setPen(QPen(QColor(lineColor), qApp->toPixel(qApp->widthHairLine())/factor, mainLine->setPen(QPen(CorrectColor(lineColor), qApp->toPixel(qApp->widthHairLine())/factor,
LineStyleToPenStyle(typeLine))); LineStyleToPenStyle(typeLine)));
mainLine->setEnabled(enabled); mainLine->setEnabled(enabled);
} }

View File

@ -56,7 +56,7 @@ public:
public slots: public slots:
virtual void SetFactor(qreal factor); virtual void SetFactor(qreal factor);
virtual void Disable(bool disable); virtual void Disable(bool disable, const QString &namePP);
protected: protected:
/** @brief formula string with length formula. */ /** @brief formula string with length formula. */
QString formulaLength; QString formulaLength;

View File

@ -163,9 +163,9 @@ void VToolPoint::SetFactor(qreal factor)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolPoint::Disable(bool disable) void VToolPoint::Disable(bool disable, const QString &namePP)
{ {
enabled = !disable; enabled = !CorrectDisable(disable, namePP);
this->setEnabled(enabled); this->setEnabled(enabled);
namePoint->setEnabled(enabled); namePoint->setEnabled(enabled);
} }

View File

@ -55,7 +55,7 @@ public slots:
void NameChangePosition(const QPointF &pos); void NameChangePosition(const QPointF &pos);
virtual void ShowTool(quint32 id, bool enable); virtual void ShowTool(quint32 id, bool enable);
virtual void SetFactor(qreal factor); virtual void SetFactor(qreal factor);
virtual void Disable(bool disable); virtual void Disable(bool disable, const QString &namePP);
void DeleteFromLabel(); void DeleteFromLabel();
virtual void EnableToolMove(bool move); virtual void EnableToolMove(bool move);
void PointChoosed(); void PointChoosed();

View File

@ -100,9 +100,9 @@ void VMainGraphicsScene::setTransform(const QTransform &transform)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VMainGraphicsScene::SetDisable(bool disable) void VMainGraphicsScene::SetDisableTools(bool disable, const QString &namePP)
{ {
emit DisableItem(disable); emit DisableItem(disable, namePP);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -47,7 +47,7 @@ public:
void setVerScrollBar(const qint32 &value); void setVerScrollBar(const qint32 &value);
QTransform transform() const; QTransform transform() const;
void setTransform(const QTransform &transform); void setTransform(const QTransform &transform);
void SetDisable(bool enabled); void SetDisableTools(bool enabled, const QString &namePP);
QPointF getScenePos() const; QPointF getScenePos() const;
public slots: public slots:
void ChoosedItem(quint32 id, const SceneObject &type); void ChoosedItem(quint32 id, const SceneObject &type);
@ -79,7 +79,7 @@ signals:
* @param factor scene scale factor. * @param factor scene scale factor.
*/ */
void NewFactor(qreal factor); void NewFactor(qreal factor);
void DisableItem(bool disable); void DisableItem(bool disable, const QString &namePP);
void EnableToolMove(bool move); void EnableToolMove(bool move);
void CurveDetailsMode(bool mode); void CurveDetailsMode(bool mode);
private: private: