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

List:       kde-commits
Subject:    Re: playground/office/flake
From:       Thorsten Zachmann <t.zachmann () zagge ! de>
Date:       2006-05-01 6:38:53
Message-ID: 200605010838.54644.t.zachmann () zagge ! de
[Download RAW message or body]

Hello Thomas,

> First version of a Repaint Manager.
> This allows each KoShape to have a repaint() method which will cause the
> canvas to repaint it.
> Design is a bit tricky due to the fact that each object can have more then
> one canvas it works on; I have to work on that a little more but the idea
> is already visible in the KoRepaintManager.h file
>
> The bigest sacrifice I had to make is that KoShapeManager now has its own
> list of the objects and a add/remove for the objects.
> With the ShapeManager being a QObject anyway we can probably add some
> slots to minimize the pain of a shadow administration.
>
> Note that the repaint manager is currently not enabled as there are some
> repainting bugs.
> Edit FlakeCanvas::updateCanvas (in testapp/mainwindow.cpp) to enabled it.

I have some questions to your patch. I don't understand why we need a repaint 
manger for every view. I think one repaint manager for the same data would be 
enough. 
Every canvas would know the repaint manager and the repaint manager would know 
the canvases. Then you say the repaint manger to repaint the object/rect and 
it repaints the canvases. This would minimise the administration for managing 
the objects needed.
I have attached a patch which is doing that. It is still very basic as I had 
not much time this morning and I have to go now. So it still has repainting 
problems but nothing that can't be fixed. At least I hope so :-). 
I really like to know what all of you think about it and which way we should 
go.

I would be happy if you could post such big changes before you commit them, so 
that every body could comment on them. 

Thorsten

["repaintmanager.diff" (text/x-diff)]

Index: testapp/mainwindow.h
===================================================================
--- testapp/mainwindow.h	(revision 536039)
+++ testapp/mainwindow.h	(working copy)
@@ -39,13 +39,15 @@ class QCheckBox;
 class KoSelection;
 class KoShape;
 class KoPathShape;
