File indexing completed on 2024-04-28 16:13:35
0001 /* 0002 * This file is part of the KDE project 0003 * 0004 * Copyright (C) 2013 Arjen Hiemstra <ahiemstra@heimr.nl> 0005 * 0006 * This library is free software; you can redistribute it and/or 0007 * modify it under the terms of the GNU Library General Public 0008 * License as published by the Free Software Foundation; either 0009 * version 2 of the License, or (at your option) any later version. 0010 * 0011 * This library is distributed in the hope that it will be useful, 0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0014 * Library General Public License for more details. 0015 * 0016 * You should have received a copy of the GNU Library General Public License 0017 * along with this library; see the file COPYING.LIB. If not, write to 0018 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0019 * Boston, MA 02110-1301, USA. 0020 * 0021 */ 0022 0023 #ifndef CALLIGRA_COMPONENTS_VIEW_H 0024 #define CALLIGRA_COMPONENTS_VIEW_H 0025 0026 #include <QQuickPaintedItem> 0027 0028 namespace Calligra { 0029 namespace Components { 0030 0031 class Document; 0032 0033 /** 0034 * \brief The view provides a View object for viewing Documents. 0035 * 0036 * The View object provides a view on a document. 0037 */ 0038 0039 class View : public QQuickPaintedItem 0040 { 0041 Q_OBJECT 0042 /** 0043 * \property document 0044 * \brief The document this object provides a view on. 0045 * 0046 * \default null 0047 * \get document() const 0048 * \set setDocument() 0049 * \notify documentChanged() 0050 */ 0051 Q_PROPERTY(Calligra::Components::Document* document READ document WRITE setDocument NOTIFY documentChanged) 0052 /** 0053 * \property zoom 0054 * \brief The zoom level the view renders the document at. 0055 * 0056 * \note For more extensive control, use a ViewController object. 0057 * 0058 * \default -1.0 when #document is null or #document is not loaded. 1.0 otherwise. 0059 * \get zoom() const 0060 * \set setZoom() 0061 * \notify zoomChanged() 0062 */ 0063 Q_PROPERTY(float zoom READ zoom WRITE setZoom NOTIFY zoomChanged) 0064 0065 public: 0066 /** 0067 * Constructor. 0068 * 0069 * \param parent The parent item. 0070 */ 0071 explicit View(QQuickItem* parent = 0); 0072 /** 0073 * Destructor. 0074 */ 0075 ~View() override; 0076 0077 /** 0078 * Inherited from QQuickPaintedItem. 0079 */ 0080 void paint(QPainter* painter) override; 0081 0082 /** 0083 * Getter for property #document. 0084 */ 0085 Document* document() const; 0086 /** 0087 * Setter for property #document. 0088 */ 0089 void setDocument(Document* newValue); 0090 0091 /** 0092 * Getter for property #zoom. 0093 */ 0094 float zoom() const; 0095 /** 0096 * Setter for property #zoom. 0097 */ 0098 void setZoom(float newValue); 0099 0100 Q_SIGNALS: 0101 /** 0102 * \brief Emitted when a link in the document is clicked. 0103 * 0104 * \param url The URL of the link that was clicked. For internal links, the protocol 0105 * `document://` will be used. 0106 */ 0107 void linkClicked(const QUrl& url); 0108 0109 /** 0110 * Notify signal for property #document. 0111 */ 0112 void documentChanged(); 0113 /** 0114 * Notify signal for property #zoom. 0115 */ 0116 void zoomChanged(); 0117 0118 protected: 0119 /** 0120 * Inherited from QQuickPaintedItem. 0121 */ 0122 void geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry) override; 0123 0124 private: 0125 class Private; 0126 Private* const d; 0127 }; 0128 0129 } // Namespace Components 0130 } // Namespace Calligra 0131 0132 Q_DECLARE_METATYPE(Calligra::Components::View*) 0133 0134 #endif // CALLIGRA_COMPONENTS_VIEW_H