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

Adam Treat treat at kde.org
Fri Aug 31 21:37:06 CEST 2007


SVN commit 707015 by treat:

* Fix a crash nicholas found and disable gradient
editor as it is not ready.


 M  +3 -7      libkstapp/viewitem.cpp  
 M  +14 -10    libkstapp/viewitemdialog.cpp  
 M  +4 -3      libkstapp/viewitemdialog.h  
 M  +1 -1      widgets/fillandstroke.cpp  


--- branches/work/kst/portto4/kst/src/libkstapp/viewitem.cpp #707014:707015
@@ -378,13 +378,9 @@
 
 void ViewItem::edit() {
 
-  QList<ViewItem*> list;
-  QList<QGraphicsItem*> select = scene()->selectedItems();
-  foreach(QGraphicsItem *item, select) {
-    list << qgraphicsitem_cast<ViewItem*>(item);
-  }
-
-  ViewItemDialog::self()->show(list);
+  QList<QGraphicsItem*> list = scene()->selectedItems();
+  if (!list.isEmpty())
+    ViewItemDialog::self()->show(list);
 }
 
 
--- branches/work/kst/portto4/kst/src/libkstapp/viewitemdialog.cpp #707014:707015
@@ -11,9 +11,11 @@
 
 #include "viewitemdialog.h"
 
-#include "viewitem.h"
 #include "fillandstroke.h"
 
+#include <QPen>
+#include <QBrush>
+#include <QAbstractGraphicsShapeItem>
 #include <QDebug>
 
 namespace Kst {
@@ -55,7 +57,7 @@
 ViewItemDialog::~ViewItemDialog() {
 }
 
-void ViewItemDialog::show(QList<ViewItem*> items) {
+void ViewItemDialog::show(QList<QGraphicsItem*> items) {
   Q_ASSERT(!items.isEmpty());
 
   _items = items;
@@ -69,7 +71,7 @@
 }
 
 void ViewItemDialog::setupFill() {
-  ViewItem *first = _items.first();
+  QAbstractGraphicsShapeItem *first = qgraphicsitem_cast<QAbstractGraphicsShapeItem*>(_items.first());
   Q_ASSERT(first);
 
   QBrush b = first->brush();
@@ -83,7 +85,7 @@
 
 
 void ViewItemDialog::setupStroke() {
-  ViewItem *first = _items.first();
+  QAbstractGraphicsShapeItem *first = qgraphicsitem_cast<QAbstractGraphicsShapeItem*>(_items.first());
   Q_ASSERT(first);
 
   QPen p = first->pen();
@@ -101,7 +103,7 @@
 
 
 void ViewItemDialog::fillChanged() {
-  ViewItem *first = _items.first();
+  QAbstractGraphicsShapeItem *first = qgraphicsitem_cast<QAbstractGraphicsShapeItem*>(_items.first());
   Q_ASSERT(first);
 
   QBrush b = first->brush();
@@ -113,14 +115,15 @@
 //   if (gradient.type() != QGradient::NoGradient)
 //     b = QBrush(gradient);
 
-  foreach(ViewItem *item, _items) {
-    item->setBrush(b);
+  foreach(QGraphicsItem *item, _items) {
+    QAbstractGraphicsShapeItem *shape = qgraphicsitem_cast<QAbstractGraphicsShapeItem*>(item);
+    shape->setBrush(b);
   }
 }
 
 
 void ViewItemDialog::strokeChanged() {
-  ViewItem *first = _items.first();
+  QAbstractGraphicsShapeItem *first = qgraphicsitem_cast<QAbstractGraphicsShapeItem*>(_items.first());
   Q_ASSERT(first);
 
   QPen p = first->pen();
@@ -136,8 +139,9 @@
   p.setCapStyle(_fillAndStroke->capStyle());
   p.setBrush(b);
 
-  foreach(ViewItem *item, _items) {
-    item->setPen(p);
+  foreach(QGraphicsItem *item, _items) {
+    QAbstractGraphicsShapeItem *shape = qgraphicsitem_cast<QAbstractGraphicsShapeItem*>(item);
+    shape->setPen(p);
   }
 }
 
--- branches/work/kst/portto4/kst/src/libkstapp/viewitemdialog.h #707014:707015
@@ -17,9 +17,10 @@
 
 #include "kst_export.h"
 
+class QGraphicsItem;
+
 namespace Kst {
 
-class ViewItem;
 class FillAndStroke;
 
 class KST_EXPORT ViewItemDialog : public QDialog
@@ -28,7 +29,7 @@
 public:
   static ViewItemDialog *self();
 
-  void show(QList<ViewItem*> items);
+  void show(QList<QGraphicsItem*> items);
 
 private:
   ViewItemDialog(QWidget *parent = 0);
@@ -45,7 +46,7 @@
   void setVisible(bool visible);
 
 private:
-  QList<ViewItem*> _items;
+  QList<QGraphicsItem*> _items;
   FillAndStroke *_fillAndStroke;
 };
 
--- branches/work/kst/portto4/kst/src/widgets/fillandstroke.cpp #707014:707015
@@ -79,7 +79,7 @@
   connect(_joinStyle, SIGNAL(currentIndexChanged(int)), this, SIGNAL(strokeChanged()));
   connect(_capStyle, SIGNAL(currentIndexChanged(int)), this, SIGNAL(strokeChanged()));
 
-  _gradientEditor->setEnabled(true);
+  _gradientEditor->setEnabled(false);
 }
 
 


More information about the Kst mailing list