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.
In addition, plots with blank names do not get their "Unique plot name" field filled in properly.
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);