[Kst] kdeextragear-2/kst/kst
George Staikos
staikos at kde.org
Mon May 31 20:13:28 CEST 2004
CVS commit by staikos:
some subtle mouse handling fixes
M +0 -2 kst.h 1.60
M +58 -27 kst2dplot.cpp 1.47
M +2 -1 kst2dplot.h 1.23
--- kdeextragear-2/kst/kst/kst.h #1.59:1.60
@@ -111,6 +111,4 @@ class KstApp : public KMdiMainFrm {
QString newWindow();
- // FIXME: make this private again, add an accessor, fix compilation
-
protected:
virtual void customEvent(QCustomEvent *e);
--- kdeextragear-2/kst/kst/kst2dplot.cpp #1.46:1.47
@@ -2023,5 +2023,4 @@ void Kst2DPlot::mouseReleaseEvent(QWidge
double new_xmin, new_xmax, new_ymin, new_ymax;
QRect plotregion;
- unsigned int count;
bool doUpdate = false;
@@ -2106,4 +2105,6 @@ void Kst2DPlot::mouseReleaseEvent(QWidge
double y = double(e->y() - plotregion.top()) / double(plotregion.height());
// FIXME
+ Q_UNUSED(x)
+ Q_UNUSED(y)
//labelDialog->showI(i_plot, i_label, x, y);
}
@@ -2183,5 +2184,10 @@ void Kst2DPlot::zoomRectUpdate(QWidget *
void Kst2DPlot::setCursorForMode(QWidget *view) {
- switch (_mouse.mode) {
+ setCursorForMode(view, _mouse.mode);
+}
+
+
+void Kst2DPlot::setCursorForMode(QWidget *view, KstMouseModeType mode) {
+ switch (mode) {
case Y_ZOOMBOX:
view->setCursor(QCursor(Qt::SizeVerCursor));
@@ -2205,11 +2211,35 @@ void Kst2DPlot::setCursorForMode(QWidget
void Kst2DPlot::keyReleaseEvent(QWidget *view, QKeyEvent *e) {
- if (_mouse.zooming() || _mouse.mode == INACTIVE) {
- if (_mouse.mode != INACTIVE) {
- KstMouseModeType newType = XY_ZOOMBOX; // FIXME: wrong
+ ButtonState s = e->stateAfter();
+ KstMouseModeType newType;
QPoint c = view->mapFromGlobal(QCursor::pos());
QRect pr = GetPlotRegion();
- int x, y;
- // likewise wrong with above. change.
+ int x = _mouse.pressLocation.x(), y = _mouse.pressLocation.y();
+ if (s & Qt::ShiftButton) {
+ newType = Y_ZOOMBOX;
+ } else if (s & Qt::ControlButton) {
+ newType = X_ZOOMBOX;
+ } else {
+ // FIXME: wrong
+ newType = XY_ZOOMBOX;
+ }
+
+ if (newType == Y_ZOOMBOX) {
+ if (c.y() > pr.bottom()) {
+ y = pr.bottom() + 1;
+ } else if (c.y() < pr.top()) {
+ y = pr.top();
+ } else {
+ y = c.y();
+ }
+ } else if (newType == X_ZOOMBOX) {
+ if (c.x() > pr.right()) {
+ x = pr.right() + 1;
+ } else if (c.x() < pr.left()) {
+ x = pr.left();
+ } else {
+ x = c.x();
+ }
+ } else {
if (c.x() > pr.right()) {
x = pr.right() + 1;
@@ -2227,5 +2257,8 @@ void Kst2DPlot::keyReleaseEvent(QWidget
y = c.y();
}
+ }
+ if (_mouse.zooming() || _mouse.mode == INACTIVE) {
+ if (_mouse.mode != INACTIVE) {
QPoint newp(x, y);
QPainter p;
@@ -2242,9 +2275,7 @@ void Kst2DPlot::keyReleaseEvent(QWidget
p.end();
}
- setCursorForMode(view);
- e->accept();
- } else {
- e->ignore();
}
+ setCursorForMode(view, newType);
+ e->accept();
}
--- kdeextragear-2/kst/kst/kst2dplot.h #1.22:1.23
@@ -185,5 +185,6 @@ protected:
private:
- void setCursorForMode(QWidget *view);
+ void setCursorForMode(QWidget *view, KstMouseModeType mode);
+ void setCursorForMode(QWidget *view); // gets the mode from the mouse
void zoomRectUpdate(QWidget *view, KstMouseModeType t, int x, int y);
inline void commonConstructor(const QString& in_tag,
More information about the Kst
mailing list