[Kst] kdeextragear-2/kst/kst

Rick Chern rchern at interchange.ubc.ca
Mon Aug 16 18:42:42 CEST 2004


CVS commit by rchern: 

Make sure checks for duplicate plot names are done for both new and edit plots.

CCMAIL: 87146-done at bugs.kde.org


  M +39 -24    kstplotdialog_i.cpp   1.76
  M +1 -1      kstplotdialog_i.h   1.30


--- kdeextragear-2/kst/kst/kstplotdialog_i.cpp  #1.75:1.76
@@ -529,29 +529,8 @@ void KstPlotDialogI::new_I() {
   }
 
-  KstApp *app = KstApp::inst();
-  KMdiIterator<KMdiChildView*> *iter;
-  QString name = Name->text();
-  //check the name
-  KstViewObjectPtr rc;
-  iter = app->createIterator();
-  while (iter->currentItem()) {
-    KMdiChildView *childview = iter->currentItem();
-    KstViewWindow *viewwindow = dynamic_cast<KstViewWindow*>(childview);
-    if (viewwindow) {
-      rc = viewwindow->view()->findChild(name);
-      if (rc) {
-        QString message = i18n("Could not create a new plot.\n"
-            "%1: not a unique plot name.\n"
-            "Change it to a unique name.").arg(Name->text());
-
-        KMessageBox::sorry(this, message);
-        Name->setFocus();
-        app->deleteIterator(iter);
+  //check plot name
+  if (!checkPlotName()) {
         return;
       }
-    }
-    iter->next();
-  }
-  app->deleteIterator(iter);
 
   Kst2DPlotPtr plot = static_cast<KstViewWindow*>(c)->view()->createPlot<Kst2DPlot>(Name->text());
@@ -611,4 +590,11 @@ void KstPlotDialogI::edit_I() {
   }
 
+  //check the plot name
+  if (Name->text() != Select->currentText()) {
+    if (!checkPlotName()) {
+    return;
+    }
+  }
+
   KMdiChildView *c = KstApp::inst()->findWindow(_window->currentText());
   if (!c) {
@@ -1199,4 +1185,33 @@ void KstPlotDialogI::newWindow() {
 }
 
+bool KstPlotDialogI::checkPlotName() {
+  KstApp *app = KstApp::inst();
+  KMdiIterator<KMdiChildView*> *iter;
+  QString name = Name->text();
+  //check the name
+  KstViewObjectPtr rc;
+  iter = app->createIterator();
+  while (iter->currentItem()) {
+    KMdiChildView *childview = iter->currentItem();
+    KstViewWindow *viewwindow = dynamic_cast<KstViewWindow*>(childview);
+    if (viewwindow) {
+      rc = viewwindow->view()->findChild(name);
+      if (rc) {
+        QString message = i18n("Could not create a new plot.\n"
+            "%1: not a unique plot name.\n"
+            "Change it to a unique name.").arg(Name->text());
+
+        KMessageBox::sorry(this, message);
+        Name->setFocus();
+        app->deleteIterator(iter);
+        return false;
+      }
+    }
+    iter->next();
+  }
+  app->deleteIterator(iter);
+  return true;
+}
+
 #include "kstplotdialog_i.moc"
 // vim: et ts=2 sw=2

--- kdeextragear-2/kst/kst/kstplotdialog_i.h  #1.29:1.30
@@ -103,5 +103,5 @@ class KstPlotDialogI : public KstPlotDia
   private:
     void fill2DPlotList(Kst2DPlotList& plots);
-
+    bool checkPlotName();
     KstDoc *doc;
     KstLabel *SampleLabel;





More information about the Kst mailing list