From 2b12dca3f09a05b9337837faa198463955326e07 Mon Sep 17 00:00:00 2001 From: hkiel Date: Wed, 24 May 2017 09:54:44 +0200 Subject: [PATCH] New caption for omc messages also highlight error cells in red, warning cells in yellow --- OMNotebook/OMNotebookGUI/graphcell.cpp | 11 +++++++++ OMNotebook/OMNotebookGUI/graphcelldelegate.h | 2 +- OMNotebook/OMNotebookGUI/inputcelldelegate.h | 1 + .../omcinteractiveenvironment.cpp | 23 ++++++++++++++++++- .../OMNotebookGUI/omcinteractiveenvironment.h | 2 ++ 5 files changed, 37 insertions(+), 2 deletions(-) diff --git a/OMNotebook/OMNotebookGUI/graphcell.cpp b/OMNotebook/OMNotebookGUI/graphcell.cpp index 5841e62383d..1fbe0f67815 100644 --- a/OMNotebook/OMNotebookGUI/graphcell.cpp +++ b/OMNotebook/OMNotebookGUI/graphcell.cpp @@ -1396,6 +1396,7 @@ namespace IAEX { { QString res = delegate->getResult(); QString error = delegate->getError(); + int errorLevel= delegate->getErrorLevel(); //delete sender(); guard->unlock(); @@ -1422,6 +1423,16 @@ namespace IAEX { output_->selectAll(); output_->textCursor().insertText( res ); + QPalette pal = output_->palette(); // define pallete for textEdit.. + if (errorLevel >= 2) { + pal.setColor(QPalette::Base, QColor(0xff,0xe0,0xe0)); + } else if (errorLevel == 1) { + pal.setColor(QPalette::Base, QColor(0xff,0xff,0xe0)); + } else { + pal.setColor(QPalette::Base, Qt::white); + } + output_->setPalette(pal); + QList actions; while((p=res.indexOf(e, p)) > 0) { diff --git a/OMNotebook/OMNotebookGUI/graphcelldelegate.h b/OMNotebook/OMNotebookGUI/graphcelldelegate.h index 07e2e66877d..d5f810bc602 100644 --- a/OMNotebook/OMNotebookGUI/graphcelldelegate.h +++ b/OMNotebook/OMNotebookGUI/graphcelldelegate.h @@ -54,7 +54,7 @@ namespace IAEX { public: virtual QString getResult() = 0; - virtual QString getError() = 0; // Added 2006-02-02 AF + virtual QString getError() = 0; // Added 2006-02-02 AF virtual void evalExpression(QString &expr) = 0; virtual void closeConnection() = 0; // Added 2006-02-02 AF virtual void reconnect() = 0; // Added 2006-02-02 AF diff --git a/OMNotebook/OMNotebookGUI/inputcelldelegate.h b/OMNotebook/OMNotebookGUI/inputcelldelegate.h index db49150e5d2..e70036c98fb 100644 --- a/OMNotebook/OMNotebookGUI/inputcelldelegate.h +++ b/OMNotebook/OMNotebookGUI/inputcelldelegate.h @@ -55,6 +55,7 @@ namespace IAEX public: virtual QString getResult() = 0; virtual QString getError() = 0; // Added 2006-02-02 AF + virtual int getErrorLevel() = 0; // Added 2006-02-02 AF virtual void evalExpression(const QString expr) = 0; }; diff --git a/OMNotebook/OMNotebookGUI/omcinteractiveenvironment.cpp b/OMNotebook/OMNotebookGUI/omcinteractiveenvironment.cpp index 617a7302881..d7075fd543b 100644 --- a/OMNotebook/OMNotebookGUI/omcinteractiveenvironment.cpp +++ b/OMNotebook/OMNotebookGUI/omcinteractiveenvironment.cpp @@ -139,6 +139,17 @@ namespace IAEX return error_; } + /*! + * \author Hennning Kiel + * \date 2017-05-24 + * + *\brief Method to get error message severity from OMC + */ + int OmcInteractiveEnvironment::getErrorLevel() + { + return severity; + } + // QMutex omcMutex; /*! @@ -172,14 +183,24 @@ namespace IAEX error_ = MMC_STRINGDATA(reply_str); error_ = error_.trimmed(); if( error_.size() > 2 ) { - error_ = QString( "OMC-ERROR: \n" ) + error_; + if (error_.contains("Error:")) { + severity = 2; + error_ = QString( "OMC-ERROR: \n" ) + error_; + } else if (error_.contains("Warning:")) { + severity = 1; + error_ = QString( "OMC-WARNING: \n" ) + error_; + } else { + severity = 0; + } } else { // no errors, clear the error. error_.clear(); + severity = 0; } MMC_ELSE() result_ = ""; error_ = ""; + severity = 3; fprintf(stderr, "Stack overflow detected and was not caught.\nSend us a bug report at https://trac.openmodelica.org/OpenModelica/newticket\n Include the following trace:\n"); printStacktraceMessages(); fflush(NULL); diff --git a/OMNotebook/OMNotebookGUI/omcinteractiveenvironment.h b/OMNotebook/OMNotebookGUI/omcinteractiveenvironment.h index e579a919b72..fe88a32f5a9 100644 --- a/OMNotebook/OMNotebookGUI/omcinteractiveenvironment.h +++ b/OMNotebook/OMNotebookGUI/omcinteractiveenvironment.h @@ -53,6 +53,7 @@ namespace IAEX static OmcInteractiveEnvironment* getInstance(); virtual QString getResult(); virtual QString getError(); + virtual int getErrorLevel(); virtual void evalExpression(const QString expr); static QString OMCVersion(); static QString OpenModelicaHome(); @@ -62,6 +63,7 @@ namespace IAEX static OmcInteractiveEnvironment* selfInstance; QString result_; QString error_; + int severity; }; } #endif