diff options
Diffstat (limited to 'qt-models/divelistmodel.cpp')
-rw-r--r-- | qt-models/divelistmodel.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/qt-models/divelistmodel.cpp b/qt-models/divelistmodel.cpp index 79d770853..f0c726fae 100644 --- a/qt-models/divelistmodel.cpp +++ b/qt-models/divelistmodel.cpp @@ -31,13 +31,28 @@ DiveListModel::DiveListModel(QObject *parent) : QAbstractListModel(parent) m_instance = this; } -void DiveListModel::addDive(dive *d) +void DiveListModel::addDive(QList<dive *>listOfDives) { - beginInsertRows(QModelIndex(), rowCount(), rowCount()); - m_dives.append(new DiveObjectHelper(d)); + if (listOfDives.isEmpty()) + return; + beginInsertRows(QModelIndex(), rowCount(), rowCount() + listOfDives.count() - 1); + foreach (dive *d, listOfDives) { + m_dives.append(new DiveObjectHelper(d)); + } endInsertRows(); } +void DiveListModel::addAllDives() +{ + QList<dive *>listOfDives; + int i; + struct dive *d; + for_each_dive (i, d) + listOfDives.append(d); + addDive(listOfDives); + +} + void DiveListModel::insertDive(int i, DiveObjectHelper *newDive) { beginInsertRows(QModelIndex(), i, i); |