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

List:       kde-commits
Subject:    koffice/kspread/ui
From:       Stefan Nikolaus <nikolaus.kde () googlemail ! com>
Date:       2010-06-26 8:15:08
Message-ID: 20100626081508.37F9EAC8DF () svn ! kde ! org
[Download RAW message or body]

SVN commit 1142955 by nikolaus:

Cleanup:	Pass CellToolBase* instead of KoTool*, KoCanvasBase* and Selection* to the \
constructors.



 M  +18 -12    AbstractSelectionStrategy.cpp  
 M  +3 -2      AbstractSelectionStrategy.h  
 M  +3 -3      AutoFillStrategy.cpp  
 M  +1 -3      AutoFillStrategy.h  
 M  +6 -6      CellToolBase.cpp  
 M  +3 -2      DragAndDropStrategy.cpp  
 M  +1 -3      DragAndDropStrategy.h  
 M  +2 -2      HyperlinkStrategy.cpp  
 M  +1 -2      HyperlinkStrategy.h  
 M  +3 -3      MergeStrategy.cpp  
 M  +1 -3      MergeStrategy.h  
 M  +2 -2      PasteStrategy.cpp  
 M  +1 -3      PasteStrategy.h  
 M  +5 -4      SelectionStrategy.cpp  
 M  +1 -3      SelectionStrategy.h  


--- trunk/koffice/kspread/ui/AbstractSelectionStrategy.cpp #1142954:1142955
@@ -19,6 +19,7 @@
 
 #include "AbstractSelectionStrategy.h"
 
+#include "CellToolBase.h"
 #include "kspread_limits.h"
 #include "RowColumnFormat.h"
 #include "Selection.h"
@@ -27,24 +28,23 @@
 #include <KoCanvasBase.h>
 #include <KoSelection.h>
 #include <KoShapeManager.h>
-#include <KoToolBase.h>
 
 using namespace KSpread;
 
 class AbstractSelectionStrategy::Private
 {
 public:
-    Selection* selection;
+    CellToolBase *cellTool;
     QPointF start;
 };
 