+class KoRepaintManager;
 
 class FlakeCanvas : public QWidget, public KoCanvasBase
 {
     Q_OBJECT
 
 public:
-    FlakeCanvas(KSillyCommandHistory *commandHistory, QList<KoShape*> &objects);
+    FlakeCanvas(KSillyCommandHistory *commandHistory, QList<KoShape*> &objects, \
KoRepaintManager *repaintManager); +
     virtual ~FlakeCanvas() {};
 
     static QList<KoShape *> createObjects();
@@ -57,6 +59,7 @@ public: // KoCanvasBase interface method
     void addCommand(KCommand *command, bool execute = true);
 
     KoShapeManager *shapeManager() const { return m_shapeManager; }
+    KoRepaintManager *repaintManager() const { return m_repaintManager; }
 
     /**
      * Tell the canvas repaint the specified rectangle. The coordinates
@@ -116,6 +119,7 @@ private:
     KSillyCommandHistory *m_commandHistory;
     KoShapeManager *m_shapeManager;
     bool m_snapToGrid;
+    KoRepaintManager *m_repaintManager;
 };
 
 
@@ -142,7 +146,7 @@ private:
     void setStatus(QString string);
     void createDockWindows();
 
-    QWidget * m_canvas;
+    FlakeCanvas * m_canvas;
     KSillyCommandHistory *m_commandHistory;
 
     QMenu * m_fileMenu;
Index: testapp/mainwindow.cpp
===================================================================
--- testapp/mainwindow.cpp	(revision 536039)
+++ testapp/mainwindow.cpp	(working copy)
@@ -38,10 +38,11 @@
 #include <KoPathShape.h>
 #include <KoGfxEvent.h>
 #include <KoSelection.h>
+#include <KoRepaintManager.h>
 
 #include "math.h"
 
-FlakeCanvas::FlakeCanvas(KSillyCommandHistory *commandHistory, QList<KoShape *> \
&objects) +FlakeCanvas::FlakeCanvas(KSillyCommandHistory *commandHistory, \
QList<KoShape*> &objects, KoRepaintManager *repaintManager )  : QWidget()
     , m_objects(objects)
     , m_tool( "Default", 0, "Default", this )
@@ -49,10 +50,11 @@ FlakeCanvas::FlakeCanvas(KSillyCommandHi
     , m_viewConverter(&m_zoomHandler)
     , m_commandHistory(commandHistory)
     , m_snapToGrid(false)
+    , m_repaintManager(repaintManager)
 {
     setBackgroundRole(QPalette::Base);
 
-    m_shapeManager = new KoShapeManager(this, m_objects);
+    m_shapeManager = new KoShapeManager(m_objects);
     setMouseTracking( true );
 
     connect( m_shapeManager, SIGNAL(selectionChanged()), this, \
SLOT(selectionChanged()) ); @@ -130,7 +132,7 @@ void FlakeCanvas::zoomHChanged(int \
zoom)  
     foreach ( KoShape * shape, m_shapeManager->selection()->selectedObjects(true) ) \
{  shape ->scale(hScale, shape->scaleY());
-        shape->repaint();
+        repaintManager()->repaint( shape );
     }
 }
 
@@ -139,7 +141,7 @@ void FlakeCanvas::zoomVChanged(int zoom)
     double vScale = double(zoom/1000.0);
     foreach ( KoShape * shape, m_shapeManager->selection()->selectedObjects(true) ) \
{  shape ->scale(shape->scaleX(), vScale);
-        shape->repaint();
+        repaintManager()->repaint( shape );
     }
 }
 
@@ -155,14 +157,14 @@ void FlakeCanvas::rotate(int rotate)
 {
     foreach ( KoShape * shape, m_shapeManager->selection()->selectedObjects(true) ) \
{  shape->rotate(rotate);
-        shape->repaint();
+        repaintManager()->repaint( shape );
     }
 }
 
 void FlakeCanvas::zIndexChanged(int newZIndex) {
     foreach ( KoShape * shape, m_shapeManager->selection()->selectedObjects(true) ) \
{  shape ->setZIndex(newZIndex);
-        shape->repaint();
+        repaintManager()->repaint( shape );
     }
 
 }
@@ -185,7 +187,7 @@ void FlakeCanvas::setVisible(int visible
     if(visible == Qt::PartiallyChecked) return;
     foreach ( KoShape * shape, m_shapeManager->selection()->selectedObjects() ) {
         shape->setVisible(visible == Qt::Checked);
-        shape->repaint();
+        repaintManager()->repaint( shape );
     }
 }
 
@@ -304,10 +306,14 @@ void FlakeCanvas::updateCanvas(const QRe
 MainWindow::MainWindow()
 {
     m_commandHistory = new KSillyCommandHistory();
+    KoRepaintManager *repaintManager = new KoRepaintManager();
     QList<KoShape *> testObjects = FlakeCanvas::createObjects();
-    m_canvas = new FlakeCanvas(m_commandHistory, testObjects);
+    m_canvas = new FlakeCanvas(m_commandHistory, testObjects, repaintManager );
+    repaintManager->addCanvas( m_canvas );
     QSplitter *splitter = new QSplitter(Qt::Vertical);
-    splitter->addWidget(new FlakeCanvas(m_commandHistory, testObjects));
+    FlakeCanvas *c2 = new FlakeCanvas(m_commandHistory, testObjects, repaintManager \
); +    repaintManager->addCanvas( c2 );
+    splitter->addWidget(c2);
     splitter->addWidget(m_canvas);
     QList<int> sizes;
     sizes << 0 << 100;
Index: lib/KoShapeMoveStrategy.cpp
===================================================================
--- lib/KoShapeMoveStrategy.cpp	(revision 536039)
+++ lib/KoShapeMoveStrategy.cpp	(working copy)
@@ -31,10 +31,12 @@
 #include "KoGfxEvent.h"
 #include "KoCommand.h"
 #include "kcommand.h"
+#include "KoRepaintManager.h"
 
 KoShapeMoveStrategy::KoShapeMoveStrategy( KoCanvasBase *canvas, const QPointF \
&clicked)  : KoInteractionStrategy(canvas)
 , m_start(clicked)
+, m_repaintManager( canvas->repaintManager() )
 {
     KoSelectionSet selectedObjects = \
canvas->shapeManager()->selection()->selectedObjects(true);  foreach(KoShape *shape, \
selectedObjects) { @@ -56,9 +58,9 @@ void KoShapeMoveStrategy::handleMouseMov
                 (event->m_event.modifiers() & Qt::ShiftModifier) == \
Qt::ShiftModifier)  applyGrid(newPos);
         m_newPositions[i] = newPos;
-        shape->repaint();
+        m_repaintManager->repaint( shape );
         shape->setPos(newPos);
-        shape->repaint();
+        m_repaintManager->repaint( shape );
         i++;
     }
 }
@@ -66,5 +68,5 @@ void KoShapeMoveStrategy::handleMouseMov
 KCommand* KoShapeMoveStrategy::createCommand() {
     if(m_diff.x() == 0 && m_diff.y() == 0)
         return 0;
-    return new KoShapeMoveCommand(m_selectedObjects, m_previousPositions, \
m_newPositions); +    return new KoShapeMoveCommand(m_selectedObjects, \
m_previousPositions, m_newPositions, m_repaintManager);  }
Index: lib/KoCommand.cpp
===================================================================
--- lib/KoCommand.cpp	(revision 536039)
+++ lib/KoCommand.cpp	(working copy)
@@ -1,28 +1,30 @@
 #include "KoCommand.h"
 #include "KoShape.h"
+#include "KoRepaintManager.h"
 
 #include <QString>
 
-KoShapeMoveCommand::KoShapeMoveCommand(const KoSelectionSet &shapes, QList<QPointF> \
                &previousPositions, QList<QPointF> &newPositions)
-: m_newPositions(newPositions)
-, m_previousPositions(previousPositions)
+KoShapeMoveCommand::KoShapeMoveCommand(const KoSelectionSet &shapes, QList<QPointF> \
&previousPositions, QList<QPointF> &newPositions, KoRepaintManager * repaintManager) \
+: m_previousPositions(previousPositions) +, m_newPositions(newPositions)
+, m_repaintManager( repaintManager )
 {
     m_shapes = shapes.toList();
 }
 
 void KoShapeMoveCommand::execute() {
     for(int i=0; i < m_shapes.count(); i++) {
-        m_shapes.at(i)->repaint();
+        m_repaintManager->repaint( m_shapes.at(i) );
         m_shapes.at(i)->setPos( m_newPositions.at(i) );
-        m_shapes.at(i)->repaint();
+        m_repaintManager->repaint( m_shapes.at(i) );
     }
 }
 
 void KoShapeMoveCommand::unexecute() {
     for(int i=0; i < m_shapes.count(); i++) {
-        m_shapes.at(i)->repaint();
+        m_repaintManager->repaint( m_shapes.at(i) );
         m_shapes.at(i)->setPos( m_previousPositions.at(i) );
-        m_shapes.at(i)->repaint();
+        m_repaintManager->repaint( m_shapes.at(i) );
     }
 }
 
Index: lib/KoSelection.cpp
===================================================================
--- lib/KoSelection.cpp	(revision 536039)
+++ lib/KoSelection.cpp	(working copy)
@@ -206,10 +206,3 @@ bool KoSelection::isSelected(const KoSha
 
     return false;
 }
-
-void KoSelection::repaintSelectionHandles() {
-    recalcSelectionBox();
-    QRectF bb( QPointF( -HANDLE_DISTANCE, -HANDLE_DISTANCE),
-            QSizeF(size().width() + 2*HANDLE_DISTANCE, size().height() + \
                2*HANDLE_DISTANCE));
-    repaint(bb);
-}
Index: lib/KoShapeRubberSelectStrategy.h
===================================================================
--- lib/KoShapeRubberSelectStrategy.h	(revision 536039)
+++ lib/KoShapeRubberSelectStrategy.h	(working copy)
@@ -31,6 +31,7 @@ class QPointF;
 
 class KoGfxEvent;
 class KoCanvasBase;
+class KoRepaintManager;
 
 /**
  * Implement the rubber band selection of flake objects.
@@ -56,6 +57,7 @@ public:
 
 private:
     QRectF m_selectRect;
+    KoRepaintManager * m_repaintManager;
 };
 
 #endif /* KODEFRUBBERSELECT_H */
Index: lib/KoRepaintManager.cpp
===================================================================
--- lib/KoRepaintManager.cpp	(revision 536039)
+++ lib/KoRepaintManager.cpp	(working copy)
@@ -25,6 +25,29 @@
 #include <QRectF>
 #include <QDebug>
 
+KoRepaintManager::KoRepaintManager()
+{
+}
+
+void KoRepaintManager::repaint( QRectF &rect ) 
+{
+    foreach ( KoCanvasBase *canvas, m_canvases )
+    {
+        canvas->updateCanvas( rect );
+    }
+}
+
+void KoRepaintManager::repaint( KoShape *shape ) 
+{
+    QRectF rect( shape->boundingBox() );
+    repaint( rect );
+}
+
+void KoRepaintManager::addCanvas(KoCanvasBase *canvas)
+{
+    m_canvases.push_back( canvas );
+}
+#if 0
 KoRepaintManager::KoRepaintManager(KoCanvasBase *canvas, KoSelection *selection)
 : m_canvas (canvas)
 , m_selection(selection)
@@ -68,3 +91,4 @@ void KoRepaintManager::repaint(QRectF &r
     }
     m_locked = false;
 }
