[Kst] kdeextragear-2/kst/kst
George Staikos
staikos at kde.org
Sun Apr 18 08:17:52 CEST 2004
CVS commit by staikos:
added support for dragging plot groups and undoing drags when re-entering the
view that started the drag. drag re-enter is buggy still.
M +10 -0 kstplotgroup.cpp 1.5
M +3 -0 kstplotgroup.h 1.4
M +16 -1 ksttoplevelview.cpp 1.31
M +10 -11 ksttoplevelview.h 1.19
M +10 -2 kstviewwidget.cpp 1.17
M +1 -0 kstviewwidget.h 1.7
--- kdeextragear-2/kst/kst/kstplotgroup.cpp #1.4:1.5
@@ -79,4 +79,14 @@ bool KstPlotGroup::popupMenu(KPopupMenu
}
+
+KstViewObjectPtr create_KstPlotGroup() {
+ return KstViewObjectPtr(new KstPlotGroup);
+}
+
+
+KstViewObjectFactoryMethod KstPlotGroup::factory() const {
+ return &create_KstPlotGroup;
+}
+
#include "kstplotgroup.moc"
// vim: ts=2 sw=2 et
--- kdeextragear-2/kst/kst/kstplotgroup.h #1.3:1.4
@@ -36,4 +36,7 @@ class KstPlotGroup : public KstMetaPlot
virtual void paint(QPainter& p);
void flatten();
+
+ protected:
+ virtual KstViewObjectFactoryMethod factory() const;
};
--- kdeextragear-2/kst/kst/ksttoplevelview.cpp #1.30:1.31
@@ -207,4 +207,19 @@ void KstTopLevelView::setCursorFor(const
+void KstTopLevelView::restartMove() {
+ _pressDirection = 0;
+ _cursor.setShape(Qt::SizeAllCursor);
+ _w->setCursor(_cursor);
+ //_pressTarget = FIXME;
+ if (_selectionList.isEmpty()) { // focus move
+ assert(_pressTarget);
+ _moveOffset = _w->mapFromGlobal(QCursor::pos()) - _pressTarget->position();
+ } else { // selection move
+ assert(_pressTarget);
+ _moveOffset = _w->mapFromGlobal(QCursor::pos()) - _pressTarget->position();
+ }
+}
+
+
bool KstTopLevelView::handlePress(const QPoint& pos) {
//kdDebug() << "HANDLE PRESS" << endl;
@@ -563,5 +578,5 @@ void KstTopLevelView::cancelMouseOperati
if (_mode == LayoutMode) {
clearFocus();
- _pressTarget = 0L;
+ //_pressTarget = 0L;
_prevBand = QRect(-1, -1, 0, 0);
}
--- kdeextragear-2/kst/kst/ksttoplevelview.h #1.18:1.19
@@ -45,10 +45,4 @@ class KstTopLevelView : public KstViewOb
void clearFocus();
- void updateFocus(const QPoint& pos);
- bool handlePress(const QPoint& pos);
- void pressMove(const QPoint& pos);
- void releasePress(const QPoint& pos);
- void setCursorFor(const QPoint& pos, const QRect& objGeom);
-
enum ViewMode { LayoutMode = 0, DisplayMode, Unknown = 15 };
ViewMode viewMode() const { return _mode; }
@@ -59,11 +53,7 @@ class KstTopLevelView : public KstViewOb
bool trackingIsMove() const;
- bool popupMenu(KPopupMenu *menu, const QPoint& pos);
-
KstViewObjectList& selectionList() { return _selectionList; }
KstViewObjectPtr pressTarget() const { return _pressTarget; }
- void cancelMouseOperations();
-
private slots:
void menuClosed();
@@ -71,6 +61,15 @@ class KstTopLevelView : public KstViewOb
protected:
- // For the view to call
void resized(const QSize& size);
+ void cancelMouseOperations();
+ void updateFocus(const QPoint& pos);
+ bool handlePress(const QPoint& pos);
+ void pressMove(const QPoint& pos);
+ void releasePress(const QPoint& pos);
+ void setCursorFor(const QPoint& pos, const QRect& objGeom);
+ bool popupMenu(KPopupMenu *menu, const QPoint& pos);
+
+ // Called as a response to drag re-entering widget()
+ void restartMove();
private:
--- kdeextragear-2/kst/kst/kstviewwidget.cpp #1.16:1.17
@@ -49,4 +49,5 @@ QDragObject *KstViewWidget::dragObject()
}
+ _drag = d;
return d;
}
@@ -163,6 +164,13 @@ void KstViewWidget::paintEvent(QPaintEve
void KstViewWidget::dragEnterEvent(QDragEnterEvent *e) {
// FIXME: Draw a nice bullseye :)
- if (e->source() != this && KstPlotDrag::mimeType()) {
+ if (e->provides(KstPlotDrag::mimeType())) {
+ if (e->source() == this) {
+ delete _drag;
+ _drag = 0L;
+ _view->restartMove();
+ e->accept(false);
+ } else {
e->acceptAction(true);
+ }
} else {
QWidget::dragEnterEvent(e);
--- kdeextragear-2/kst/kst/kstviewwidget.h #1.6:1.7
@@ -55,4 +55,5 @@ class KstViewWidget : public QWidget {
bool _dragEnabled : 1;
KPopupMenu *_menu;
+ QDragObject *_drag;
};
More information about the Kst
mailing list