Changeset View
Changeset View
Standalone View
Standalone View
src/backends/python/pythonsession.h
Show All 20 Lines | |||||
21 | 21 | | |||
22 | #ifndef _PYTHONSESSION_H | 22 | #ifndef _PYTHONSESSION_H | ||
23 | #define _PYTHONSESSION_H | 23 | #define _PYTHONSESSION_H | ||
24 | 24 | | |||
25 | #include "session.h" | 25 | #include "session.h" | ||
26 | #include <cantor_pythonbackend_export.h> | 26 | #include <cantor_pythonbackend_export.h> | ||
27 | #include <QStringList> | 27 | #include <QStringList> | ||
28 | 28 | | |||
29 | namespace Cantor { | | |||
30 | class DefaultVariableModel; | | |||
31 | } | | |||
32 | | ||||
33 | class PythonExpression; | 29 | class PythonExpression; | ||
30 | class PythonVariableModel; | ||||
34 | class KDirWatch; | 31 | class KDirWatch; | ||
35 | class QDBusInterface; | 32 | class QDBusInterface; | ||
36 | class KProcess; | 33 | class KProcess; | ||
37 | 34 | | |||
38 | class CANTOR_PYTHONBACKEND_EXPORT PythonSession : public Cantor::Session | 35 | class CANTOR_PYTHONBACKEND_EXPORT PythonSession : public Cantor::Session | ||
39 | { | 36 | { | ||
40 | Q_OBJECT | 37 | Q_OBJECT | ||
41 | public: | 38 | public: | ||
Show All 9 Lines | |||||
51 | Cantor::Expression* evaluateExpression(const QString& command, Cantor::Expression::FinishingBehavior behave = Cantor::Expression::FinishingBehavior::DoNotDelete, bool internal = false) override; | 48 | Cantor::Expression* evaluateExpression(const QString& command, Cantor::Expression::FinishingBehavior behave = Cantor::Expression::FinishingBehavior::DoNotDelete, bool internal = false) override; | ||
52 | Cantor::CompletionObject* completionFor(const QString& command, int index=-1) override; | 49 | Cantor::CompletionObject* completionFor(const QString& command, int index=-1) override; | ||
53 | QSyntaxHighlighter* syntaxHighlighter(QObject* parent) override; | 50 | QSyntaxHighlighter* syntaxHighlighter(QObject* parent) override; | ||
54 | QAbstractItemModel* variableModel() override; | 51 | QAbstractItemModel* variableModel() override; | ||
55 | void setWorksheetPath(const QString& path) override; | 52 | void setWorksheetPath(const QString& path) override; | ||
56 | 53 | | |||
57 | virtual bool integratePlots() const = 0; | 54 | virtual bool integratePlots() const = 0; | ||
58 | virtual QStringList autorunScripts() const = 0; | 55 | virtual QStringList autorunScripts() const = 0; | ||
56 | virtual bool variableManagement() const = 0; | ||||
59 | 57 | | |||
60 | private: | 58 | private: | ||
61 | Cantor::DefaultVariableModel* m_variableModel; | 59 | PythonVariableModel* m_variableModel; | ||
62 | 60 | | |||
63 | QList<PythonExpression*> m_runningExpressions; | 61 | QList<PythonExpression*> m_runningExpressions; | ||
64 | PythonExpression* m_currentExpression; | 62 | PythonExpression* m_currentExpression; | ||
65 | 63 | | |||
66 | QDBusInterface* m_pIface; | 64 | QDBusInterface* m_pIface; | ||
67 | KProcess* m_pProcess; | 65 | KProcess* m_pProcess; | ||
68 | QString serverName; | 66 | QString serverName; | ||
69 | QString DbusChannelName; | 67 | QString DbusChannelName; | ||
70 | 68 | | |||
71 | QString worksheetPath; | 69 | QString worksheetPath; | ||
72 | int m_pythonVersion; | 70 | int m_pythonVersion; | ||
73 | 71 | | |||
72 | bool m_needUpdate; | ||||
73 | | ||||
74 | protected: | 74 | protected: | ||
75 | QString m_output; | 75 | QString m_output; | ||
76 | QString m_error; | 76 | QString m_error; | ||
77 | 77 | | |||
78 | private: | 78 | private: | ||
79 | void listVariables(); | | |||
80 | | ||||
81 | void getPythonCommandOutput(const QString& commandProcessing); | 79 | void getPythonCommandOutput(const QString& commandProcessing); | ||
82 | 80 | | |||
83 | QString identifyPythonModule(const QString& command) const; | 81 | QString identifyPythonModule(const QString& command) const; | ||
84 | QString identifyVariableModule(const QString& command) const; | 82 | QString identifyVariableModule(const QString& command) const; | ||
85 | bool identifyKeywords(const QString& command); | 83 | bool identifyKeywords(const QString& command); | ||
86 | 84 | | |||
87 | void runPythonCommand(const QString& command) const; | 85 | void runPythonCommand(const QString& command) const; | ||
88 | QString getOutput() const; | 86 | QString getOutput() const; | ||
89 | QString getError() const; | 87 | QString getError() const; | ||
90 | 88 | | |||
91 | virtual void readExpressionOutput(const QString& commandProcessing); | 89 | virtual void readExpressionOutput(const QString& commandProcessing); | ||
92 | 90 | | |||
93 | protected: | 91 | protected: | ||
94 | void updateOutput(); | 92 | void updateOutput(); | ||
95 | 93 | | |||
96 | private Q_SLOTS: | 94 | private Q_SLOTS: | ||
97 | void readOutput(const QString& commandProcessing); | 95 | void readOutput(const QString& commandProcessing); | ||
98 | void expressionFinished(); | 96 | void expressionFinished(); | ||
99 | | ||||
100 | Q_SIGNALS: | | |||
101 | void updateHighlighter(); | | |||
102 | void newVariable(const QString variable); | | |||
103 | void clearVariables(); | | |||
104 | }; | 97 | }; | ||
105 | 98 | | |||
106 | #endif /* _PYTHONSESSION_H */ | 99 | #endif /* _PYTHONSESSION_H */ |