diff --git a/oscar/Graphs/gFlagsLine.cpp b/oscar/Graphs/gFlagsLine.cpp index af70c680..87880f8a 100644 --- a/oscar/Graphs/gFlagsLine.cpp +++ b/oscar/Graphs/gFlagsLine.cpp @@ -177,7 +177,7 @@ void gFlagsGroup::paint(QPainter &painter, gGraph &g, const QRegion ®ion) qint64 minx,maxx,dur; g.graphView()->GetXBounds(minx,maxx); dur = maxx - minx; - #if 0 + #if BAR_TITLE_BAR_DEBUG // debug for minimum size for event flags. adding required height for enabled events , number eventTypes , height of an event bar QString text= QString("%1 -> %2 %3: %4 H:%5 Vis:%6 barH:%7"). arg(QDateTime::fromMSecsSinceEpoch(minx).time().toString()). diff --git a/oscar/Graphs/gFlagsLine.h b/oscar/Graphs/gFlagsLine.h index cf80d2f5..eccc7a26 100644 --- a/oscar/Graphs/gFlagsLine.h +++ b/oscar/Graphs/gFlagsLine.h @@ -145,7 +145,6 @@ class gFlagsGroup: public LayerGroup QList availableChans; QVector lvisible; - QVector visflags; float m_barh; bool m_empty; bool m_rebuild_cpap; diff --git a/oscar/Graphs/gGraph.cpp b/oscar/Graphs/gGraph.cpp index f9e116ba..1e714335 100644 --- a/oscar/Graphs/gGraph.cpp +++ b/oscar/Graphs/gGraph.cpp @@ -1116,12 +1116,12 @@ void gGraph::mouseReleaseEvent(QMouseEvent *event) if ((m_graphview->horizTravel() < mouse_movement_threshold) && (x > left && x < w + left && y > top && y < h)) { if ((event->modifiers() & Qt::ShiftModifier) != 0) { - qint64 zz = (qint64)screenToTime(x); - qint64 zz_min,zz_max; - // set range 3 before and 20 second after. - zz_min = zz - 180000; // before ms - zz_max = zz + 20000; // after ms - m_graphview->SetXBounds(zz_min, zz_max, m_group); + qint64 time = (qint64)screenToTime(x); + qint64 period =qint64(p_profile->general->eventWindowSize())*60000L; // eventwindowsize units minutes + qint64 small =period/10; + qint64 start = time - period; + qint64 end = time + small; + m_graphview->SetXBounds(start, end); return; } // normal click in main area diff --git a/oscar/SleepLib/profiles.h b/oscar/SleepLib/profiles.h index 6729b1b5..d6a169e9 100644 --- a/oscar/SleepLib/profiles.h +++ b/oscar/SleepLib/profiles.h @@ -752,7 +752,7 @@ class UserSettings : public PrefSettings : PrefSettings(profile) { initPref(STR_US_UnitSystem, US_Metric); - initPref(STR_US_EventWindowSize, 4.0); + setPref(STR_US_EventWindowSize, 3.0); m_skipEmptyDays = initPref(STR_US_SkipEmptyDays, true).toBool(); initPref(STR_US_RebuildCache, false); // FIXME: jedimark: can't remember... m_calculateRDI = initPref(STR_US_CalculateRDI, false).toBool(); diff --git a/oscar/daily.cpp b/oscar/daily.cpp index bb6091e5..2e9fa504 100644 --- a/oscar/daily.cpp +++ b/oscar/daily.cpp @@ -832,8 +832,8 @@ void Daily::UpdateEventsTree(QTreeWidget *tree,Day *day) } if (day->hasMachine(MT_CPAP) || day->hasMachine(MT_OXIMETER) || day->hasMachine(MT_POSITION)) { - QTreeWidgetItem * start = new QTreeWidgetItem(QStringList(tr("Session Start Times"))); - QTreeWidgetItem * end = new QTreeWidgetItem(QStringList(tr("Session End Times"))); + QTreeWidgetItem * start = new QTreeWidgetItem(QStringList(tr("Session Start Times")),eventTypeStart); + QTreeWidgetItem * end = new QTreeWidgetItem(QStringList(tr("Session End Times")),eventTypeEnd); tree->insertTopLevelItem(cnt++ , start); tree->insertTopLevelItem(cnt++ , end); for (QList::iterator s=day->begin(); s!=day->end(); ++s) { @@ -2225,28 +2225,35 @@ void Daily::on_RangeUpdate(double minx, double /*maxx*/) } -void Daily::on_treeWidget_itemClicked(QTreeWidgetItem *item, int column) +void Daily::on_treeWidget_itemClicked(QTreeWidgetItem *item, int ) { - Q_UNUSED(column); + if (!item) return; + QTreeWidgetItem* parent = item->parent(); + if (!parent) return; + gGraph *g=GraphView->findGraph(STR_GRAPH_SleepFlags); + if (!g) return; QDateTime d; if (!item->data(0,Qt::UserRole).isNull()) { - qint64 winsize=qint64(p_profile->general->eventWindowSize())*60000L; - qint64 t=item->data(0,Qt::UserRole).toLongLong(); + int eventType = parent->type(); + qint64 time = item->data(0,Qt::UserRole).toLongLong(); - double st=t-(winsize/2); - double et=t+(winsize/2); + // for events display 3 minutes before and 20 seconds after + // for start time skip abit before graph + // for end time skip abut after graph - gGraph *g=GraphView->findGraph(STR_GRAPH_SleepFlags); - if (!g) return; - if (strmin_x) { - st=g->rmin_x; - et=st+winsize; + qint64 period = qint64(p_profile->general->eventWindowSize())*60000L; // eventwindowsize units minutes + qint64 small = period/10; + + qint64 start,end; + if (eventType == eventTypeStart ) { + start = time - small; + end = time + period; + } else { + start = time - period; + end = time + small; } - if (et>g->rmax_x) { - et=g->rmax_x; - st=et-winsize; - } - GraphView->SetXBounds(st,et); + + GraphView->SetXBounds(start,end); } } diff --git a/oscar/daily.h b/oscar/daily.h index b7dce856..faa7a904 100644 --- a/oscar/daily.h +++ b/oscar/daily.h @@ -369,6 +369,9 @@ private: gLineChart *leakchart; + const int eventTypeStart = QTreeWidgetItem::UserType+1; + const int eventTypeEnd = QTreeWidgetItem::UserType+2; + #ifndef REMOVE_FITNESS bool ZombieMeterMoved; #endif