+#endif
Index: lib/KoShapeManager.h
===================================================================
--- lib/KoShapeManager.h	(revision 536039)
+++ lib/KoShapeManager.h	(working copy)
@@ -26,7 +26,6 @@
 
 class KoShape;
 class KoSelection;
-class KoRepaintManager;
 class KoViewConverter;
 class KoCanvasBase;
 
@@ -47,13 +46,13 @@ public:
     /**
      * Empty constructor.
      */
-    KoShapeManager(KoCanvasBase *canvas);
+    KoShapeManager();
     /**
      * Constructor that takes a list of objects, convenience version.
      * @param objects the objects to start out with, see also setObjects()
      * @param canvas the canvas this shape manager is working on.
      */
-    KoShapeManager(KoCanvasBase *canvas, QList<KoShape *> &objects);
+    KoShapeManager(QList<KoShape *> &objects);
     virtual ~KoShapeManager();
 
     /**
@@ -64,17 +63,6 @@ public:
     void setObjects( QList<KoShape *> &objects );
     const QList<KoShape *> & objects() const { return m_objects; }
 
-    /**
-     * Add a KoShape to be displayed and managed by this manager.
-     * @param shape the shape to add
-     */
-    void add(KoShape *shape);
-    /**
-     * Remove a KoShape from this manager
-     * @param shape the shape to remove
-     */
-    void remove(KoShape *shape);
-
     KoSelection * selection() const { return m_selection; }
 
     /**
@@ -92,9 +80,8 @@ signals:
     void selectionChanged();
 
 private:
-    QList<KoShape *> m_objects;
+    QList<KoShape *> & m_objects;
     KoSelection * m_selection;
-    KoRepaintManager *m_repaintManager;
 };
 
 #endif /* KOOBJECTMANAGER_H */
