File indexing completed on 2024-05-19 12:17:42
0001 /* 0002 SPDX-FileCopyrightText: 2008 Pino Toscano <pino@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef _OKULAR_SAVEINTERFACE_H_ 0008 #define _OKULAR_SAVEINTERFACE_H_ 0009 0010 #include "../core/okularcore_export.h" 0011 0012 #include <QObject> 0013 0014 namespace Okular 0015 { 0016 class AnnotationProxy; 0017 0018 /** 0019 * @short Abstract interface for saving 0020 * 0021 * This interface defines a way to save (or help saving) the document opened 0022 * by the Generator. 0023 * 0024 * How to use it in a custom Generator: 0025 * @code 0026 class MyGenerator : public Okular::Generator, public Okular::SaveInterface 0027 { 0028 Q_OBJECT 0029 Q_INTERFACES( Okular::SaveInterface ) 0030 0031 ... 0032 }; 0033 * @endcode 0034 * and - of course - implementing its methods. 0035 */ 0036 class OKULARCORE_EXPORT SaveInterface 0037 { 0038 public: 0039 /** 0040 * The possible options for the saving. 0041 */ 0042 enum SaveOption { 0043 NoOption = 0, 0044 SaveChanges = 1 ///< The possibility to save with the current changes to the document. 0045 }; 0046 Q_DECLARE_FLAGS(SaveOptions, SaveOption) 0047 0048 SaveInterface() 0049 { 0050 } 0051 0052 /** 0053 * Destroys the save interface. 0054 */ 0055 virtual ~SaveInterface() 0056 { 0057 } 0058 0059 SaveInterface(const SaveInterface &) = delete; 0060 SaveInterface &operator=(const SaveInterface &) = delete; 0061 0062 /** 0063 * Query for the supported saving options. 0064 * 0065 * @note NoOption is never queried 0066 */ 0067 virtual bool supportsOption(SaveOption option) const = 0; 0068 0069 /** 0070 * Save to the specified @p fileName with the specified @p options. 0071 */ 0072 virtual bool save(const QString &fileName, SaveOptions options, QString *errorText) = 0; 0073 0074 /** 0075 * Returns the annotation proxy. Generators can return NULL if native 0076 * annotations are not supported. 0077 * 0078 * @note Returning NULL is equivalent to returning an AnnotationProxy 0079 * that doesn't support any capability. 0080 * @since 0.15 (KDE 4.9) 0081 */ 0082 virtual AnnotationProxy *annotationProxy() const = 0; 0083 }; 0084 0085 } 0086 0087 Q_DECLARE_INTERFACE(Okular::SaveInterface, "org.kde.okular.SaveInterface/0.3") 0088 Q_DECLARE_OPERATORS_FOR_FLAGS(Okular::SaveInterface::SaveOptions) 0089 0090 #endif