-AbstractSelectionStrategy::AbstractSelectionStrategy(KoToolBase *parent, Selection \
*selection, +AbstractSelectionStrategy::AbstractSelectionStrategy(CellToolBase \
*cellTool,  const QPointF documentPos, Qt::KeyboardModifiers modifiers)
-        : KoInteractionStrategy(parent)
+        : KoInteractionStrategy(cellTool)
         , d(new Private)
 {
     Q_UNUSED(modifiers)
-    d->selection = selection;
+    d->cellTool = cellTool;
     d->start = documentPos;
 }
 
@@ -56,27 +56,28 @@
 void AbstractSelectionStrategy::handleMouseMove(const QPointF& documentPos, \
Qt::KeyboardModifiers modifiers)  {
     Q_UNUSED(modifiers)
+    Selection *const selection = d->cellTool->selection();
     const KoShape *shape = \
                tool()->canvas()->shapeManager()->selection()->firstSelectedShape();
     const QPointF position = documentPos - (shape ? shape->position() : QPointF(0.0, \
0.0));  // In which cell did the user click?
     double xpos;
     double ypos;
-    int col = d->selection->activeSheet()->leftColumn(position.x(), xpos);
-    int row = d->selection->activeSheet()->topRow(position.y(), ypos);
+    int col = selection->activeSheet()->leftColumn(position.x(), xpos);
+    int row = selection->activeSheet()->topRow(position.y(), ypos);
     // Check boundaries.
     if (col > KS_colMax || row > KS_rowMax) {
         kDebug(36005) << "col or row is out of range:" << "col:" << col << " row:" \
<< row;  return;
     }
     // Test whether mouse is over the Selection.handle
-    if (hitTestSelectionSizeGrip(tool()->canvas(), d->selection, position)) {
+    if (hitTestSelectionSizeGrip(tool()->canvas(), selection, position)) {
         // If the cursor is over the handle, than it might be already on the next \
cell.  // Recalculate the cell position!
-        col = d->selection->activeSheet()->leftColumn(position.x() - \
                tool()->canvas()->viewConverter()->viewToDocumentX(2.0), xpos);
-        row = d->selection->activeSheet()->topRow(position.y() - \
tool()->canvas()->viewConverter()->viewToDocumentY(2.0), ypos); +        col = \
selection->activeSheet()->leftColumn(position.x() - \
tool()->canvas()->viewConverter()->viewToDocumentX(2.0), xpos); +        row = \
selection->activeSheet()->topRow(position.y() - \
tool()->canvas()->viewConverter()->viewToDocumentY(2.0), ypos);  }
     // Update the selection.
-    d->selection->update(QPoint(col, row));
+    selection->update(QPoint(col, row));
     tool()->repaintDecorations();
 }
 
@@ -158,9 +159,14 @@
     return false;
 }
 
+CellToolBase *AbstractSelectionStrategy::cellTool() const
+{
+    return d->cellTool;
+}
+
 Selection* AbstractSelectionStrategy::selection() const
 {
-    return d->selection;
+    return d->cellTool->selection();
 }
 
 const QPointF& AbstractSelectionStrategy::startPosition() const
--- trunk/koffice/kspread/ui/AbstractSelectionStrategy.h #1142954:1142955
@@ -28,6 +28,7 @@
 
 namespace KSpread
 {
+class CellToolBase;
 class Selection;
 
 /**
@@ -45,8 +46,7 @@
     /**
      * Constructor.
      */
-    AbstractSelectionStrategy(KoToolBase* parent, Selection* selection,
-                              const QPointF position, Qt::KeyboardModifiers \
modifiers); +    AbstractSelectionStrategy(CellToolBase *cellTool, const QPointF \
position, Qt::KeyboardModifiers modifiers);  
     /**
      * Destructor.
@@ -82,6 +82,7 @@
                                          const QPointF &position);
 
 protected:
+    CellToolBase *cellTool() const;
     Selection* selection() const;
     const QPointF& startPosition() const;
 
--- trunk/koffice/kspread/ui/AutoFillStrategy.cpp #1142954:1142955
@@ -33,12 +33,12 @@
     QRect autoFillSource;
 };
 
-AutoFillStrategy::AutoFillStrategy(KoToolBase *parent, Selection *selection,
+AutoFillStrategy::AutoFillStrategy(CellToolBase *cellTool,
                                    const QPointF documentPos, Qt::KeyboardModifiers \
                modifiers)
-        : AbstractSelectionStrategy(parent, selection, documentPos, modifiers)
+        : AbstractSelectionStrategy(cellTool, documentPos, modifiers)
         , d(new Private)
 {
-    d->autoFillSource = selection->lastRange();
+    d->autoFillSource = selection()->lastRange();
 }
 
 AutoFillStrategy::~AutoFillStrategy()
--- trunk/koffice/kspread/ui/AutoFillStrategy.h #1142954:1142955
@@ -25,7 +25,6 @@
 
 namespace KSpread
 {
-class Selection;
 
 /**
  * A strategy for automatic filling values into selected cells.
@@ -39,8 +38,7 @@
     /**
      * Constructor.
      */
-    AutoFillStrategy(KoToolBase *parent, Selection *selection,
-                     const QPointF position, Qt::KeyboardModifiers modifiers);
+    AutoFillStrategy(CellToolBase *cellTool, const QPointF position, \
Qt::KeyboardModifiers modifiers);  
     /**
      * Destructor.
--- trunk/koffice/kspread/ui/CellToolBase.cpp #1142954:1142955
@@ -1133,14 +1133,14 @@
     // Autofilling or merging, if the selection handle was hit.
     if (SelectionStrategy::hitTestSelectionSizeGrip(canvas(), selection(), \
position)) {  if (event->button() == Qt::LeftButton)
-            return new AutoFillStrategy(this, selection(), event->point, \
event->modifiers()); +            return new AutoFillStrategy(this, event->point, \
event->modifiers());  else if (event->button() == Qt::MidButton)
-            return new MergeStrategy(this, selection(), event->point, \
event->modifiers()); +            return new MergeStrategy(this, event->point, \
event->modifiers());  }
 
     // Pasting with the middle mouse button.
     if (event->button() == Qt::MidButton) {
-        return new PasteStrategy(this, selection(), event->point, \
event->modifiers()); +        return new PasteStrategy(this, event->point, \
event->modifiers());  }
 
     // Check, if the selected area was hit.
@@ -1203,7 +1203,7 @@
                 url = cellView.testAnchor(cell, position.x() - xpos, position.y() - \
ypos);  }
             if (!url.isEmpty()) {
-                return new HyperlinkStrategy(this, selection(), event->point,
+                return new HyperlinkStrategy(this, event->point,
                                              event->modifiers(), url, \
cellView.textRect());  }
         }
@@ -1211,10 +1211,10 @@
 
     // Drag & drop, if the selected area was hit.
     if (hitSelection && !selection()->referenceSelectionMode()) {
-        return new DragAndDropStrategy(this, selection(), event->point, \
event->modifiers()); +        return new DragAndDropStrategy(this, event->point, \
event->modifiers());  }
 
-    return new SelectionStrategy(this, selection(), event->point, \
event->modifiers()); +    return new SelectionStrategy(this, event->point, \
event->modifiers());  }
 
 void CellToolBase::selectionChanged(const Region& region)
--- trunk/koffice/kspread/ui/DragAndDropStrategy.cpp #1142954:1142955
@@ -50,12 +50,13 @@
     bool started;
 };
 
-DragAndDropStrategy::DragAndDropStrategy(KoToolBase *parent, Selection *selection,
+DragAndDropStrategy::DragAndDropStrategy(CellToolBase *cellTool,
         const QPointF documentPos, Qt::KeyboardModifiers modifiers)
-        : AbstractSelectionStrategy(parent, selection, documentPos, modifiers)
+        : AbstractSelectionStrategy(cellTool, documentPos, modifiers)
         , d(new Private)
 {
     d->lastPoint = documentPos;
+    Selection *const selection = this->selection();
     const KoShape *shape = \
                tool()->canvas()->shapeManager()->selection()->firstSelectedShape();
     const QPointF position = documentPos - (shape ? shape->position() : QPointF(0.0, \
0.0));  
--- trunk/koffice/kspread/ui/DragAndDropStrategy.h #1142954:1142955
@@ -25,7 +25,6 @@
 
 namespace KSpread
 {
-class Selection;
 
 /**
  * A strategy for dragging cells.
@@ -39,8 +38,7 @@
     /**
      * Constructor.
      */
-    DragAndDropStrategy(KoToolBase* parent, Selection* selection,
-                        const QPointF position, Qt::KeyboardModifiers modifiers);
+    DragAndDropStrategy(CellToolBase *cellTool, const QPointF position, \
Qt::KeyboardModifiers modifiers);  
     /**
      * Destructor.
--- trunk/koffice/kspread/ui/HyperlinkStrategy.cpp #1142954:1142955
@@ -44,10 +44,10 @@
     QString url;
 };
 
-HyperlinkStrategy::HyperlinkStrategy(KoToolBase* parent, Selection* selection,
+HyperlinkStrategy::HyperlinkStrategy(CellToolBase *cellTool,
                                      const QPointF documentPos, \
                Qt::KeyboardModifiers modifiers,
                                      const QString& url, const QRectF& textRect)
-        : AbstractSelectionStrategy(parent, selection, documentPos, modifiers)
+        : AbstractSelectionStrategy(cellTool, documentPos, modifiers)
         , d(new Private)
 {
     d->lastPoint = documentPos;
--- trunk/koffice/kspread/ui/HyperlinkStrategy.h #1142954:1142955
@@ -27,7 +27,6 @@
 
 namespace KSpread
 {
-class Selection;
 
 /**
  * A strategy for visiting a hyperlink.
@@ -42,7 +41,7 @@
     /**
      * Constructor.
      */
-    HyperlinkStrategy(KoToolBase* parent, Selection* selection,
+    HyperlinkStrategy(CellToolBase *cellTool,
                       const QPointF position, Qt::KeyboardModifiers modifiers,
                       const QString& url, const QRectF& textRect);
 
--- trunk/koffice/kspread/ui/MergeStrategy.cpp #1142954:1142955
@@ -30,12 +30,12 @@
     QRect initialSelection;
 };
 
-MergeStrategy::MergeStrategy(KoToolBase *parent, Selection *selection,
+MergeStrategy::MergeStrategy(CellToolBase *cellTool,
                              const QPointF documentPos, Qt::KeyboardModifiers \
                modifiers)
-        : AbstractSelectionStrategy(parent, selection, documentPos, modifiers)
+        : AbstractSelectionStrategy(cellTool, documentPos, modifiers)
         , d(new Private)
 {
-    d->initialSelection = selection->lastRange();
+    d->initialSelection = selection()->lastRange();
 }
 
 MergeStrategy::~MergeStrategy()
--- trunk/koffice/kspread/ui/MergeStrategy.h #1142954:1142955
@@ -25,7 +25,6 @@
 
 namespace KSpread
 {
-class Selection;
 
 /**
  * A strategy for merging cells.
@@ -39,8 +38,7 @@
     /**
      * Constructor.
      */
-    MergeStrategy(KoToolBase *parent, Selection *selection,
-                  const QPointF position, Qt::KeyboardModifiers modifiers);
+    MergeStrategy(CellToolBase *cellTool, const QPointF position, \
Qt::KeyboardModifiers modifiers);  
     /**
      * Destructor.
--- trunk/koffice/kspread/ui/PasteStrategy.cpp #1142954:1142955
@@ -34,9 +34,9 @@
 public:
 };
 
-PasteStrategy::PasteStrategy(KoToolBase *parent, Selection *selection,
+PasteStrategy::PasteStrategy(CellToolBase *cellTool,
                              const QPointF documentPos, Qt::KeyboardModifiers \
                modifiers)
-        : SelectionStrategy(parent, selection, documentPos, modifiers)
+        : SelectionStrategy(cellTool, documentPos, modifiers)
         , d(new Private)
 {
 }
--- trunk/koffice/kspread/ui/PasteStrategy.h #1142954:1142955
@@ -25,7 +25,6 @@
 
 namespace KSpread
 {
-class Selection;
 
 /**
  * A strategy for pasting the global mouse selection.
@@ -40,8 +39,7 @@
     /**
      * Constructor.
      */
-    PasteStrategy(KoToolBase *parent, Selection *selection,
-                  const QPointF position, Qt::KeyboardModifiers modifiers);
+    PasteStrategy(CellToolBase *cellTool, const QPointF position, \
Qt::KeyboardModifiers modifiers);  
     /**
      * Destructor.
--- trunk/koffice/kspread/ui/SelectionStrategy.cpp #1142954:1142955
@@ -19,6 +19,7 @@
 
 #include "SelectionStrategy.h"
 
+#include "CellToolBase.h"
 #include "kspread_limits.h"
 #include "Selection.h"
 #include "Sheet.h"
@@ -26,7 +27,6 @@
 #include <KoCanvasBase.h>
 #include <KoSelection.h>
 #include <KoShapeManager.h>
-#include <KoToolBase.h>
 
 using namespace KSpread;
 
@@ -36,9 +36,9 @@
     Cell startCell;
 };
 
-SelectionStrategy::SelectionStrategy(KoToolBase *parent, Selection *selection,
+SelectionStrategy::SelectionStrategy(CellToolBase *cellTool,
                                      const QPointF documentPos, \
                Qt::KeyboardModifiers modifiers)
-        : AbstractSelectionStrategy(parent, selection, documentPos, modifiers)
+        : AbstractSelectionStrategy(cellTool, documentPos, modifiers)
         , d(new Private)
 {
     d->startCell = Cell();
@@ -46,6 +46,7 @@
     const KoShape* shape = \
                tool()->canvas()->shapeManager()->selection()->firstSelectedShape();
     const QPointF position = documentPos - (shape ? shape->position() : QPointF(0.0, \
0.0));  Sheet *const sheet = this->selection()->activeSheet();
+    Selection *const selection = this->selection();
 
 #if 0 // KSPREAD_WIP_DRAG_REFERENCE_SELECTION
     // Check, if the selected area was hit.
@@ -116,7 +117,7 @@
 {
 #if 0 // KSPREAD_WIP_DRAG_REFERENCE_SELECTION
     Q_UNUSED(modifiers);
-    const KoShape* shape = \
m_canvas->shapeManager()->selection()->firstSelectedShape(); +    const KoShape* \
                shape = \
                tool()->canvas()->shapeManager()->selection()->firstSelectedShape();
     const QPointF position = documentPos - (shape ? shape->position() : QPointF(0.0, \
0.0));  Sheet *const sheet = selection()->activeSheet();
 
--- trunk/koffice/kspread/ui/SelectionStrategy.h #1142954:1142955
@@ -25,7 +25,6 @@
 
 namespace KSpread
 {
-class Selection;
 
 /**
  * A strategy for selecting cell ranges.
@@ -43,8 +42,7 @@
     /**
      * Constructor.
      */
-    SelectionStrategy(KoToolBase *parent, Selection *selection,
-                      const QPointF position, Qt::KeyboardModifiers modifiers);
+    SelectionStrategy(CellToolBase *cellTool, const QPointF position, \
Qt::KeyboardModifiers modifiers);  
     /**
      * Destructor.


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

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