File indexing completed on 2025-02-16 09:45:45
0001 /* 0002 SPDX-FileCopyrightText: 2009 Alexander Rieder <alexanderrieder@gmail.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 0008 #ifndef CANTOR_H 0009 #define CANTOR_H 0010 0011 #include <QObject> 0012 #include <KParts/MainWindow> 0013 0014 #include <QList> 0015 #include <QStringList> 0016 #include <QMap> 0017 0018 #include "lib/panelpluginhandler.h" 0019 #include "lib/panelplugin.h" 0020 0021 class QTabWidget; 0022 class KRecentFilesAction; 0023 0024 namespace Cantor{ 0025 class WorksheetAccessInterface; 0026 } 0027 0028 namespace KParts{ 0029 class ReadWritePart; 0030 } 0031 0032 /** 0033 * This is the application "Shell". It has a menubar, toolbar, and 0034 * statusbar but relies on the "Part" to do all the real work. 0035 */ 0036 class CantorShell : public KParts::MainWindow 0037 { 0038 Q_OBJECT 0039 public: 0040 /** 0041 * Default Constructor 0042 */ 0043 CantorShell(); 0044 0045 /** 0046 * Default Destructor 0047 */ 0048 ~CantorShell() override; 0049 0050 Cantor::WorksheetAccessInterface* currentWorksheetAccessInterface(); 0051 void addWorksheet(); 0052 0053 protected: 0054 /** 0055 * This method is called when it is time for the app to save its 0056 * properties for session management purposes. 0057 */ 0058 void saveProperties(KConfigGroup &) override; 0059 0060 /** 0061 * This method is called when this app is restored. The KConfig 0062 * object points to the session management config file that was saved 0063 * with @ref saveProperties 0064 */ 0065 void readProperties(const KConfigGroup &) override; 0066 0067 Q_SIGNALS: 0068 void showHelp(QString); 0069 void hierarchyChanged(QStringList, QStringList, QList<int>); 0070 void hierarhyEntryNameChange(QString, QString, int); 0071 void requestScrollToHierarchyEntry(QString); 0072 void settingsChanges(); 0073 void requestDocumentation(const QString&); 0074 0075 public Q_SLOTS: 0076 void addWorksheet(const QString&); 0077 /// Use this method/slot to load whatever file/URL you have 0078 void load(const QUrl&); 0079 0080 private Q_SLOTS: 0081 void fileNew(); 0082 void fileOpen(); 0083 void onWorksheetSave(const QUrl&); 0084 void optionsConfigureKeys(); 0085 0086 void activateWorksheet(int index); 0087 0088 void setTabCaption(const QString&, const QIcon&); 0089 void updateBackendForPart(const QString&); 0090 void closeTab(int index = -1); 0091 0092 void showSettings(); 0093 0094 void openExample(); 0095 0096 void initPanels(); 0097 void updatePanel(); 0098 void updateNewSubmenu(); 0099 0100 void pluginVisibilityRequested(); 0101 void pluginCommandRunRequested(const QString&); 0102 0103 private: 0104 void setupActions(); 0105 void closeEvent(QCloseEvent*) override; 0106 bool reallyClose(bool checkAllParts = true); 0107 bool reallyCloseThisPart(KParts::ReadWritePart*); 0108 void updateWindowTitle(const QString&, bool modified = false); 0109 void saveDockPanelsState(KParts::ReadWritePart*); 0110 KParts::ReadWritePart* findPart(QWidget*); 0111 0112 private: 0113 QMap<KParts::ReadWritePart*, QStringList> m_pluginsVisibility; 0114 QMap<KParts::ReadWritePart*, Cantor::PanelPluginHandler::PanelStates> m_pluginsStates; 0115 QList<KParts::ReadWritePart*> m_parts; 0116 QMap<KParts::ReadWritePart*, QString> m_parts2Backends; 0117 KParts::ReadWritePart* m_part{nullptr}; 0118 QTabWidget* m_tabWidget; 0119 QList<QDockWidget*> m_panels; 0120 QList<QAction*> m_newBackendActions; 0121 KRecentFilesAction* m_recentProjectsAction; 0122 0123 Cantor::PanelPluginHandler m_panelHandler{nullptr}; 0124 0125 // For better UX: set previous used filter in "Open" action as default filter 0126 QString m_previousFilter; 0127 }; 0128 0129 #endif // CANTOR_H