#ifndef NOTEBOOKMGR_H #define NOTEBOOKMGR_H #include #include #include #include #include "namebasedserver.h" #include "sessionconfig.h" #include "global.h" #include "notebook/notebook.h" namespace vnotex { class IVersionController; class IVersionControllerFactory; class INotebookConfigMgr; class INotebookConfigMgrFactory; class INotebookBackend; class INotebookBackendFactory; class INotebookFactory; class NotebookParameters; class NotebookMgr : public QObject { Q_OBJECT public: explicit NotebookMgr(QObject *p_parent = nullptr); void init(); QSharedPointer getBundleNotebookFactory() const; QList> getAllNotebookFactories() const; QList> getAllVersionControllerFactories() const; QList> getAllNotebookConfigMgrFactories() const; QList> getAllNotebookBackendFactories() const; QSharedPointer createNotebookBackend(const QString &p_backendName, const QString &p_rootFolderPath) const; QSharedPointer createVersionController(const QString &p_controllerName) const; QSharedPointer createNotebookConfigMgr(const QString &p_mgrName, const QSharedPointer &p_backend) const; void loadNotebooks(); QSharedPointer newNotebook(const QSharedPointer &p_parameters); void importNotebook(const QSharedPointer &p_notebook); const QVector> &getNotebooks() const; ID getCurrentNotebookId() const; // Find the notebook with the same directory as root folder. QSharedPointer findNotebookByRootFolderPath(const QString &p_rootFolderPath) const; QSharedPointer findNotebookById(ID p_id) const; void closeNotebook(ID p_id); void removeNotebook(ID p_id); public slots: void setCurrentNotebook(ID p_notebookId); signals: void notebooksUpdated(); void notebookUpdated(const Notebook *p_notebook); void notebookAboutToClose(const Notebook *p_notebook); void notebookAboutToRemove(const Notebook *p_notebook); void currentNotebookChanged(const QSharedPointer &p_notebook); private: void initVersionControllerServer(); void initConfigMgrServer(); void initBackendServer(); void initNotebookServer(); void saveNotebooksToConfig() const; void readNotebooksFromConfig(); void loadCurrentNotebookId(); QSharedPointer readNotebookFromConfig(const SessionConfig::NotebookItem &p_item); void setCurrentNotebookAfterUpdate(); void addNotebook(const QSharedPointer &p_notebook); QSharedPointer> m_versionControllerServer; QSharedPointer> m_configMgrServer; QSharedPointer> m_backendServer; QSharedPointer> m_notebookServer; QVector> m_notebooks; ID m_currentNotebookId = 0; }; } // ns vnotex #endif // NOTEBOOKMGR_H