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

George Staikos staikos at kde.org
Mon May 28 18:42:31 CEST 2007


SVN commit 669150 by staikos:

more refactoring


 M  +1 -1      CMakeLists.txt  
 M  +6 -6      kstmainwindow.cpp  
 M  +5 -3      kstmainwindow.h  
 D             kstplotview.cpp  
 D             kstplotview.h  
 M  +10 -10    labelitem.cpp  
 M  +3 -3      labelitem.h  
 M  +13 -13    lineitem.cpp  
 M  +3 -3      lineitem.h  
 A             view.cpp   kstplotview.cpp#669142 [License: GPL (v2+)]
 A             view.h   kstplotview.h#669142 [License: GPL (v2+)]
 M  +2 -3      viewcommand.cpp  
 M  +3 -3      viewcommand.h  
 M  +4 -4      viewitem.cpp  
 M  +4 -4      viewitem.h  


--- branches/work/kst/portto4/kst/src/libkstapp/CMakeLists.txt #669149:669150
@@ -3,7 +3,7 @@
 set(kstapp_LIB_SRCS
    kstapplication.cpp
    kstmainwindow.cpp
-   kstplotview.cpp
+   view.cpp
    viewitem.cpp
    lineitem.cpp
    labelitem.cpp
--- branches/work/kst/portto4/kst/src/libkstapp/kstmainwindow.cpp #669149:669150
@@ -11,7 +11,7 @@
 
 #include "kstmainwindow.h"
 #include "kstapplication.h"
-#include "kstplotview.h"
+#include "view.h"
 #include "labelitem.h"
 #include "lineitem.h"
 
@@ -54,13 +54,13 @@
 }
 
 
