Bug 87386 - Blank plot names are allowed
Summary: Blank plot names are allowed
Status: RESOLVED FIXED
Alias: None
Product: kst
Classification: Applications
Component: general (show other bugs)
Version: 1.x
Platform: Compiled Sources Linux
: NOR wishlist
Target Milestone: ---
Assignee: Rick Chern
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-08-17 21:40 UTC by Rick Chern
Modified: 2004-08-17 22:25 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rick Chern 2004-08-17 21:40:25 UTC
Version:           1.0.0-devel (using KDE KDE 3.2.1)
Installed from:    Compiled From Sources
OS:                Linux

Currently, Kst allows plots with blank names.  This seems to be ok, because duplicate blank names are not allowed, and saving/loading of plots with blank names seems to work.  

However, it is a bit weird.
Comment 1 Rick Chern 2004-08-17 22:06:32 UTC
In addition, plots with blank names do not get their "Unique plot name" field filled in properly.
Comment 2 Rick Chern 2004-08-17 22:25:11 UTC
CVS commit by rchern: 

- Don't allow blank plot names
- strip whitespace from beginning and end of names, but still allow whitespace in between.  Names that differ only by beginning/ending whitespace are considered duplicates and are not allowed.


  M +22 -14    kstplotdialog_i.cpp   1.81


--- kdeextragear-2/kst/kst/kstplotdialog_i.cpp  #1.80:1.81
@@ -522,4 +522,9 @@ void KstPlotDialogI::applyPlotColors(Kst
 
 void KstPlotDialogI::new_I() {
+  //check plot name
+  if (!checkPlotName()) {
+    return;
+  }
+
   KMdiChildView *c = KstApp::inst()->findWindow(_window->currentText());
   if (!c) {
@@ -533,10 +538,5 @@ void KstPlotDialogI::new_I() {
   }
 
-  //check plot name
-  if (!checkPlotName()) {
-    return;
-  }
-
-  Kst2DPlotPtr plot = static_cast<KstViewWindow*>(c)->view()->createPlot<Kst2DPlot>(Name->text());
+  Kst2DPlotPtr plot = static_cast<KstViewWindow*>(c)->view()->createPlot<Kst2DPlot>(Name->text().stripWhiteSpace());
 
   if (_reGrid->isChecked()) {
@@ -581,5 +581,5 @@ void KstPlotDialogI::new_I() {
   //doc->setDelay(UpdateDelay->value());
 
-  _plotName = Name->text();
+  _plotName = Name->text().stripWhiteSpace();
   update();
 
@@ -595,5 +595,5 @@ void KstPlotDialogI::edit_I() {
 
   //check the plot name
-  if (Name->text() != Select->currentText()) {
+  if (Name->text().stripWhiteSpace() != Select->currentText()) {
     if (!checkPlotName()) {
     return;
@@ -613,5 +613,5 @@ void KstPlotDialogI::edit_I() {
     Kst2DPlotPtr plot = *plots.at(index);
 
-    plot->setTagName(Name->text());
+    plot->setTagName(Name->text().stripWhiteSpace());
     /* add the curves */
     plot->Curves.clear();
@@ -1190,7 +1190,16 @@ void KstPlotDialogI::newWindow() {
 
 bool KstPlotDialogI::checkPlotName() {
+  //first check if name is blank
+  if (Name->text().stripWhiteSpace().isEmpty()) {
+    QString message = i18n("The plot name is empty. Please enter a unique name for the plot.");
+    KMessageBox::sorry(this, message);
+    Name->setFocus();
+    return false;
+  }
+
+  //now check if it's a duplicate
   KstApp *app = KstApp::inst();
   KMdiIterator<KMdiChildView*> *iter;
-  QString name = Name->text();
+  QString name = Name->text().stripWhiteSpace();
   //check the name
   KstViewObjectPtr rc;
@@ -1202,7 +1211,6 @@ bool KstPlotDialogI::checkPlotName() {
       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());
+        QString message = i18n("%1: not a unique plot name.\n"
+            "Change it to a unique name.").arg(Name->text().stripWhiteSpace());
 
         KMessageBox::sorry(this, message);