diff options
author | Tomaz Canabrava <tomaz.canabrava@intel.com> | 2015-01-08 10:52:54 -0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-01-08 07:42:25 -0800 |
commit | 55cc16d77df3c43504ab932329c8fc15412d11e4 (patch) | |
tree | a4167638d400231a502cbabf803be21b6fce39f0 /qt-ui | |
parent | 76725265fca15461931d9dc0e40ce1f73f903075 (diff) | |
download | subsurface-55cc16d77df3c43504ab932329c8fc15412d11e4.tar.gz |
Dive d/l selection UI: Add the check states
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/downloadfromdivecomputer.cpp | 19 | ||||
-rw-r--r-- | 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 { |