-KstPlotView *KstMainWindow::currentPlotView() const {
-  return qobject_cast<KstPlotView*>(_tabWidget->currentWidget());
+View *KstMainWindow::currentPlotView() const {
+  return qobject_cast<View*>(_tabWidget->currentWidget());
 }
 
 
-KstPlotView *KstMainWindow::createPlotView() {
-  KstPlotView *plotView = new KstPlotView;
+View *KstMainWindow::createPlotView() {
+  View *plotView = new View;
   connect(plotView, SIGNAL(destroyed(QObject*)),
           this, SLOT(plotViewDestroyed(QObject*)));
   _undoGroup->addStack(plotView->undoStack());
@@ -81,7 +81,7 @@
 
 
 void KstMainWindow::plotViewDestroyed(QObject *object) {
-  KstPlotView *plotView = qobject_cast<KstPlotView*>(object);
+  View *plotView = qobject_cast<View*>(object);
   _tabWidget->removeTab(_tabWidget->indexOf(plotView));
 }
 
--- branches/work/kst/portto4/kst/src/libkstapp/kstmainwindow.h #669149:669150
@@ -19,7 +19,9 @@
 class QTabWidget;
 class QUndoGroup;
 
-class KstPlotView;
+namespace Kst {
+class View;
+}
 
 class KstMainWindow : public QMainWindow
 {
@@ -30,9 +32,9 @@
 
   QUndoGroup *undoGroup() const;
   QTabWidget *tabWidget() const;
-  KstPlotView *currentPlotView() const;
+  Kst::View *currentPlotView() const;
 
-  KstPlotView *createPlotView();
+  Kst::View *createPlotView();
 
 private Q_SLOTS:
   void aboutToQuit();
--- branches/work/kst/portto4/kst/src/libkstapp/labelitem.cpp #669149:669150
@@ -18,18 +18,18 @@
 
 namespace Kst {
 
-LabelItem::LabelItem(KstPlotView *parent)
+LabelItem::LabelItem(View *parent)
     : ViewItem(parent) {
   setFlags(ItemIsMovable | ItemIsSelectable | ItemIsFocusable);
-  parent->setMouseMode(KstPlotView::Create);
+  parent->setMouseMode(View::Create);
   parent->setCursor(Qt::IBeamCursor);
 
   //If the mouseMode is changed again before we're done with creation
   //delete ourself.
   connect(parent, SIGNAL(mouseModeChanged()), this, SLOT(deleteLater()));
 
-  connect(parent, SIGNAL(creationPolygonChanged(KstPlotView::CreationEvent)),
-          this, SLOT(creationPolygonChanged(KstPlotView::CreationEvent)));
+  connect(parent, SIGNAL(creationPolygonChanged(View::CreationEvent)),
+          this, SLOT(creationPolygonChanged(View::CreationEvent)));
 }
 
 
@@ -50,8 +50,8 @@
 }
 
 
-void LabelItem::creationPolygonChanged(KstPlotView::CreationEvent event) {
-  if (event == KstPlotView::MousePress) {
+void LabelItem::creationPolygonChanged(View::CreationEvent event) {
+  if (event == View::MousePress) {
 
     bool ok;
     QString text = QInputDialog::getText(parentView(), QObject::tr("label"),
@@ -59,11 +59,11 @@
                                          QString::null, &ok);
     if (!ok || text.isEmpty()) {
       //This will delete...
-      parentView()->setMouseMode(KstPlotView::Default);
+      parentView()->setMouseMode(View::Default);
       return;
     }
 
-    const QPolygonF poly = mapFromScene(parentView()->creationPolygon(KstPlotView::MousePress));
+    const QPolygonF poly = mapFromScene(parentView()->creationPolygon(View::MousePress));
     setText(text);
     setPos(poly[0]);
     parentView()->scene()->addItem(this);
@@ -74,8 +74,8 @@
 #endif
 
     parentView()->disconnect(this, SLOT(deleteLater())); //Don't delete ourself
-    parentView()->disconnect(this, SLOT(creationPolygonChanged(KstPlotView::CreationEvent)));
-    parentView()->setMouseMode(KstPlotView::Default);
+    parentView()->disconnect(this, SLOT(creationPolygonChanged(View::CreationEvent)));
+    parentView()->setMouseMode(View::Default);
     emit creationComplete();
     return;
   }
--- branches/work/kst/portto4/kst/src/libkstapp/labelitem.h #669149:669150
@@ -21,7 +21,7 @@
 {
   Q_OBJECT
 public:
-  LabelItem(KstPlotView *parent);
+  LabelItem(View *parent);
   virtual ~LabelItem();
 
   virtual QGraphicsItem *graphicsItem() { return this; }
@@ -30,7 +30,7 @@
   QVariant itemChange(GraphicsItemChange change, const QVariant &value);
 
 private Q_SLOTS:
-  void creationPolygonChanged(KstPlotView::CreationEvent event);
+  void creationPolygonChanged(View::CreationEvent event);
 };
 
 
@@ -38,7 +38,7 @@
 {
 public:
   CreateLabelCommand() : CreateCommand(QObject::tr("Create Label")) {}
-  CreateLabelCommand(KstPlotView *view): CreateCommand(view, QObject::tr("Create Label")) {}
+  CreateLabelCommand(View *view): CreateCommand(view, QObject::tr("Create Label")) {}
   virtual ~CreateLabelCommand() {}
   virtual void createItem();
 };
--- branches/work/kst/portto4/kst/src/libkstapp/lineitem.cpp #669149:669150
@@ -17,18 +17,18 @@
 
 namespace Kst {
 
-LineItem::LineItem(KstPlotView *parent)
+LineItem::LineItem(View *parent)
     : ViewItem(parent) {
   setFlags(ItemIsMovable | ItemIsSelectable | ItemIsFocusable);
-  parent->setMouseMode(KstPlotView::Create);
+  parent->setMouseMode(View::Create);
   parent->setCursor(Qt::CrossCursor);
 
   //If the mouseMode is changed again before we're done with creation
   //delete ourself.
   connect(parent, SIGNAL(mouseModeChanged()), this, SLOT(deleteLater()));
 
-  connect(parent, SIGNAL(creationPolygonChanged(KstPlotView::CreationEvent)),
-          this, SLOT(creationPolygonChanged(KstPlotView::CreationEvent)));
+  connect(parent, SIGNAL(creationPolygonChanged(View::CreationEvent)),
+          this, SLOT(creationPolygonChanged(View::CreationEvent)));
 }
 
 
@@ -36,23 +36,23 @@
 }
 
 
-void LineItem::creationPolygonChanged(KstPlotView::CreationEvent event) {
-  if (event == KstPlotView::MousePress) {
-    const QPolygonF poly = mapFromScene(parentView()->creationPolygon(KstPlotView::MousePress));
+void LineItem::creationPolygonChanged(View::CreationEvent event) {
+  if (event == View::MousePress) {
+    const QPolygonF poly = mapFromScene(parentView()->creationPolygon(View::MousePress));
     setLine(QLineF(poly[0], poly[0])); //start and end
     parentView()->scene()->addItem(this);
     setZValue(1);
     return;
   }
 
-  if (event == KstPlotView::MouseMove) {
-    const QPolygonF poly = mapFromScene(parentView()->creationPolygon(KstPlotView::MouseMove));
+  if (event == View::MouseMove) {
+    const QPolygonF poly = mapFromScene(parentView()->creationPolygon(View::MouseMove));
     setLine(QLineF(line().p1(), poly.last())); //start and end
     return;
   }
 
-  if (event == KstPlotView::MouseRelease) {
-    const QPolygonF poly = mapFromScene(parentView()->creationPolygon(KstPlotView::MouseRelease));
+  if (event == View::MouseRelease) {
+    const QPolygonF poly = mapFromScene(parentView()->creationPolygon(View::MouseRelease));
     setLine(QLineF(line().p1(), poly.last())); //start and end
 
 #ifdef DEBUG_GEOMETRY
@@ -60,8 +60,8 @@
 #endif
 
     parentView()->disconnect(this, SLOT(deleteLater())); //Don't delete ourself
-    parentView()->disconnect(this, SLOT(creationPolygonChanged(KstPlotView::CreationEvent)));
-    parentView()->setMouseMode(KstPlotView::Default);
+    parentView()->disconnect(this, SLOT(creationPolygonChanged(View::CreationEvent)));
+    parentView()->setMouseMode(View::Default);
     emit creationComplete();
     return;
   }
--- branches/work/kst/portto4/kst/src/libkstapp/lineitem.h #669149:669150
@@ -21,20 +21,20 @@
 {
   Q_OBJECT
 public:
-  LineItem(KstPlotView *parent);
+  LineItem(View *parent);
   virtual ~LineItem();
 
   virtual QGraphicsItem *graphicsItem() { return this; }
 
 private Q_SLOTS:
-  void creationPolygonChanged(KstPlotView::CreationEvent event);
+  void creationPolygonChanged(View::CreationEvent event);
 };
 
 class KST_EXPORT CreateLineCommand : public CreateCommand
 {
 public:
   CreateLineCommand() : CreateCommand(QObject::tr("Create Line")) {}
-  CreateLineCommand(KstPlotView *view) : CreateCommand(view, QObject::tr("Create Line")) {}
+  CreateLineCommand(View *view) : CreateCommand(view, QObject::tr("Create Line")) {}
   virtual ~CreateLineCommand() {}
   virtual void createItem();
 };
--- branches/work/kst/portto4/kst/src/libkstapp/viewcommand.cpp #669149:669150
@@ -11,7 +11,7 @@
 
 #include "viewcommand.h"
 #include "kstapplication.h"
-#include "kstplotview.h"
+#include "view.h"
 
 #include <QDebug>
 #include <QObject>
@@ -24,8 +24,7 @@
 }
 
 
-ViewCommand::ViewCommand(KstPlotView *view, const QString &text,
-                                       bool addToStack, QUndoCommand *parent)
+ViewCommand::ViewCommand(View *view, const QString &text, bool addToStack, QUndoCommand *parent)
     : QUndoCommand(text, parent), _view(view) {
   if (addToStack)
     _view->undoStack()->push(this);
--- branches/work/kst/portto4/kst/src/libkstapp/viewcommand.h #669149:669150
@@ -16,19 +16,19 @@
 #include <QUndoCommand>
 #include "kst_export.h"
 
-class KstPlotView;
 
 namespace Kst {
+class View;
 
 class KST_EXPORT ViewCommand : public QUndoCommand
 {
 public:
   ViewCommand(const QString &text, bool addToStack = true, QUndoCommand *parent = 0);
-  ViewCommand(KstPlotView *view, const QString &text, bool addToStack = true, QUndoCommand *parent = 0);
+  ViewCommand(View *view, const QString &text, bool addToStack = true, QUndoCommand *parent = 0);
   virtual ~ViewCommand();
 
 protected:
-  QPointer<KstPlotView> _view;
+  QPointer<View> _view;
 };
 
 }
--- branches/work/kst/portto4/kst/src/libkstapp/viewitem.cpp #669149:669150
@@ -18,7 +18,7 @@
 
 namespace Kst {
 
-ViewItem::ViewItem(KstPlotView *parent)
+ViewItem::ViewItem(View *parent)
     : QObject(parent) {
 #ifdef DEBUG_GEOMETRY
   QColor semiRed(QColor(255, 0, 0, 50));
@@ -35,8 +35,8 @@
 }
 
 
-KstPlotView *ViewItem::parentView() const {
-  return qobject_cast<KstPlotView*>(parent());
+View *ViewItem::parentView() const {
+  return qobject_cast<View*>(parent());
 }
 
 
@@ -70,7 +70,7 @@
 }
 
 
-CreateCommand::CreateCommand(KstPlotView *view, const QString &text, QUndoCommand *parent)
+CreateCommand::CreateCommand(View *view, const QString &text, QUndoCommand *parent)
     : ViewCommand(view, text, false, parent) {
 }
 
--- branches/work/kst/portto4/kst/src/libkstapp/viewitem.h #669149:669150
@@ -15,7 +15,7 @@
 #include <QObject>
 #include "kst_export.h"
 #include "viewcommand.h"
-#include "kstplotview.h" //forward declare, but enums??
+#include "view.h" //forward declare, but enums??
 
 // #define DEBUG_GEOMETRY 1
 
@@ -27,10 +27,10 @@
 {
   Q_OBJECT
 public:
-  ViewItem(KstPlotView *parent);
+  ViewItem(View *parent);
   virtual ~ViewItem();
 
-  KstPlotView *parentView() const;
+  View *parentView() const;
 
   virtual QGraphicsItem *graphicsItem() = 0;
 
@@ -63,7 +63,7 @@
   Q_OBJECT
 public:
   CreateCommand(const QString &text, QUndoCommand *parent = 0);
-  CreateCommand(KstPlotView *view, const QString &text, QUndoCommand *parent = 0);
+  CreateCommand(View *view, const QString &text, QUndoCommand *parent = 0);
   virtual ~CreateCommand();
 
   virtual void undo();


More information about the Kst mailing list