Changeset View
Changeset View
Standalone View
Standalone View
src/backends/qalculate/qalculatesession.h
Show All 14 Lines | |||||
15 | * along with this program; if not, write to the Free Software * | 15 | * along with this program; if not, write to the Free Software * | ||
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * | 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * | ||
17 | *************************************************************************************/ | 17 | *************************************************************************************/ | ||
18 | 18 | | |||
19 | #ifndef QALCULATE_SESSION_H | 19 | #ifndef QALCULATE_SESSION_H | ||
20 | #define QALCULATE_SESSION_H | 20 | #define QALCULATE_SESSION_H | ||
21 | 21 | | |||
22 | #include "session.h" | 22 | #include "session.h" | ||
23 | #include "qalculateexpression.h" | ||||
23 | 24 | | |||
24 | #include <QSharedPointer> | 25 | #include <QSharedPointer> | ||
26 | #include <QQueue> | ||||
27 | #include <QMap> | ||||
25 | 28 | | |||
26 | #include <libqalculate/Variable.h> | 29 | #include <libqalculate/Variable.h> | ||
27 | #include <libqalculate/MathStructure.h> | 30 | #include <libqalculate/MathStructure.h> | ||
28 | 31 | | |||
29 | namespace Cantor { | 32 | namespace Cantor { | ||
30 | class DefaultVariableModel; | 33 | class DefaultVariableModel; | ||
31 | } | 34 | } | ||
32 | 35 | | |||
33 | class QalculateEngine; | 36 | class QalculateEngine; | ||
37 | class QProcess; | ||||
38 | | ||||
34 | 39 | | |||
35 | class QalculateSession : public Cantor::Session | 40 | class QalculateSession : public Cantor::Session | ||
36 | { | 41 | { | ||
37 | Q_OBJECT | 42 | Q_OBJECT | ||
38 | 43 | | |||
39 | private: | 44 | private: | ||
40 | QList<KnownVariable*> m_ansVariables; | | |||
41 | Cantor::DefaultVariableModel* m_variableModel; | 45 | Cantor::DefaultVariableModel* m_variableModel; | ||
46 | QProcess* m_process; | ||||
47 | QalculateExpression* m_currentExpression; | ||||
48 | QString m_output; | ||||
49 | QString m_finalOutput; | ||||
50 | QString m_currentCommand; | ||||
51 | QString m_saveError; | ||||
52 | QQueue<QalculateExpression*> m_expressionQueue; | ||||
53 | QQueue<QString> m_commandQueue; | ||||
54 | bool m_isSaveCommand; | ||||
55 | | ||||
56 | | ||||
57 | private: | ||||
58 | void runExpressionQueue(); | ||||
59 | void runCommandQueue(); | ||||
60 | QString parseSaveCommand(QString& currentCmd); | ||||
61 | void storeVariables(QString& currentCmd, QString output); | ||||
42 | 62 | | |||
43 | public: | 63 | public: | ||
44 | QalculateSession( Cantor::Backend* backend); | 64 | QalculateSession( Cantor::Backend* backend); | ||
45 | ~QalculateSession(); | 65 | ~QalculateSession(); | ||
46 | 66 | | |||
47 | virtual void login(); | 67 | virtual void login(); | ||
48 | virtual void logout(); | 68 | virtual void logout(); | ||
49 | 69 | | |||
50 | virtual void interrupt(); | 70 | virtual void interrupt(); | ||
51 | 71 | | |||
52 | virtual Cantor::Expression* evaluateExpression(const QString& command, Cantor::Expression::FinishingBehavior behave); | 72 | virtual Cantor::Expression* evaluateExpression(const QString& command, Cantor::Expression::FinishingBehavior behave); | ||
53 | virtual Cantor::CompletionObject* completionFor(const QString& cmd, int index=-1); | 73 | virtual Cantor::CompletionObject* completionFor(const QString& cmd, int index=-1); | ||
54 | virtual Cantor::SyntaxHelpObject* syntaxHelpFor(const QString& cmd); | 74 | virtual Cantor::SyntaxHelpObject* syntaxHelpFor(const QString& cmd); | ||
55 | virtual QSyntaxHighlighter* syntaxHighlighter(QObject* parent); | 75 | virtual QSyntaxHighlighter* syntaxHighlighter(QObject* parent); | ||
56 | 76 | | |||
57 | void setLastResult(MathStructure); | 77 | void runExpression(); | ||
58 | QAbstractItemModel* variableModel(); | 78 | QAbstractItemModel* variableModel(); | ||
79 | | ||||
80 | public: | ||||
81 | QMap<QString,QString> variables; | ||||
82 | | ||||
83 | public Q_SLOTS: | ||||
84 | void readOutput(); | ||||
85 | void readError(); | ||||
86 | void processStarted(); | ||||
87 | void currentExpressionStatusChanged(Cantor::Expression::Status status); | ||||
59 | }; | 88 | }; | ||
60 | 89 | | |||
61 | #endif | 90 | #endif |