File indexing completed on 2024-05-05 17:04:25
0001 /* This file is part of the KDE project 0002 * Copyright (C) 2012 Arjen Hiemstra <ahiemstra@heimr.nl> 0003 * 0004 * This program is free software; you can redistribute it and/or modify 0005 * it under the terms of the GNU General Public License as published by 0006 * the Free Software Foundation; either version 2 of the License, or 0007 * (at your option) any later version. 0008 * 0009 * This program is distributed in the hope that it will be useful, 0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0012 * GNU General Public License for more details. 0013 * 0014 * You should have received a copy of the GNU General Public License 0015 * along with this program; if not, write to the Free Software 0016 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 0017 */ 0018 0019 #ifndef DOCUMENTMANAGER_H 0020 #define DOCUMENTMANAGER_H 0021 0022 #include <QObject> 0023 #include <QVariantMap> 0024 0025 #include <KWDocument.h> 0026 0027 class RecentFileManager; 0028 class Settings; 0029 class ProgressProxy; 0030 class KoPart; 0031 class DocumentManager : public QObject 0032 { 0033 Q_OBJECT 0034 public: 0035 KoDocument* document() const; 0036 Q_INVOKABLE QObject* doc() const; 0037 KoPart* part(const QString& type = WORDS_MIME_TYPE); 0038 ProgressProxy* progressProxy() const; 0039 Settings* settingsManager() const; 0040 void setSettingsManager(Settings* newManager); 0041 RecentFileManager* recentFileManager() const; 0042 bool isTemporaryFile() const; 0043 0044 Q_INVOKABLE void setDocAndPart(KoDocument* document, KoPart* part); 0045 0046 public Q_SLOTS: 0047 void newDocument(int width, int height, float resolution); 0048 void newDocument(const QVariantMap& options); 0049 void openDocument(const QString& document, bool import = false); 0050 void closeDocument(); 0051 bool save(); 0052 void saveAs(const QString &filename, const QString &mimetype); 0053 void reload(); 0054 void setTemporaryFile(bool temp); 0055 0056 static DocumentManager* instance(); 0057 0058 Q_SIGNALS: 0059 void documentChanged(); 0060 void aboutToDeleteDocument(); 0061 void documentSaved(); 0062 0063 private: 0064 explicit DocumentManager(QObject *parent = 0); 0065 ~DocumentManager() override; 0066 0067 class Private; 0068 Private * const d; 0069 0070 static DocumentManager *sm_instance; 0071 0072 private Q_SLOTS: 0073 void delayedNewDocument(); 0074 void delayedSaveAs(); 0075 void delayedOpenDocument(); 0076 }; 0077 0078 #endif // DOCUMENTMANAGER_H