mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
Dive pictures: use modelReset signal when reseting picture list
In the old code a combination of removeRows()/insertRows() was used to signal a model reset. Replace this by a single, modelReset signal. This saves a call to plotPictures() and will allow us to be smarter in the future, when removing pictures. Reset-model and remove-items are semantically different. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
3646fa800b
commit
fbe1144eaf
2 changed files with 3 additions and 7 deletions
|
@ -1119,6 +1119,7 @@ void ProfileWidget2::setProfileState()
|
||||||
connect(DivePictureModel::instance(), &DivePictureModel::dataChanged, this, &ProfileWidget2::updatePictures);
|
connect(DivePictureModel::instance(), &DivePictureModel::dataChanged, this, &ProfileWidget2::updatePictures);
|
||||||
connect(DivePictureModel::instance(), SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SLOT(plotPictures()));
|
connect(DivePictureModel::instance(), SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SLOT(plotPictures()));
|
||||||
connect(DivePictureModel::instance(), SIGNAL(rowsRemoved(const QModelIndex &, int, int)), this, SLOT(plotPictures()));
|
connect(DivePictureModel::instance(), SIGNAL(rowsRemoved(const QModelIndex &, int, int)), this, SLOT(plotPictures()));
|
||||||
|
connect(DivePictureModel::instance(), &DivePictureModel::modelReset, this, &ProfileWidget2::plotPictures);
|
||||||
#endif
|
#endif
|
||||||
/* show the same stuff that the profile shows. */
|
/* show the same stuff that the profile shows. */
|
||||||
|
|
||||||
|
|
|
@ -57,10 +57,9 @@ void DivePictureModel::updateThumbnails()
|
||||||
|
|
||||||
void DivePictureModel::updateDivePictures()
|
void DivePictureModel::updateDivePictures()
|
||||||
{
|
{
|
||||||
|
beginResetModel();
|
||||||
if (!pictures.isEmpty()) {
|
if (!pictures.isEmpty()) {
|
||||||
beginRemoveRows(QModelIndex(), 0, pictures.count() - 1);
|
|
||||||
pictures.clear();
|
pictures.clear();
|
||||||
endRemoveRows();
|
|
||||||
rowDDStart = rowDDEnd = 0;
|
rowDDStart = rowDDEnd = 0;
|
||||||
Thumbnailer::instance()->clearWorkQueue();
|
Thumbnailer::instance()->clearWorkQueue();
|
||||||
}
|
}
|
||||||
|
@ -83,11 +82,7 @@ void DivePictureModel::updateDivePictures()
|
||||||
}
|
}
|
||||||
|
|
||||||
updateThumbnails();
|
updateThumbnails();
|
||||||
|
endResetModel();
|
||||||
if (!pictures.isEmpty()) {
|
|
||||||
beginInsertRows(QModelIndex(), 0, pictures.count() - 1);
|
|
||||||
endInsertRows();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int DivePictureModel::columnCount(const QModelIndex &parent) const
|
int DivePictureModel::columnCount(const QModelIndex &parent) const
|
||||||
|
|
Loading…
Reference in a new issue