File indexing completed on 2024-05-05 17:09:08
0001 /* 0002 * This file is part of the KDE project 0003 * Copyright (C) 2013 Arjen Hiemstra <ahiemstra@heimr.nl> 0004 * 0005 * This program is free software; you can redistribute it and/or modify 0006 * it under the terms of the GNU General Public License as published by 0007 * the Free Software Foundation; either version 2 of the License, or 0008 * (at your option) any later version. 0009 * 0010 * This program is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0013 * GNU General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU General Public License 0016 * along with this program; if not, write to the Free Software 0017 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 0018 */ 0019 0020 #ifndef CQCANVASCONTROLLERITEM_H 0021 #define CQCANVASCONTROLLERITEM_H 0022 0023 #include <QDeclarativeItem> 0024 0025 class CQCanvasControllerItem : public QDeclarativeItem 0026 { 0027 Q_OBJECT 0028 Q_PROPERTY(QDeclarativeItem* canvas READ canvas WRITE setCanvas NOTIFY canvasChanged) 0029 Q_PROPERTY(QDeclarativeItem* flickable READ flickable WRITE setFlickable NOTIFY flickableChanged) 0030 Q_PROPERTY(QSize documentSize READ documentSize NOTIFY documentSizeChanged) 0031 Q_PROPERTY(qreal zoom READ zoom WRITE setZoom NOTIFY zoomChanged) 0032 Q_PROPERTY(qreal minimumZoom READ minimumZoom WRITE setMinimumZoom NOTIFY minimumZoomChanged) 0033 Q_PROPERTY(qreal maximumZoom READ maximumZoom WRITE setMaximumZoom NOTIFY maximumZoomChanged) 0034 public: 0035 explicit CQCanvasControllerItem(QDeclarativeItem* parent = 0); 0036 ~CQCanvasControllerItem(); 0037 0038 void paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget* ); 0039 0040 QDeclarativeItem* canvas() const; 0041 void setCanvas(QDeclarativeItem* canvas); 0042 0043 QDeclarativeItem* flickable() const; 0044 void setFlickable(QDeclarativeItem* item); 0045 0046 QSize documentSize() const; 0047 0048 qreal zoom() const; 0049 void setZoom(qreal newZoom); 0050 /** 0051 * Zoom to fit page, but without changing the mode. This is used for 0052 * reader mode in Calligra Gemini. 0053 */ 0054 Q_INVOKABLE void zoomToPage(); 0055 0056 qreal minimumZoom() const; 0057 void setMinimumZoom(qreal newZoom); 0058 0059 qreal maximumZoom() const; 0060 void setMaximumZoom(qreal newZoom); 0061 0062 public Q_SLOTS: 0063 void beginZoomGesture(); 0064 void endZoomGesture(); 0065 0066 void zoomBy(qreal amount, const QPointF& center = QPointF()); 0067 0068 void fitToWidth(qreal width); 0069 0070 void returnToBounds(); 0071 0072 Q_SIGNALS: 0073 void canvasChanged(); 0074 void flickableChanged(); 0075 void documentSizeChanged(); 0076 void zoomChanged(); 0077 void minimumZoomChanged(); 0078 void maximumZoomChanged(); 0079 void movingFastChanged(); 0080 0081 protected: 0082 virtual void geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry); 0083 virtual QVariant itemChange(GraphicsItemChange change, const QVariant& value); 0084 0085 private Q_SLOTS: 0086 void updateDocumentSize(const QSize& size); 0087 void updateDocumentPosition(const QPoint& pos); 0088 void canvasControllerChanged(); 0089 0090 private: 0091 class Private; 0092 Private * const d; 0093 }; 0094 0095 #endif // CQCANVASCONTROLLERITEM_H