cantor_part.h 5.23 KB
Newer Older
Alexander Rieder's avatar
Alexander Rieder committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/*
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
    as published by the Free Software Foundation; either version 2
    of the License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor,
    Boston, MA  02110-1301, USA.

    ---
    Copyright (C) 2009 Alexander Rieder <alexanderrieder@gmail.com>
*/

Alexander Rieder's avatar
Alexander Rieder committed
21
22
#ifndef CANTORPART_H
#define CANTORPART_H
23

24
#include <QPointer>
25
#include <QVector>
26
27

#include <KParts/ReadWritePart>
28
29
30
31
#include <lib/session.h>

class QWidget;
class Worksheet;
32
class WorksheetView;
33
class SarchBar;
34
class SearchBar;
35
class ScriptEditorWidget;
36
class KAboutData;
37
class QAction;
38
class KToggleAction;
39
class KSelectAction;
40
class QProgressDialog;
41

42
43
namespace Cantor{
    class PanelPluginHandler;
André Wöbbeking's avatar
André Wöbbeking committed
44
}
45

46
47
48
49
50
51
52
/**
 * This is a "Part".  It that does all the real work in a KPart
 * application.
 *
 * @short Main Part
 * @author Alexander Rieder <alexanderrieder@gmail.com>
 */
Alexander Rieder's avatar
Alexander Rieder committed
53
class CantorPart : public KParts::ReadWritePart
54
55
56
57
58
59
{
    Q_OBJECT
public:
    /**
     * Default constructor
     */
60
    CantorPart(QWidget *parentWidget,QObject *parent, const QVariantList &args);
61
62
63
64

    /**
     * Destructor
     */
65
    ~CantorPart() override;
66
67
68
69
70
71

    /**
     * This is a virtual function inherited from KParts::ReadWritePart.
     * A shell will use this to inform this Part if it should act
     * read-only
     */
72
    void setReadWrite(bool rw) override;
73
74
75
76

    /**
     * Reimplemented to disable and enable Save action
     */
77
    void setModified(bool modified) override;
78

79
    KAboutData& createAboutData();
80
81
82

    Worksheet* worksheet();

83
Q_SIGNALS:
84
    void setCaption(const QString& caption, const QIcon& icon);
85
    void showHelp(const QString& help);
86
    void worksheetSave(const QUrl& url);
87
88
    void requestOpenWorksheet(const QUrl& url);
    void setBackendName(const QString& name);
Shubham  .'s avatar
Shubham . committed
89
    void requestDocumentation(const QString& keyword);
90

91
92
93
public Q_SLOTS:
    void updateCaption();

94
95
96
97
protected:
    /**
     * This must be implemented by each part
     */
98
    bool openFile() override;
99
100
101
102

    /**
     * This must be implemented by each read-write part
     */
103
    bool saveFile() override;
104

105
106
107
108
    /**
     * Called when this part becomes the active one,
     * or if it looses activity
     **/
109
    void guiActivateEvent( KParts::GUIActivateEvent * event ) override;
110
111


112
    void loadAssistants();
Alexander Rieder's avatar
Alexander Rieder committed
113
    void adjustGuiToSession();
114

115
116
    void setReadOnly();

117
protected Q_SLOTS:
118
    void fileSaveAs();
119
    void fileSavePlain();
120
    void exportToLatex();
121
122
    void evaluateOrInterrupt();
    void restartBackend();
123
    void zoomValueEdited(const QString& text);
124
    void updateZoomWidgetValue(double zoom);
125
    void enableTypesetting(bool enable);
126
    void showBackendHelp();
127
    void print();
128
    void printPreview();
129

Alexander Rieder's avatar
Alexander Rieder committed
130
    void worksheetStatusChanged(Cantor::Session::Status stauts);
131
    void showSessionError(const QString& error);
132
133
    void worksheetSessionLoginStarted();
    void worksheetSessionLoginDone();
134
135
    void initialized();

136
137
138
    void pluginsChanged();
    void runCommand(const QString& value);

139
    void runAssistant();
140
    void publishWorksheet();
141
142

    void showScriptEditor(bool show);
143
    void scriptEditorClosed();
144
    void runScript(const QString& file);
145

146
147
    void showSearchBar();
    void showExtendedSearchBar();
148
149
    void findNext();
    void findPrev();
150
151
    void searchBarDeleted();

152
153
154
155
156
157
158
159
160
161
162
163
    /** sets the status message, or cached it, if the StatusBar is blocked.
     *  Use this method instead of "emit setStatusBarText"
     */
    void setStatusMessage(const QString& message);
    /** Shows an important status message. It makes sure the message is displayed,
     *  by blocking the statusbarText for 3 seconds
     */
    void showImportantStatusMessage(const QString& message);
    /** Blocks the StatusBar for new messages, so the currently shown one won't be overridden
     */
    void blockStatusBar();
    /** Removes the block from the StatusBar, and shows the last one of the StatusMessages that
Martin Küttler's avatar
Martin Küttler committed
164
        where set during the block
165
166
    **/
    void unblockStatusBar();
167
168
private:
    Worksheet *m_worksheet;
169
    WorksheetView *m_worksheetview;
170
    SearchBar *m_searchBar;
171
    QPointer<ScriptEditorWidget> m_scriptEditor;
172
    Cantor::PanelPluginHandler* m_panelHandler;
173

174
    QProgressDialog* m_initProgressDlg;
175
    bool m_showProgressDlg;
176
    QAction * m_evaluate;
177
    QAction * m_restart;
178
    KSelectAction* m_zoom;
179
    QAction* m_currectZoomAction;
180
181
182
    QAction * m_save;
    QAction * m_findNext;
    QAction * m_findPrev;
183
    KToggleAction* m_typeset;
Alexander Rieder's avatar
Alexander Rieder committed
184
    KToggleAction* m_highlight;
185
    KToggleAction* m_completion;
186
    KToggleAction* m_exprNumbering;
187
    KToggleAction* m_animateWorksheet;
188
    KToggleAction* m_embeddedMath;
189
    QAction * m_showBackendHelp;
190
    QVector<QAction*> m_editActions;
191
192
193

    QString m_cachedStatusMessage;
    bool m_statusBarBlocked;
194
    unsigned int m_sessionStatusCounter;
195
196
};

Alexander Rieder's avatar
Alexander Rieder committed
197
#endif // CANTORPART_H