Index: lib/KoShapeContainer.cpp
===================================================================
--- lib/KoShapeContainer.cpp	(revision 536039)
+++ lib/KoShapeContainer.cpp	(working copy)
@@ -146,9 +146,10 @@ void KoShapeContainer::ChildrenData::set
     if(relation->m_inside == clipping)
         return;
     relation->m_inside = clipping;
-    relation->child()->repaint();
+    //TODO
+    //relation->child()->repaint();
     relation->child()->recalcMatrix();
-    relation->child()->repaint();
+    //relation->child()->repaint();
 }
 
 void KoShapeContainer::ChildrenData::remove(KoShape *child) {
Index: lib/KoShape.h
===================================================================
--- lib/KoShape.h	(revision 536039)
+++ lib/KoShape.h	(working copy)
@@ -33,7 +33,6 @@ class QRectF;
 class KoSelection;
 class KoGfxEvent;
 class KoShapeContainer;
-class KoRepaintManager;
 
 /**
  * Base class for all flake objects. Flake objects extend this class
@@ -273,39 +272,6 @@ public:
     void setParent(KoShapeContainer *parent);
 
     /**
-     * Request a repaint to be queued.
-     * The repaint will be of the entire Shape, including its selection handles \
                should this
-     * shape be selected.
-     * <p>This method will return immediately and only request a repaint. Successive \
                calls
-     * will be merged into an appropriate repaint action.
-     */
-    void repaint() const;
-
-    /**
-     * Request a repaint to be queued.
-     * The repaint will be restricted to the parameters rectangle, which is expected \
                to be
-     * in points (the internal coordinates system of KoShape) and it is expected to \
                be
-     * normalized.
-     * <p>This method will return immediately and only request a repaint. Successive \
                calls
-     * will be merged into an appropriate repaint action.
-     * @param shape the rectangle (in pt) to queue for repaint.
-     */
-    void repaint(QRectF &shape) const;
-
-    /**
-     * Request a repaint to be queued.
-     * The repaint will be restricted to the parameters rectangle, which is expected \
                to be
-     * in points (the internal coordinates system of KoShape).
-     * <p>This method will return immediately and only request a repaint. Successive \
                calls
-     * will be merged into an appropriate repaint action.
-     * @param x the x coordinate measured from the topleft position of this shape
-     * @param y the y coordinate measured from the topleft position of this shape
-     * @param width the width of the repaint rectangle
-     * @param height the height of the repaint rectangle
-     */
-    void repaint(double x, double y, double width, double height) const;
-
-    /**
      * This is a method used to sort a list using the STL sorting methods.
      * @param g1 the first object
      * @param g2 the second object
@@ -317,6 +283,13 @@ public:
      */
     virtual void recalcMatrix();
 
+    /**
+     * Create a matrix that describes all the transformations done on this shape.
+     * @param converter if not null, this method uses the converter to mark the \
right +     *        offsets in the current view.
+     */
+    QMatrix KoShape::transformationMatrix(KoViewConverter *converter) const;
+
 protected:
     QMatrix m_invMatrix;
     KoGfxStyle m_style;
@@ -348,21 +321,6 @@ private:
     KoShapeContainer *m_parent;
 
     bool m_visible, m_locked;
-
-    KoRepaintManager *m_repaintManager;
-
-private:
-    friend class KoShapeManager;
-    friend class KoShapeContainer;
-    void setRepaintManager(KoRepaintManager *manager);
-
-    /**
-     * Create a matrix that describes all the transformations done on this shape.
-     * @param converter if not null, this method uses the converter to mark the \
                right
-     *        offsets in the current view.
-     */
-    QMatrix KoShape::transformationMatrix(KoViewConverter *converter) const;
-
 };
 
 #endif /* KOGRAPHICBASE_H */
