summaryrefslogtreecommitdiffstats
path: root/qt-models/divepicturemodel.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2018-07-14 17:40:24 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-07-18 09:06:37 -0700
commitc5f66c5538d149aaab92316096070fcb01cf8f1b (patch)
treeddc208dac40450a9c7791ca8218d9772c3ea450d /qt-models/divepicturemodel.cpp
parent8ff7314b219d2eab85f7777e470091a76cf25107 (diff)
downloadsubsurface-c5f66c5538d149aaab92316096070fcb01cf8f1b.tar.gz
Dive media: transport dive-id in drag'n'drop events
9efb56e2d43161d952efb444d1f13d87bfdd45b5 introduced rather complex logic for picture drag'n'drop events onto the profile. Among other things, the code had to check whether the picture actually belongs to the displayed dive. This can be simplified by transporting the dive-id in the drag'n'drop event structure. The flow goes like this: DivePictureModel--(1)-->DivePictureWidget--(2)-->ProfileWidget For (1), we can use the Qt::UserRole role. This was used to transport the picture-offset, but this is not needed anymore since ProfileWidget was decoupled from DivePictureModel. For (2), we simply replace the "position" value, which was never used. Why would the receiver care which pixel was pressed in the media-tab? This commit also contains a minor cleanup in DivePictureWidget: QListView::mousePressEvent(event) was called in both branches of an if and can therefore be removed from the if. This is so trivial, that it doesn't warrant its own commit. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models/divepicturemodel.cpp')
-rw-r--r--qt-models/divepicturemodel.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/qt-models/divepicturemodel.cpp b/qt-models/divepicturemodel.cpp
index 0aaf8f868..c881ce5bf 100644
--- a/qt-models/divepicturemodel.cpp
+++ b/qt-models/divepicturemodel.cpp
@@ -96,14 +96,16 @@ QVariant DivePictureModel::data(const QModelIndex &index, int role) const
break;
case Qt::DisplayPropertyRole:
ret = QFileInfo(entry.filename).filePath();
+ break;
+ case Qt::UserRole:
+ ret = entry.diveId;
+ break;
}
} else if (index.column() == 1) {
switch (role) {
- case Qt::UserRole:
- ret = QVariant::fromValue(entry.offsetSeconds);
- break;
case Qt::DisplayRole:
ret = entry.filename;
+ break;
}
}
return ret;