[Kst] kdeextragear-2/kst/kst
George Staikos
staikos at kde.org
Fri Sep 12 23:49:30 CEST 2003
CVS commit by staikos:
hotspot changes as discussed - labels now drag from the point selected and drop
exactly where they appear to be dropping.
M +4 -4 kstlabel.cpp 1.15
M +2 -1 kstlabel.h 1.13
M +7 -4 kstview.cpp 1.32
M +1 -0 kstview.h 1.17
--- kdeextragear-2/kst/kst/kstlabel.cpp #1.14:1.15
@@ -431,7 +431,7 @@ void KstLabel::setDoScalarReplacement(bo
// Use for dragging labels
-KstLabelDrag::KstLabelDrag(QWidget *dragSource, int p, int n, const QPixmap &pm)
-: QDragObject(dragSource), _plot(p), _label(n) {
- setPixmap(pm);
+KstLabelDrag::KstLabelDrag(QWidget *dragSource, int p, int n, const QPoint& hotSpot, const QPixmap &pm)
+: QDragObject(dragSource), _plot(p), _label(n), _hs(hotSpot) {
+ setPixmap(pm, hotSpot);
}
@@ -455,5 +455,5 @@ QByteArray KstLabelDrag::encodedData(con
if (QCString(mime) == "application/x-kst-label-number") {
QDataStream ds(a, IO_WriteOnly);
- ds << _plot << _label;
+ ds << _plot << _label << _hs;
}
return a;
--- kdeextragear-2/kst/kst/kstlabel.h #1.12:1.13
@@ -107,5 +107,5 @@ private:
class KstLabelDrag : public QDragObject {
public:
- KstLabelDrag(QWidget *dragSource, int p, int n, const QPixmap& pm);
+ KstLabelDrag(QWidget *dragSource, int p, int n, const QPoint& hotSpot, const QPixmap& pm);
virtual ~KstLabelDrag();
@@ -116,4 +116,5 @@ class KstLabelDrag : public QDragObject
private:
int _plot, _label;
+ QPoint _hs;
};
--- kdeextragear-2/kst/kst/kstview.cpp #1.31:1.32
@@ -365,9 +365,10 @@ void KstView::mouseMoveEvent(QMouseEvent
KstPlot *plot = KST::plotList.at(plot_num);
KstLabel *label = plot->labelList.at(i_label);
- QPixmap pm(label->extents.width(), label->extents.height());
+ QRect oldExtents = label->extents;
+ QPixmap pm(oldExtents.width(), oldExtents.height());
pm.fill();
QPainter p(&pm);
label->draw(p, 0, 0, true);
- QDragObject *d = new KstLabelDrag(this, plot_num, i_label, pm);
+ QDragObject *d = new KstLabelDrag(this, plot_num, i_label, _draggablePoint - plot->GetWinRegion().topLeft() - oldExtents.topLeft(), pm);
d->dragMove();
_draggableLabel = -1;
@@ -470,4 +471,5 @@ void KstView::mousePressEvent(QMouseEven
_draggablePlot = -1;
_draggableLabel = MouseInfo->getLabelNum(e);
+ _draggablePoint = e->pos();
/* search through the plots */
for (i = 0; i < KST::plotList.count(); i++) {
@@ -662,5 +664,6 @@ void KstView::dropEvent(QDropEvent *e) {
QDataStream ds(e->encodedData("application/x-kst-label-number"), IO_ReadOnly);
int plot, label;
- ds >> plot >> label;
+ QPoint hs;
+ ds >> plot >> label >> hs;
int posplot = -1, plotCount = KST::plotList.count();
KstPlot *plotPtr = 0L;
@@ -686,5 +689,5 @@ void KstView::dropEvent(QDropEvent *e) {
}
- QPoint pos = e->pos() - plotPtr->GetPlotRegion().topLeft();
+ QPoint pos = e->pos() - plotPtr->GetPlotRegion().topLeft() - hs;
QSize divisor = plotPtr->GetPlotRegion().size();
l->move(float(pos.x())/divisor.width(), float(pos.y())/divisor.height());
--- kdeextragear-2/kst/kst/kstview.h #1.16:1.17
@@ -120,4 +120,5 @@ private:
int _draggablePlot, _draggableLabel;
+ QPoint _draggablePoint;
signals:
More information about the Kst
mailing list