[Kst] branches/work/kst/kst1kde4/kst/src/widgets
Andrew Walker
arwalker at sumusltd.com
Fri Feb 26 02:49:08 CET 2010
SVN commit 1096167 by arwalker:
draft build of widgets for kst1kde4
M +2 -2 CMakeLists.txt
M +32 -31 draggablelistbox.cpp
M +4 -4 draggablelistbox.h
M +12 -7 draggablelistview.cpp
M +3 -3 draggablelistview.h
M +9 -7 kstcombobox.cpp
M +22 -5 plotlistbox.cpp
M +1 -1 plotlistbox.h
M +12 -5 vectorlistview.cpp
M +1 -1 vectorlistview.h
--- branches/work/kst/kst1kde4/kst/src/widgets/CMakeLists.txt #1096166:1096167
@@ -26,9 +26,9 @@
datarangewidget.ui
colorpalettewidget.ui)
-ADD_LIBRARY(kstwidgets SHARED ${kstwidgets_LIB_SRCS})
+kde4_add_library(kstwidgets SHARED ${kstwidgets_LIB_SRCS})
-target_link_libraries(kstwidgets kio kstmath)
+target_link_libraries(kstwidgets kio kstmath ${KDE4_KDEUI_LIBS} ${KDE4_KPARTS_LIBS} ${QT_LIBRARIES})
set_target_properties(kstwidgets PROPERTIES VERSION 1.0.0 SOVERSION 1)
install(TARGETS kstwidgets
--- branches/work/kst/kst1kde4/kst/src/widgets/draggablelistbox.cpp #1096166:1096167
@@ -20,7 +20,7 @@
#include "draggablelistbox.h"
DraggableListBox::DraggableListBox(QWidget *parent, const char *name)
-: QListBox(parent, name), _pressPos(-1, -1), _dragEnabled(false) {
+: QListWidget(parent), _pressPos(-1, -1), _dragEnabled(false) {
}
@@ -38,7 +38,7 @@
}
-QDragObject *DraggableListBox::dragObject() {
+QMimeData *DraggableListBox::dragObject() {
return 0L;
}
@@ -47,15 +47,16 @@
if (_dragEnabled) {
_pressPos = QPoint(-1, -1);
- if (e->button() & Qt::LeftButton && !isRubberSelecting()) {
- QListBoxItem *item;
+ if (e->button() & Qt::LeftButton /* xxx && !isRubberSelecting()*/) {
+ QListWidgetItem *item;
+
if ((item = itemAt(e->pos()))) {
setCurrentItem(item);
if (!item->isSelected()) {
- if (!(e->state() & Qt::ControlButton)) {
+ if (!(e->buttons() & Qt::ControlModifier)) {
clearSelection();
}
- setSelected(item, true);
+ item->setSelected(true);
}
_pressPos = e->pos();
e->accept();
@@ -64,51 +65,53 @@
}
}
- QListBox::mousePressEvent(e);
+ QListWidget::mousePressEvent(e);
}
void DraggableListBox::mouseReleaseEvent(QMouseEvent *e) {
_pressPos = QPoint(-1, -1);
- QListBox::mouseReleaseEvent(e);
+
+ QListWidget::mouseReleaseEvent(e);
}
void DraggableListBox::mouseMoveEvent(QMouseEvent *e) {
- if (_dragEnabled && e->state() & Qt::LeftButton && _pressPos != QPoint(-1, -1)) {
+ if (_dragEnabled && (e->buttons() & Qt::LeftButton) && _pressPos != QPoint(-1, -1)) {
QPoint delta = e->pos() - _pressPos;
+
if (delta.manhattanLength() > QApplication::startDragDistance()) {
_pressPos = QPoint(-1, -1);
startDrag();
}
e->accept();
} else {
- QListBox::mouseMoveEvent(e);
+ QListWidget::mouseMoveEvent(e);
}
}
void DraggableListBox::startDrag() {
- QDragObject *o = dragObject();
+ QMimeData *o = dragObject();
+ QDrag drag(this);
+
+ drag.setMimeData(o);
if (o) {
- o->drag();
+ drag.start();
}
}
bool DraggableListBox::up() {
bool bRetVal = false;
+ int i;
if (count() > 1) {
- QString C;
+ for (i=1; i<count(); i++) {
+ if (item(i)->isSelected()) {
+ insertItem(i-1, takeItem(i));
+ i--;
- for (unsigned i=1; i<count(); i++) {
- if (isSelected(i)) {
- C = text(i);
- removeItem(i);
- --i;
- insertItem(C, i);
- setSelected(i, true);
- while (isSelected(i) && (i < count())) {
+ while (i < count( ) && item(i)->isSelected( )) {
++i;
}
@@ -122,17 +125,15 @@
bool DraggableListBox::down() {
bool bRetVal = false;
+ int i;
if (count() > 1) {
- QString C;
- for (int i=int(count())-2; i>=0; i--) {
- if (isSelected(i)) {
- C = text(i);
- removeItem(i);
- ++i;
- insertItem(C, i);
- setSelected(i, true);
- while (isSelected(i) && (i > 0)) {
+ for (i = count()-2; i>=0; i--) {
+ if (item(i)->isSelected()) {
+ insertItem(i+1, takeItem(i));
+ i++;
+
+ while (i > 0 && item(i)->isSelected( )) {
--i;
}
@@ -144,5 +145,5 @@
return bRetVal;
}
-#include "draggablelistbox.moc"
+//#include "draggablelistbox.moc"
--- branches/work/kst/kst1kde4/kst/src/widgets/draggablelistbox.h #1096166:1096167
@@ -18,18 +18,18 @@
#ifndef DRAGGABLELISTBOX_H
#define DRAGGABLELISTBOX_H
-#include <qlistbox.h>
-#include <qdragobject.h>
+#include <QListWidget>
+#include <QMimeData>
#include "kst_export.h"
-class KST_EXPORT DraggableListBox : public QListBox {
+class KST_EXPORT DraggableListBox : public QListWidget {
Q_OBJECT
public:
DraggableListBox(QWidget *parent = 0L, const char *name = 0L);
virtual ~DraggableListBox();
- virtual QDragObject *dragObject();
+ virtual QMimeData *dragObject();
bool dragEnabled() const;
virtual void setDragEnabled(bool enabled);
--- branches/work/kst/kst1kde4/kst/src/widgets/draggablelistview.cpp #1096166:1096167
@@ -15,11 +15,12 @@
* *
***************************************************************************/
-#include <qapplication.h>
+#include <QApplication>
+#include <QMouseEvent>
#include "draggablelistview.h"
DraggableListView::DraggableListView(QWidget *parent, const char *name)
-: QListView(parent, name), _pressPos(-1, -1), _dragEnabled(false) {
+: QListView(parent), _pressPos(-1, -1), _dragEnabled(false) {
}
@@ -37,7 +38,7 @@
}
-QDragObject *DraggableListView::dragObject() {
+QMimeData *DraggableListView::dragObject() {
return 0L;
}
@@ -47,6 +48,7 @@
_pressPos = QPoint(-1, -1);
if (e->button() & Qt::LeftButton) {
+/* xxx
QListViewItem *item;
if ((item = itemAt(e->pos()))) {
setCurrentItem(item);
@@ -60,6 +62,7 @@
e->accept();
return;
}
+*/
}
}
@@ -74,7 +77,7 @@
void DraggableListView::mouseMoveEvent(QMouseEvent *e) {
- if (_dragEnabled && e->state() & Qt::LeftButton && _pressPos != QPoint(-1, -1)) {
+ if (_dragEnabled && ( e->buttons() & Qt::LeftButton ) && _pressPos != QPoint(-1, -1)) {
QPoint delta = e->pos() - _pressPos;
if (delta.manhattanLength() > QApplication::startDragDistance()) {
_pressPos = QPoint(-1, -1);
@@ -88,11 +91,13 @@
void DraggableListView::startDrag() {
- QDragObject *o = dragObject();
+ QMimeData *o = dragObject();
+ QDrag drag(this);
+
+ drag.setMimeData(o);
if (o) {
- o->drag();
+ drag.start();
}
}
-#include "draggablelistview.moc"
--- branches/work/kst/kst1kde4/kst/src/widgets/draggablelistview.h #1096166:1096167
@@ -18,8 +18,8 @@
#ifndef DRAGGABLELISTVIEW_H
#define DRAGGABLELISTVIEW_H
-#include <qlistview.h>
-#include <qdragobject.h>
+#include <QListView>
+#include <QMimeData>
#include "kst_export.h"
@@ -29,7 +29,7 @@
DraggableListView(QWidget *parent = 0L, const char *name = 0L);
virtual ~DraggableListView();
- virtual QDragObject *dragObject();
+ virtual QMimeData *dragObject();
bool dragEnabled() const;
virtual void setDragEnabled(bool enabled);
--- branches/work/kst/kst1kde4/kst/src/widgets/kstcombobox.cpp #1096166:1096167
@@ -18,14 +18,14 @@
#include "kstcombobox.h"
KstComboBox::KstComboBox(QWidget *parent, const char *name)
- : KComboBox(parent, name), _trueRW(false) {
+ : KComboBox(parent), _trueRW(false) {
commonConstructor();
}
KstComboBox::KstComboBox(bool rw, QWidget *parent, const char *name)
- : KComboBox(false, parent, name), _trueRW(rw) {
+ : KComboBox(false, parent), _trueRW(rw) {
commonConstructor();
}
@@ -43,11 +43,11 @@
QComboBox::setEditable( true );
if (!_trueRW) { //if not truly read write then go into psuedo mode for read only
- setInsertionPolicy( NoInsertion );
- setCompletionMode( KGlobalSettings::CompletionPopupAuto );
+// xxx setInsertionPolicy( NoInsertion );
+// xxx setCompletionMode( KGlobalSettings::CompletionPopupAuto );
//DON'T HANDLE THE EDIT'S RETURNPRESSED IN qcombobox.cpp... RATHER HANDLE HERE!
- disconnect( lineEdit(), SIGNAL(returnPressed()), this, SLOT(returnPressed()) );
+// xxx disconnect( lineEdit(), SIGNAL(returnPressed()), this, SLOT(returnPressed()) );
connect( this, SIGNAL(returnPressed()), this, SLOT(validate()) );
}
}
@@ -62,7 +62,7 @@
if (KCompletion *comp = completionObject()) {
comp->clear();
for (int i = 0; i < count(); ++i) {
- comp->addItem(text(i));
+// xxx comp->addItem(text(i));
}
}
}
@@ -83,6 +83,7 @@
void KstComboBox::validate(bool rp) {
+/* xxx
if (!_trueRW) {
int match = -1;
for (int i = 0; i < count(); ++i) {
@@ -101,8 +102,9 @@
emit activated(text(match));
}
}
+*/
}
-#include "kstcombobox.moc"
+// xxx #include "kstcombobox.moc"
--- branches/work/kst/kst1kde4/kst/src/widgets/plotlistbox.cpp #1096166:1096167
@@ -15,13 +15,14 @@
* *
***************************************************************************/
+#include <QDragMoveEvent>
#include "plotlistbox.h"
PlotListBox::PlotListBox(QWidget *parent, const char *name)
: DraggableListBox(parent, name) {
setDragEnabled(true);
setAcceptDrops(true);
- setSelectionMode(QListBox::Extended);
+ setSelectionMode(QAbstractItemView::ExtendedSelection);
}
@@ -29,8 +30,10 @@
}
-QDragObject *PlotListBox::dragObject() {
- QStoredDrag *drag = new QStoredDrag("application/x-kst-plot-list", this);
+QMimeData *PlotListBox::dragObject() {
+/* xxx
+ QStoredDrag *drag = 0L;
+ drag = new QStoredDrag("application/x-kst-plot-list", this);
QStringList entries;
for (QListBoxItem *entry = firstItem(); entry; entry = entry->next()) {
@@ -45,15 +48,18 @@
drag->setEncodedData(data);
return drag;
+*/
+ return 0L;
}
void PlotListBox::dragMoveEvent(QDragMoveEvent *e) {
- e->accept(e->provides("application/x-kst-plot-list") && e->source() != this);
+// xxx e->accept(e->provides("application/x-kst-plot-list") && e->source() != this);
}
void PlotListBox::dropEvent(QDropEvent *e) {
+/* xxx
if (!e->provides("application/x-kst-plot-list") || e->source() == this) {
e->accept(false);
return;
@@ -70,11 +76,21 @@
emit changed();
}
clearSelection();
+
e->accept(true);
+*/
}
void PlotListBox::startDrag() {
+ QMimeData *o = dragObject();
+ QDrag drag(this);
+
+ drag.setMimeData(o);
+ if (o) {
+ drag.start();
+ }
+/* xxx
QDragObject *o = dragObject();
if (o && o->dragMove()) {
QByteArray data = o->encodedData("application/x-kst-plot-list");
@@ -89,7 +105,8 @@
}
clearSelection();
}
+*/
}
-#include "plotlistbox.moc"
+// xxx #include "plotlistbox.moc"
--- branches/work/kst/kst1kde4/kst/src/widgets/plotlistbox.h #1096166:1096167
@@ -27,7 +27,7 @@
KST_EXPORT PlotListBox(QWidget *parent = 0L, const char *name = 0L);
virtual ~PlotListBox();
- virtual QDragObject *dragObject();
+ virtual QMimeData *dragObject();
protected:
virtual void dragMoveEvent(QDragMoveEvent *e);
--- branches/work/kst/kst1kde4/kst/src/widgets/vectorlistview.cpp #1096166:1096167
@@ -15,13 +15,13 @@
* *
***************************************************************************/
-#include <ksdebug.h>
+#include <QDragMoveEvent>
#include "vectorlistview.h"
VectorListView::VectorListView(QWidget *parent, const char *name)
: DraggableListView(parent, name) {
setAcceptDrops(true);
- setSelectionMode(QListView::Extended);
+ setSelectionMode(QAbstractItemView::ExtendedSelection);
}
@@ -29,7 +29,8 @@
}
-QDragObject *VectorListView::dragObject() {
+QMimeData *VectorListView::dragObject() {
+/*
QStoredDrag *drag = new QStoredDrag("application/x-kst-vector-list", this);
QStringList entries;
@@ -45,15 +46,18 @@
drag->setEncodedData(data);
return drag;
+*/
+ return 0L;
}
void VectorListView::dragMoveEvent(QDragMoveEvent *e) {
- e->accept(e->provides("application/x-kst-vector-list") && e->source() != this);
+// xxx e->accept(e->provides("application/x-kst-vector-list") && e->source() != this);
}
void VectorListView::dropEvent(QDropEvent *e) {
+/* xxx
if (!e->provides("application/x-kst-vector-list") || e->source() == this) {
e->accept(false);
return;
@@ -74,10 +78,12 @@
clearSelection();
e->accept(true);
emit dropped(e);
+*/
}
void VectorListView::startDrag() {
+/* xxx
QDragObject *o = dragObject();
if (o && o->dragMove()) {
QByteArray data = o->encodedData("application/x-kst-vector-list");
@@ -90,7 +96,8 @@
clearSelection();
}
+*/
}
-#include "vectorlistview.moc"
+// xxx #include "vectorlistview.moc"
--- branches/work/kst/kst1kde4/kst/src/widgets/vectorlistview.h #1096166:1096167
@@ -27,7 +27,7 @@
KST_EXPORT VectorListView(QWidget *parent = 0L, const char *name = 0L);
virtual ~VectorListView();
- virtual QDragObject *dragObject();
+ virtual QMimeData *dragObject();
protected:
virtual void dragMoveEvent(QDragMoveEvent *e);
More information about the Kst
mailing list