Index: lib/KoCanvasBase.h
===================================================================
--- lib/KoCanvasBase.h	(revision 536039)
+++ lib/KoCanvasBase.h	(working copy)
@@ -31,6 +31,7 @@
 class KoSelection;
 class KCommand;
 class KoShapeManager;
+class KoRepaintManager;
 
 /**
  * KoCanvasBase is the interface actual application canvas classes
@@ -85,6 +86,9 @@ public:
     virtual void updateCanvas(const QRectF& rc) = 0;
 
 
+    virtual KoRepaintManager *repaintManager() const = 0;
+
+
 #if 0
 /*  The next list of methods are naming taken from Krita, which means they have \
                allready been
     toughened by time.  So, if you ever need a method in this interface; please \
                uncomment the
Index: lib/KoShapeMoveStrategy.h
===================================================================
--- lib/KoShapeMoveStrategy.h	(revision 536039)
+++ lib/KoShapeMoveStrategy.h	(working copy)
@@ -28,6 +28,7 @@
 #include <QPointF>
 
 class KoCanvasBase;
+class KoRepaintManager;
 
 /**
  * Implements the Move action on an object or selected objects.
@@ -51,6 +52,7 @@ private:
     QList<QPointF> m_previousPositions;
     QList<QPointF> m_newPositions;
     QPointF m_start, m_diff;
+    KoRepaintManager *m_repaintManager;
 };
 
 #endif /* KODEFMOVE_H */
