changed zooming to events from event tab be be the same as a shift click on a graph

This commit is contained in:
LoudSnorer 2023-03-18 08:50:48 -04:00
parent 731e40b74b
commit d1504bb644
6 changed files with 36 additions and 27 deletions

View File

@ -177,7 +177,7 @@ void gFlagsGroup::paint(QPainter &painter, gGraph &g, const QRegion &region)
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()).

View File

@ -145,7 +145,6 @@ class gFlagsGroup: public LayerGroup
QList<ChannelID> availableChans;
QVector<gFlagsLine *> lvisible;
QVector<gFlagsLine *> visflags;
float m_barh;
bool m_empty;
bool m_rebuild_cpap;

View File

@ -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

View File

@ -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();

View File

@ -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<Session *>::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 (st<g->rmin_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);
}
}

View File

@ -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