[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    playground/edu/mathematik/src
From:       Alexander Rieder <alexanderrieder () gmail ! com>
Date:       2009-05-24 16:53:09
Message-ID: 1243183989.181520.32561.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 972348 by arieder:

show error message in own cell


 M  +11 -18    backends/maxima/maximaexpression.cpp  
 M  +20 -0     worksheetentry.cpp  
 M  +3 -0      worksheetentry.h  


--- trunk/playground/edu/mathematik/src/backends/maxima/maximaexpression.cpp \
#972347:972348 @@ -204,32 +204,25 @@
     kDebug()<<"out: "<<m_outputCache;
     kDebug()<<"err: "<<m_errCache;
 
+    QString text=m_outputCache.trimmed();
+    MathematiK::TextResult* result;
 
-    if(m_errCache.isEmpty())
-    {
-        QString text=m_outputCache.trimmed();
-        MathematiK::TextResult* result;
+    if(m_isHelpRequest)
+        result=new MathematiK::HelpResult(text);
+    else
+        result=new MathematiK::TextResult(text);
 
-        if(m_isHelpRequest)
-            result=new MathematiK::HelpResult(text);
-        else
-            result=new MathematiK::TextResult(text);
+    setResult(result);
+    setStatus(MathematiK::Expression::Done);
 
-        setResult(result);
-        setStatus(MathematiK::Expression::Done);
-    }else
+    if(!m_errCache.isEmpty())
     {
-        QString text=m_errCache.trimmed()+'\n'+m_outputCache.trimmed();
-        MathematiK::TextResult* result;
-
-        result=new MathematiK::TextResult(text);
-
-        setResult(result);
+        setErrorMessage(m_errCache.trimmed());
         setStatus(MathematiK::Expression::Error);
     }
 
     m_outputCache=QString();
-
+    m_errCache=QString();
 }
 
 bool MaximaExpression::needsLatexResult()
--- trunk/playground/edu/mathematik/src/worksheetentry.cpp #972347:972348
@@ -92,6 +92,7 @@
     m_informationCells.clear();
 
     connect(expr, SIGNAL(gotResult()), this, SLOT(updateResult()));
+    connect(expr, SIGNAL(statusChanged(MathematiK::Expression::Status)), this, \
                SLOT(expressionChangedStatus(MathematiK::Expression::Status)));
     connect(expr, SIGNAL(needsAdditionalInformation(const QString&)), this, \
SLOT(showAdditionalInformationPrompt(const QString&)));  }
 
@@ -142,6 +143,25 @@
     m_worksheet->ensureCursorVisible();
 }
 
+void WorksheetEntry::expressionChangedStatus(MathematiK::Expression::Status status)
+{
+    if(status==MathematiK::Expression::Error)
+    {
+        if(!m_errorCell.isValid())
+        {
+            int row;
+            if(actualInformationCell().isValid())
+                row=actualInformationCell().row()+1;
+            else
+                row=commandCell().row()+1;
+            m_table->insertRows(row, 1);
+            m_errorCell=m_table->cellAt(row, 1);
+        }
+
+        m_errorCell.firstCursorPosition().insertText(m_expression->errorMessage());
+    }
+}
+
 bool WorksheetEntry::isEmpty()
 {
     QTextCursor c=m_commandCell.firstCursorPosition();
--- trunk/playground/edu/mathematik/src/worksheetentry.h #972347:972348
@@ -23,6 +23,7 @@
 
 #include <QObject>
 #include <QTextTableCell>
+#include "lib/expression.h"
 
 class QTextDocument;
 namespace MathematiK{
@@ -78,6 +79,7 @@
 
   public slots:
     void updateResult();
+    void expressionChangedStatus(MathematiK::Expression::Status status);
     void showAdditionalInformationPrompt(const QString& question);
     void showContextHelp();
   private slots:
@@ -86,6 +88,7 @@
     QTextTable* m_table;
     QTextTableCell m_commandCell;
     QList<QTextTableCell> m_informationCells;
+    QTextTableCell m_errorCell;
     QTextTableCell m_resultCell;
     MathematiK::Expression* m_expression;
     Worksheet* m_worksheet;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic