[Kst] kdeextragear-2/kst/kst

Rick Chern rchern at interchange.ubc.ca
Fri Jul 16 20:59:05 CEST 2004


CVS commit by rchern: 

Allow manually adding plot markers using the plot dialog


  M +37 -0     kstplotdialog_i.cpp   1.56


--- kdeextragear-2/kst/kst/kstplotdialog_i.cpp  #1.55:1.56
@@ -216,4 +216,8 @@ KstPlotDialogI::KstPlotDialogI(KstDoc *i
   connect(PlotMarkerList, SIGNAL(selectionChanged()),
           this, SLOT(updateButtons()));
+  connect(NewPlotMarker, SIGNAL(returnPressed()),
+          this, SLOT(addPlotMarker()));
+  connect(NewPlotMarker, SIGNAL(textChanged(const QString &)),
+          this, SLOT(updateButtons()));
 }
 
@@ -939,4 +943,6 @@ void KstPlotDialogI::updateButtons() {
 
   /** updates for Plot Markers tab **/
+  AddPlotMarker->setEnabled(NewPlotMarker->text() != QString(""));
+
   bSelected = false;
   count = PlotMarkerList->count();
@@ -1058,5 +1064,36 @@ void KstPlotDialogI::updatePlotList() {
 
 void KstPlotDialogI::addPlotMarker() {
+  //silently do nothing if there is no text, to be consistent
+  //with "Add" button disabled
+  if (NewPlotMarker->text() == QString("")) {
+    return;
+  }
 
+  bool ok;
+  double newMarkerVal = NewPlotMarker->text().toDouble(&ok);
+
+  if (ok) {
+    uint i = 0;
+    QString stringnum;
+    stringnum.setNum(newMarkerVal, 'f', 64);
+    while ((i < PlotMarkerList->count()) && (PlotMarkerList->text(i).toDouble() < newMarkerVal)) {
+      i++;
+    }
+    if (i == PlotMarkerList->count()) {
+      PlotMarkerList->insertItem(stringnum, -1);
+      NewPlotMarker->clear();
+      return;
+    }
+    if (newMarkerVal != PlotMarkerList->text(i).toDouble()) {
+      PlotMarkerList->insertItem(stringnum, i);
+      NewPlotMarker->clear();
+      return;
+    }
+    QMessageBox::information( this, i18n("Kst"),
+    i18n("A plot marker with equal (or very close) value already exists."));
+    return;
+  }
+  QMessageBox::information( this, i18n("Kst"),
+  i18n("The text you have entered is not a valid number.  Please enter a valid number."));
 }
 





More information about the Kst mailing list