Skip to content

Commit

Permalink
Only track the Component attributes if they really changed.
Browse files Browse the repository at this point in the history
  • Loading branch information
adeas31 committed Oct 27, 2015
1 parent bd1887e commit 7c88237
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 5 deletions.
42 changes: 42 additions & 0 deletions OMEdit/OMEditGUI/Component/Component.cpp
Expand Up @@ -217,6 +217,48 @@ void ComponentInfo::setArrayIndex(QString arrayIndex)
}
}

/*!
* \brief ComponentInfo::operator ==
* \param componentInfo
* Compares the ComponentInfo and returns true if its equal.
* \return
*/
bool ComponentInfo::operator==(const ComponentInfo &componentInfo) const
{
qDebug() << (componentInfo.getClassName() == this->getClassName());
qDebug() << (componentInfo.getName() == this->getName());
qDebug() << (componentInfo.getComment() == this->getComment());
qDebug() << (componentInfo.getProtected() == this->getProtected());
qDebug() << (componentInfo.getFinal() == this->getFinal());
qDebug() << (componentInfo.getFlow() == this->getFlow());
qDebug() << (componentInfo.getStream() == this->getStream());
qDebug() << (componentInfo.getReplaceable() == this->getReplaceable());
qDebug() << (componentInfo.getVariablity() == this->getVariablity());
qDebug() << (componentInfo.getInner() == this->getInner());
qDebug() << (componentInfo.getOuter() == this->getOuter());
qDebug() << (componentInfo.getCausality() == this->getCausality());
qDebug() << (componentInfo.getArrayIndex() == this->getArrayIndex());

return (componentInfo.getClassName() == this->getClassName()) && (componentInfo.getName() == this->getName()) &&
(componentInfo.getComment() == this->getComment()) && (componentInfo.getProtected() == this->getProtected()) &&
(componentInfo.getFinal() == this->getFinal()) && (componentInfo.getFlow() == this->getFlow()) &&
(componentInfo.getStream() == this->getStream()) && (componentInfo.getReplaceable() == this->getReplaceable()) &&
(componentInfo.getVariablity() == this->getVariablity()) && (componentInfo.getInner() == this->getInner()) &&
(componentInfo.getOuter() == this->getOuter()) && (componentInfo.getCausality() == this->getCausality()) &&
(componentInfo.getArrayIndex() == this->getArrayIndex());
}

/*!
* \brief ComponentInfo::operator !=
* \param componentInfo
* Compares the ComponentInfo and returns true if its not equal.
* \return
*/
bool ComponentInfo::operator!=(const ComponentInfo &componentInfo) const
{
return !operator==(componentInfo);
}

Component::Component(QString name, LibraryTreeItem *pLibraryTreeItem, QString transformation, QPointF position, ComponentInfo *pComponentInfo,
GraphicsView *pGraphicsView)
: QGraphicsItem(0), mpReferenceComponent(0), mpParentComponent(0)
Expand Down
2 changes: 2 additions & 0 deletions OMEdit/OMEditGUI/Component/Component.h
Expand Up @@ -99,6 +99,8 @@ class ComponentInfo : public QObject
void setArrayIndex(QString arrayIndex);
QString getArrayIndex() const {return mArrayIndex;}
bool isArray() const {return mIsArray;}
bool operator==(const ComponentInfo &componentInfo) const;
bool operator!=(const ComponentInfo &componentInfo) const;
private:
QString mClassName;
QString mName;
Expand Down
13 changes: 8 additions & 5 deletions OMEdit/OMEditGUI/Component/ComponentProperties.cpp
Expand Up @@ -1133,11 +1133,14 @@ void ComponentAttributes::updateComponentAttributes()
newComponentInfo.setOuter(mpOuterCheckBox->isChecked());
newComponentInfo.setCausality(causality);
newComponentInfo.setArrayIndex(mpDimensionsTextBox->text());

UpdateComponentAttributesCommand *pUpdateComponentAttributesCommand = new UpdateComponentAttributesCommand(mpComponent, oldComponentInfo,
newComponentInfo, false);
pModelWidget->getUndoStack()->push(pUpdateComponentAttributesCommand);
pModelWidget->updateModelicaText();
/* If user has really changed the Component's attributes then push that change on the stack.
*/
if (oldComponentInfo != newComponentInfo) {
UpdateComponentAttributesCommand *pUpdateComponentAttributesCommand = new UpdateComponentAttributesCommand(mpComponent, oldComponentInfo,
newComponentInfo, false);
pModelWidget->getUndoStack()->push(pUpdateComponentAttributesCommand);
pModelWidget->updateModelicaText();
}
accept();
}

Expand Down

0 comments on commit 7c88237

Please sign in to comment.