Make all mouse events save history

This commit is contained in:
Mark Watkins 2014-07-20 00:09:04 +10:00
parent 60b32905be
commit cbeba3fe05
4 changed files with 30 additions and 10 deletions

View File

@ -761,6 +761,7 @@ void gGraph::mouseMoveEvent(QMouseEvent *event)
min_x = rmax_x - xx;
}
m_graphview->saveHistory();
m_graphview->SetXBounds(min_x, max_x, m_group, false);
doredraw = true;
} else {
@ -784,6 +785,7 @@ void gGraph::mouseMoveEvent(QMouseEvent *event)
min_x = rmax_x - xx;
}
m_graphview->saveHistory();
m_graphview->SetXBounds(min_x, max_x, m_group, false);
doredraw = true;
}
@ -889,6 +891,7 @@ void gGraph::mouseReleaseEvent(QMouseEvent *event)
} else {
if (a2 - a1 < zoom_hard_limit) { a2 = a1 + zoom_hard_limit; }
m_graphview->saveHistory();
m_graphview->SetXBounds(a1, a2, m_group);
}
} else {
@ -906,7 +909,7 @@ void gGraph::mouseReleaseEvent(QMouseEvent *event)
qDebug() << "Foo2??";
} else {
if (a2 - a1 < zoom_hard_limit) { a2 = a1 + zoom_hard_limit; }
m_graphview->saveHistory();
m_graphview->SetXBounds(a1, a2, m_group);
}
}
@ -980,6 +983,7 @@ void gGraph::mouseReleaseEvent(QMouseEvent *event)
min_x = rmax_x - xx;
}
m_graphview->saveHistory();
m_graphview->SetXBounds(min_x, max_x, m_group);
m_lastx23 = x;
}
@ -1116,6 +1120,9 @@ void gGraph::ZoomX(double mult, int origin_px)
min = max - q;
}
extern const int max_history;
m_graphview->saveHistory();
m_graphview->SetXBounds(min, max, m_group);
//updateSelectionTime(max-min);
}

View File

@ -39,6 +39,7 @@
extern MainWindow *mainwin;
extern QLabel *qstatus2;
gToolTip::gToolTip(gGraphView *graphview)
: m_graphview(graphview)
{
@ -1573,13 +1574,7 @@ void gGraphView::mouseReleaseEvent(QMouseEvent *event)
if (m_button_down) {
m_button_down = false;
m_metaselect = event->modifiers() & Qt::ShiftModifier;
const int max_history = 20;
history.push_front(SelectionHistoryItem(m_minx, m_maxx));
if (history.size() > max_history) {
history.pop_back();
}
saveHistory();
if (m_metaselect) {
m_point_released = event->pos();
@ -1603,7 +1598,10 @@ void gGraphView::keyReleaseEvent(QKeyEvent *event)
if (history.size() > 0) {
SelectionHistoryItem h = history.takeFirst();
SetXBounds(h.minx, h.maxx);
// could Forward push this to another list?
} else {
ResetBounds();
}
return;
@ -1731,8 +1729,9 @@ void gGraphView::wheelEvent(QWheelEvent *event)
// What to do when ctrl+wheel is used on the graph title ??
} else {
// send event to graph..
if (!m_button_down)
if (!m_button_down) {
m_graphs[i]->wheelEvent(event);
}
}
} else if ((y >= py + h) && (y <= py + h + graphSpacer + 1)) {
// What to do when the wheel is used on the resize handle?
@ -1812,6 +1811,7 @@ void gGraphView::wheelEvent(QWheelEvent *event)
g->min_x = g->max_x - xx;
}
saveHistory();
SetXBounds(g->min_x, g->max_x, group);
}
}
@ -1891,6 +1891,7 @@ void gGraphView::keyPressEvent(QKeyEvent *event)
g->max_x = g->rmin_x + xx;
}
saveHistory();
SetXBounds(g->min_x, g->max_x, group);
} else if (event->key() == Qt::Key_Right) {
double xx = g->max_x - g->min_x;
@ -1906,6 +1907,7 @@ void gGraphView::keyPressEvent(QKeyEvent *event)
g->min_x = g->rmax_x - xx;
}
saveHistory();
SetXBounds(g->min_x, g->max_x, group);
} else if (event->key() == Qt::Key_Up) {
float zoom = 0.75F;

View File

@ -269,6 +269,13 @@ class gGraphView
inline void setPrintScaleX(float x) { print_scaleX = x; }
inline void setPrintScaleY(float y) { print_scaleY = y; }
void saveHistory() {
history.push_front(SelectionHistoryItem(m_minx, m_maxx));
if (history.size() > max_history) {
history.pop_back();
}
}
//! \brief Returns true if all Graph objects contain NO day data. ie, graph area is completely empty.
bool isEmpty();
@ -374,6 +381,8 @@ class gGraphView
int strings_drawn_this_frame;
int strings_cached_this_frame;
QList<SelectionHistoryItem> history;
protected:
//! \brief The heart of the drawing code
@ -464,7 +473,7 @@ class gGraphView
qint64 m_minx, m_maxx;
QList<SelectionHistoryItem> history;
QList<SelectionHistoryItem> fwd_history;
float print_scaleX, print_scaleY;
QPixmap previous_day_snapshot;

View File

@ -56,6 +56,8 @@ const QColor COLOR_ALT_BG2 =
COLOR_White; // Alternating Background Color 2 (Event Flags)
const int max_history = 50;
#ifndef M_PI
const double M_PI = 3.141592653589793;
#endif