mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Dive pictures: Don't update all pictures on drag & drop to profile
In the old code, we used to reload the whole picture list on drag & drop to the profile. Instead, only update the drag&dropped picture and repaint the profile-pictures. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
d33e3b22fc
commit
c71a5d7413
3 changed files with 25 additions and 7 deletions
|
@ -2060,14 +2060,14 @@ void ProfileWidget2::dropEvent(QDropEvent *event)
|
||||||
if (QString(picture->filename) == filename) {
|
if (QString(picture->filename) == filename) {
|
||||||
picture->offset.seconds = lrint(timeAxis->valueAt(mappedPos));
|
picture->offset.seconds = lrint(timeAxis->valueAt(mappedPos));
|
||||||
mark_divelist_changed(true);
|
mark_divelist_changed(true);
|
||||||
|
#ifndef SUBSURFACE_MOBILE
|
||||||
|
DivePictureModel::instance()->updateDivePictureOffset(filename, picture->offset.seconds);
|
||||||
|
plotPictures();
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
copy_dive(current_dive, &displayed_dive);
|
copy_dive(current_dive, &displayed_dive);
|
||||||
#ifndef SUBSURFACE_MOBILE
|
|
||||||
DivePictureModel::instance()->updateDivePictures();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
if (event->source() == this) {
|
if (event->source() == this) {
|
||||||
event->setDropAction(Qt::MoveAction);
|
event->setDropAction(Qt::MoveAction);
|
||||||
|
|
|
@ -153,12 +153,28 @@ int DivePictureModel::rowCount(const QModelIndex &parent) const
|
||||||
return pictures.count();
|
return pictures.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int DivePictureModel::findPictureId(const QString &filename)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < pictures.size(); ++i)
|
||||||
|
if (pictures[i].filename == filename)
|
||||||
|
return i;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
void DivePictureModel::updateThumbnail(QString filename, QImage thumbnail)
|
void DivePictureModel::updateThumbnail(QString filename, QImage thumbnail)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < pictures.size(); ++i) {
|
int i = findPictureId(filename);
|
||||||
if (pictures[i].filename != filename)
|
if (i >= 0) {
|
||||||
continue;
|
|
||||||
pictures[i].image = thumbnail;
|
pictures[i].image = thumbnail;
|
||||||
emit dataChanged(createIndex(i, 0), createIndex(i, 1));
|
emit dataChanged(createIndex(i, 0), createIndex(i, 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DivePictureModel::updateDivePictureOffset(const QString &filename, int offsetSeconds)
|
||||||
|
{
|
||||||
|
int i = findPictureId(filename);
|
||||||
|
if (i >= 0) {
|
||||||
|
pictures[i].offsetSeconds = offsetSeconds;
|
||||||
|
emit dataChanged(createIndex(i, 0), createIndex(i, 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -24,12 +24,14 @@ public:
|
||||||
void updateDivePicturesWhenDone(QList<QFuture<void>>);
|
void updateDivePicturesWhenDone(QList<QFuture<void>>);
|
||||||
void removePicture(const QString& fileUrl, bool last);
|
void removePicture(const QString& fileUrl, bool last);
|
||||||
int rowDDStart, rowDDEnd;
|
int rowDDStart, rowDDEnd;
|
||||||
|
void updateDivePictureOffset(const QString &filename, int offsetSeconds);
|
||||||
public slots:
|
public slots:
|
||||||
void setZoomLevel(int level);
|
void setZoomLevel(int level);
|
||||||
void updateThumbnail(QString filename, QImage thumbnail);
|
void updateThumbnail(QString filename, QImage thumbnail);
|
||||||
private:
|
private:
|
||||||
DivePictureModel();
|
DivePictureModel();
|
||||||
QList<PictureEntry> pictures;
|
QList<PictureEntry> pictures;
|
||||||
|
int findPictureId(const QString &filename); // Return -1 if not found
|
||||||
double zoomLevel; // -1.0: minimum, 0.0: standard, 1.0: maximum
|
double zoomLevel; // -1.0: minimum, 0.0: standard, 1.0: maximum
|
||||||
int size;
|
int size;
|
||||||
int defaultSize;
|
int defaultSize;
|
||||||
|
|
Loading…
Add table
Reference in a new issue