File indexing completed on 2025-02-09 04:11:16
0001 /* 0002 SPDX-License-Identifier: GPL-2.0-or-later 0003 0004 SPDX-FileCopyrightText: 2009 Alexander Rieder <alexanderrieder@gmail.com> 0005 */ 0006 0007 #ifndef CANTORPART_H 0008 #define CANTORPART_H 0009 0010 #include <QPointer> 0011 0012 #include <KParts/ReadWritePart> 0013 #include <cantor/session.h> 0014 0015 class QWidget; 0016 class Worksheet; 0017 class WorksheetView; 0018 class SarchBar; 0019 class SearchBar; 0020 class ScriptEditorWidget; 0021 class KAboutData; 0022 class QAction; 0023 class KToggleAction; 0024 class KProgressDialog; 0025 0026 namespace Cantor { 0027 class PanelPluginHandler; 0028 } 0029 0030 /** 0031 * This is a "Part". It that does all the real work in a KPart 0032 * application. 0033 * 0034 * @short Main Part 0035 * @author Alexander Rieder <alexanderrieder@gmail.com> 0036 */ 0037 class CantorPart : public KParts::ReadWritePart 0038 { 0039 Q_OBJECT 0040 public: 0041 /** 0042 * Default constructor 0043 */ 0044 CantorPart(QWidget *parentWidget,QObject *parent, const QVariantList &args); 0045 0046 /** 0047 * Destructor 0048 */ 0049 ~CantorPart() override; 0050 0051 /** 0052 * This is a virtual function inherited from KParts::ReadWritePart. 0053 * A shell will use this to inform this Part if it should act 0054 * read-only 0055 */ 0056 void setReadWrite(bool rw) override; 0057 0058 /** 0059 * Reimplemented to disable and enable Save action 0060 */ 0061 void setModified(bool modified) override; 0062 0063 KAboutData& createAboutData(); 0064 0065 Worksheet* worksheet(); 0066 0067 Q_SIGNALS: 0068 void setCaption(const QString& caption); 0069 void showHelp(const QString& help); 0070 0071 protected: 0072 /** 0073 * This must be implemented by each part 0074 */ 0075 bool openFile() override; 0076 0077 /** 0078 * This must be implemented by each read-write part 0079 */ 0080 bool saveFile() override; 0081 0082 /** 0083 * Called when this part becomes the active one, 0084 * or if it looses activity 0085 **/ 0086 void guiActivateEvent( KParts::GUIActivateEvent * event ) override; 0087 0088 0089 void loadAssistants(); 0090 void adjustGuiToSession(); 0091 0092 protected Q_SLOTS: 0093 void fileSaveAs(); 0094 void fileSavePlain(); 0095 void exportToLatex(); 0096 void evaluateOrInterrupt(); 0097 void restartBackend(); 0098 void enableTypesetting(bool enable); 0099 void showBackendHelp(); 0100 void print(); 0101 void printPreview(); 0102 0103 void worksheetStatusChanged(Cantor::Session::Status stauts); 0104 void showSessionError(const QString& error); 0105 void worksheetSessionChanged(); 0106 void initialized(); 0107 void updateCaption(); 0108 0109 void pluginsChanged(); 0110 void runCommand(const QString& value); 0111 0112 void runAssistant(); 0113 void publishWorksheet(); 0114 0115 void showScriptEditor(bool show); 0116 void scriptEditorClosed(); 0117 void runScript(const QString& file); 0118 0119 void showSearchBar(); 0120 void showExtendedSearchBar(); 0121 void findNext(); 0122 void findPrev(); 0123 void searchBarDeleted(); 0124 0125 /** sets the status message, or cached it, if the StatusBar is blocked. 0126 * Use this method instead of "emit setStatusBarText" 0127 */ 0128 void setStatusMessage(const QString& message); 0129 /** Shows an important status message. It makes sure the message is displayed, 0130 * by blocking the statusbarText for 3 seconds 0131 */ 0132 void showImportantStatusMessage(const QString& message); 0133 /** Blocks the StatusBar for new messages, so the currently shown one won't be overridden 0134 */ 0135 void blockStatusBar(); 0136 /** Removes the block from the StatusBar, and shows the last one of the StatusMessages that 0137 where set during the block 0138 **/ 0139 void unblockStatusBar(); 0140 private: 0141 Worksheet *m_worksheet; 0142 WorksheetView *m_worksheetview; 0143 SearchBar *m_searchBar; 0144 QPointer<ScriptEditorWidget> m_scriptEditor; 0145 Cantor::PanelPluginHandler* m_panelHandler; 0146 0147 KProgressDialog* m_initProgressDlg; 0148 QAction * m_evaluate; 0149 QAction * m_save; 0150 QAction * m_findNext; 0151 QAction * m_findPrev; 0152 KToggleAction* m_typeset; 0153 KToggleAction* m_highlight; 0154 KToggleAction* m_completion; 0155 KToggleAction* m_exprNumbering; 0156 KToggleAction* m_animateWorksheet; 0157 QAction * m_showBackendHelp; 0158 0159 QString m_cachedStatusMessage; 0160 bool m_statusBarBlocked; 0161 }; 0162 0163 #endif // CANTORPART_H