[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [calligra/active-declarativecanvasitem-shantanu] active: Wrap the canvas item inside a declarative i
From:       Shantanu Tushar <shaan7in () gmail ! com>
Date:       2012-08-06 17:47:55
Message-ID: 20120806174755.9B335A6094 () git ! kde ! org
[Download RAW message or body]

Git commit 0ec5980b676c4448a7c77e7709461e12e6e34ff0 by Shantanu Tushar.
Committed on 06/08/2012 at 19:46.
Pushed by shantanu into branch 'active-declarativecanvasitem-shantanu'.

Wrap the canvas item inside a declarative item. Put that in a flickable,
let the canvascontroller act independently.
Smooth scroll on searches.

M  +1    -0    active/CMakeLists.txt
M  +31   -14   active/qml/Doc.qml
M  +42   -28   active/src/CACanvasController.cpp
M  +6    -1    active/src/CACanvasController.h
A  +131  -0    active/src/CACanvasItem.cpp     [License: GPL (v2+)]
A  +63   -0    active/src/CACanvasItem.h     [License: GPL (v2+)]
M  +3    -3    active/src/CAPresentationHandler.cpp
M  +2    -1    active/src/CAPresentationHandler.h
M  +1    -3    active/src/CASpreadsheetHandler.cpp
M  +2    -6    active/src/CATextDocumentHandler.cpp
M  +3    -1    active/src/MainWindow.cpp

http://commits.kde.org/calligra/0ec5980b676c4448a7c77e7709461e12e6e34ff0

diff --git a/active/CMakeLists.txt b/active/CMakeLists.txt
index 2dcff6a..2a05295 100644
--- a/active/CMakeLists.txt
+++ b/active/CMakeLists.txt
@@ -23,6 +23,7 @@ qt4_add_resources(calligra-active_RCC_SRCS ${calligra-active_RCCS})
 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/calligra_active_global.h.in \
${CMAKE_CURRENT_BINARY_DIR}/calligra_active_global.h)  
 set(calligra-active_SRCS
+    src/CACanvasItem.cpp
     src/CAPresentationHandler.cpp
     src/CASpreadsheetHandler.cpp
     src/CATextDocumentHandler.cpp
diff --git a/active/qml/Doc.qml b/active/qml/Doc.qml
index 1c7076f..10f84f9 100644
--- a/active/qml/Doc.qml
+++ b/active/qml/Doc.qml
@@ -30,7 +30,7 @@ Item {
 
     CADocumentController {
         id: docDocumentController
-        canvasController: canvas
+        canvasController: theCanvasController
         onDocumentOpened: {
             docRootRect.documentLoaded();
             docToolbars.initToolbars();
@@ -38,29 +38,46 @@ Item {
     }
 
     CanvasController {
-        id: canvas
+        id: theCanvasController
         anchors.fill: parent
-
-        cameraX: docFlickable.contentX
-        cameraY: docFlickable.contentY
+        caCanvasItem: canvasItem
 
         Flickable {
             id: docFlickable
             anchors.fill: parent
-            z: 1
+            contentWidth: canvasItem.width; contentHeight: canvasItem.height
+            contentX: Math.max(theCanvasController.cameraX - width/2, 0)
+            contentY: Math.max(theCanvasController.cameraY - height/2, 0)
 
-            contentWidth: canvas.docWidth; contentHeight: canvas.docHeight;
+            CACanvasItem {
+                id: canvasItem
+                editable: false
+//                 width: docRootRect.width
 
-            MouseArea {
-                anchors.fill: parent
-                z: 1
+                Rectangle {
+                    color: "red"; opacity: 0.1; radius: 10; anchors.fill: parent; z: \
2  
-                onClicked: docToolbars.toggle()
+                    MouseArea {
+                        anchors.fill: parent
+                        onClicked: docToolbars.toggle()
+                    }
+                }
+            }
+
+            Behavior on contentX {
+                NumberAnimation {
+                    duration: 1000
+                    easing.type: Easing.OutExpo
+                }
             }
-        }
 
-        onCameraXChanged: if (docFlickable.contentX != cameraX) \
                docFlickable.contentX = cameraX
-        onCameraYChanged: if (docFlickable.contentY != cameraY) \
docFlickable.contentY = cameraY +            Behavior on contentY {
+                NumberAnimation {
+                    duration: 1000
+                    easing.type: Easing.OutExpo
+                }
+            }
+        }
     }
 
     Toolbars {
diff --git a/active/src/CACanvasController.cpp b/active/src/CACanvasController.cpp
index 4325ddd..e24e0d8 100644
--- a/active/src/CACanvasController.cpp
+++ b/active/src/CACanvasController.cpp
@@ -24,12 +24,14 @@
 
 
 #include "CACanvasController.h"
+#include "CACanvasItem.h"
 
 #include <KoCanvasBase.h>
 #include <KoShape.h>
 #include <KoZoomController.h>
 #include <KoZoomHandler.h>
 
+#include <KDE/KActionCollection>
 #include <KDebug>
 
 #include <QPoint>
@@ -56,6 +58,10 @@ void CACanvasController::setZoomWithWheel (bool zoom)
 
 void CACanvasController::updateDocumentSize (const QSize& sz, bool \
recalculateCenter)  {
+    m_caCanvasItem->updateDocumentSize(sz, recalculateCenter);
+    KoCanvasController::setDocumentSize(sz);
+
+    return;
     m_documentSize = sz;
     emit docHeightChanged();
     emit docWidthChanged();
@@ -97,7 +103,8 @@ void CACanvasController::zoomTo (const QRect& rect)
 
 void CACanvasController::zoomBy (const QPoint& center, qreal zoom)
 {
-    //kDebug() << center << zoom;
+    proxyObject->emitZoomBy(zoom);
+    canvas()->canvasItem()->update();
 }
 
 void CACanvasController::zoomOut (const QPoint& center)
@@ -112,21 +119,13 @@ void CACanvasController::zoomIn (const QPoint& center)
 
 void CACanvasController::ensureVisible (KoShape* shape)
 {
-    setCameraX (shape->position().x());
-    setCameraY (shape->position().y());
+    ensureVisible(shape->boundingRect(), true);
 }
 
 void CACanvasController::ensureVisible (const QRectF& rect, bool smooth)
 {
-    if (smooth) {
-        setCameraY(rect.center().y());
-    } else {
-        int y = rect.center().y() - height()/2;
-        if (y<0) {
-            y = 0;
-        }
-        setCameraY(y);
-    }
+    setCameraX(rect.center().x());
+    setCameraY(rect.center().y());
 }
 
 int CACanvasController::canvasOffsetY() const
@@ -151,7 +150,7 @@ int CACanvasController::visibleHeight() const
 
 KoCanvasBase* CACanvasController::canvas() const
 {
-    return m_canvas;
+    return m_caCanvasItem->koCanvas();
 }
 
 KoCanvasControllerProxyObject* CACanvasController::canvasControllerProxyObject()
@@ -159,15 +158,29 @@ KoCanvasControllerProxyObject* \
CACanvasController::canvasControllerProxyObject()  return proxyObject;
 }
 
-void CACanvasController::setCanvas (KoCanvasBase* canvas)
+QObject* CACanvasController::caCanvasItem()
 {
-    QGraphicsWidget* widget = canvas->canvasItem();
-    widget->setParentItem (this);
-    canvas->setCanvasController (this);
-    widget->setVisible (true);
-    m_canvas = canvas;
+    return dynamic_cast<QObject*>(m_caCanvasItem);
+}
 
-    zoomToFit();
+void CACanvasController::setCACanvasItem(QObject* caCanvas)
+{
+    m_caCanvasItem = static_cast<CACanvasItem*>(caCanvas);
+}
+
+void CACanvasController::setCanvas (KoCanvasBase* canvas)
+{
+//     m_canvas = canvas;
+    canvas->setCanvasController(this);
+    m_caCanvasItem->setKoCanvas(canvas);
+    emit caCanvasItemChanged();
+//     QGraphicsWidget* widget = canvas->canvasItem();
+//     widget->setParentItem (this);
+//     canvas->setCanvasController (this);
+//     widget->setVisible (true);
+//     m_canvas = canvas;
+// 
+//     zoomToFit();
 }
 
 void CACanvasController::setDrawShadow (bool drawShadow)
@@ -221,6 +234,7 @@ void CACanvasController::setCameraY (int cameraY)
 
 void CACanvasController::centerToCamera()
 {
+    return;
     if (proxyObject) {
         proxyObject->emitMoveDocumentOffset (m_currentPoint);
     }
@@ -233,6 +247,7 @@ CACanvasController::~CACanvasController()
 
 void CACanvasController::zoomToFit()
 {
+    return;
     emit needsCanvasResize(QSizeF(width(), height()));
     emit docHeightChanged();
     emit docWidthChanged();
@@ -240,11 +255,14 @@ void CACanvasController::zoomToFit()
 
 void CACanvasController::updateCanvas()
 {
+    return;
     emit needCanvasUpdate();
 }
 
 void CACanvasController::geometryChanged (const QRectF& newGeometry, const QRectF& \
oldGeometry)  {
+    QDeclarativeItem::geometryChanged (newGeometry, oldGeometry);
+    return;
     if (m_canvas) {
         QGraphicsWidget* widget = m_canvas->canvasItem();
         widget->setParentItem (this);
@@ -253,7 +271,6 @@ void CACanvasController::geometryChanged (const QRectF& \
newGeometry, const QRect  
         zoomToFit();
     }
-    QDeclarativeItem::geometryChanged (newGeometry, oldGeometry);
 }
 
 KoZoomController* CACanvasController::zoomController()
@@ -266,15 +283,12 @@ KoZoomHandler* CACanvasController::zoomHandler()
     return m_zoomHandler;
 }
 
-void CACanvasController::setZoomController (KoZoomController* zoomController)
-{
-    m_zoomController = zoomController;
-    connect(m_zoomController, SIGNAL(zoomChanged(KoZoomMode::Mode,qreal)), \
                SLOT(updateZoomValue(KoZoomMode::Mode,qreal)));
-}
-
 void CACanvasController::setZoomHandler (KoZoomHandler* zoomHandler)
 {
-    m_zoomHandler = zoomHandler;
+    if (!m_zoomController) {
+        m_zoomHandler = zoomHandler;
+        m_zoomController = new KoZoomController(this, zoomHandler, new \
KActionCollection(this)); +    }
 }
 
 void CACanvasController::setZoom(qreal zoom)
diff --git a/active/src/CACanvasController.h b/active/src/CACanvasController.h
index 58fe084..2046b2b 100644
--- a/active/src/CACanvasController.h
+++ b/active/src/CACanvasController.h
@@ -31,6 +31,7 @@
 
 #include <QDeclarativeItem>
 
+class CACanvasItem;
 class KoCanvasBase;
 class KoZoomController;
 class KoZoomHandler;
@@ -44,6 +45,7 @@ class CACanvasController : public QDeclarativeItem, public \
                KoCanvasController
     Q_PROPERTY (int cameraX READ cameraX WRITE setCameraX NOTIFY cameraXChanged)
     Q_PROPERTY (int cameraY READ cameraY WRITE setCameraY NOTIFY cameraYChanged)
     Q_PROPERTY (qreal zoom READ zoom WRITE setZoom NOTIFY zoomChanged)
+    Q_PROPERTY (QObject* caCanvasItem READ caCanvasItem WRITE setCACanvasItem NOTIFY \
caCanvasItemChanged)  
 public:
     explicit CACanvasController (QDeclarativeItem* parent = 0);
@@ -72,6 +74,8 @@ public:
     virtual void setDrawShadow (bool drawShadow);
     virtual QSize viewportSize() const;
     virtual void scrollContentsBy (int dx, int dy);
+    QObject *caCanvasItem();
+    void setCACanvasItem(QObject *caCanvas);
 
     qreal docWidth() const;
     qreal docHeight() const;
@@ -86,7 +90,6 @@ public:
     KoZoomHandler* zoomHandler();
     KoZoomController* zoomController();
     void setZoomHandler (KoZoomHandler* zoomHandler);
-    void setZoomController (KoZoomController* zoomController);
 
 public slots:
     void centerToCamera();
@@ -102,6 +105,7 @@ private:
     QSizeF m_documentSize;
     QList<CADocumentInfo*> m_recentFiles;
     qreal m_zoom;
+    CACanvasItem *m_caCanvasItem;
 
 protected:
     virtual void geometryChanged (const QRectF& newGeometry, const QRectF& \
oldGeometry); @@ -114,6 +118,7 @@ signals:
     void needCanvasUpdate();
     void needsCanvasResize(const QSizeF canvasSize);
     void zoomChanged();
+    void caCanvasItemChanged();
 };
 
 #endif // CACANVASCONTROLLER_H
diff --git a/active/src/CACanvasItem.cpp b/active/src/CACanvasItem.cpp
new file mode 100644
index 0000000..0c56d8e
--- /dev/null
+++ b/active/src/CACanvasItem.cpp
@@ -0,0 +1,131 @@
+/*
+ * This file is part of the KDE project
+ *
+ * Copyright (C) 2012 Shantanu Tushar <shaan7in@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#include "CACanvasItem.h"
+
+#include <KoCanvasBase.h>
+
+#include <KDE/KDebug>
+#include <KoCanvasController.h>
+
+#include <QtGui/QGraphicsWidget>
+#include <QtCore/QTimer>
+
+CACanvasItem::CACanvasItem(QDeclarativeItem* parent)
+    : QDeclarativeItem(parent)
+    , m_koCanvas(0)
+    , m_shouldIgnoreGeometryChange(false)
+    , m_editable(false)
+{
+    setFlag (QGraphicsItem::ItemHasNoContents, false);
+}
+
+KoCanvasBase* CACanvasItem::koCanvas()
+{
+    return m_koCanvas;
+}
+
+void CACanvasItem::setKoCanvas(KoCanvasBase* koCanvas)
+{
+    if (!koCanvas)
+        return;
+    if (m_koCanvasGraphicsWidget) {
+        m_koCanvasGraphicsWidget->removeEventFilter(this);
+        m_koCanvasGraphicsWidget->disconnect(this);
+    }
+    m_koCanvas = koCanvas;
+    m_koCanvasGraphicsWidget = dynamic_cast<QGraphicsWidget*>(koCanvas);
+    m_koCanvasGraphicsWidget->setParentItem(this);
+    m_koCanvasGraphicsWidget->installEventFilter(this);
+    m_koCanvasGraphicsWidget->setVisible(true);
+    connect(m_koCanvasGraphicsWidget, SIGNAL(geometryChanged()), \
SLOT(resizeToCanvas())); +}
+
+void CACanvasItem::geometryChanged(const QRectF& newGeometry, const QRectF& \
oldGeometry) +{
+    if (!m_shouldIgnoreGeometryChange && m_koCanvasGraphicsWidget) {
+        m_koCanvasGraphicsWidget->setGeometry(newGeometry);
+        m_koCanvas->canvasController()->zoomBy(oldGeometry.center().toPoint(), \
newGeometry.width()/oldGeometry.width()); +    }
+    QDeclarativeItem::geometryChanged(newGeometry, oldGeometry);
+}
+
+bool CACanvasItem::eventFilter(QObject* o, QEvent* e)
+{
+    if (o == m_koCanvasGraphicsWidget) {
+        if (e->type() == QEvent::Move) {
+            m_shouldIgnoreGeometryChange = true;
+            QMoveEvent *moveEvent = static_cast<QMoveEvent*>(e);
+            setPos(QPointF(moveEvent->pos()));
+        } else if (e->type() == QEvent::Resize) {
+            m_shouldIgnoreGeometryChange = true;
+            QResizeEvent *resizeEvent = static_cast<QResizeEvent*>(e);
+            setWidth(resizeEvent->size().width());
+            setHeight(resizeEvent->size().height());
+        } else if (!m_editable) {
+            return true;
+        }
+    }
+    QTimer::singleShot(0, this, SLOT(resetShouldIgnoreGeometryChange()));
+    return QObject::eventFilter(o, e);
+}
+
+void CACanvasItem::resetShouldIgnoreGeometryChange()
+{
+    m_shouldIgnoreGeometryChange = false;
+}
+
+void CACanvasItem::resizeToCanvas()
+{
+    if (!m_koCanvasGraphicsWidget)
+        return;
+    m_shouldIgnoreGeometryChange = true;
+    setPos(m_koCanvasGraphicsWidget->geometry().topLeft());
+    setWidth(m_koCanvasGraphicsWidget->geometry().size().width());
+    setHeight(m_koCanvasGraphicsWidget->geometry().size().height());
+
+    QTimer::singleShot(0, this, SLOT(resetShouldIgnoreGeometryChange()));
+}
+
+bool CACanvasItem::editable() const
+{
+    return m_editable;
+}
+
+void CACanvasItem::setEditable(bool value)
+{
+    m_editable = value;
+}
+
+void CACanvasItem::updateDocumentSize(QSize sz, bool recalculateCenter)
+{
+    setHeight(sz.height());
+    setWidth(sz.width());
+
+    m_koCanvasGraphicsWidget->setGeometry(x(), y(), width(), height());
+}
+
+CACanvasItem::~CACanvasItem()
+{
+
+}
+
+#include "CACanvasItem.moc"
diff --git a/active/src/CACanvasItem.h b/active/src/CACanvasItem.h
new file mode 100644
index 0000000..8bec718
--- /dev/null
+++ b/active/src/CACanvasItem.h
@@ -0,0 +1,63 @@
+/*
+ * This file is part of the KDE project
+ *
+ * Copyright (C) 2012 Shantanu Tushar <shaan7in@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#ifndef CACANVASITEM_H
+#define CACANVASITEM_H
+
+#include <QtDeclarative/QDeclarativeItem>
+
+class QGraphicsWidget;
+class KoCanvasBase;
+
+class CACanvasItem : public QDeclarativeItem
+{
+    Q_OBJECT
+    Q_PROPERTY (bool editable READ editable WRITE setEditable NOTIFY \
editableChanged) +public:
+    CACanvasItem(QDeclarativeItem* parent = 0);
+    virtual ~CACanvasItem();
+
+    KoCanvasBase *koCanvas();
+    void setKoCanvas(KoCanvasBase *koCanvas);
+    bool editable() const;
+    void setEditable(bool value);
+    void updateDocumentSize(QSize sz, bool recalculateCenter);
+
+signals:
+    void koCanvasChanged();
+    void editableChanged();
+
+protected:
+    virtual void geometryChanged(const QRectF& newGeometry, const QRectF& \
oldGeometry); +    virtual bool eventFilter(QObject* o, QEvent* e);
+
+private slots:
+    void resetShouldIgnoreGeometryChange();
+    void resizeToCanvas();
+
+private:
+    KoCanvasBase *m_koCanvas;
+    QGraphicsWidget *m_koCanvasGraphicsWidget;
+    bool m_shouldIgnoreGeometryChange;
+    bool m_editable;
+};
+
+#endif // CACANVASITEM_H
diff --git a/active/src/CAPresentationHandler.cpp \
b/active/src/CAPresentationHandler.cpp index 6b7adc1..e1f14b5 100644
--- a/active/src/CAPresentationHandler.cpp
+++ b/active/src/CAPresentationHandler.cpp
@@ -101,7 +101,6 @@ bool CAPresentationHandler::openDocument (const QString& uri)
                                 d->document);
         paCanvasItem->setView (d->paView);
 
-        documentController()->canvasController()->setZoomController \
                (d->paView->zoomController());
         documentController()->canvasController()->setZoomHandler \
(static_cast<KoZoomHandler*> (paCanvasItem->viewConverter()));  
         // update the canvas whenever we scroll, the canvas controller must emit \
this signal on scrolling/panning @@ -124,6 +123,7 @@ bool \
CAPresentationHandler::openDocument (const QString& uri)  
     d->document;
 
+    emit totalNumberOfSlidesChanged();
     nextSlide();
 
     return true;
@@ -175,11 +175,11 @@ void CAPresentationHandler::zoomToFit()
     if (canvasSize.width() < canvasSize.height()) {
         canvasItem->setGeometry (0, (canvasSize.height() - newSize.height()) / 2,
                                  newSize.width(), newSize.height());
-        zoomHandler->setZoom (canvasSize.width() / pageSize.width() * 0.75);
+        zoomHandler->setZoom (canvasSize.width() / pageSize.width() * 0.65);
     } else {
         canvasItem->setGeometry ( (canvasSize.width() - newSize.width()) / 2, 0,
                                   newSize.width(), newSize.height());
-        zoomHandler->setZoom (canvasSize.height() / pageSize.height() * 0.75);
+        zoomHandler->setZoom (canvasSize.height() / pageSize.height() * 0.65);
     }
 
     updateCanvas();
diff --git a/active/src/CAPresentationHandler.h b/active/src/CAPresentationHandler.h
index abe8193..b19928d 100644
--- a/active/src/CAPresentationHandler.h
+++ b/active/src/CAPresentationHandler.h
@@ -32,7 +32,7 @@ class CAPresentationHandler : public CAAbstractDocumentHandler
     Q_OBJECT
     Q_PROPERTY(int slideshowDelay READ slideshowDelay WRITE setSlideshowDelay NOTIFY \
                slideshowDelayChanged)
     Q_PROPERTY(int currentSlideNumber READ currentSlideNumber NOTIFY \
                currentSlideNumChanged)
-    Q_PROPERTY(int totalNumberOfSlides READ totalNumberOfSlides)
+    Q_PROPERTY(int totalNumberOfSlides READ totalNumberOfSlides NOTIFY \
totalNumberOfSlidesChanged)  
 public:
     explicit CAPresentationHandler (CADocumentController* documentController);
@@ -67,6 +67,7 @@ signals:
     void slideshowStarted();
     void slideshowStopped();
     void currentSlideNumChanged();
+    void totalNumberOfSlidesChanged();
 
 protected:
     virtual KoDocument* document();
diff --git a/active/src/CASpreadsheetHandler.cpp \
b/active/src/CASpreadsheetHandler.cpp index b1cfe49..2727eed 100644
--- a/active/src/CASpreadsheetHandler.cpp
+++ b/active/src/CASpreadsheetHandler.cpp
@@ -91,9 +91,7 @@ bool CASpreadsheetHandler::openDocument (const QString& uri)
 
     KoZoomHandler* zoomHandler = new KoZoomHandler();
     documentController()->canvasController()->setZoomHandler (zoomHandler);
-    KoZoomController* zoomController = new KoZoomController \
                (dynamic_cast<KoCanvasController*> \
                (documentController()->canvasController()),
-            zoomHandler, d->document->actionCollection());
-    documentController()->canvasController()->setZoomController (zoomController);
+    KoZoomController* zoomController = \
documentController()->canvasController()->zoomController();  zoomController->setZoom \
(KoZoomMode::ZOOM_CONSTANT, 1.0);  
     documentController()->canvasController()->setCanvasMode \
                (KoCanvasController::Spreadsheet);
diff --git a/active/src/CATextDocumentHandler.cpp \
b/active/src/CATextDocumentHandler.cpp index 6d772a4..281532a 100644
--- a/active/src/CATextDocumentHandler.cpp
+++ b/active/src/CATextDocumentHandler.cpp
@@ -118,23 +118,19 @@ bool CATextDocumentHandler::openDocument (const QString& uri)
 
     KoZoomHandler* zoomHandler = static_cast<KoZoomHandler*> \
                (kwCanvasItem->viewConverter());
     documentController()->canvasController()->setZoomHandler (zoomHandler);
-    KoZoomController* zoomController =
-        new KoZoomController (dynamic_cast<KoCanvasController*> \
                (documentController()->canvasController()),
-                              zoomHandler, doc->actionCollection());
-    documentController()->canvasController()->setZoomController (zoomController);
+    KoZoomController* zoomController = \
documentController()->canvasController()->zoomController();  d->currentTextDocPage = \
d->document->pageManager()->begin();  zoomController->setPageSize \
(d->currentTextDocPage.rect().size());  zoomController->setZoom \
(KoZoomMode::ZOOM_CONSTANT, 1.0);  
     if (kwCanvasItem) {
-        kwCanvasItem->updateSize();
-
         // whenever the size of the document viewed in the canvas changes, inform \
                the zoom controller
         connect (kwCanvasItem, SIGNAL (documentSize (QSizeF)), zoomController, SLOT \
                (setDocumentSize (QSizeF)));
         // update the canvas whenever we scroll, the canvas controller must emit \
                this signal on scrolling/panning
         connect (documentController()->canvasController()->canvasControllerProxyObject(), \
SIGNAL (moveDocumentOffset (const QPoint&)),  kwCanvasItem, SLOT (setDocumentOffset \
(QPoint)));  kwCanvasItem->updateSize();
+        kDebug() << "HANDLEEEE " << kwCanvasItem->geometry();
     }
 
     connect (documentController()->canvasController(), SIGNAL (needsCanvasResize \
                (QSizeF)), SLOT (resizeCanvas (QSizeF)));
diff --git a/active/src/MainWindow.cpp b/active/src/MainWindow.cpp
index 99309ca..f05377b 100644
--- a/active/src/MainWindow.cpp
+++ b/active/src/MainWindow.cpp
@@ -23,6 +23,7 @@
 #include "CACanvasController.h"
 #include "CADocumentInfo.h"
 #include "CADocumentController.h"
+#include "CACanvasItem.h"
 #include "calligra_active_global.h"
 
 #include <KDE/KGlobal>
@@ -42,6 +43,7 @@ MainWindow::MainWindow (QWidget* parent)
     qmlRegisterType<CACanvasController> ("CalligraActive", 1, 0, \
                "CanvasController");
     qmlRegisterType<CADocumentInfo> ("CalligraActive", 1, 0, "CADocumentInfo");
     qmlRegisterType<CADocumentController> ("CalligraActive", 1, 0, \
"CADocumentController"); +    qmlRegisterType<CACanvasItem> ("CalligraActive", 1, 0, \
"CACanvasItem");  qmlRegisterInterface<KoCanvasController> ("KoCanvasController");
 
     m_view = new QDeclarativeView (this);
@@ -84,7 +86,7 @@ MainWindow::MainWindow (QWidget* parent)
 
     setCentralWidget (m_view);
     connect (m_view, SIGNAL (sceneResized (QSize)), SLOT (adjustWindowSize \
                (QSize)));
-    resize (800, 600);
+    resize (1024, 768);
 
     if (!documentPath.isEmpty()) {
         QTimer::singleShot(1000, this, SLOT(checkForAndOpenDocument()));


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic