[Kst] kdeextragear-2/kst/kst

George Staikos staikos at kde.org
Thu Apr 8 12:23:35 CEST 2004


CVS commit by staikos: 

use "standard actions" that might be common across different view objects to
reduce the effort it takes to write new objects


  M +3 -16     kst2dplot.cpp   1.6
  M +0 -5      kst2dplot.h   1.3
  M +18 -0     kstviewobject.cpp   1.17
  M +16 -0     kstviewobject.h   1.13


--- kdeextragear-2/kst/kst/kst2dplot.cpp  #1.5:1.6
@@ -50,23 +50,10 @@ void Kst2DPlot::paint(QPainter& p) {
 
 bool Kst2DPlot::popupMenu(KPopupMenu *menu, const QPoint& pos, KstViewObjectPtr topLevelParent) {
+  _standardActions |= Delete;
+
   KstViewObject::popupMenu(menu, pos, topLevelParent);
-  _view = dynamic_cast<KstTopLevelView*>(topLevelParent.data());
-  if (_view && _parent) {
-    menu->insertItem(i18n("Delete"), this, SLOT(deleteObject()));
     return true;
-  }
-
-  return false;
 }
 
-
-void Kst2DPlot::deleteObject() {
-  if (_parent) {
-    _parent->removeChild(this);
-  }
-  //_view->paint(true);
-}
-
-
 #include "kst2dplot.moc"
 // vim: ts=2 sw=2 et

--- kdeextragear-2/kst/kst/kst2dplot.h  #1.2:1.3
@@ -20,5 +20,4 @@
 
 #include "kstplotbase.h"
-#include "ksttoplevelview.h"
 
 class Kst2DPlot : public KstPlotBase {
@@ -36,8 +35,4 @@ class Kst2DPlot : public KstPlotBase {
   public slots:
     virtual void paint(QPainter& p);
-
-  private slots:
-    void deleteObject();
-    KstTopLevelViewPtr _view;
 };
 

--- kdeextragear-2/kst/kst/kstviewobject.cpp  #1.16:1.17
@@ -24,7 +24,9 @@
 
 #include <kdebug.h>
+#include <klocale.h>
 #include <kpopupmenu.h>
 
 KstViewObject::KstViewObject() : KstObject(), _geom(0, 0, 1, 1), _focus(false) {
+  _standardActions = 0;
 }
 
@@ -32,4 +34,5 @@ KstViewObject::KstViewObject() : KstObje
 KstViewObject::KstViewObject(QDomElement& e) : KstObject() {
   Q_UNUSED(e)
+  _standardActions = 0;
 }
 
@@ -285,5 +288,13 @@ bool KstViewObject::popupMenu(KPopupMenu
   Q_UNUSED(pos)
   Q_UNUSED(topParent)
+
+  if (_standardActions & Delete) {
+    menu->insertItem(i18n("Delete"), this, SLOT(deleteObject()));
+  }
+
+  // FIXME: implement the rest of the actions
+
   menu->insertTitle(tagName(), -1, 0);
+
   return false;
 }
@@ -289,4 +300,11 @@ bool KstViewObject::popupMenu(KPopupMenu
 }
 
+
+void KstViewObject::deleteObject() {
+  if (_parent) {
+    _parent->removeChild(this);
+  }
+}
+
 #include "kstviewobject.moc"
 // vim: ts=2 sw=2 et

--- kdeextragear-2/kst/kst/kstviewobject.h  #1.12:1.13
@@ -83,4 +83,16 @@ class KstViewObject : public KstObject {
     virtual bool popupMenu(KPopupMenu *menu, const QPoint& pos, KstViewObjectPtr topParent);
 
+    typedef int StandardAction;
+    enum StandardActions { Delete =          1,
+                           Copy =            2,
+                           Cut =             4,
+                           Paste =           8,
+                           Raise =          16,
+                           Lower =          32,
+                           RaiseToTop =     64,
+                           LowerToBottom = 128,
+                           Properties =    256,
+                        };
+
   public slots:
     virtual void paint(QPainter& p);
@@ -89,4 +101,7 @@ class KstViewObject : public KstObject {
     virtual void parentResized(const QSize& old, const QSize& size);
 
+    /***********  Actions ************/
+    virtual void deleteObject();
+
   protected:
     KstViewObjectList _children;
@@ -96,4 +111,5 @@ class KstViewObject : public KstObject {
     bool _selected : 1;
     KstViewObjectPtr _parent;
+    int _standardActions;
 };
 





More information about the Kst mailing list