[Kst] kdeextragear-2/kst/kst
Rick Chern
rchern at interchange.ubc.ca
Fri Aug 13 23:20:44 CEST 2004
CVS commit by rchern:
Check all windows for plot name when creating a new plot
CCMAIL: 87146-done at bugs.kde.org
M +57 -26 kstviewwindow.h 1.20
--- kdeextragear-2/kst/kst/kstviewwindow.h #1.19:1.20
@@ -30,4 +30,6 @@
#include <klocale.h>
+#include "kst.h"
+#include "kst2dplot.h"
#include "kstdatacollection.h"
#include "kstdefaultnames.h"
@@ -101,36 +103,65 @@ class KstViewWindow : public KMdiChildVi
template<class T>
QString KstViewWindow::createPlot(const QString& suggestedName, bool prompt) {
+
+ KstApp *app = KstApp::inst();
+ KMdiIterator<KMdiChildView*> *iter;
+
QString name = suggestedName;
+ bool duplicate = true;
+ while (duplicate) {
+ duplicate = false;
KstViewObjectPtr rc;
- if (!name.isEmpty()) {
- rc = _view->findChild(name);
- }
-
- while (name.isEmpty() || rc) {
+ //check the name
+ iter = app->createIterator();
+ while (iter->currentItem() && !duplicate) {
+ KMdiChildView *childview = iter->currentItem();
+ KstViewWindow *viewwindow = dynamic_cast<KstViewWindow*>(childview);
+ if (viewwindow) {
+ rc = viewwindow->view()->findChild(name);
+ if (rc) {
+ duplicate = true;
name = KST::suggestPlotName();
- rc = _view->findChild(name);
}
-
- if (!prompt) {
- _view->createPlot<T>(name);
- return name;
+ }
+ iter->next();
+ }
+ app->deleteIterator(iter);
}
+ if (prompt) {
bool ok = false;
- QString newName = name;
- do {
- newName = KLineEditDlg::getText(i18n("Enter a name for the new plot:"), newName, &ok, 0L);
- if (ok) {
- rc = _view->findChild(name);
- if (!rc) {
- _view->createPlot<T>(name);
- return name;
+ name = KLineEditDlg::getText(i18n("Enter a name for the new plot:"), name, &ok, 0L);
+ if (!ok) {
+ return QString();
}
- } else {
- break;
+ //check the name
+ duplicate = true;
+ while (duplicate) {
+ duplicate = false;
+ KstViewObjectPtr rc;
+ //check the name
+ iter = app->createIterator();
+ while (iter->currentItem() && !duplicate) {
+ KMdiChildView *childview = iter->currentItem();
+ KstViewWindow *viewwindow = dynamic_cast<KstViewWindow*>(childview);
+ if (viewwindow) {
+ rc = viewwindow->view()->findChild(name);
+ if (rc) {
+ duplicate = true;
+ name = KLineEditDlg::getText(i18n("Enter a name for the new plot:"), name, &ok, 0L);
+ if (!ok) {
+ app->deleteIterator(iter);
+ return QString();
}
- } while(true);
-
- return QString::null;
+ }
+ }
+ iter->next();
+ }
+ app->deleteIterator(iter);
+ }
+ }
+ //create the plot now
+ _view->createPlot<T>(name);
+ return name;
}
More information about the Kst
mailing list