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