[Kst] branches/work/kst/portto4/kst/src/libkstapp

Mike Fenton mike at staikos.net
Mon Feb 25 22:33:39 CET 2008


SVN commit 779319 by fenton:

Fix for Layout mode not removing gribs.
Add improved grip updating for ViewItem.


 M  +3 -12     arrowitem.cpp  
 M  +5 -1      builtingraphics.cpp  
 M  +0 -3      circleitem.cpp  
 M  +2 -11     lineitem.cpp  
 M  +14 -22    viewitem.cpp  
 M  +1 -0      viewitem.h  


--- branches/work/kst/portto4/kst/src/libkstapp/arrowitem.cpp #779318:779319
@@ -39,7 +39,7 @@
 
 void ArrowItem::paint(QPainter *painter) {
   painter->drawLine(line());
-  double deltax = 4.0;
+  double deltax = 2.0 * painter->pen().widthF();
   double theta = atan2(double(line().y1() - line().y2()), double(line().x1() - line().x2())) - M_PI / 2.0;
   double sina = sin(theta);
   double cosa = cos(theta);
@@ -86,14 +86,11 @@
 
 
 QPainterPath ArrowItem::leftMidGrip() const {
-  if (gripMode() == Move)
-    return QPainterPath();
-
   QRectF bound = gripBoundingRect();
   QRectF grip = QRectF(bound.topLeft(), sizeOfGrip());
   grip.moveCenter(QPointF(grip.center().x(), bound.center().y()));
   QPainterPath path;
-  if (gripMode() == Resize || gripMode() == Scale)
+  if (gripMode() == Resize || gripMode() == Scale || gripMode() == Move)
     path.addRect(grip);
   else
     path.addEllipse(grip);
@@ -103,14 +100,11 @@
 
 
 QPainterPath ArrowItem::rightMidGrip() const {
-  if (gripMode() == Move)
-    return QPainterPath();
-
   QRectF bound = gripBoundingRect();
   QRectF grip = QRectF(bound.topRight() - QPointF(sizeOfGrip().width(), 0), sizeOfGrip());
   grip.moveCenter(QPointF(grip.center().x(), bound.center().y()));
   QPainterPath path;
-  if (gripMode() == Resize || gripMode() == Scale)
+  if (gripMode() == Resize || gripMode() == Scale || gripMode() == Move)
     path.addRect(grip);
   else
     path.addEllipse(grip);
@@ -120,9 +114,6 @@
 
 
 QPainterPath ArrowItem::grips() const {
-  if (gripMode() == Move)
-    return QPainterPath();
-
   QPainterPath grips;
   grips.addPath(leftMidGrip());
   grips.addPath(rightMidGrip());
--- branches/work/kst/portto4/kst/src/libkstapp/builtingraphics.cpp #779318:779319
@@ -18,15 +18,19 @@
 #include "pictureitem.h"
 #include "plotitem.h"
 #include "svgitem.h"
+#include "arrowitem.h"
+#include "circleitem.h"
 
 namespace Kst {
   namespace Builtins {
     void initGraphics() {
+      new ArrowItemFactory;
       new BoxItemFactory;
-      new LineItemFactory;
+      new CircleItemFactory;
       new EllipseItemFactory;
       new LabelItemFactory;
       new LayoutBoxItemFactory;
+      new LineItemFactory;
       new PictureItemFactory;
       new PlotItemFactory;
       new SvgItemFactory;
--- branches/work/kst/portto4/kst/src/libkstapp/circleitem.cpp #779318:779319
@@ -83,9 +83,6 @@
 
 
 QPainterPath CircleItem::grips() const {
-  if (gripMode() == Move)
-    return QPainterPath();
-
   QPainterPath grips;
   grips.addPath(topLeftGrip());
   grips.addPath(topRightGrip());
--- branches/work/kst/portto4/kst/src/libkstapp/lineitem.cpp #779318:779319
@@ -66,14 +66,11 @@
 
 
 QPainterPath LineItem::leftMidGrip() const {
-  if (gripMode() == Move)
-    return QPainterPath();
-
   QRectF bound = gripBoundingRect();
   QRectF grip = QRectF(bound.topLeft(), sizeOfGrip());
   grip.moveCenter(QPointF(grip.center().x(), bound.center().y()));
   QPainterPath path;
-  if (gripMode() == Resize || gripMode() == Scale)
+  if (gripMode() == Resize || gripMode() == Scale || gripMode() == Move)
     path.addRect(grip);
   else
     path.addEllipse(grip);
@@ -83,14 +80,11 @@
 
 
 QPainterPath LineItem::rightMidGrip() const {
-  if (gripMode() == Move)
-    return QPainterPath();
-
   QRectF bound = gripBoundingRect();
   QRectF grip = QRectF(bound.topRight() - QPointF(sizeOfGrip().width(), 0), sizeOfGrip());
   grip.moveCenter(QPointF(grip.center().x(), bound.center().y()));
   QPainterPath path;
-  if (gripMode() == Resize || gripMode() == Scale)
+  if (gripMode() == Resize || gripMode() == Scale || gripMode() == Move)
     path.addRect(grip);
   else
     path.addEllipse(grip);
@@ -100,9 +94,6 @@
 
 
 QPainterPath LineItem::grips() const {
-  if (gripMode() == Move)
-    return QPainterPath();
-
   QPainterPath grips;
   grips.addPath(leftMidGrip());
   grips.addPath(rightMidGrip());
--- branches/work/kst/portto4/kst/src/libkstapp/viewitem.cpp #779318:779319
@@ -59,6 +59,8 @@
   setFlags(ItemIsMovable | ItemIsSelectable | ItemIsFocusable);
   connect(parent, SIGNAL(mouseModeChanged(View::MouseMode)),
           this, SLOT(viewMouseModeChanged(View::MouseMode)));
+  connect(parent, SIGNAL(viewModeChanged(View::ViewMode)),
+          this, SLOT(updateView()));
 }
 
 
@@ -377,13 +379,10 @@
 
 
 QPainterPath ViewItem::topLeftGrip() const {
-  if (_gripMode == Move)
-    return QPainterPath();
-
   QRectF bound = gripBoundingRect();
   QRectF grip = QRectF(bound.topLeft(), sizeOfGrip());
   QPainterPath path;
-  if (_gripMode == Resize || _gripMode == Scale)
+  if (_gripMode == Resize || _gripMode == Scale || _gripMode == Move)
     path.addRect(grip);
   else
     path.addEllipse(grip);
@@ -397,13 +396,10 @@
 
 
 QPainterPath ViewItem::topRightGrip() const {
-  if (_gripMode == Move)
-    return QPainterPath();
-
   QRectF bound = gripBoundingRect();
   QRectF grip = QRectF(bound.topRight() - QPointF(sizeOfGrip().width(), 0), sizeOfGrip());
   QPainterPath path;
-  if (_gripMode == Resize || _gripMode == Scale)
+  if (_gripMode == Resize || _gripMode == Scale || _gripMode == Move)
     path.addRect(grip);
   else
     path.addEllipse(grip);
@@ -417,13 +413,10 @@
 
 
 QPainterPath ViewItem::bottomRightGrip() const {
-  if (_gripMode == Move)
-    return QPainterPath();
-
   QRectF bound = gripBoundingRect();
   QRectF grip = QRectF(bound.bottomRight() - QPointF(sizeOfGrip().width(), sizeOfGrip().height()), sizeOfGrip());
   QPainterPath path;
-  if (_gripMode == Resize || _gripMode == Scale)
+  if (_gripMode == Resize || _gripMode == Scale || _gripMode == Move)
     path.addRect(grip);
   else
     path.addEllipse(grip);
@@ -437,13 +430,10 @@
 
 
 QPainterPath ViewItem::bottomLeftGrip() const {
-  if (_gripMode == Move)
-    return QPainterPath();
-
   QRectF bound = gripBoundingRect();
   QRectF grip = QRectF(bound.bottomLeft() - QPointF(0, sizeOfGrip().height()), sizeOfGrip());
   QPainterPath path;
-  if (_gripMode == Resize || _gripMode == Scale)
+  if (_gripMode == Resize || _gripMode == Scale || _gripMode == Move)
     path.addRect(grip);
   else
     path.addEllipse(grip);
@@ -533,10 +523,6 @@
 
 
 QPainterPath ViewItem::grips() const {
-
-  if (_gripMode == Move)
-    return QPainterPath();
-
   QPainterPath grips;
   grips.addPath(topLeftGrip());
   grips.addPath(topRightGrip());
@@ -628,7 +614,6 @@
 
 
 void ViewItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
-
   Q_UNUSED(option);
   Q_UNUSED(widget);
 
@@ -639,7 +624,7 @@
   painter->save();
   painter->setPen(Qt::DotLine);
   painter->setBrush(Qt::NoBrush);
-  if (isSelected() || isHovering()
+  if ((isSelected() || isHovering())
       && parentView()->mouseMode() != View::Create
       && parentView()->viewMode() != View::Data) {
     painter->drawPath(shape());
@@ -649,6 +634,8 @@
       painter->fillPath(grips(), Qt::black);
     else if (_gripMode == Rotate)
       painter->fillPath(grips(), Qt::red);
+    else if (_gripMode == Move)
+      painter->fillPath(grips(), Qt::transparent);
   }
 
 #ifdef DEBUG_GEOMETRY
@@ -1705,6 +1692,11 @@
 }
 
 
+void ViewItem::updateView() {
+  update();
+}
+
+
 #ifndef QT_NO_DEBUG_STREAM
 QDebug operator<<(QDebug dbg, ViewItem *viewItem) {
     dbg.nospace() << viewItem->name();
--- branches/work/kst/portto4/kst/src/libkstapp/viewitem.h #779318:779319
@@ -188,6 +188,7 @@
 
   private Q_SLOTS:
     void viewMouseModeChanged(View::MouseMode oldMode);
+    void updateView();
 
   private:
     bool tryShortcut(const QString &keySequence);


More information about the Kst mailing list