Changeset View
Changeset View
Standalone View
Standalone View
src/lib/session.h
Show All 34 Lines | |||||
35 | * Namespace collecting all Classes of the Cantor Libraries | 35 | * Namespace collecting all Classes of the Cantor Libraries | ||
36 | */ | 36 | */ | ||
37 | namespace Cantor | 37 | namespace Cantor | ||
38 | { | 38 | { | ||
39 | class Backend; | 39 | class Backend; | ||
40 | class SessionPrivate; | 40 | class SessionPrivate; | ||
41 | class CompletionObject; | 41 | class CompletionObject; | ||
42 | class SyntaxHelpObject; | 42 | class SyntaxHelpObject; | ||
43 | class DefaultVariableModel; | ||||
43 | 44 | | |||
44 | /** | 45 | /** | ||
45 | * The Session object is the main class used to interact with a Backend. | 46 | * The Session object is the main class used to interact with a Backend. | ||
46 | * It is used to evaluate Expressions, get completions, syntax highlighting, etc. | 47 | * It is used to evaluate Expressions, get completions, syntax highlighting, etc. | ||
47 | * | 48 | * | ||
48 | * @author Alexander Rieder | 49 | * @author Alexander Rieder | ||
49 | */ | 50 | */ | ||
50 | class CANTOR_EXPORT Session : public QObject | 51 | class CANTOR_EXPORT Session : public QObject | ||
51 | { | 52 | { | ||
52 | Q_OBJECT | 53 | Q_OBJECT | ||
53 | public: | 54 | public: | ||
54 | enum Status { | 55 | enum Status { | ||
55 | Running, ///< the session is busy, running some expression | 56 | Running, ///< the session is busy, running some expression | ||
56 | Done, ///< the session has done all the jobs, and is now waiting for more | 57 | Done, ///< the session has done all the jobs, and is now waiting for more | ||
57 | Disable ///< the session don't login yet, or already logout | 58 | Disable ///< the session don't login yet, or already logout | ||
58 | }; | 59 | }; | ||
59 | 60 | | |||
60 | /** | 61 | /** | ||
61 | * Create a new Session. This should not yet set up the complete session, | 62 | * Create a new Session. This should not yet set up the complete session, | ||
62 | * thats job of the login() function | 63 | * thats job of the login() function | ||
63 | * @see login() | 64 | * @see login() | ||
64 | */ | 65 | */ | ||
65 | explicit Session( Backend* backend); | 66 | explicit Session( Backend* backend); | ||
67 | | ||||
68 | /** | ||||
69 | * Similar to Session::Session, but also specify variable model for automatically handles model's updates | ||||
70 | */ | ||||
71 | explicit Session( Backend* backend, DefaultVariableModel* model); | ||||
72 | | ||||
66 | /** | 73 | /** | ||
67 | * Destructor | 74 | * Destructor | ||
68 | */ | 75 | */ | ||
69 | ~Session() override; | 76 | ~Session() override; | ||
70 | 77 | | |||
71 | /** | 78 | /** | ||
72 | * Login to the Session. In this function you should do anything needed to set up | 79 | * Login to the Session. In this function you should do anything needed to set up | ||
73 | * the session, and make it ready for usage. The method should be implemented non-blocking. | 80 | * the session, and make it ready for usage. The method should be implemented non-blocking. | ||
▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Line(s) | |||||
132 | /** | 139 | /** | ||
133 | * returns a syntax highlighter for this session | 140 | * returns a syntax highlighter for this session | ||
134 | * @param parent QObject the Highlighter's parent | 141 | * @param parent QObject the Highlighter's parent | ||
135 | * @return QSyntaxHighlighter doing the highlighting for this Session | 142 | * @return QSyntaxHighlighter doing the highlighting for this Session | ||
136 | */ | 143 | */ | ||
137 | virtual QSyntaxHighlighter* syntaxHighlighter(QObject* parent); | 144 | virtual QSyntaxHighlighter* syntaxHighlighter(QObject* parent); | ||
138 | 145 | | |||
139 | /** | 146 | /** | ||
140 | * returns a Model to interact with the variables | 147 | * returns a Model to interact with the variables or nullptr, if | ||
141 | * @return QAbstractItemModel to interact with the variables | 148 | * this backend have a variable model, which not inherit from | ||
149 | * default variable model class (in this case @see variableDataModel()) | ||||
150 | * @return DefaultVariableModel to interact with the variables | ||||
142 | */ | 151 | */ | ||
143 | virtual QAbstractItemModel* variableModel(); | 152 | virtual DefaultVariableModel* variableModel() const; | ||
153 | | ||||
154 | /** | ||||
155 | * returns QAbstractItemModel to interact with the variables | ||||
156 | */ | ||||
157 | virtual QAbstractItemModel* variableDataModel() const; | ||||
144 | 158 | | |||
145 | /** | 159 | /** | ||
146 | * Enables/disables Typesetting for this session. | 160 | * Enables/disables Typesetting for this session. | ||
147 | * For this setting to make effect, the Backend must support | 161 | * For this setting to make effect, the Backend must support | ||
148 | * LaTeX typesetting (as indicated by the capabilities() flag. | 162 | * LaTeX typesetting (as indicated by the capabilities() flag. | ||
149 | * @param enable true to enable, false to disable typesetting | 163 | * @param enable true to enable, false to disable typesetting | ||
150 | */ | 164 | */ | ||
151 | virtual void setTypesettingEnabled(bool enable); | 165 | virtual void setTypesettingEnabled(bool enable); | ||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Line(s) | 202 | protected: | |||
203 | 217 | | |||
204 | /** | 218 | /** | ||
205 | * Execute first expression in expression queue. | 219 | * Execute first expression in expression queue. | ||
206 | * Also, this function changes the status from Queued to Computing. | 220 | * Also, this function changes the status from Queued to Computing. | ||
207 | * @see expressionQueue() const | 221 | * @see expressionQueue() const | ||
208 | */ | 222 | */ | ||
209 | virtual void runFirstExpression(); | 223 | virtual void runFirstExpression(); | ||
210 | 224 | | |||
225 | /** | ||||
226 | * Opposite action to Session::runFirstExpression() | ||||
227 | * This method dequeue the expression and go to next expression, if queue not empty | ||||
228 | * Also, this method updates variableModel, if needed | ||||
229 | * If queue empty, session change status to Done | ||||
230 | */ | ||||
231 | virtual void finishFirstExpression(); | ||||
232 | | ||||
233 | /** | ||||
234 | * Starts variable update immideatly, usefull for subclasses, which run internal command | ||||
235 | * which could change variables listen | ||||
236 | */ | ||||
237 | virtual void forceVariableUpdate(); | ||||
asemke: updateVariables() is shorter and sounds better. | |||||
238 | | ||||
239 | /** | ||||
240 | * Setting variable model, usefull, if model constructor requires functional session | ||||
241 | */ | ||||
242 | void setVariableModel(DefaultVariableModel* model); | ||||
243 | | ||||
211 | Q_SIGNALS: | 244 | Q_SIGNALS: | ||
212 | void statusChanged(Cantor::Session::Status newStatus); | 245 | void statusChanged(Cantor::Session::Status newStatus); | ||
213 | void loginStarted(); | 246 | void loginStarted(); | ||
214 | void loginDone(); | 247 | void loginDone(); | ||
215 | void error(const QString& msg); | 248 | void error(const QString& msg); | ||
216 | 249 | | |||
217 | private: | 250 | private: | ||
218 | SessionPrivate* d; | 251 | SessionPrivate* d; | ||
219 | }; | 252 | }; | ||
220 | } | 253 | } | ||
221 | #endif /* _SESSION_H */ | 254 | #endif /* _SESSION_H */ |
updateVariables() is shorter and sounds better.