File indexing completed on 2024-10-06 04:26:02
0001 /* 0002 SPDX-FileCopyrightText: 1998-2007 Sebastian Trueg <trueg@k3b.org> 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 0006 #ifndef _K3B_PROJECT_MANAGER_H_ 0007 #define _K3B_PROJECT_MANAGER_H_ 0008 0009 #include "k3bdoc.h" 0010 0011 #include <QList> 0012 #include <QObject> 0013 0014 0015 class QUrl; 0016 0017 namespace K3b { 0018 0019 class ProjectManager : public QObject 0020 { 0021 Q_OBJECT 0022 0023 public: 0024 explicit ProjectManager( QObject* parent = 0 ); 0025 ~ProjectManager() override; 0026 0027 QList<Doc*> projects() const; 0028 0029 /** 0030 * Create a new project including loading user defaults and creating 0031 * the dcop interface. 0032 */ 0033 Doc* createProject( Doc::Type type ); 0034 0035 /** 0036 * Opens a K3b project. 0037 * \return 0 if url does not point to a valid k3b project file, the new project otherwise. 0038 */ 0039 Doc* openProject( const QUrl &url ); 0040 0041 /** 0042 * saves the document under filename and format. 0043 */ 0044 bool saveProject( Doc*, const QUrl &url ); 0045 0046 Doc* activeDoc() const { return activeProject(); } 0047 Doc* activeProject() const; 0048 Doc* findByUrl( const QUrl& url ); 0049 bool isEmpty() const; 0050 0051 /** 0052 * \return D-BUS object path of given project 0053 */ 0054 QString dbusPath( Doc* doc ) const; 0055 0056 public Q_SLOTS: 0057 void addProject( K3b::Doc* ); 0058 void removeProject( K3b::Doc* ); 0059 void setActive( K3b::Doc* ); 0060 void loadDefaults( K3b::Doc* ); 0061 0062 Q_SIGNALS: 0063 void newProject( K3b::Doc* ); 0064 void projectSaved( K3b::Doc* ); 0065 void closingProject( K3b::Doc* ); 0066 void projectChanged( K3b::Doc* doc ); 0067 void activeProjectChanged( K3b::Doc* ); 0068 0069 private Q_SLOTS: 0070 void slotProjectChanged( K3b::Doc* doc ); 0071 0072 private: 0073 // used internal 0074 Doc* createEmptyProject( Doc::Type ); 0075 0076 class Private; 0077 Private* d; 0078 }; 0079 } 0080 0081 #endif