Index: lib/KoCommand.h
===================================================================
--- lib/KoCommand.h	(revision 536039)
+++ lib/KoCommand.h	(working copy)
@@ -28,6 +28,7 @@
 #include <QPointF>
 
 class KoShape;
+class KoRepaintManager;
 class QString;
 
 /// The undo / redo command for shape moving.
@@ -41,7 +42,7 @@ public:
      * @param newPositions the new positions for the shapes.
      *  this list naturally must have the same amount of items as the shapes set.
      */
-    KoShapeMoveCommand(const KoSelectionSet &shapes, QList<QPointF> \
&previousPositions, QList<QPointF> &newPositions); +    KoShapeMoveCommand(const \
KoSelectionSet &shapes, QList<QPointF> &previousPositions, QList<QPointF> \
&newPositions, KoRepaintManager *repaintManager );  void execute ();
     void unexecute ();
     QString name () const;
@@ -49,6 +50,7 @@ public:
 private:
     QList<KoShape*> m_shapes;
     QList<QPointF> m_previousPositions, m_newPositions;
+    KoRepaintManager * m_repaintManager;
 };
 
 #endif
Index: lib/KoShapeRubberSelectStrategy.cpp
===================================================================
--- lib/KoShapeRubberSelectStrategy.cpp	(revision 536039)
+++ lib/KoShapeRubberSelectStrategy.cpp	(working copy)
@@ -29,10 +29,12 @@
 #include "KoShapeManager.h"
 #include "KoSelection.h"
 #include "KoCanvasBase.h"
+#include "KoRepaintManager.h"
 
 KoShapeRubberSelectStrategy::KoShapeRubberSelectStrategy( KoCanvasBase *canvas, \
const QPointF &clicked )  : KoInteractionStrategy( canvas )
 , m_selectRect(clicked, QSizeF(0, 0))
+, m_repaintManager( canvas->repaintManager() )
 {
 }
 
@@ -57,15 +59,17 @@ void KoShapeRubberSelectStrategy::paint(
 
 void KoShapeRubberSelectStrategy::handleMouseMove( KoGfxEvent *event )
 {
-    m_canvas->updateCanvas(m_selectRect.normalized());
+    KoSelection * selection = m_canvas->shapeManager()->selection();
+    selection->deselectAll();
+    QRectF rect( m_selectRect.normalized() );
     m_selectRect.setBottomRight( event->m_point );
-    m_canvas->updateCanvas(m_selectRect.normalized());
+    rect.unite( m_selectRect.normalized() );
+    m_repaintManager->repaint( rect );
 }
 
 void KoShapeRubberSelectStrategy::finishInteraction()
 {
     KoSelection * selection = m_canvas->shapeManager()->selection();
-    selection->repaintSelectionHandles();
     selection->deselectAll();
     const QList<KoShape *> &objects = m_canvas->shapeManager()->objects();
     foreach ( KoShape * object, objects )
@@ -76,6 +80,6 @@ void KoShapeRubberSelectStrategy::finish
             selection->select( object );
         }
     }
