Added selection history. Hit escape key to go back to last selected area

This commit is contained in:
Mark Watkins 2014-07-19 23:38:07 +10:00
parent 3fe43ef621
commit 60b32905be
2 changed files with 35 additions and 0 deletions

View File

@ -1574,6 +1574,13 @@ void gGraphView::mouseReleaseEvent(QMouseEvent *event)
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();
}
if (m_metaselect) {
m_point_released = event->pos();
} else {
@ -1592,6 +1599,15 @@ void gGraphView::keyReleaseEvent(QKeyEvent *event)
m_metaselect = false;
timedRedraw(50);
}
if (event->key() == Qt::Key_Escape) {
if (history.size() > 0) {
SelectionHistoryItem h = history.takeFirst();
SetXBounds(h.minx, h.maxx);
} else {
}
return;
}
#ifdef BROKEN_OPENGL_BUILD
QWidget::keyReleaseEvent(event);
#else

View File

@ -152,6 +152,23 @@ class gToolTip : public QObject
void timerDone();
};
struct SelectionHistoryItem {
SelectionHistoryItem() {
minx=maxx=0;
}
SelectionHistoryItem(quint64 m1, quint64 m2) {
minx=m1;
maxx=m2;
}
SelectionHistoryItem(const SelectionHistoryItem & copy) {
minx = copy.minx;
maxx = copy.maxx;
}
quint64 minx;
quint64 maxx;
};
/*! \class gGraphView
\brief Main OpenGL Graph Area, derived from QGLWidget
@ -446,6 +463,8 @@ class gGraphView
bool m_showsplitter;
qint64 m_minx, m_maxx;
QList<SelectionHistoryItem> history;
float print_scaleX, print_scaleY;
QPixmap previous_day_snapshot;