From 55cc16d77df3c43504ab932329c8fc15412d11e4 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 8 Jan 2015 10:52:54 -0200 Subject: [PATCH] Dive d/l selection UI: Add the check states Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/downloadfromdivecomputer.cpp | 19 +++++++++++++------ qt-ui/downloadfromdivecomputer.h | 1 + 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/qt-ui/downloadfromdivecomputer.cpp b/qt-ui/downloadfromdivecomputer.cpp index 31d1ddaa0..91e38ae36 100644 --- a/qt-ui/downloadfromdivecomputer.cpp +++ b/qt-ui/downloadfromdivecomputer.cpp @@ -500,7 +500,8 @@ void DownloadThread::run() DiveImportedModel::DiveImportedModel(QObject *o) : QAbstractTableModel(o), lastIndex(0), - firstIndex(0) + firstIndex(0), + checkStates(0) { } @@ -525,13 +526,17 @@ QVariant DiveImportedModel::data(const QModelIndex& index, int role) const struct dive* d = get_dive( index.row() + firstIndex); if (role == Qt::DisplayRole) { switch(index.column()){ - case 0 : return QVariant(d->when); - case 1 : return QVariant(d->duration); - case 2 : return QVariant(d->maxdepth); - case 3 : return QVariant(d->latitude); - case 4 : return QVariant(d->longitude); + case 0 : return QVariant((int) d->when); + case 1 : return QVariant(d->duration.seconds); + case 2 : return QVariant(d->maxdepth.mm); + case 3 : return QVariant(d->latitude.udeg); + case 4 : return QVariant(d->longitude.udeg); } } + if (role == Qt::CheckStateRole) { + return checkStates[index.row() + firstIndex] ? Qt::Checked : Qt::Unchecked; + } + return QVariant(); } void DiveImportedModel::setImportedDivesIndexes(int first, int last) @@ -541,5 +546,7 @@ void DiveImportedModel::setImportedDivesIndexes(int first, int last) beginInsertRows(QModelIndex(), 0, last - first); lastIndex = last; firstIndex = first; + delete[] checkStates; + checkStates = new bool[last-first]; endInsertRows(); } diff --git a/qt-ui/downloadfromdivecomputer.h b/qt-ui/downloadfromdivecomputer.h index 799b0c991..c49ad9a40 100644 --- a/qt-ui/downloadfromdivecomputer.h +++ b/qt-ui/downloadfromdivecomputer.h @@ -37,6 +37,7 @@ public: private: int firstIndex; int lastIndex; + bool *checkStates; }; class DownloadFromDCWidget : public QDialog {