Fix SummaryChart tooltips

This commit is contained in:
Mark Watkins 2013-10-25 21:33:28 +10:00
parent d7fdc94fbd
commit 8553fdfd1c
2 changed files with 19 additions and 14 deletions

View File

@ -709,16 +709,21 @@ QString formatTime(EventDataType v, bool show_seconds=false, bool duration=false
return QString().sprintf("%i:%02i%s",h,m,pm);
}
bool SummaryChart::mouseMoveEvent(QMouseEvent *event)
bool SummaryChart::mouseMoveEvent(QMouseEvent *event,gGraph * graph)
{
int x=event->x()-l_left;
int y=event->y()-l_top;
if ((x<0 || y<0 || x>l_width || y>l_height)) {
int x=event->x();
int y=event->y();
if (!m_rect.contains(x,y)) {
// if ((x<0 || y<0 || x>l_width || y>l_height)) {
hl_day=-1;
//graph->timedRedraw(2000);
return false;
}
x-=m_rect.left();
y-=m_rect.top();
double xx=l_maxx-l_minx;
double xmult=xx/double(l_width+barw);
@ -739,8 +744,8 @@ bool SummaryChart::mouseMoveEvent(QMouseEvent *event)
QHash<short,EventDataType> & valhash=d.value();
x+=gYAxis::Margin+gGraphView::titleWidth; //graph->m_marginleft+
int y=event->y()+rtop-15;
x+=m_rect.left(); //gYAxis::Margin+gGraphView::titleWidth; //graph->m_marginleft+
int y=event->y()-m_rect.top()+rtop-15;
//QDateTime dt1=QDateTime::fromTime_t(hl_day*86400).toLocalTime();
QDateTime dt2=QDateTime::fromTime_t(hl_day*86400).toUTC();
@ -858,7 +863,7 @@ bool SummaryChart::mouseMoveEvent(QMouseEvent *event)
return false;
}
bool SummaryChart::mousePressEvent(QMouseEvent * event)
bool SummaryChart::mousePressEvent(QMouseEvent * event,gGraph * graph)
{
if (event->modifiers() & Qt::ShiftModifier) {
//qDebug() << "Jump to daily view?";
@ -868,7 +873,7 @@ bool SummaryChart::mousePressEvent(QMouseEvent * event)
return false;
}
bool SummaryChart::keyPressEvent(QKeyEvent * event)
bool SummaryChart::keyPressEvent(QKeyEvent * event,gGraph * graph)
{
Q_UNUSED(event)
//qDebug() << "Summarychart Keypress";
@ -877,11 +882,11 @@ bool SummaryChart::keyPressEvent(QKeyEvent * event)
#include "mainwindow.h"
extern MainWindow *mainwin;
bool SummaryChart::mouseReleaseEvent(QMouseEvent * event)
bool SummaryChart::mouseReleaseEvent(QMouseEvent * event,gGraph * graph)
{
if (event->modifiers() & Qt::ShiftModifier) {
if (hl_day<0) {
mouseMoveEvent(event);
mouseMoveEvent(event,graph);
}
if (hl_day>0) {
QDateTime d=QDateTime::fromTime_t(hl_day*86400).toUTC();

View File

@ -95,16 +95,16 @@ class SummaryChart:public Layer
float tz_hours;
//! \brief Key was pressed that effects this layer
virtual bool keyPressEvent(QKeyEvent * event);
virtual bool keyPressEvent(QKeyEvent * event,gGraph * graph);
//! \brief Mouse moved over this layers area (shows the hover-over tooltips here)
virtual bool mouseMoveEvent(QMouseEvent * event);
virtual bool mouseMoveEvent(QMouseEvent * event,gGraph * graph);
//! \brief Mouse Button was pressed over this area
virtual bool mousePressEvent(QMouseEvent * event);
virtual bool mousePressEvent(QMouseEvent * event,gGraph * graph);
//! \brief Mouse Button was released over this area. (jumps to daily view here)
virtual bool mouseReleaseEvent(QMouseEvent * event);
virtual bool mouseReleaseEvent(QMouseEvent * event,gGraph * graph);
};