[Kst] kdeextragear-2/kst/kst

Rick Chern rchern at interchange.ubc.ca
Fri Jul 30 22:59:06 CEST 2004


CVS commit by rchern: 

Show images in popup menu


  M +60 -23    kst2dplot.cpp   1.191
  M +3 -1      kst2dplot.h   1.81


--- kdeextragear-2/kst/kst/kst2dplot.cpp  #1.190:1.191
@@ -2162,5 +2162,6 @@ bool Kst2DPlot::popupMenu(KPopupMenu *me
 
   n_curves = Curves.count();
-  if (n_curves > 0) {
+  int n_images = _images.count();
+  if (n_curves + n_images > 0) {
     menu->insertSeparator();
 
@@ -2168,4 +2169,6 @@ bool Kst2DPlot::popupMenu(KPopupMenu *me
     _curveFitMap.clear();
     _curveRemoveMap.clear();
+    _imageEditMap.clear();
+    _imageRemoveMap.clear();
 
     //
@@ -2181,4 +2184,12 @@ bool Kst2DPlot::popupMenu(KPopupMenu *me
       hasEntry = true;
     }
+    //repeat for images
+    for (i = n_curves; i < n_images + n_curves; i++) {
+      QString tag = _images[i-n_curves]->tagName();
+      _imageEditMap[i] = tag;
+      submenu->insertItem(tag, i);
+      submenu->connectItem(i, this, SLOT(editImage(int)));
+      hasEntry = true;
+    }
     id = menu->insertItem(i18n("Edit..."), submenu);
     menu->setItemEnabled(id, hasEntry);
@@ -2187,4 +2198,5 @@ bool Kst2DPlot::popupMenu(KPopupMenu *me
     // Fit... menu
     //
+    if (n_curves > 0) {
     submenu = new KPopupMenu(menu);
     hasEntry = false;
@@ -2213,5 +2225,5 @@ bool Kst2DPlot::popupMenu(KPopupMenu *me
     id = menu->insertItem(i18n("Filter..."), submenu);
     submenu->setItemEnabled(id, hasEntry);
-
+    }
     //
     // Remove menu...
@@ -2226,4 +2238,12 @@ bool Kst2DPlot::popupMenu(KPopupMenu *me
       hasEntry = true;
     }
+    //repeat for images
+    for (i = n_curves; i < n_images + n_curves; i++) {
+      QString tag = _images[i-n_curves]->tagName();
+      _imageRemoveMap[i] = tag;
+      submenu->insertItem(tag, i);
+      submenu->connectItem(i, this, SLOT(removeImage(int)));
+      hasEntry = true;
+    }
     id = menu->insertItem(i18n("Remove"), submenu);
     menu->setItemEnabled(id, hasEntry);
@@ -3884,4 +3904,21 @@ bool Kst2DPlot::curveToMarkersFallingDet
   return _curveToMarkersFallingDetect;
 }
+
+void Kst2DPlot::editImage(int id) {
+  KstImagePtr image = *(_images.findTag(_imageEditMap[id]));
+  if (image) {
+    image->showDialog();
+  }
+}
+
+void Kst2DPlot::removeImage(int id) {
+  KstImagePtr image = *(_images.findTag(_imageRemoveMap[id]));
+  if (image) {
+    removeImage(image);
+    if (_menuView) {
+      _menuView->paint();
+    }
+  }
+}
 #include "kst2dplot.moc"
 // vim: ts=2 sw=2 et

--- kdeextragear-2/kst/kst/kst2dplot.h  #1.80:1.81
@@ -230,8 +230,10 @@ public slots:
   virtual void paint(KstPaintType type, QPainter& p);
   void editCurve(int id);
+  void editImage(int id);
   void matchAxis(int id);
   void fitCurve(int id);
   void filterCurve(int id);
   void removeCurve(int id);
+  void removeImage(int id);
   void setDirty();
 
@@ -319,5 +321,5 @@ private:
   QPoint _draggablePoint;
 
-  QMap<int, QString> _curveEditMap, _curveFitMap, _curveRemoveMap;
+  QMap<int, QString> _curveEditMap, _curveFitMap, _curveRemoveMap, _imageEditMap, _imageRemoveMap;
   QMap<int, QGuardedPtr<Kst2DPlot> > _plotMap;
 





More information about the Kst mailing list