[Kst] kdeextragear-2/kst/kst

George Staikos staikos at kde.org
Thu Jul 10 10:53:36 CEST 2003


CVS commit by staikos: 

- usage note for kstplugin
- only activate Edit and Delete buttons when they're meaningful


  M +20 -6     kstdatamanager_i.cpp   1.19
  M +4 -0      kstplugin.h   1.19


--- kdeextragear-2/kst/kst/kstdatamanager_i.cpp  #1.18:1.19
@@ -45,6 +45,6 @@
 class KstObjectItem : public QListViewItem {
   public:
-    KstObjectItem(QListViewItem *parent, KstVectorPtr x)
-    : QListViewItem(parent), _rtti(RTTI_OBJ_VECTOR), _v(x) {
+    KstObjectItem(QListViewItem *parent, KstVectorPtr x, KstDataManagerI *dm)
+    : QListViewItem(parent), _rtti(RTTI_OBJ_VECTOR), _v(x), _dm(dm) {
       assert(x);
       setText(0, x->tagName());
@@ -55,6 +55,6 @@ class KstObjectItem : public QListViewIt
     }
 
-    KstObjectItem(QListView *parent, KstDataObjectPtr x)
-    : QListViewItem(parent), _rtti(RTTI_OBJ_OBJECT), _d(x) {
+    KstObjectItem(QListView *parent, KstDataObjectPtr x, KstDataManagerI *dm)
+    : QListViewItem(parent), _rtti(RTTI_OBJ_OBJECT), _d(x), _dm(dm) {
       assert(x.data());
       setText(0, x->tagName());
@@ -66,5 +66,5 @@ class KstObjectItem : public QListViewIt
       //          << x->outputVectors().count() << " out vectors." << endl;
       for (unsigned i = 0; i < x->outputVectors().count(); i++) {
-        new KstObjectItem(this, x->outputVectors()[i]);
+        new KstObjectItem(this, x->outputVectors()[i], _dm);
       }
     }
@@ -78,8 +78,19 @@ class KstObjectItem : public QListViewIt
     KstDataObjectPtr dataObject() { return _d; }
 
+  protected:
+    virtual void activate() {
+      bool act = true;
+      if (_rtti == RTTI_OBJ_VECTOR) {
+        act = false;
+      }
+      _dm->Edit->setEnabled(act);
+      _dm->Delete->setEnabled(act);
+    }
+
   private:
     int              _rtti;
     KstVectorPtr     _v;
     KstDataObjectPtr _d;
+    KstDataManagerI *_dm;
 };
 
@@ -151,6 +162,9 @@ void KstDataManagerI::update() {
                                     it != KST::dataObjectList.end();
                                                                 ++it) {
-    new KstObjectItem(DataView, *it);
+    new KstObjectItem(DataView, *it, this);
   }
+
+  Edit->setEnabled(false);
+  Delete->setEnabled(false);
 }
 

--- kdeextragear-2/kst/kst/kstplugin.h  #1.18:1.19
@@ -27,4 +27,8 @@
 #include <qdom.h>
 
+/*  Usage notes:
+ *   - Output vectors are created internally, but may be renamed.
+ *   - Input vectors must be set before setPlugin(), else it will fail.
+ */
 
 class KstPlugin : public KstDataObject {




More information about the Kst mailing list