File indexing completed on 2024-05-12 12:58:01
0001 /* 0002 * This file is part of the KDE project 0003 * 0004 * SPDX-FileCopyrightText: 2013 Arjen Hiemstra <ahiemstra@heimr.nl> 0005 * 0006 * SPDX-License-Identifier: LGPL-2.0-or-later 0007 * 0008 */ 0009 0010 #ifndef CALLIGRA_COMPONENTS_VIEW_H 0011 #define CALLIGRA_COMPONENTS_VIEW_H 0012 0013 #include <QQuickPaintedItem> 0014 0015 namespace Calligra { 0016 namespace Components { 0017 0018 class Document; 0019 0020 /** 0021 * \brief The view provides a View object for viewing Documents. 0022 * 0023 * The View object provides a view on a document. 0024 */ 0025 0026 class View : public QQuickPaintedItem 0027 { 0028 Q_OBJECT 0029 /** 0030 * \property document 0031 * \brief The document this object provides a view on. 0032 * 0033 * \default null 0034 * \get document() const 0035 * \set setDocument() 0036 * \notify documentChanged() 0037 */ 0038 Q_PROPERTY(Calligra::Components::Document* document READ document WRITE setDocument NOTIFY documentChanged) 0039 /** 0040 * \property zoom 0041 * \brief The zoom level the view renders the document at. 0042 * 0043 * \note For more extensive control, use a ViewController object. 0044 * 0045 * \default -1.0 when #document is null or #document is not loaded. 1.0 otherwise. 0046 * \get zoom() const 0047 * \set setZoom() 0048 * \notify zoomChanged() 0049 */ 0050 Q_PROPERTY(float zoom READ zoom WRITE setZoom NOTIFY zoomChanged) 0051 0052 public: 0053 /** 0054 * Constructor. 0055 * 0056 * \param parent The parent item. 0057 */ 0058 explicit View(QQuickItem* parent = 0); 0059 /** 0060 * Destructor. 0061 */ 0062 ~View() override; 0063 0064 /** 0065 * Inherited from QQuickPaintedItem. 0066 */ 0067 void paint(QPainter* painter) override; 0068 0069 /** 0070 * Getter for property #document. 0071 */ 0072 Document* document() const; 0073 /** 0074 * Setter for property #document. 0075 */ 0076 void setDocument(Document* newValue); 0077 0078 /** 0079 * Getter for property #zoom. 0080 */ 0081 float zoom() const; 0082 /** 0083 * Setter for property #zoom. 0084 */ 0085 void setZoom(float newValue); 0086 0087 Q_SIGNALS: 0088 /** 0089 * \brief Emitted when a link in the document is clicked. 0090 * 0091 * \param url The URL of the link that was clicked. For internal links, the protocol 0092 * `document://` will be used. 0093 */ 0094 void linkClicked(const QUrl& url); 0095 0096 /** 0097 * Notify signal for property #document. 0098 */ 0099 void documentChanged(); 0100 /** 0101 * Notify signal for property #zoom. 0102 */ 0103 void zoomChanged(); 0104 0105 protected: 0106 /** 0107 * Inherited from QQuickPaintedItem. 0108 */ 0109 void geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry) override; 0110 0111 private: 0112 class Private; 0113 Private* const d; 0114 }; 0115 0116 } // Namespace Components 0117 } // Namespace Calligra 0118 0119 Q_DECLARE_METATYPE(Calligra::Components::View*) 0120 0121 #endif // CALLIGRA_COMPONENTS_VIEW_H