summaryrefslogtreecommitdiffstats
path: root/qt-models/models.cpp
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2015-05-28 17:51:07 -0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-05-29 14:11:52 -0700
commita56429d31e1b734d19865dfefd5338b07292590e (patch)
tree74417080d56fc83904d490b88a4230abe1e3526d /qt-models/models.cpp
parent257f8063c4437eced155ec5ad0b40791ca814dfb (diff)
downloadsubsurface-a56429d31e1b734d19865dfefd5338b07292590e.tar.gz
Move DiveComputerModel to qt-models
Another attempt to make it easyer to create the mobile version of Subsurface. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-models/models.cpp')
-rw-r--r--qt-models/models.cpp112
1 files changed, 0 insertions, 112 deletions
diff --git a/qt-models/models.cpp b/qt-models/models.cpp
index 15e5d9a00..bbd5d7a0c 100644
--- a/qt-models/models.cpp
+++ b/qt-models/models.cpp
@@ -699,118 +699,6 @@ bool DiveTripModel::setData(const QModelIndex &index, const QVariant &value, int
return diveItem->setData(index, value, role);
}
-/*####################################################################
- *
- * Dive Computer Model
- *
- *####################################################################
- */
-
-DiveComputerModel::DiveComputerModel(QMultiMap<QString, DiveComputerNode> &dcMap, QObject *parent) : CleanerTableModel()
-{
- setHeaderDataStrings(QStringList() << "" << tr("Model") << tr("Device ID") << tr("Nickname"));
- dcWorkingMap = dcMap;
- numRows = 0;
-}
-
-QVariant DiveComputerModel::data(const QModelIndex &index, int role) const
-{
- QList<DiveComputerNode> values = dcWorkingMap.values();
- DiveComputerNode node = values.at(index.row());
-
- QVariant ret;
- if (role == Qt::DisplayRole || role == Qt::EditRole) {
- switch (index.column()) {
- case ID:
- ret = QString("0x").append(QString::number(node.deviceId, 16));
- break;
- case MODEL:
- ret = node.model;
- break;
- case NICKNAME:
- ret = node.nickName;
- break;
- }
- }
-
- if (index.column() == REMOVE) {
- switch (role) {
- case Qt::DecorationRole:
- ret = trashIcon();
- break;
- case Qt::SizeHintRole:
- ret = trashIcon().size();
- break;
- case Qt::ToolTipRole:
- ret = tr("Clicking here will remove this dive computer.");
- break;
- }
- }
- return ret;
-}
-
-int DiveComputerModel::rowCount(const QModelIndex &parent) const
-{
- return numRows;
-}
-
-void DiveComputerModel::update()
-{
- QList<DiveComputerNode> values = dcWorkingMap.values();
- int count = values.count();
-
- if (numRows) {
- beginRemoveRows(QModelIndex(), 0, numRows - 1);
- numRows = 0;
- endRemoveRows();
- }
-
- if (count) {
- beginInsertRows(QModelIndex(), 0, count - 1);
- numRows = count;
- endInsertRows();
- }
-}
-
-Qt::ItemFlags DiveComputerModel::flags(const QModelIndex &index) const
-{
- Qt::ItemFlags flags = QAbstractItemModel::flags(index);
- if (index.column() == NICKNAME)
- flags |= Qt::ItemIsEditable;
- return flags;
-}
-
-bool DiveComputerModel::setData(const QModelIndex &index, const QVariant &value, int role)
-{
- QList<DiveComputerNode> values = dcWorkingMap.values();
- DiveComputerNode node = values.at(index.row());
- dcWorkingMap.remove(node.model, node);
- node.nickName = value.toString();
- dcWorkingMap.insert(node.model, node);
- emit dataChanged(index, index);
- return true;
-}
-
-void DiveComputerModel::remove(const QModelIndex &index)
-{
- QList<DiveComputerNode> values = dcWorkingMap.values();
- DiveComputerNode node = values.at(index.row());
- dcWorkingMap.remove(node.model, node);
- update();
-}
-
-void DiveComputerModel::dropWorkingList()
-{
- // how do I prevent the memory leak ?
-}
-
-void DiveComputerModel::keepWorkingList()
-{
- if (dcList.dcMap != dcWorkingMap)
- mark_divelist_changed(true);
- dcList.dcMap = dcWorkingMap;
-}
-
/*#################################################################
* #
* # Yearly Statistics Model