Skip to content

Commit

Permalink
ticket:5481 Updated the parameter when the value is changed
Browse files Browse the repository at this point in the history
  • Loading branch information
adeas31 committed May 16, 2019
1 parent 41b846d commit 89b4204
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
18 changes: 14 additions & 4 deletions OMEdit/OMEdit/OMEditGUI/Annotations/TextAnnotation.cpp
Expand Up @@ -63,7 +63,7 @@ TextAnnotation::TextAnnotation(ShapeAnnotation *pShapeAnnotation, Component *pPa
: ShapeAnnotation(pParent), mpComponent(pParent)
{
updateShape(pShapeAnnotation);
updateTextString();
initUpdateTextString();
setPos(mOrigin);
setRotation(mRotation);
connect(pShapeAnnotation, SIGNAL(updateReferenceShapes()), pShapeAnnotation, SIGNAL(changed()));
Expand Down Expand Up @@ -96,7 +96,7 @@ TextAnnotation::TextAnnotation(Component *pParent)
mExtents.replace(0, QPointF(-50, -50));
mExtents.replace(1, QPointF(50, 50));
setTextString("%name");
updateTextString();
initUpdateTextString();
setPos(mOrigin);
setRotation(mRotation);
}
Expand Down Expand Up @@ -142,7 +142,7 @@ TextAnnotation::TextAnnotation(GraphicsView *pGraphicsView)
mExtents.replace(0, QPointF(-100, 20));
mExtents.replace(1, QPointF(100, -20));
setTextString("%name");
updateTextString();
initUpdateTextString();
setPos(mOrigin);
setRotation(mRotation);
setShapeFlags(true);
Expand Down Expand Up @@ -186,7 +186,7 @@ void TextAnnotation::parseShapeAnnotation(QString annotation)
mOriginalTextString = StringHandler::removeFirstLastQuotes(list.at(9));
}
mTextString = mOriginalTextString;
updateTextString();
initUpdateTextString();
// 11th item of the list contains the fontSize.
mFontSize = list.at(10).toFloat();
// 12th item of the list contains the optional textColor, {-1, -1, -1} if not set
Expand Down Expand Up @@ -520,6 +520,16 @@ void TextAnnotation::updateShape(ShapeAnnotation *pShapeAnnotation)
ShapeAnnotation::setDefaults(pShapeAnnotation);
}

void TextAnnotation::initUpdateTextString()
{
if (mpComponent) {
if (mOriginalTextString.contains("%")) {
updateTextString();
connect(mpComponent, SIGNAL(displayTextChanged()), SLOT(updateTextString()), Qt::UniqueConnection);
}
}
}

/*!
* \brief TextAnnotation::updateTextStringHelper
* Helper function for TextAnnotation::updateTextString()
Expand Down
1 change: 1 addition & 0 deletions OMEdit/OMEdit/OMEditGUI/Annotations/TextAnnotation.h
Expand Up @@ -68,6 +68,7 @@ class TextAnnotation : public ShapeAnnotation
private:
Component *mpComponent;

void initUpdateTextString();
void updateTextStringHelper(QRegExp regExp);
public slots:
void updateTextString();
Expand Down

0 comments on commit 89b4204

Please sign in to comment.