[Kst] branches/work/kst/portto4/kst/src/libkstapp
Mike Fenton
mike at staikos.net
Wed Nov 21 22:02:27 CET 2007
SVN commit 739769 by fenton:
Add Implementation for ChooseColorDialog.
M +53 -1 choosecolordialog.cpp
M +10 -0 choosecolordialog.h
M +56 -47 choosecolordialog.ui
--- branches/work/kst/portto4/kst/src/libkstapp/choosecolordialog.cpp #739768:739769
@@ -13,6 +13,9 @@
#include "datavector.h"
#include "datacollection.h"
+#include "objectstore.h"
+#include "mainwindow.h"
+#include "document.h"
#include "colorsequence.h"
@@ -24,10 +27,19 @@
setupUi(this);
grid = 0;
+ 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(OK, SIGNAL(clicked()), this, SLOT(OKClicked()));
}
ChooseColorDialog::~ChooseColorDialog() {
+ delete grid;
}
@@ -42,7 +54,7 @@
// cannot use dataSourceList.fileNames() as it contains datasources that
// are not used by any curves or vectors
- DataVectorList vcList; //FIXME // = ObjectSubList<Vector, DataVector>(vectorList);
+ DataVectorList vcList = _store->getObjects<DataVector>();
QStringList fileNameList;
for (DataVectorList::Iterator vc_iter = vcList.begin();
@@ -102,6 +114,46 @@
delete grid;
}
+
+void ChooseColorDialog::OKClicked() {
+ applyChange();
+ accept();
}
+
+void ChooseColorDialog::applyChange() {
+ CurveList curveList = _store->getObjects<Curve>();
+ for (CurveList::iterator curve_iter = curveList.begin(); curve_iter != curveList.end(); ++curve_iter)
+ {
+ VectorPtr vector;
+ CurvePtr curve = kst_cast<Curve>(*curve_iter);
+ if (_xVector->isChecked()) {
+ vector = curve->xVector();
+ } else {
+ vector = curve->yVector();
+ }
+ if (DataVectorPtr dataVector = kst_cast<DataVector>(vector))
+ {
+ curve->writeLock();
+ curve->setColor(getColorForFile(dataVector->filename()));
+ curve->update(0);
+ curve->unlock();
+ }
+ }
+}
+
+
+QColor ChooseColorDialog::getColorForFile(const QString &fileName) {
+ QList<ColorButton*>::Iterator kc_iter = colorButtons.begin();
+ for (QList<QLineEdit*>::Iterator fn_iter = lineEdits.begin(); fn_iter != lineEdits.end(); ++fn_iter) {
+ if (fileName == (*fn_iter)->text()) {
+ return (*kc_iter)->color();
+ }
+ ++kc_iter;
+ }
+ return QColor();
+}
+
+}
+
// vim: ts=2 sw=2 et
--- branches/work/kst/portto4/kst/src/libkstapp/choosecolordialog.h #739768:739769
@@ -23,6 +23,8 @@
namespace Kst {
+class ObjectStore;
+
class KST_EXPORT ChooseColorDialog : public QDialog, Ui::ChooseColorDialog
{
Q_OBJECT
@@ -32,7 +34,13 @@
void exec();
+ private slots:
+ void OKClicked();
+ void applyChange();
+
private:
+ QColor getColorForFile(const QString &fileName);
+
QGridLayout* grid;
void updateColorGroup();
@@ -41,6 +49,8 @@
QList<QLineEdit*> lineEdits;
QList<ColorButton*> colorButtons;
+ ObjectStore *_store;
+
};
}
--- branches/work/kst/portto4/kst/src/libkstapp/choosecolordialog.ui #739768:739769
@@ -5,7 +5,7 @@
<rect>
<x>0</x>
<y>0</y>
- <width>413</width>
+ <width>425</width>
<height>162</height>
</rect>
</property>
@@ -13,52 +13,6 @@
<string>Assign Curve Color From File</string>
</property>
<layout class="QGridLayout" >
- <item row="2" column="0" >
- <layout class="QGridLayout" >
- <property name="leftMargin" >
- <number>0</number>
- </property>
- <property name="topMargin" >
- <number>0</number>
- </property>
- <property name="rightMargin" >
- <number>0</number>
- </property>
- <property name="bottomMargin" >
- <number>0</number>
- </property>
- <item row="0" column="2" >
- <widget class="QPushButton" name="Cancel" >
- <property name="text" >
- <string>Cancel</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1" >
- <widget class="QPushButton" name="OK" >
- <property name="text" >
- <string>OK</string>
- </property>
- </widget>
- </item>
- <item row="0" column="0" >
- <spacer>
- <property name="orientation" >
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeType" >
- <enum>QSizePolicy::Expanding</enum>
- </property>
- <property name="sizeHint" >
- <size>
- <width>160</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
<item row="0" column="0" >
<widget class="QGroupBox" name="colorGroup" >
<property name="title" >
@@ -131,6 +85,61 @@
</layout>
</widget>
</item>
+ <item row="2" column="0" >
+ <layout class="QHBoxLayout" >
+ <property name="leftMargin" >
+ <number>0</number>
+ </property>
+ <property name="topMargin" >
+ <number>0</number>
+ </property>
+ <property name="rightMargin" >
+ <number>0</number>
+ </property>
+ <property name="bottomMargin" >
+ <number>0</number>
+ </property>
+ <item>
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeType" >
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>150</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="OK" >
+ <property name="whatsThis" >
+ <string>Apply new colors to applicable vectors.</string>
+ </property>
+ <property name="text" >
+ <string>&OK</string>
+ </property>
+ <property name="default" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="Cancel" >
+ <property name="whatsThis" >
+ <string>Close dialog without applying further changes.</string>
+ </property>
+ <property name="text" >
+ <string>&Cancel</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11" />
More information about the Kst
mailing list