[Kst] branches/work/kst/portto4/kst/src/libkstapp
Mike Fenton
mike at staikos.net
Wed Dec 5 22:36:11 CET 2007
SVN commit 745284 by fenton:
Add Apply function and EditMultiple support to EquationDialog.
M +75 -6 equationdialog.cpp
M +6 -0 equationdialog.h
--- branches/work/kst/portto4/kst/src/libkstapp/equationdialog.cpp #745283:745284
@@ -12,6 +12,7 @@
#include "equationdialog.h"
#include "dialogpage.h"
+#include "editmultiplewidget.h"
#include "datacollection.h"
#include "dataobjectcollection.h"
@@ -42,6 +43,10 @@
connect(Operators, SIGNAL(activated(QString)), this, SLOT(equationOperatorUpdate(const QString&)));
connect(_vectors, SIGNAL(selectionChanged(QString)), this, SLOT(equationUpdate(const QString&)));
connect(_scalars, SIGNAL(selectionChanged(QString)), this, SLOT(equationUpdate(const QString&)));
+
+ connect(_xVectors, SIGNAL(selectionChanged(QString)), this, SIGNAL(modified()));
+ connect(_equation, SIGNAL(textChanged(const QString &)), this, SIGNAL(modified()));
+ connect(_doInterpolation, SIGNAL(clicked()), this, SIGNAL(modified()));
}
@@ -117,6 +122,11 @@
}
+bool EquationTab::xVectorDirty() const {
+ return _xVectors->selectedVectorDirty();
+}
+
+
void EquationTab::setXVector(VectorPtr vector) {
_xVectors->setSelectedVector(vector);
}
@@ -127,6 +137,11 @@
}
+bool EquationTab::equationDirty() const {
+ return (!_equation->text().isEmpty());
+}
+
+
void EquationTab::setEquation(const QString &equation) {
_equation->setText(equation);
}
@@ -137,6 +152,11 @@
}
+bool EquationTab::doInterpolationDirty() const {
+ return _doInterpolation->checkState() == Qt::PartiallyChecked;
+}
+
+
void EquationTab::setDoInterpolation(bool doInterpolation) {
_doInterpolation->setChecked(doInterpolation);
}
@@ -166,6 +186,14 @@
}
+void EquationTab::clearTabValues() {
+ _xVectors->clearSelection();
+ _equation->clear();
+ _doInterpolation->setCheckState(Qt::PartiallyChecked);
+ _curveAppearance->clearValues();
+}
+
+
EquationDialog::EquationDialog(ObjectPtr dataObject, QWidget *parent)
: DataDialog(dataObject, parent) {
@@ -186,6 +214,10 @@
}
connect(_equationTab, SIGNAL(optionsChanged()), this, SLOT(updateButtons()));
+ connect(this, SIGNAL(editMultipleMode()), this, SLOT(editMultipleMode()));
+ connect(this, SIGNAL(editSingleMode()), this, SLOT(editSingleMode()));
+
+ connect(_equationTab, SIGNAL(modified()), this, SLOT(modified()));
updateButtons();
}
@@ -200,8 +232,18 @@
}
+void EquationDialog::editMultipleMode() {
+ _equationTab->clearTabValues();
+}
+
+
+void EquationDialog::editSingleMode() {
+ configureTab(dataObject());
+}
+
+
void EquationDialog::updateButtons() {
- _buttonBox->button(QDialogButtonBox::Ok)->setEnabled(_equationTab->xVector() && !_equationTab->equation().isEmpty());
+ _buttonBox->button(QDialogButtonBox::Ok)->setEnabled((_equationTab->xVector() && !_equationTab->equation().isEmpty()) || (editMode() == EditMultiple));
}
@@ -213,6 +255,14 @@
_equationTab->setEquation(equation->equation());
_equationTab->setDoInterpolation(equation->doInterp());
_equationTab->hideCurveOptions();
+ if (_editMultipleWidget) {
+ QStringList objectList;
+ EquationList objects = _document->objectStore()->getObjects<Equation>();
+ foreach(EquationPtr object, objects) {
+ objectList.append(object->tag().displayString());
+ }
+ _editMultipleWidget->addObjects(objectList);
+ }
}
}
@@ -287,12 +337,31 @@
ObjectPtr EquationDialog::editExistingDataObject() const {
if (EquationPtr equation = kst_cast<Equation>(dataObject())) {
- equation->writeLock();
- equation->setEquation(_equationTab->equation());
- equation->setExistingXVector(_equationTab->xVector(), _equationTab->doInterpolation());
+ if (editMode() == EditMultiple) {
+ QStringList objects = _editMultipleWidget->selectedObjects();
+ foreach (QString objectTag, objects) {
+ EquationPtr equation = kst_cast<Equation>(_document->objectStore()->retrieveObject(ObjectTag::fromString(objectTag)));
+ if (equation) {
+ VectorPtr xVector = _equationTab->xVectorDirty() ? _equationTab->xVector() : equation->vXIn();
+ const QString equationString = _equationTab->equationDirty() ? _equationTab->equation() : equation->equation();
+ const bool doInterpolation = _equationTab->doInterpolationDirty() ? _equationTab->doInterpolation() : equation->doInterp();
- equation->update(0);
- equation->unlock();
+ equation->writeLock();
+ equation->setEquation(equationString);
+ equation->setExistingXVector(xVector, doInterpolation);
+
+ equation->update(0);
+ equation->unlock();
+ }
+ }
+ } else {
+ equation->writeLock();
+ equation->setEquation(_equationTab->equation());
+ equation->setExistingXVector(_equationTab->xVector(), _equationTab->doInterpolation());
+
+ equation->update(0);
+ equation->unlock();
+ }
}
return dataObject();
}
--- branches/work/kst/portto4/kst/src/libkstapp/equationdialog.h #745283:745284
@@ -30,18 +30,22 @@
void setObjectStore(ObjectStore *store);
VectorPtr xVector() const;
+ bool xVectorDirty() const;
void setXVector(VectorPtr vector);
QString equation() const;
+ bool equationDirty() const;
void setEquation(const QString &equation);
bool doInterpolation() const;
+ bool doInterpolationDirty() const;
void setDoInterpolation(bool doInterpolation);
CurveAppearance *curveAppearance() const;
CurvePlacement *curvePlacement() const;
void hideCurveOptions();
+ void clearTabValues();
Q_SIGNALS:
void optionsChanged();
@@ -68,6 +72,8 @@
private Q_SLOTS:
void updateButtons();
+ void editMultipleMode();
+ void editSingleMode();
private:
void configureTab(ObjectPtr object);
More information about the Kst
mailing list