-    selection->repaintSelectionHandles();
-    m_canvas->updateCanvas(m_selectRect.normalized());
+    QRectF rect( m_selectRect.normalized() );
+    m_repaintManager->repaint( rect );
 }
Index: lib/KoSelection.h
===================================================================
--- lib/KoSelection.h	(revision 536039)
+++ lib/KoSelection.h	(working copy)
@@ -77,16 +77,6 @@ public:
 
     virtual QRectF boundingBox() const;
 
-    /**
-     * Request a repaint of the size of the selectionHandles to be queued.
-     * Since selectionHandles are positioned outside any objects an \
                KoShape.repaint()
-     * will not repaint the selectionHandles. This method therefor queues a repaint
-     * that takes into acount the selection handles.
-     * <p>This method will return immediately and only request a repaint. Successive \
                calls
-     * will be merged into an appropriate repaint action.
-     */
-    void repaintSelectionHandles();
-
 signals:
     /// emitted when the selection is changed
     void selectionChanged();
Index: lib/KoShapeManager.cpp
===================================================================
--- lib/KoShapeManager.cpp	(revision 536039)
+++ lib/KoShapeManager.cpp	(working copy)
@@ -23,51 +23,35 @@
 #include "KoSelection.h"
 #include "KoShape.h"
 #include "KoCanvasBase.h"
-#include "KoRepaintManager.h"
 
 #include <QDebug>
 #include <QPainter>
 
-KoShapeManager::KoShapeManager( KoCanvasBase *canvas, QList<KoShape *> &objects )
-: m_selection( new KoSelection() )
+KoShapeManager::KoShapeManager( QList<KoShape *> &objects )
+: m_objects( objects )
+, m_selection( new KoSelection() )
 {
     connect( m_selection, SIGNAL(selectionChanged()), this, \
                SIGNAL(selectionChanged()) );
-    m_repaintManager = new KoRepaintManager(canvas, m_selection);
     setObjects(objects);
-    m_selection->setRepaintManager(m_repaintManager);
 }
 
-KoShapeManager::KoShapeManager(KoCanvasBase *canvas)
+KoShapeManager::KoShapeManager()
 : m_objects()
 , m_selection( new KoSelection() )
 {
     connect( m_selection, SIGNAL(selectionChanged()), this, \
                SIGNAL(selectionChanged()) );
-    m_repaintManager = new KoRepaintManager(canvas, m_selection);
-    m_selection->setRepaintManager(m_repaintManager);
 }
 
 
 KoShapeManager::~KoShapeManager()
 {
     delete m_selection;
-    m_repaintManager->dismantle();
 }
 
 
 void KoShapeManager::setObjects( QList<KoShape *> &objects )
 {
     m_objects = objects;
-    foreach(KoShape *shape, m_objects)
-        shape->setRepaintManager(m_repaintManager);
-}
-
-void KoShapeManager::add(KoShape *shape) {
-    shape->setRepaintManager(m_repaintManager);
-    m_objects.append(shape);
-}
-
-void KoShapeManager::remove(KoShape *shape) {
-    m_objects.removeAll(shape);
 }
 
 void KoShapeManager::paint( QPainter &painter, KoViewConverter &converter, bool \
                forPrint)
Index: lib/KoShape.cpp
===================================================================
--- lib/KoShape.cpp	(revision 536039)
+++ lib/KoShape.cpp	(working copy)
@@ -39,7 +39,6 @@ KoShape::KoShape()
 , m_parent( 0 )
 , m_visible( true )
 , m_locked( false )
-, m_repaintManager(0)
 {
     recalcMatrix();
 }
@@ -202,36 +201,6 @@ int KoShape::zIndex() const {
     return m_zIndex;
 }
 
