[Kst] branches/work/kst/portto4/kst/src/widgets
Mike Fenton
mike at staikos.net
Thu Nov 13 21:19:44 CET 2008
SVN commit 883911 by fenton:
Add simple scalar creation to ScalarSelector.
M +32 -2 scalarselector.cpp
M +1 -1 scalarselector.h
M +5 -1 scalarselector.ui
--- branches/work/kst/portto4/kst/src/widgets/scalarselector.cpp #883910:883911
@@ -15,6 +15,8 @@
#include "datacollection.h"
#include "objectstore.h"
+#include "enodes.h"
+
namespace Kst {
ScalarSelector::ScalarSelector(QWidget *parent, ObjectStore *store)
@@ -66,8 +68,36 @@
}
-ScalarPtr ScalarSelector::selectedScalar() const {
- //qDebug() << "xxx text: " << _scalar->currentText();
+ScalarPtr ScalarSelector::selectedScalar() {
+// qDebug() << "xxx text: " << _scalar->currentText();
+ if (_scalar->findText(_scalar->currentText(),Qt::MatchExactly) == -1) {
+ // Create the Scalar.
+ bool ok = false;
+ double value = _scalar->currentText().toDouble(&ok);
+ if (!ok) {
+ value = Equations::interpret(_store, _scalar->currentText().toLatin1(), &ok);
+ }
+
+ if (!ok) {
+ return 0; //invalid
+ }
+
+ ScalarPtr scalar = _store->createObject<Scalar>();
+ scalar->setValue(value);
+ scalar->setOrphan(true);
+ scalar->setEditable(true);
+
+ scalar->writeLock();
+ scalar->update();
+ scalar->unlock();
+
+ _scalar->clearEditText();
+ fillScalars();
+ setSelectedScalar(scalar);
+
+ return scalar;
+ }
+
return qVariantValue<Scalar*>(_scalar->itemData(_scalar->currentIndex()));
}
--- branches/work/kst/portto4/kst/src/widgets/scalarselector.h #883910:883911
@@ -33,7 +33,7 @@
void setObjectStore(ObjectStore *store);
- ScalarPtr selectedScalar() const;
+ ScalarPtr selectedScalar();
void setSelectedScalar(ScalarPtr selectedScalar);
void fillScalars();
--- branches/work/kst/portto4/kst/src/widgets/scalarselector.ui #883910:883911
@@ -42,7 +42,11 @@
</widget>
</item>
<item row="0" column="0" >
- <widget class="Kst::ComboBox" name="_scalar" />
+ <widget class="Kst::ComboBox" name="_scalar" >
+ <property name="editable" >
+ <bool>true</bool>
+ </property>
+ </widget>
</item>
<item row="0" column="2" >
<widget class="QToolButton" name="_newScalar" >
More information about the Kst
mailing list