[Kst] kdeextragear-2/kst/kst
Rick Chern
rchern at interchange.ubc.ca
Wed Aug 11 23:18:10 CEST 2004
CVS commit by rchern:
Versions of KST::suggest for arrays and images.
M +7 -9 kstarraydialog_i.cpp 1.11
M +33 -0 kstdefaultnames.cpp 1.4
M +2 -0 kstdefaultnames.h 1.4
M +7 -11 kstimagedialog_i.cpp 1.19
--- kdeextragear-2/kst/kst/kstarraydialog_i.cpp #1.10:1.11
@@ -142,15 +142,13 @@ bool KstArrayDialogI::new_I() {
}
(*vector_iter)->readLock();
+
//create a unique name
- KstArrayList arrays = kstObjectSubList<KstDataObject, KstArray>(KST::dataObjectList);
- int arrayCount = arrays.count() + 1;
- QString tag_name = _tagName->text();
- tag_name.replace("<New_Array>", "A" + QString::number(arrayCount) + "-" + (*vector_iter)->tagName());
- while (KST::dataTagNameNotUnique(tag_name, false)) {
- tag_name.sprintf("A%d-", arrayCount);
- tag_name += (*vector_iter)->tagName();
- arrayCount++;
+ QString tag_name = KST::suggestArrayName((*vector_iter)->tagName());
+ if (KST::dataTagNameNotUnique(tag_name)) {
+ _tagName->setFocus();
+ (*vector_iter)->readUnlock();
+ return false;
}
- arrays.clear();
+
KstArrayPtr array = new KstArray(tag_name, *vector_iter,
_nX->cleanText().toUInt(),
--- kdeextragear-2/kst/kst/kstdefaultnames.cpp #1.3:1.4
@@ -110,3 +110,36 @@ QString KST::suggestPluginName(const QSt
}
+/* takes a vector or plugin of the form V2-GYRO1 and returns a unique */
+/* array name of the form A1-GYRO1 */
+QString KST::suggestArrayName(const QString& vector_name) {
+ QString name;
+ KstVCurveList curves =
+ kstObjectSubList<KstDataObject, KstVCurve>(KST::dataObjectList);
+
+ QString field = vector_name;
+ field.remove( QRegExp( "^[VP][0-9]{1,2}\\-" ) );
+ int n = KST::dataObjectList.count();
+ do {
+ n++;
+ name = QString("A%1-%2").arg(n).arg(field);
+ } while ( KST::dataObjectList.findTag(name) != KST::dataObjectList.end() );
+ return name;
+}
+
+/* takes an array name of the form A2-GYRO1 and returns a unique */
+/* image name of the form Img1-GYRO1 */
+QString KST::suggestImageName(const QString& array_name) {
+ QString name;
+ KstVCurveList curves =
+ kstObjectSubList<KstDataObject, KstVCurve>(KST::dataObjectList);
+
+ QString field = array_name;
+ field.remove( QRegExp( "^[A][0-9]{1,2}\\-" ) );
+ int n = KST::dataObjectList.count();
+ do {
+ n++;
+ name = QString("Img%1-%2").arg(n).arg(field);
+ } while ( KST::dataObjectList.findTag(name) != KST::dataObjectList.end() );
+ return name;
+}
// vim: ts=2 sw=2 et
--- kdeextragear-2/kst/kst/kstdefaultnames.h #1.3:1.4
@@ -30,4 +30,6 @@ namespace KST {
extern QString suggestHistogramName(const QString& vector_name);
extern QString suggestPluginName(const QString& pname, const QString& vname = QString::null);
+ extern QString suggestArrayName(const QString& vector_name);
+ extern QString suggestImageName(const QString& array_name);
}
--- kdeextragear-2/kst/kst/kstimagedialog_i.cpp #1.18:1.19
@@ -206,5 +206,4 @@ bool KstImageDialogI::new_I() {
KstArrayList arrays = kstObjectSubList<KstDataObject, KstArray>(KST::dataObjectList);
- KST::dataObjectList.lock().readLock();
KstArrayPtr array = *arrays.findTag(_array->selectedArray());
if (!array) {
@@ -212,17 +211,14 @@ bool KstImageDialogI::new_I() {
return false;
}
-
+ KST::dataObjectList.lock().readLock();
array->readLock();
+
//create a unique name
- KstImageList images = kstObjectSubList<KstDataObject, KstImage>(KST::dataObjectList);
- int imageCount = images.count() + 1;
- QString tag_name = _tagName->text();
- tag_name.replace("<New_Image>", "Img" + QString::number(imageCount) + "-" + array->tagName());
- while (KST::dataTagNameNotUnique(tag_name, false)) {
- tag_name.sprintf("Img%d-", imageCount);
- tag_name += array->tagName();
- imageCount++;
+ QString tag_name = KST::suggestImageName(array->tagName());
+ if (KST::dataTagNameNotUnique(tag_name)) {
+ _tagName->setFocus();
+ KST::dataObjectList.lock().readUnlock();
+ return false;
}
- images.clear();
KstImagePtr image;
More information about the Kst
mailing list