mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
DiveListModel: don't add the dives one at a time
Most of the time we are adding all the dives, so do this in a single model operation. This makes the case when adding a single dive (in the undo delete function) slightly more complicated, but that seems totally worth it for the speedup in the common case. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
f16a3a1709
commit
1634c62b9a
3 changed files with 30 additions and 24 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue