[Kst] extragear/graphics/kst/src
George Staikos
staikos at kde.org
Tue Apr 18 22:04:07 CEST 2006
SVN commit 531244 by staikos:
make drag and drop work between the two listviews.
M +18 -7 libkstapp/datawizard.ui
M +23 -3 libkstapp/datawizard.ui.h
M +2 -0 widgets/Makefile.am
A widgets/draggablelistview.cpp [License: GPL (v2+)]
A widgets/draggablelistview.h [License: GPL (v2+)]
M +6 -0 widgets/kstwidgets.cpp
A widgets/vectorlistview.cpp [License: GPL (v2+)]
A widgets/vectorlistview.h [License: GPL (v2+)]
--- trunk/extragear/graphics/kst/src/libkstapp/datawizard.ui #531243:531244
@@ -242,7 +242,7 @@
<enum>Horizontal</enum>
</property>
<property name="sizeType">
- <enum>Expanding</enum>
+ <enum>MinimumExpanding</enum>
</property>
<property name="sizeHint">
<size>
@@ -259,7 +259,7 @@
<enum>Horizontal</enum>
</property>
<property name="sizeType">
- <enum>Expanding</enum>
+ <enum>MinimumExpanding</enum>
</property>
<property name="sizeHint">
<size>
@@ -289,7 +289,7 @@
<enum>Horizontal</enum>
</property>
<property name="sizeType">
- <enum>Expanding</enum>
+ <enum>MinimumExpanding</enum>
</property>
<property name="sizeHint">
<size>
@@ -319,7 +319,7 @@
<enum>Horizontal</enum>
</property>
<property name="sizeType">
- <enum>Expanding</enum>
+ <enum>MinimumExpanding</enum>
</property>
<property name="sizeHint">
<size>
@@ -349,7 +349,7 @@
<enum>Horizontal</enum>
</property>
<property name="sizeType">
- <enum>Expanding</enum>
+ <enum>MinimumExpanding</enum>
</property>
<property name="sizeHint">
<size>
@@ -398,7 +398,7 @@
<property name="name">
<cstring>unnamed</cstring>
</property>
- <widget class="QListView" row="1" column="0" rowspan="1" colspan="2">
+ <widget class="VectorListView" row="1" column="0" rowspan="1" colspan="2">
<column>
<property name="text">
<string>Field/Column</string>
@@ -488,7 +488,7 @@
<string>Search Filter: Fields matching this filter will be selected and moved to the top of the list (but not checked). '*' and '?' wild cards are supported.</string>
</property>
</widget>
- <widget class="QListView" row="2" column="0" rowspan="1" colspan="2">
+ <widget class="VectorListView" row="2" column="0" rowspan="1" colspan="2">
<column>
<property name="text">
<string>Field/Column</string>
@@ -1509,6 +1509,12 @@
<receiver>DataWizard</receiver>
<slot>remove()</slot>
</connection>
+ <connection>
+ <sender>_vectors</sender>
+ <signal>dropped(QDropEvent*)</signal>
+ <receiver>DataWizard</receiver>
+ <slot>vectorsDroppedBack(QDropEvent*)</slot>
+ </connection>
</connections>
<tabstops>
<tabstop>_url</tabstop>
@@ -1574,6 +1580,8 @@
<include location="global" impldecl="in implementation">kiconloader.h</include>
<include location="global" impldecl="in implementation">qguardedptr.h</include>
<include location="global" impldecl="in implementation">qregexp.h</include>
+ <include location="global" impldecl="in implementation">qlistview.h</include>
+ <include location="global" impldecl="in implementation">qheader.h</include>
<include location="global" impldecl="in implementation">assert.h</include>
<include location="global" impldecl="in implementation">stdlib.h</include>
<include location="global" impldecl="in implementation">math.h</include>
@@ -1599,6 +1607,7 @@
<variable access="private">bool _inTest;</variable>
<variable access="private">QGuardedPtr<QWidget> _configWidget;</variable>
<variable access="private">KstDataSourceList _sourceCache;</variable>
+ <variable access="private">QMap<QString,QString> _countMap;</variable>
</variables>
<slots>
<slot access="private">init()</slot>
@@ -1630,6 +1639,7 @@
<slot access="private">add()</slot>
<slot access="private">remove()</slot>
<slot access="private">clear()</slot>
+ <slot access="private">vectorsDroppedBack(QDropEvent *e)</slot>
</slots>
<functions>
<function returnType="bool">xVectorOk()</function>
@@ -1651,5 +1661,6 @@
<includehint>fftoptionswidget.h</includehint>
<includehint>kstcombobox.h</includehint>
<includehint>kstcombobox.h</includehint>
+ <includehint>vectorlistview.h</includehint>
</includehints>
</UI>
--- trunk/extragear/graphics/kst/src/libkstapp/datawizard.ui.h #531243:531244
@@ -30,6 +30,8 @@
disconnect(finishButton(), SIGNAL(clicked()), (QDialog*)this, SLOT(accept()));
connect(finishButton(), SIGNAL(clicked()), this, SLOT(finished()));
+ _vectors->setAcceptDrops(true);
+ _vectorsToPlot->setAcceptDrops(true);
_vectors->addColumn(i18n("Position"));
_vectors->setSorting(1);
@@ -201,16 +203,17 @@
count = fl.count();
if (count > 0) {
- count = 1+(int)log10((double)count);
+ count = 1 + int(log10(double(count)));
} else {
count = 1;
}
for (QStringList::ConstIterator it = fl.begin(); it != fl.end(); ++it) {
QListViewItem *item = new QListViewItem(_vectors, *it);
+ item->setDragEnabled(true);
QString str;
- str.sprintf("%0*d", count, index);
+ str.sprintf("%0*d", count, index++);
item->setText(1, str);
- ++index;
+ _countMap[*it] = str;
}
_vectors->sort();
@@ -1240,7 +1243,24 @@
_vectorsToPlot->currentItem()->setSelected(true);
}
setNextEnabled(_pageVectors, yVectorsOk());
+
+ vectorsDroppedBack(0L); // abuse
}
+void DataWizard::vectorsDroppedBack(QDropEvent *e)
+{
+ Q_UNUSED(e)
+ // Note: e can be null
+ QListViewItemIterator it(_vectors);
+ while (it.current()) {
+ QListViewItem *i = it.current();
+ if (i->text(1).isEmpty()) {
+ i->setText(1, _countMap[i->text(0)]);
+ }
+ ++it;
+ }
+ _vectors->sort();
+}
+
// vim: ts=8 sw=4 noet
--- trunk/extragear/graphics/kst/src/widgets/Makefile.am #531243:531244
@@ -17,7 +17,9 @@
curveappearancewidget.ui \
fftoptionswidget.ui \
draggablelistbox.cpp \
+ draggablelistview.cpp \
plotlistbox.cpp \
+ vectorlistview.cpp \
kstcombobox.cpp \
datarangewidget.ui
--- trunk/extragear/graphics/kst/src/widgets/kstwidgets.cpp #531243:531244
@@ -25,6 +25,7 @@
#include "kstcombobox.h"
#include "scalarselector.h"
#include "stringselector.h"
+#include "vectorlistview.h"
#include "vectorselector.h"
#ifndef KDE_Q_EXPORT_PLUGIN
@@ -52,6 +53,7 @@
rc += "KstFFTOptions";
rc += "MatrixSelector";
rc += "PlotListBox";
+ rc += "VectorListView";
rc += "ScalarSelector";
rc += "StringSelector";
rc += "VectorSelector";
@@ -99,6 +101,8 @@
return "plotlistbox.h";
if (key == QString::fromLatin1("KstComboBox"))
return "kstcombobox.h";
+ if (key == QString::fromLatin1("VectorListView"))
+ return "vectorlistview.h";
return QString::null;
}
@@ -134,6 +138,8 @@
return new KstDataRange(parent, name);
if (key == QString::fromLatin1("PlotListBox"))
return new PlotListBox(parent, name);
+ if (key == QString::fromLatin1("VectorListView"))
+ return new VectorListView(parent, name);
if (key == QString::fromLatin1("KstComboBox"))
return new KstComboBox(parent, name);
return 0L;
More information about the Kst
mailing list