[Kst] branches/work/kst/portto4/kst/src
Adam Treat
treat at kde.org
Mon Oct 1 19:17:56 CEST 2007
SVN commit 719683 by treat:
* Flesh out the vectorselector. It basically works now.
* Provide metatype information for a host of KstObject's.
M +2 -0 libkst/kstmatrix.h
M +3 -0 libkst/kstobject.h
M +2 -0 libkst/kstscalar.h
M +2 -0 libkst/kststring.h
M +2 -0 libkst/kstvector.h
M +0 -3 libkstapp/sessionmodel.cpp
M +1 -0 libkstmath/kstdataobject.h
M +24 -7 widgets/vectorselector.cpp
--- branches/work/kst/portto4/kst/src/libkst/kstmatrix.h #719682:719683
@@ -167,6 +167,8 @@
KstObject::UpdateType internalUpdate(KstObject::UpdateType providerUpdateType);
};
+Q_DECLARE_METATYPE(KstMatrix*)
+
typedef KstObjectList<KstMatrixPtr> KstMatrixList;
typedef KstObjectMap<KstMatrixPtr> KstMatrixMap;
typedef KstObjectCollection<KstMatrix> KstMatrixCollection;
--- branches/work/kst/portto4/kst/src/libkst/kstobject.h #719682:719683
@@ -24,6 +24,7 @@
#include <qstring.h>
#include <qdebug.h>
#include <qstringlist.h>
+#include <QMetaType>
#include "kst_export.h"
#include "kstsharedptr.h"
@@ -77,6 +78,8 @@
KstObject::UpdateType _lastUpdate;
} KST_EXPORT;
+Q_DECLARE_METATYPE(KstObject*)
+
typedef KstSharedPtr<KstObject> KstObjectPtr;
template <typename T, typename U>
--- branches/work/kst/portto4/kst/src/libkst/kstscalar.h #719682:719683
@@ -82,6 +82,8 @@
bool _editable;
};
+Q_DECLARE_METATYPE(KstScalar*)
+
typedef KstSharedPtr<KstScalar> KstScalarPtr;
typedef KstObjectList<KstScalarPtr> KstScalarList;
typedef KstObjectMap<KstScalarPtr> KstScalarMap;
--- branches/work/kst/portto4/kst/src/libkst/kststring.h #719682:719683
@@ -69,6 +69,8 @@
bool _editable;
};
+Q_DECLARE_METATYPE(KstString*)
+
typedef KstSharedPtr<KstString> KstStringPtr;
typedef KstObjectList<KstStringPtr> KstStringList;
typedef KstObjectMap<KstStringPtr> KstStringMap;
--- branches/work/kst/portto4/kst/src/libkst/kstvector.h #719682:719683
@@ -206,6 +206,8 @@
KstObject::UpdateType internalUpdate(KstObject::UpdateType providerRC);
} KST_EXPORT;
+Q_DECLARE_METATYPE(KstVector*)
+
typedef KstObjectList<KstVectorPtr> KstVectorList;
typedef KstObjectMap<KstVectorPtr> KstVectorMap;
typedef KstObjectCollection<KstVector> KstVectorCollection;
--- branches/work/kst/portto4/kst/src/libkstapp/sessionmodel.cpp #719682:719683
@@ -15,9 +15,6 @@
#include <kstdatacollection.h>
#include <kstdataobjectcollection.h>
-Q_DECLARE_METATYPE(KstVector*)
-Q_DECLARE_METATYPE(KstDataObject*)
-
namespace Kst {
SessionModel::SessionModel()
--- branches/work/kst/portto4/kst/src/libkstmath/kstdataobject.h #719682:719683
@@ -168,6 +168,7 @@
static KstDataObjectPtr createPlugin();
};
+Q_DECLARE_METATYPE(KstDataObject*)
#endif
// vim: ts=2 sw=2 et
--- branches/work/kst/portto4/kst/src/widgets/vectorselector.cpp #719682:719683
@@ -33,6 +33,8 @@
connect(_newVector, SIGNAL(pressed()), this, SLOT(newVector()));
connect(_editVector, SIGNAL(pressed()), this, SLOT(editVector()));
+
+ //FIXME need to find a way to call fillVectors when the vectorList changes
}
@@ -41,26 +43,30 @@
KstVectorPtr VectorSelector::selectedVector() const {
- return 0;
+ return qVariantValue<KstVector*>(_vector->itemData(_vector->currentIndex()));
}
void VectorSelector::setSelectedVector(KstVectorPtr selectedVector) {
- Q_UNUSED(selectedVector);
+ int i = _vector->findData(qVariantFromValue(selectedVector.data()));
+ Q_ASSERT(i != -1);
+ _vector->setCurrentIndex(i);
}
void VectorSelector::newVector() {
DialogLauncher::self()->showVectorDialog();
+ fillVectors();
}
void VectorSelector::editVector() {
+ DialogLauncher::self()->showVectorDialog(KstObjectPtr(selectedVector()));
}
void VectorSelector::fillVectors() {
- QStringList vectors;
+ QHash<QString, KstVectorPtr> vectors;
KST::vectorList.lock().readLock();
@@ -71,20 +77,31 @@
continue;
vector->readLock();
- vectors << vector->tag().displayString();
+ vectors.insert(vector->tag().displayString(), vector);
vector->unlock();
}
KST::vectorList.lock().unlock();
- qSort(vectors);
+ QStringList list = vectors.keys();
+ qSort(list);
+
if (allowEmptySelection()) {
- vectors.prepend(tr("<None>"));
+ list.prepend(tr("<None>"));
+ vectors.insert(tr("<None>"), KstVectorPtr());
}
+ KstVectorPtr current = selectedVector();
+
_vector->clear();
- _vector->addItems(vectors);
+ foreach (QString string, list) {
+ KstVectorPtr v = vectors.value(string);
+ _vector->addItem(string, qVariantFromValue(v.data()));
+ }
+
+ if (current)
+ setSelectedVector(current);
}
}
More information about the Kst
mailing list