File indexing completed on 2024-04-28 04:32:48

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_VIEW_H
0008 #define OKULAR_VIEW_H
0009 
0010 #include "okularcore_export.h"
0011 #include <QObject>
0012 class QString;
0013 class QVariant;
0014 
0015 namespace Okular
0016 {
0017 class Document;
0018 class DocumentPrivate;
0019 class ViewPrivate;
0020 
0021 /**
0022  * @short View on the document
0023  *
0024  * The View class represents a "view" on a document.
0025  * A view can be registered with only a document at a time.
0026  *
0027  * @since 0.7 (KDE 4.1)
0028  */
0029 class OKULARCORE_EXPORT View
0030 {
0031     /// @cond PRIVATE
0032     friend class Document;
0033     friend class DocumentPrivate;
0034     /// @endcond
0035 
0036 public:
0037     /**
0038      * The capabilities of a view
0039      */
0040     enum ViewCapability {
0041         Zoom,             ///< Possibility to get/set the zoom of the view
0042         ZoomModality,     ///< Possibility to get/set the zoom mode of the view
0043         Continuous,       ///< Possibility to toggle continuous mode @since 1.9
0044         ViewModeModality, ///< Possibility to get/set the view mode @since 1.9
0045         TrimMargins       ///< Possibility to toggle trim-margins mode @since 1.9
0046     };
0047 
0048     /**
0049      * The access type of a capability
0050      */
0051     enum CapabilityFlag {
0052         NoFlag = 0,
0053         CapabilityRead = 0x01,        ///< Possibility to read a capability
0054         CapabilityWrite = 0x02,       ///< Possibility to write a capability
0055         CapabilitySerializable = 0x04 ///< The capability is suitable for being serialized/deserialized
0056     };
0057     Q_DECLARE_FLAGS(CapabilityFlags, CapabilityFlag)
0058 
0059     virtual ~View();
0060 
0061     /**
0062      * Return the document which this view is associated to,
0063      * or null if it is not associated with any document.
0064      */
0065     Document *viewDocument() const;
0066 
0067     /**
0068      * Return the name of this view.
0069      */
0070     QString name() const;
0071 
0072     /**
0073      * Query whether the view support the specified @p capability.
0074      */
0075     virtual bool supportsCapability(ViewCapability capability) const;
0076 
0077     /**
0078      * Query the flags for the specified @p capability.
0079      */
0080     virtual CapabilityFlags capabilityFlags(ViewCapability capability) const;
0081 
0082     /**
0083      * Query the value of the specified @p capability.
0084      */
0085     virtual QVariant capability(ViewCapability capability) const;
0086 
0087     /**
0088      * Sets a new value for the specified @p capability.
0089      */
0090     virtual void setCapability(ViewCapability capability, const QVariant &option);
0091 
0092 protected:
0093     /**
0094      * Construct a new view with the specified @p name.
0095      */
0096     explicit View(const QString &name);
0097 
0098     /// @cond PRIVATE
0099     Q_DECLARE_PRIVATE(View)
0100     ViewPrivate *d_ptr;
0101     /// @endcond
0102 
0103 private:
0104     Q_DISABLE_COPY(View)
0105 };
0106 
0107 }
0108 
0109 Q_DECLARE_OPERATORS_FOR_FLAGS(Okular::View::CapabilityFlags)
0110 
0111 #endif