Warning, file /education/cantor/src/cantor_part.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 SPDX-License-Identifier: GPL-2.0-or-later 0003 SPDX-FileCopyrightText: 2009 Alexander Rieder <alexanderrieder@gmail.com> 0004 */ 0005 0006 #ifndef CANTORPART_H 0007 #define CANTORPART_H 0008 0009 #include <QPointer> 0010 #include <QRegularExpression> 0011 #include <QVector> 0012 0013 #include <KParts/ReadWritePart> 0014 #include "lib/session.h" 0015 0016 class QWidget; 0017 class Worksheet; 0018 class WorksheetView; 0019 class SearchBar; 0020 class ScriptEditorWidget; 0021 class KAboutData; 0022 class QAction; 0023 class KToggleAction; 0024 class KSelectAction; 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* , QObject*, 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) override; 0057 0058 /** 0059 * Reimplemented to disable and enable Save action 0060 */ 0061 void setModified(bool) override; 0062 0063 KAboutData& createAboutData(); 0064 0065 Worksheet* worksheet(); 0066 0067 Q_SIGNALS: 0068 void setCaption(const QString& caption, const QIcon& icon); 0069 void showHelp(const QString&); 0070 void hierarchyChanged(QStringList, QStringList, QList<int>); 0071 void hierarhyEntryNameChange(QString name, QString searchName, int depth); 0072 void worksheetSave(const QUrl&); 0073 void setBackendName(const QString&); 0074 void requestScrollToHierarchyEntry(QString); 0075 void settingsChanges(); 0076 void requestDocumentation(const QString& keyword); 0077 0078 public Q_SLOTS: 0079 void updateCaption(); 0080 0081 protected: 0082 /** 0083 * This must be implemented by each part 0084 */ 0085 bool openFile() override; 0086 0087 /** 0088 * This must be implemented by each read-write part 0089 */ 0090 bool saveFile() override; 0091 0092 /** 0093 * Called when this part becomes the active one, 0094 * or if it looses activity 0095 **/ 0096 void guiActivateEvent(KParts::GUIActivateEvent*) override; 0097 0098 void loadAssistants(); 0099 void adjustGuiToSession(); 0100 0101 void setReadOnly(); 0102 0103 protected Q_SLOTS: 0104 void fileSaveAs(); 0105 void fileSavePlain(); 0106 void exportToPDF(); 0107 void exportToLatex(); 0108 void evaluateOrInterrupt(); 0109 void restartBackend(); 0110 void zoomValueEdited(const QString&); 0111 void updateZoomWidgetValue(double); 0112 void enableTypesetting(bool); 0113 void showBackendHelp(); 0114 void print(); 0115 void printPreview(); 0116 0117 void worksheetStatusChanged(Cantor::Session::Status); 0118 void showSessionError(const QString&); 0119 void worksheetSessionLoginStarted(); 0120 void worksheetSessionLoginDone(); 0121 void initialized(); 0122 0123 void runCommand(const QString&); 0124 0125 void runAssistant(); 0126 void publishWorksheet(); 0127 0128 void showScriptEditor(bool); 0129 void scriptEditorClosed(); 0130 void runScript(const QString&); 0131 0132 void showSearchBar(); 0133 void showExtendedSearchBar(); 0134 void findNext(); 0135 void findPrev(); 0136 void searchBarDeleted(); 0137 0138 /** sets the status message, or cached it, if the StatusBar is blocked. 0139 * Use this method instead of "emit setStatusBarText" 0140 */ 0141 void setStatusMessage(const QString&); 0142 /** Shows an important status message. It makes sure the message is displayed, 0143 * by blocking the statusbarText for 3 seconds 0144 */ 0145 void showImportantStatusMessage(const QString&); 0146 /** Blocks the StatusBar for new messages, so the currently shown one won't be overridden 0147 */ 0148 void blockStatusBar(); 0149 /** Removes the block from the StatusBar, and shows the last one of the StatusMessages that 0150 where set during the block 0151 **/ 0152 void unblockStatusBar(); 0153 0154 private: 0155 Worksheet* m_worksheet{nullptr}; 0156 WorksheetView* m_worksheetview{nullptr}; 0157 SearchBar* m_searchBar{nullptr}; 0158 QPointer<ScriptEditorWidget> m_scriptEditor; 0159 0160 QAction* m_evaluate; 0161 QAction* m_restart; 0162 KSelectAction* m_zoom; 0163 QAction* m_currectZoomAction{nullptr}; 0164 QAction* m_save; 0165 QAction* m_findNext; 0166 QAction* m_findPrev; 0167 KToggleAction* m_typeset; 0168 KToggleAction* m_highlight; 0169 KToggleAction* m_completion; 0170 KToggleAction* m_exprNumbering; 0171 KToggleAction* m_animateWorksheet; 0172 KToggleAction* m_embeddedMath; 0173 QVector<QAction*> m_editActions; 0174 0175 QString m_cachedStatusMessage; 0176 bool m_statusBarBlocked{false}; 0177 unsigned int m_sessionStatusCounter{0}; 0178 const QRegularExpression m_zoomRegexp{QLatin1String("(?:%?(\\d+(?:\\.\\d+)?)(?:%|\\s*))")}; 0179 0180 private Q_SLOTS: 0181 void documentationRequested(const QString&); 0182 }; 0183 0184 #endif // CANTORPART_H