File indexing completed on 2024-05-12 16:28:23

0001 /*
0002  * This file is part of the KDE project
0003  * 
0004  * Copyright (C) 2013 Shantanu Tushar <shantanu@kde.org>
0005  * Copyright (C) 2013 Sujith Haridasan <sujith.h@gmail.com>
0006  * Copyright (C) 2013 Arjen Hiemstra <ahiemstra@heimr.nl>
0007  * 
0008  * This library is free software; you can redistribute it and/or
0009  * modify it under the terms of the GNU Library General Public
0010  * License as published by the Free Software Foundation; either
0011  * version 2 of the License, or (at your option) any later version.
0012  * 
0013  * This library is distributed in the hope that it will be useful,
0014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0016  * Library General Public License for more details.
0017  * 
0018  * You should have received a copy of the GNU Library General Public License
0019  * along with this library; see the file COPYING.LIB.  If not, write to
0020  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0021  * Boston, MA 02110-1301, USA.
0022  * 
0023  */
0024 
0025 #include "ComponentsKoCanvasController.h"
0026 
0027 #include <QPoint>
0028 #include <QSize>
0029 #include <QGraphicsWidget>
0030 
0031 #include <QDebug>
0032 
0033 #include <KoCanvasBase.h>
0034 
0035 using namespace Calligra::Components;
0036 
0037 class ComponentsKoCanvasController::Private
0038 {
0039 public:
0040     Private() : canvas(0) { }
0041     KoCanvasBase *canvas;
0042 };
0043 
0044 ComponentsKoCanvasController::ComponentsKoCanvasController(KActionCollection* actionCollection)
0045     : KoCanvasController(actionCollection), d(new Private)
0046 {
0047 }
0048 
0049 ComponentsKoCanvasController::~ComponentsKoCanvasController()
0050 {
0051     delete d;
0052 }
0053 
0054 void ComponentsKoCanvasController::setVastScrolling(qreal factor)
0055 {
0056     Q_UNUSED(factor)
0057 }
0058 
0059 void ComponentsKoCanvasController::setZoomWithWheel(bool zoom)
0060 {
0061     Q_UNUSED(zoom)
0062 }
0063 
0064 void ComponentsKoCanvasController::updateDocumentSize(const QSize& sz, bool recalculateCenter)
0065 {
0066     setDocumentSize(sz);
0067     emit documentSizeChanged(sz);
0068 }
0069 
0070 void ComponentsKoCanvasController::setScrollBarValue(const QPoint& value)
0071 {
0072     setDocumentOffset(const_cast<QPoint&>(value));
0073     proxyObject->emitMoveDocumentOffset(value);
0074     emit documentPositionChanged(value);
0075 }
0076 
0077 QPoint ComponentsKoCanvasController::scrollBarValue() const
0078 {
0079     return QPoint();
0080 }
0081 
0082 void ComponentsKoCanvasController::pan(const QPoint& distance)
0083 {
0084     QPoint offset = documentOffset() + distance;
0085     setDocumentOffset(offset);
0086     proxyObject->emitMoveDocumentOffset(offset);
0087     emit documentPositionChanged(offset);
0088 }
0089 
0090 QPointF ComponentsKoCanvasController::preferredCenter() const
0091 {
0092     return QPointF();
0093 }
0094 
0095 void ComponentsKoCanvasController::setPreferredCenter(const QPointF& viewPoint)
0096 {
0097     Q_UNUSED(viewPoint)
0098 }
0099 
0100 void ComponentsKoCanvasController::recenterPreferred()
0101 {
0102 }
0103 
0104 void ComponentsKoCanvasController::zoomTo(const QRect& rect)
0105 {
0106     Q_UNUSED(rect)
0107 }
0108 
0109 void ComponentsKoCanvasController::zoomBy(const QPoint& center, qreal zoom)
0110 {
0111     Q_UNUSED(center)
0112     Q_UNUSED(zoom)
0113 }
0114 
0115 void ComponentsKoCanvasController::zoomOut(const QPoint& center)
0116 {
0117     Q_UNUSED(center)
0118 }
0119 
0120 void ComponentsKoCanvasController::zoomIn(const QPoint& center)
0121 {
0122     Q_UNUSED(center)
0123 }
0124 
0125 void ComponentsKoCanvasController::ensureVisible(KoShape* shape)
0126 {
0127     Q_UNUSED(shape)
0128 }
0129 
0130 void ComponentsKoCanvasController::ensureVisible(const QRectF& rect, bool smooth)
0131 {
0132     Q_UNUSED(rect)
0133     Q_UNUSED(smooth)
0134 }
0135 
0136 int ComponentsKoCanvasController::canvasOffsetY() const
0137 {
0138     return 0;
0139 }
0140 
0141 int ComponentsKoCanvasController::canvasOffsetX() const
0142 {
0143     return 0;
0144 }
0145 
0146 int ComponentsKoCanvasController::visibleWidth() const
0147 {
0148     return 0;
0149 }
0150 
0151 int ComponentsKoCanvasController::visibleHeight() const
0152 {
0153     return 0;
0154 }
0155 
0156 KoCanvasBase* ComponentsKoCanvasController::canvas() const
0157 {
0158     return d->canvas;
0159 }
0160 
0161 void ComponentsKoCanvasController::setCanvas(KoCanvasBase* canvas)
0162 {
0163     d->canvas = canvas;
0164     canvas->setCanvasController(this);
0165     proxyObject->emitCanvasSet(this);
0166 }
0167 
0168 void ComponentsKoCanvasController::setDrawShadow(bool drawShadow)
0169 {
0170     Q_UNUSED(drawShadow)
0171 }
0172 
0173 QSize ComponentsKoCanvasController::viewportSize() const
0174 {
0175     QGraphicsWidget *canvasWidget = dynamic_cast<QGraphicsWidget*>(d->canvas);
0176     return canvasWidget->size().toSize();
0177 }
0178 
0179 void ComponentsKoCanvasController::scrollContentsBy(int dx, int dy)
0180 {
0181     Q_UNUSED(dx)
0182     Q_UNUSED(dy)
0183 }
0184 
0185 QSize ComponentsKoCanvasController::documentSize()
0186 {
0187     return KoCanvasController::documentSize();
0188 }
0189