[Kst] branches/work/kst/portto4/kst/src
Mike Fenton
mike at staikos.net
Wed Oct 10 20:15:35 CEST 2007
SVN commit 723787 by fenton:
Implementation of ScalarSelector, ScalarTab and ScalarDialog.
M +3 -3 libkstapp/datamanager.cpp
M +3 -1 libkstapp/dialoglaunchergui.cpp
M +0 -64 libkstapp/equationtab.ui
M +3 -0 libkstapp/libkstapp.pro
A libkstapp/scalardialog.cpp [License: GPL (v2+)]
A libkstapp/scalardialog.h [License: GPL (v2+)]
A libkstapp/scalartab.ui
M +54 -1 widgets/scalarselector.cpp
M +9 -0 widgets/scalarselector.h
--- branches/work/kst/portto4/kst/src/libkstapp/datamanager.cpp #723786:723787
@@ -63,9 +63,9 @@
// connect(action, SIGNAL(triggered()), this, SLOT(showMatrixDialog()));
// _primitives->addAction(action);
//
-// action = new DataButtonAction(tr("Scalar"));
-// connect(action, SIGNAL(triggered()), this, SLOT(showScalarDialog()));
-// _primitives->addAction(action);
+ action = new DataButtonAction(tr("Scalar"));
+ connect(action, SIGNAL(triggered()), DialogLauncher::self(), SLOT(showScalarDialog()));
+ _primitives->addAction(action);
//
// action = new DataButtonAction(tr("String"));
// connect(action, SIGNAL(triggered()), this, SLOT(showStringDialog()));
--- branches/work/kst/portto4/kst/src/libkstapp/dialoglaunchergui.cpp #723786:723787
@@ -15,6 +15,7 @@
#include "curvedialog.h"
#include "equationdialog.h"
#include "vectordialog.h"
+#include "scalardialog.h"
namespace Kst {
@@ -38,7 +39,8 @@
void DialogLauncherGui::showScalarDialog(ObjectPtr objectPtr) {
- Q_UNUSED(objectPtr);
+ ScalarDialog dialog(objectPtr, kstApp->mainWindow());
+ dialog.exec();
}
--- branches/work/kst/portto4/kst/src/libkstapp/equationtab.ui #723786:723787
@@ -236,69 +236,5 @@
</hint>
</hints>
</connection>
- <connection>
- <sender>_vectors</sender>
- <signal>selectionChangedLabel(QString)</signal>
- <receiver>_equation</receiver>
- <slot>setText(QString)</slot>
- <hints>
- <hint type="sourcelabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- <hint type="destinationlabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>_vectors</sender>
- <signal>selectionChangedLabel(QString)</signal>
- <receiver>_equation</receiver>
- <slot>setFocus()</slot>
- <hints>
- <hint type="sourcelabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- <hint type="destinationlabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>_scalars</sender>
- <signal>selectionChangedLabel(QString)</signal>
- <receiver>_equation</receiver>
- <slot>setText(QString)</slot>
- <hints>
- <hint type="sourcelabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- <hint type="destinationlabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>_scalars</sender>
- <signal>selectionChangedLabel(QString)</signal>
- <receiver>_equation</receiver>
- <slot>setFocus()</slot>
- <hints>
- <hint type="sourcelabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- <hint type="destinationlabel" >
- <x>20</x>
- <y>20</y>
- </hint>
- </hints>
- </connection>
</connections>
</ui>
--- branches/work/kst/portto4/kst/src/libkstapp/libkstapp.pro #723786:723787
@@ -65,6 +65,7 @@
qgetoptions.cpp \
selectionrect.cpp \
sessionmodel.cpp \
+ scalardialog.cpp \
stroketab.cpp \
svgitem.cpp \
tabwidget.cpp \
@@ -127,6 +128,7 @@
qgetoptions.h \
selectionrect.h \
sessionmodel.h \
+ scalardialog.h \
svgitem.h \
stroketab.h \
tabwidget.h \
@@ -155,6 +157,7 @@
generaltab.ui \
gridtab.ui \
layouttab.ui \
+ scalartab.ui \
stroketab.ui \
vectoreditordialog.ui \
vectortab.ui \
--- branches/work/kst/portto4/kst/src/widgets/scalarselector.cpp #723786:723787
@@ -11,6 +11,9 @@
#include "scalarselector.h"
+#include "dialoglauncher.h"
+#include "datacollection.h"
+
namespace Kst {
ScalarSelector::ScalarSelector(QWidget *parent)
@@ -26,6 +29,12 @@
_newScalar->setFixedSize(size + 8, size + 8);
_editScalar->setFixedSize(size + 8, size + 8);
_selectScalar->setFixedSize(size + 8, size + 8);
+
+ fillScalars();
+
+ connect(_newScalar, SIGNAL(pressed()), this, SLOT(newScalar()));
+ connect(_editScalar, SIGNAL(pressed()), this, SLOT(editScalar()));
+
}
@@ -34,7 +43,7 @@
ScalarPtr ScalarSelector::selectedScalar() const {
- return 0;
+ return qVariantValue<Scalar*>(_scalar->itemData(_scalar->currentIndex()));
}
@@ -42,6 +51,50 @@
Q_UNUSED(selectedScalar);
}
+
+void ScalarSelector::newScalar() {
+ DialogLauncher::self()->showScalarDialog();
+ fillScalars();
}
+
+void ScalarSelector::editScalar() {
+ DialogLauncher::self()->showScalarDialog(ObjectPtr(selectedScalar()));
+}
+
+
+void ScalarSelector::fillScalars() {
+ QHash<QString, ScalarPtr> scalars;
+
+ scalarList.lock().readLock();
+
+ ScalarList::ConstIterator it = scalarList.begin();
+ for (; it != scalarList.end(); ++it) {
+ ScalarPtr scalar = (*it);
+
+ scalar->readLock();
+ scalars.insert(scalar->tag().displayString(), scalar);
+ scalar->unlock();
+ }
+
+ scalarList.lock().unlock();
+
+ QStringList list = scalars.keys();
+
+ qSort(list);
+
+ ScalarPtr current = selectedScalar();
+
+ _scalar->clear();
+ foreach (QString string, list) {
+ ScalarPtr v = scalars.value(string);
+ _scalar->addItem(string, qVariantFromValue(v.data()));
+ }
+
+ if (current)
+ setSelectedScalar(current);
+}
+
+}
+
// vim: ts=2 sw=2 et
--- branches/work/kst/portto4/kst/src/widgets/scalarselector.h #723786:723787
@@ -32,6 +32,15 @@
Q_SIGNALS:
void selectionChanged();
+
+ private Q_SLOTS:
+ void newScalar();
+ void editScalar();
+
+ private:
+ void fillScalars();
+
+
};
}
More information about the Kst
mailing list