Merge commit 'c853c8d9880dfdac532c06a1a686ed18d77a58bb'

This commit is contained in:
Mark Watkins 2015-08-27 14:12:37 +10:00
commit 235141e575
9 changed files with 82 additions and 33 deletions

35
.gitignore vendored
View File

@ -0,0 +1,35 @@
# C++ objects and libs
*.slo
*.lo
*.o
*.a
*.la
*.lai
*.so
*.dll
*.dylib
# Qt-es
/.qmake.cache
/.qmake.stash
*.pro.user
*.pro.user.*
*.qbs.user
*.qbs.user.*
*.moc
moc_*.cpp
qrc_*.cpp
ui_*.h
Makefile*
*-build-*
# QtCreator
*.autosave
#QtCtreator Qml
*.qmlproject.user
*.qmlproject.user.*

View File

@ -477,7 +477,7 @@ void gGraphView::dumpInfo()
Day * day = p_profile->GetGoodDay(date, MT_CPAP);
if (day) {
QDateTime dt=QDateTime::fromMSecsSinceEpoch(day->first());
QDateTime dt=QDateTime::fromMSecsSinceEpoch(day->first(), Qt::UTC);
mainwin->log(QString("Available Channels for %1").arg(dt.toString("MMM dd yyyy")));
QHash<schema::ChanType, QList<schema::Channel *> > list;
@ -1402,6 +1402,14 @@ void gGraphView::paintGL()
QString gGraphView::getRangeString()
{
// a note about time zone usage here
// even though this string will be displayed to the user
// the graph is drawn using UTC times, so no conversion
// is needed to format the date and time for the user
// i.e. if the graph says the cursor is at 5pm, then that
// is what we should display.
// passing in UTC below is necessary to prevent QT
// from automatically converting the time to local time
QString fmt;
qint64 diff = m_maxx - m_minx;
@ -1414,8 +1422,8 @@ QString gGraphView::getRangeString()
qint64 maxx = minx + 86400000L * qint64(days)-1;
QDateTime st = QDateTime::fromMSecsSinceEpoch(minx);
QDateTime et = QDateTime::fromMSecsSinceEpoch(maxx);
QDateTime st = QDateTime::fromMSecsSinceEpoch(minx, Qt::UTC);
QDateTime et = QDateTime::fromMSecsSinceEpoch(maxx, Qt::UTC);
QString txt = st.toString("d MMM") + " - " + et.addDays(-1).toString("d MMM yyyy");
return txt;
@ -1424,8 +1432,8 @@ QString gGraphView::getRangeString()
} else {
fmt = "HH:mm:ss:zzz";
}
QDateTime st = QDateTime::fromMSecsSinceEpoch(m_minx);
QDateTime et = QDateTime::fromMSecsSinceEpoch(m_maxx);
QDateTime st = QDateTime::fromMSecsSinceEpoch(m_minx, Qt::UTC);
QDateTime et = QDateTime::fromMSecsSinceEpoch(m_maxx, Qt::UTC);
QString txt = st.toString(QObject::tr("d MMM [ %1 - %2 ]").arg(fmt).arg(et.toString(fmt))) ;
@ -2142,7 +2150,10 @@ void gGraphView::onSnapshotGraphToggle()
QString basename = name+";";
if (graph->m_day) {
QDateTime date = QDateTime::fromMSecsSinceEpoch(graph->min_x);
// append the date of the graph's left edge to the snapshot name
// so the user knows what day the snapshot starts
// because the name is displayed to the user, use local time
QDateTime date = QDateTime::fromMSecsSinceEpoch(graph->min_x, Qt::LocalTime);
basename += date.date().toString(Qt::SystemLocaleLongDate);
}
QString newname;
@ -2987,8 +2998,7 @@ void gGraphView::keyPressEvent(QKeyEvent *event)
m_metaselect=false;
qint64 start,end;
getSelectionTimes(start,end);
QDateTime d1 = QDateTime::fromMSecsSinceEpoch(start);
// QDateTime d2 = QDateTime::fromMSecsSinceEpoch(end);
QDateTime d1 = QDateTime::fromMSecsSinceEpoch(start, Qt::UTC);
mainwin->getDaily()->addBookmark(start, end, QString("Bookmark at %1").arg(d1.time().toString("HH:mm:ss")));
m_graphs[m_graph_index]->cancelSelection();

View File

@ -136,7 +136,7 @@ bool gSummaryChart::mouseReleaseEvent(QMouseEvent *event, gGraph *graph)
graph->roundY(miny, maxy);
QDate date = QDateTime::fromMSecsSinceEpoch(m_minx).date();
QDate date = QDateTime::fromMSecsSinceEpoch(m_minx, Qt::UTC).date();
int days = ceil(double(m_maxx - m_minx) / 86400000.0);
@ -404,8 +404,8 @@ void gSummaryChart::paint(QPainter &painter, gGraph &graph, const QRegion &regio
m_maxx = graph.max_x;
QDateTime date2 = QDateTime::fromMSecsSinceEpoch(m_minx);
QDateTime enddate2 = QDateTime::fromMSecsSinceEpoch(m_maxx);
QDateTime date2 = QDateTime::fromMSecsSinceEpoch(m_minx, Qt::UTC);
QDateTime enddate2 = QDateTime::fromMSecsSinceEpoch(m_maxx, Qt::UTC);
QDate date = date2.date();
QDate enddate = enddate2.date();
@ -819,8 +819,8 @@ void gSessionTimesChart::paint(QPainter &painter, gGraph &graph, const QRegion &
m_minx = graph.min_x;
m_maxx = graph.max_x;
QDateTime date2 = QDateTime::fromMSecsSinceEpoch(m_minx);
QDateTime enddate2 = QDateTime::fromMSecsSinceEpoch(m_maxx);
QDateTime date2 = QDateTime::fromMSecsSinceEpoch(m_minx, Qt::UTC);
QDateTime enddate2 = QDateTime::fromMSecsSinceEpoch(m_maxx, Qt::UTC);
QDate date = date2.date();
QDate enddate = enddate2.date();
@ -900,7 +900,7 @@ void gSessionTimesChart::paint(QPainter &painter, gGraph &graph, const QRegion &
// segments
for (int j=0; j<slize; ++j) {
const SessionSlice & slice = sess->m_slices.at(j);
QDateTime st = QDateTime::fromMSecsSinceEpoch(slice.start);
QDateTime st = QDateTime::fromMSecsSinceEpoch(slice.start, Qt::LocalTime);
float s1 = float(splittime.secsTo(st)) / 3600.0;
@ -915,7 +915,7 @@ void gSessionTimesChart::paint(QPainter &painter, gGraph &graph, const QRegion &
} else {
// otherwise just show session duration
qint64 sf = sess->first();
QDateTime st = QDateTime::fromMSecsSinceEpoch(sf);
QDateTime st = QDateTime::fromMSecsSinceEpoch(sf, Qt::LocalTime);
float s1 = float(splittime.secsTo(st)) / 3600.0;
float s2 = sess->hours();

View File

@ -403,8 +403,10 @@ void gXAxisDay::paint(QPainter &painter, gGraph &graph, const QRegion &region)
minx = graph.min_x;
maxx = graph.max_x;
QDateTime date2 = QDateTime::fromMSecsSinceEpoch(minx);
QDateTime enddate2 = QDateTime::fromMSecsSinceEpoch(maxx);
QDateTime date2 = QDateTime::fromMSecsSinceEpoch(minx, Qt::UTC);
QDateTime enddate2 = QDateTime::fromMSecsSinceEpoch(maxx, Qt::UTC);
qInfo() << "Drawing date axis from " << date2 << " to " << enddate2;
QDate date = date2.date();
// QDate enddate = enddate2.date();

View File

@ -144,7 +144,7 @@ void ResmedLoader::ParseSTR(Machine *mach, QStringList strfiles)
continue;
}
QDateTime start = QDateTime::fromMSecsSinceEpoch(str.startdate);
QDateTime start = QDateTime::fromMSecsSinceEpoch(str.startdate, Qt::UTC);
QDate date = start.date();
qDebug() << "Parsing" << *it << date << str.GetNumDataRecords() << str.GetNumSignals();
@ -444,6 +444,7 @@ void ResmedLoader::ParseSTR(Machine *mach, QStringList strfiles)
laston = ontime;
// TODO UTC
QDateTime dontime = QDateTime::fromTime_t(ontime);
date = dontime.date();
R.date = date;
@ -2017,7 +2018,7 @@ int ResmedLoader::Open(QString path)
QFile::copy(path + RMS9_STR_idfile + STR_ext_TGT, backup_path + RMS9_STR_idfile + STR_ext_TGT);
QFile::copy(path + RMS9_STR_idfile + STR_ext_CRC, backup_path + RMS9_STR_idfile + STR_ext_CRC);
QDateTime dts = QDateTime::fromMSecsSinceEpoch(stredf.startdate);
QDateTime dts = QDateTime::fromMSecsSinceEpoch(stredf.startdate, Qt::UTC);
dir.mkpath(backup_path + "STR_Backup");
QString strmonthly = backup_path + "STR_Backup/STR-" + dts.toString("yyyyMM") + "." + STR_ext_EDF;

View File

@ -150,9 +150,6 @@ int SomnoposeLoader::OpenFile(QString filename)
sess->set_last(time);
ev_orientation->AddEvent(time, orientation);
ev_inclination->AddEvent(time, inclination);
// QDateTime dt=QDateTime::fromMSecsSinceEpoch(time);
// qDebug() << dt << orientation << inclination;
}
sess->setMin(POS_Orientation, ev_orientation->Min());

View File

@ -668,7 +668,7 @@ void Daily::UpdateEventsTree(QTreeWidget *tree,Day *day)
t-=float(ev.raw(o)/2.0)*1000.0;
}
QStringList a;
QDateTime d=QDateTime::fromMSecsSinceEpoch(t);
QDateTime d=QDateTime::fromMSecsSinceEpoch(t, Qt::UTC);
QString s=QString("#%1: %2 (%3)").arg((int)(++mccnt[code]),(int)3,(int)10,QChar('0')).arg(d.toString("HH:mm:ss")).arg(m.value()[z]->raw(o));
a.append(s);
QTreeWidgetItem *item=new QTreeWidgetItem(a);
@ -690,8 +690,8 @@ void Daily::UpdateEventsTree(QTreeWidget *tree,Day *day)
tree->insertTopLevelItem(cnt++ , start);
tree->insertTopLevelItem(cnt++ , end);
for (QList<Session *>::iterator s=day->begin(); s!=day->end(); ++s) {
QDateTime st = QDateTime::fromMSecsSinceEpoch((*s)->first());
QDateTime et = QDateTime::fromMSecsSinceEpoch((*s)->last());
QDateTime st = QDateTime::fromMSecsSinceEpoch((*s)->first(), Qt::UTC);
QDateTime et = QDateTime::fromMSecsSinceEpoch((*s)->last(), Qt::UTC);
QTreeWidgetItem * item = new QTreeWidgetItem(QStringList(st.toString("HH:mm:ss")));
item->setData(0,Qt::UserRole, (*s)->first());
@ -1998,7 +1998,8 @@ void Daily::RedrawGraphs()
void Daily::on_LineCursorUpdate(double time)
{
if (time > 1) {
QDateTime dt = QDateTime::fromMSecsSinceEpoch(time);
// use local time since this string is displayed to the user
QDateTime dt = QDateTime::fromMSecsSinceEpoch(time, Qt::LocalTime);
QString txt = dt.toString("MMM dd HH:mm:ss.zzz");
dateDisplay->setText(txt);
} else dateDisplay->setText(QString(GraphView->emptyText()));
@ -2215,7 +2216,7 @@ void Daily::on_bookmarkTable_itemClicked(QTableWidgetItem *item)
void Daily::addBookmark(qint64 st, qint64 et, QString text)
{
ui->bookmarkTable->blockSignals(true);
QDateTime d=QDateTime::fromTime_t(st/1000L);
QDateTime d=QDateTime::fromTime_t(st/1000L, Qt::LocalTime);
int row=ui->bookmarkTable->rowCount();
ui->bookmarkTable->insertRow(row);
QTableWidgetItem *tw=new QTableWidgetItem(text);
@ -2243,7 +2244,7 @@ void Daily::on_addBookmarkButton_clicked()
{
qint64 st,et;
GraphView->GetXBounds(st,et);
QDateTime d=QDateTime::fromTime_t(st/1000L);
QDateTime d=QDateTime::fromTime_t(st/1000L, Qt::LocalTime);
addBookmark(st,et, tr("Bookmark at %1").arg(d.time().toString("HH:mm:ss")));
}

View File

@ -475,7 +475,10 @@ gGraph *Overview::createGraph(QString code, QString name, QString units, YTicker
void Overview::on_LineCursorUpdate(double time)
{
if (time > 1) {
QDateTime dt = QDateTime::fromMSecsSinceEpoch(time,Qt::UTC);
// even though the generated string is displayed to the user
// no time zone conversion is neccessary, so pass UTC
// to prevent QT from automatically converting to local time
QDateTime dt = QDateTime::fromMSecsSinceEpoch(time, Qt::UTC);
QString txt = dt.toString("dd MMM yyyy (dddd)");
dateLabel->setText(txt);
} else dateLabel->setText(QString(GraphView->emptyText()));

View File

@ -549,7 +549,7 @@ void OximeterImport::on_calendarWidget_clicked(const QDate &date)
sessbar->clear();
if (day) {
QDateTime time=QDateTime::fromMSecsSinceEpoch(day->first());
QDateTime time=QDateTime::fromMSecsSinceEpoch(day->first(), Qt::UTC);
sessbar->clear();
QList<QColor> colors;
colors.push_back("#ffffe0");
@ -582,7 +582,7 @@ void OximeterImport::on_calendarWidget_selectionChanged()
}
void OximeterImport::onSessionSelected(Session * session)
{
QDateTime time=QDateTime::fromMSecsSinceEpoch(session->first());
QDateTime time=QDateTime::fromMSecsSinceEpoch(session->first(), Qt::UTC);
ui->dateTimeEdit->setDateTime(time);
}
@ -591,7 +591,7 @@ void OximeterImport::on_sessionBackButton_clicked()
int idx = (sessbar->selected()-1);
if (idx >= 0) {
sessbar->setSelected(idx);
QDateTime datetime = QDateTime::fromMSecsSinceEpoch(sessbar->session(idx)->first());
QDateTime datetime = QDateTime::fromMSecsSinceEpoch(sessbar->session(idx)->first(), Qt::UTC);
ui->dateTimeEdit->setDateTime(datetime);
sessbar->update();
}
@ -602,7 +602,7 @@ void OximeterImport::on_sessionForwardButton_clicked()
int idx = (sessbar->selected()+1);
if (idx < sessbar->count()) {
sessbar->setSelected(idx);
QDateTime datetime = QDateTime::fromMSecsSinceEpoch(sessbar->session(idx)->first());
QDateTime datetime = QDateTime::fromMSecsSinceEpoch(sessbar->session(idx)->first(), Qt::UTC);
ui->dateTimeEdit->setDateTime(datetime);
sessbar->update();
}