Skip to content

Commit

Permalink
Revert "Do not force redraw when undo/redo is used from Icon/Diagram …
Browse files Browse the repository at this point in the history
…view."

This reverts commit 263c70d.
  • Loading branch information
adeas31 committed Mar 30, 2017
1 parent 263c70d commit d7c851f
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 12 deletions.
1 change: 0 additions & 1 deletion OMEdit/OMEditGUI/Editors/BaseEditor.cpp
Expand Up @@ -1698,7 +1698,6 @@ void BaseEditor::initialize()
mpFindReplaceWidget->hide();
createActions();
mForceSetPlainText = false;
mTextChanged = false;
// set the layout
QVBoxLayout *pMainLayout = new QVBoxLayout;
pMainLayout->setContentsMargins(0, 0, 0, 0);
Expand Down
3 changes: 0 additions & 3 deletions OMEdit/OMEditGUI/Editors/BaseEditor.h
Expand Up @@ -278,8 +278,6 @@ class BaseEditor : public QWidget
QAction* getUnFoldAllAction() {return mpUnFoldAllAction;}
DocumentMarker* getDocumentMarker() {return mpDocumentMarker;}
void setForceSetPlainText(bool forceSetPlainText) {mForceSetPlainText = forceSetPlainText;}
void setTextChanged(bool changed) {mTextChanged = changed;}
bool isTextChanged() {return mTextChanged;}
private:
void initialize();
void createActions();
Expand All @@ -301,7 +299,6 @@ class BaseEditor : public QWidget
QAction *mpUnFoldAllAction;
DocumentMarker *mpDocumentMarker;
bool mForceSetPlainText;
bool mTextChanged;

QMenu* createStandardContextMenu();
private slots:
Expand Down
13 changes: 6 additions & 7 deletions OMEdit/OMEditGUI/Editors/CompositeModelEditor.cpp
Expand Up @@ -57,7 +57,7 @@ QString XMLDocument::toString() const


CompositeModelEditor::CompositeModelEditor(QWidget *pParent)
: BaseEditor(pParent), mLastValidText("")
: BaseEditor(pParent), mLastValidText(""), mTextChanged(false)
{
mXmlDocument = XMLDocument(this);
}
Expand All @@ -69,7 +69,7 @@ CompositeModelEditor::CompositeModelEditor(QWidget *pParent)
*/
bool CompositeModelEditor::validateText()
{
if (isTextChanged()) {
if (mTextChanged) {
// if the user makes few mistakes in the text then dont let him change the perspective
if (!mpModelWidget->compositeModelEditorTextChanged()) {
QMessageBox *pMessageBox = new QMessageBox(MainWindow::instance());
Expand All @@ -87,17 +87,17 @@ bool CompositeModelEditor::validateText()
int answer = pMessageBox->exec();
switch (answer) {
case QMessageBox::RejectRole:
setTextChanged(false);
mTextChanged = false;
// revert back to last correct version
setPlainText(mLastValidText);
return true;
case QMessageBox::AcceptRole:
default:
setTextChanged(true);
mTextChanged = true;
return false;
}
} else {
setTextChanged(false);
mTextChanged = false;
mLastValidText = mpPlainTextEdit->toPlainText();
}
}
Expand Down Expand Up @@ -1270,7 +1270,6 @@ void CompositeModelEditor::setPlainText(const QString &text, bool useInserText)
textCursor.insertText(mXmlDocument.toString());
textCursor.endEditBlock();
}
setTextChanged(false);
mForceSetPlainText = false;
mLastValidText = text;
}
Expand Down Expand Up @@ -1301,7 +1300,7 @@ void CompositeModelEditor::contentsHasChanged(int position, int charsRemoved, in
mpModelWidget->setWindowTitle(QString(mpModelWidget->getLibraryTreeItem()->getName()).append("*"));
mpModelWidget->getLibraryTreeItem()->setIsSaved(false);
MainWindow::instance()->getLibraryWidget()->getLibraryTreeModel()->updateLibraryTreeItem(mpModelWidget->getLibraryTreeItem());
setTextChanged(true);
mTextChanged = true;
}
}
}
Expand Down
1 change: 1 addition & 0 deletions OMEdit/OMEditGUI/Editors/CompositeModelEditor.h
Expand Up @@ -96,6 +96,7 @@ class CompositeModelEditor : public BaseEditor
bool deleteConnection(QString startComponentName, QString endComponentName);
private:
QString mLastValidText;
bool mTextChanged;
XMLDocument mXmlDocument;

bool existInterfacePoint(QString subModelName, QString interfaceName);
Expand Down
2 changes: 1 addition & 1 deletion OMEdit/OMEditGUI/Editors/ModelicaEditor.cpp
Expand Up @@ -51,7 +51,7 @@
* \param pParent
*/
ModelicaEditor::ModelicaEditor(QWidget *pParent)
: BaseEditor(pParent), mLastValidText("")
: BaseEditor(pParent), mLastValidText(""), mTextChanged(false)
{
mpPlainTextEdit->setCanHaveBreakpoints(true);
/* set the document marker */
Expand Down
3 changes: 3 additions & 0 deletions OMEdit/OMEditGUI/Editors/ModelicaEditor.h
Expand Up @@ -55,8 +55,11 @@ class ModelicaEditor : public BaseEditor
QString removeLeadingSpaces(QString contents);
void storeLeadingSpaces(QMap<int, int> leadingSpacesMap);
QString getPlainText();
void setTextChanged(bool changed) {mTextChanged = changed;}
bool isTextChanged() {return mTextChanged;}
private:
QString mLastValidText;
bool mTextChanged;
private slots:
virtual void showContextMenu(QPoint point);
public slots:
Expand Down

0 comments on commit d7c851f

Please sign in to comment.