-void KoShape::setRepaintManager(KoRepaintManager *manager) {
-    Q_ASSERT(manager);
-    if(m_repaintManager) {
-        // swap repaint Manager (Since that will release old ones easier)
-        m_repaintManager->removeUser();
-        manager->addChainedManager(m_repaintManager);
-    }
-    m_repaintManager = manager;
-    manager->addUser();
-}
-
-void KoShape::repaint() const {
-    if(m_repaintManager == 0 || !isVisible())
-        return;
-    QRectF rect(m_matrix.mapRect(QRectF(QPointF(0, 0), m_size)));
-    m_repaintManager->repaint(rect, this, true);
-}
-
-void KoShape::repaint(QRectF &shape) const {
-    if(m_repaintManager == 0 || !isVisible())
-        return;
-    QRectF rect(m_matrix.mapRect(shape));
-    m_repaintManager->repaint(rect);
-}
-
-void KoShape::repaint(double x, double y, double width, double height) const {
-    QRectF rect(x, y, width, height);
-    repaint(rect);
-}
-
 // static
 void KoShape::applyConversion(QPainter &painter, const KoViewConverter &converter) {
     double zoomX, zoomY;
Index: lib/KoRepaintManager.h
===================================================================
--- lib/KoRepaintManager.h	(revision 536039)
+++ lib/KoRepaintManager.h	(working copy)
@@ -41,15 +41,16 @@ public:
      * @param canvas the canvas this repaintManager is going to forward any requests \
                to.
      * @param selection the selection object that manages the selections for the \
                canvas
      */
-    KoRepaintManager(KoCanvasBase *canvas, KoSelection *selection);
+    KoRepaintManager();
 
     /**
      * attach another repaint manager to this one so repaints from our children will
      * have effect on the other managers canvas as well.
      * @param manager the other manager.
      */
-    void addChainedManager(KoRepaintManager *manager);
+    void addCanvas(KoCanvasBase *canvas);
 
+#if 0
     /**
      * Since this object is refcounted you do not delete it but you dismantle it.
      */
@@ -88,12 +89,17 @@ public:
      * Return if this manager is still actively supporting clients for a canvas.
      */
     bool isActive() { return m_active; }
+#endif
+    void repaint( QRectF &rect );
+    void repaint( KoShape *shape );
 
 private:
-    KoCanvasBase *m_canvas;
+    QList<KoCanvasBase *> m_canvases;
+#if 0
     KoSelection *m_selection;
     bool m_active, m_locked;
     QList<KoRepaintManager*> m_otherManagers;
     int m_refCount;
+#endif
 };
 #endif
Index: lib/KoInteractionStrategy.cpp
===================================================================
--- lib/KoInteractionStrategy.cpp	(revision 536039)
+++ lib/KoInteractionStrategy.cpp	(working copy)
@@ -61,18 +61,20 @@ KoInteractionStrategy* KoInteractionStra
         if((event->m_event.buttons() & Qt::LeftButton) == 0)
             ;// do nothing when not left mouse button
         else if ((event->m_event.modifiers() & Qt::ControlModifier) == \
                Qt::ControlModifier ) {
-            select->repaintSelectionHandles();
-            select->deselect(object);
+            QRectF rect( select->boundingBox() );
+            rect.unite( select->boundingBox() );
+            canvas->updateCanvas( rect );
         }
         else
             return new KoShapeMoveStrategy(canvas, event->m_point);
     }
     else { // clicked on object which is not selected
-        select->repaintSelectionHandles();
+        QRectF rect( select->boundingBox() );
         if ( ( event->m_event.modifiers() & Qt::ControlModifier ) == 0 )
             shapeManager->selection()->deselectAll();
         select->select(object);
-        select->repaintSelectionHandles();
+        canvas->updateCanvas( rect );
+        canvas->updateCanvas( select->boundingBox() );
         return new KoShapeMoveStrategy(canvas, event->m_point);
     }
     return 0;



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

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