[Kst] kdeextragear-2/kst

George Staikos staikos at kde.org
Thu Sep 11 21:04:03 CEST 2003


CVS commit by staikos: 

Create the context menu requested in the TODO file.  Added "Edit" and "Delete"
so far.  Still need to add the more advanced items.


  M +0 -2      TODO   1.13
  M +21 -1     kst/kstdatamanager_i.cpp   1.31
  M +2 -0      kst/kstdatamanager_i.h   1.9


--- kdeextragear-2/kst/TODO  #1.12:1.13
@@ -8,8 +8,6 @@
 
 RBM in data manager:
-        Edit
         for curves: Add to plot
         for vectors: make curve
-        Delete
 
 Config options:

--- kdeextragear-2/kst/kst/kstdatamanager_i.cpp  #1.30:1.31
@@ -20,8 +20,9 @@
 #include <assert.h>
 
+#include <kdebug.h>
 #include <klistview.h>
 #include <klocale.h>
-#include <kdebug.h>
 #include <kmessagebox.h>
+#include <kpopupmenu.h>
 
 #include <qlistview.h>
@@ -160,4 +161,5 @@ class KstObjectItem : public QListViewIt
     //KstRVectorPtr rvector() { return *kstObjectSubList<KstVector,KstRVector>(KST::vectorList).findTag(_name); }
     KstDataObjectPtr dataObject() { return *KST::dataObjectList.findTag(_name); }
+    bool removable() const { return _removable; }
 
   protected:
@@ -199,4 +201,6 @@ KstDataManagerI::KstDataManagerI(KstDoc 
     connect(NewVector, SIGNAL(clicked()),
             KstVectorDialogI::globalInstance(), SLOT(show_New()));
+
+    connect(DataView, SIGNAL(contextMenuRequested(QListViewItem*, const QPoint&, int)), this, SLOT(contextMenu(QListViewItem*, const QPoint&, int)));
 }
 
@@ -299,4 +303,20 @@ void KstDataManagerI::delete_I() {
   }
 }
+
+void KstDataManagerI::contextMenu(QListViewItem *i, const QPoint& p, int c) {
+  Q_UNUSED(c)
+  KstObjectItem *koi = static_cast<KstObjectItem*>(i);
+
+  if (koi->rtti() == RTTI_OBJ_OBJECT || koi->rtti() == RTTI_OBJ_DATA_VECTOR) {
+    KPopupMenu *m = new KPopupMenu(this);
+    m->setTitle(koi->text(0));
+    int id = m->insertItem(i18n("&Edit..."), this, SLOT(edit_I()));
+    //m->setItemEnabled(id, RTTI_OBJ_VECTOR != koi->rtti());
+    id = m->insertItem(i18n("&Delete"), this, SLOT(delete_I()));
+    m->setItemEnabled(id, koi->removable());
+    m->popup(p);
+  }
+}
+
 
 #include "kstdatamanager_i.moc"

--- kdeextragear-2/kst/kst/kstdatamanager_i.h  #1.8:1.9
@@ -38,4 +38,6 @@ public slots:
   void edit_I();
   void delete_I();
+  void contextMenu(QListViewItem *i, const QPoint& p, int c);
+
 private:
   KstDoc *doc;




More information about the Kst mailing list