[Kst] branches/work/kst/portto4/kst/src/libkstapp
Mike Fenton
mike at staikos.net
Wed Nov 21 18:58:38 CET 2007
SVN commit 739729 by fenton:
Add full functionality to the ChangeSampleDialog.
M +61 -17 changedatasampledialog.cpp
M +8 -1 changedatasampledialog.h
M +3 -0 changedatasampledialog.ui
--- branches/work/kst/portto4/kst/src/libkstapp/changedatasampledialog.cpp #739728:739729
@@ -13,6 +13,9 @@
#include "datacollection.h"
#include "datavector.h"
+#include "objectstore.h"
+#include "document.h"
+#include "mainwindow.h"
namespace Kst {
@@ -20,8 +23,18 @@
: QDialog(parent) {
setupUi(this);
+ if (MainWindow *mw = qobject_cast<MainWindow*>(parent)) {
+ _store = mw->document()->objectStore();
+ } else {
+ // FIXME: we need the object store
+ qFatal("ERROR: can't construct a ChangeDataSampleDialog without the object store");
+ }
+
connect(_clear, SIGNAL(clicked()), _curveList, SLOT(clearSelection()));
connect(_selectAll, SIGNAL(clicked()), this, SLOT(selectAll()));
+ connect(_curveList, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, SLOT(updateDefaults(QListWidgetItem*)));
+ connect(Apply, SIGNAL(clicked()), this, SLOT(applyChange()));
+ connect(OK, SIGNAL(clicked()), this, SLOT(OKClicked()));
}
@@ -36,30 +49,18 @@
void ChangeDataSampleDialog::updateCurveListDialog() {
- QStringList selectedCurves;
- for (int i_vector = 0; i_vector < _curveList->count(); i_vector++) {
- if (_curveList->item(i_vector)->isSelected()) {
- selectedCurves.append(_curveList->item(i_vector)->text());
- }
- }
_curveList->clear();
+ DataVectorList dataVectors = _store->getObjects<DataVector>();
-// DataVectorList rvl = ObjectSubList<Vector,DataVector>(vectorList);
- DataVectorList rvl; // FIXME
-
_curveList->blockSignals(true);
- int inserted = 0;
- for (DataVectorList::ConstIterator i = rvl.begin(); i != rvl.end(); ++i) {
+ for (DataVectorList::ConstIterator i = dataVectors.begin(); i != dataVectors.end(); ++i) {
DataVectorPtr vector = *i;
vector->readLock();
- QString tag = vector->tag().displayString();
- _curveList->addItem(tag);
- if (selectedCurves.contains(tag)) {
- _curveList->item(inserted)->setSelected(true);
- }
- ++inserted;
+ _curveList->addItem(vector->tag().displayString());
vector->unlock();
}
+
+ _curveList->selectAll();
_curveList->blockSignals(false);
}
@@ -69,6 +70,49 @@
}
+void ChangeDataSampleDialog::updateDefaults(QListWidgetItem* item) {
+ if (!item) {
+ return;
+ }
+
+ if (DataVectorPtr vector = kst_cast<DataVector>(_store->retrieveObject(Kst::ObjectTag::fromString(item->text())))) {
+ vector->readLock();
+
+ _dataRange->setCountFromEnd(vector->countFromEOF());
+ _dataRange->setStart(vector->countFromEOF() ? 0 : vector->reqStartFrame());
+ _dataRange->setReadToEnd(vector->readToEOF());
+ _dataRange->setRange(vector->readToEOF() ? 0 : vector->reqNumFrames());
+ _dataRange->setSkip(vector->skip());
+ _dataRange->setDoSkip(vector->doSkip());
+ _dataRange->setDoFilter(vector->doAve());
+
+ vector->unlock();
+ }
}
+
+void ChangeDataSampleDialog::OKClicked() {
+ applyChange();
+ accept();
+}
+
+
+void ChangeDataSampleDialog::applyChange() {
+ QList<QListWidgetItem*> selectedItems = _curveList->selectedItems();
+ for (int i = 0; i < selectedItems.size(); ++i) {
+ if (DataVectorPtr vector = kst_cast<DataVector>(_store->retrieveObject(Kst::ObjectTag::fromString(selectedItems.at(i)->text())))) {
+ vector->writeLock();
+ vector->changeFrames( (_dataRange->countFromEnd() ? -1 : _dataRange->start()),
+ (_dataRange->readToEnd() ? -1 : _dataRange->range()),
+ _dataRange->skip(),
+ _dataRange->doSkip(),
+ _dataRange->doFilter());
+ vector->unlock();
+ }
+ }
+}
+
+
+}
+
// vim: ts=2 sw=2 et
--- branches/work/kst/portto4/kst/src/libkstapp/changedatasampledialog.h #739728:739729
@@ -20,6 +20,8 @@
namespace Kst {
+class ObjectStore;
+
class KST_EXPORT ChangeDataSampleDialog : public QDialog, Ui::ChangeDataSampleDialog
{
Q_OBJECT
@@ -29,12 +31,17 @@
void exec();
- public slots:
+ private slots:
+ void updateDefaults(QListWidgetItem* item);
void selectAll();
+ void OKClicked();
+ void applyChange();
private:
void updateCurveListDialog();
+ ObjectStore *_store;
+
};
}
--- branches/work/kst/portto4/kst/src/libkstapp/changedatasampledialog.ui #739728:739729
@@ -85,6 +85,9 @@
<property name="whatsThis" >
<string>The sample ranges for the vectors selected in this list will be changed.</string>
</property>
+ <property name="selectionMode" >
+ <enum>QAbstractItemView::ExtendedSelection</enum>
+ </property>
</widget>
</item>
<item row="2" column="0" colspan="2" >
More information about the Kst
mailing list