diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2014-06-08 12:36:27 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-06-08 12:42:51 -0700 |
commit | 3a14076b1d1cbf78587305cc83802a1a9ae4c38c (patch) | |
tree | 1f29f45364e5cecfc46715e7636cdd58d4a41532 /qt-ui/profile | |
parent | a55411c55894f4c238598c9ad93d9e20604f8bdd (diff) | |
download | subsurface-3a14076b1d1cbf78587305cc83802a1a9ae4c38c.tar.gz |
Picture handling: stagger the pictures
If the pictures are too close to each other, spread them out a bit more.
This seems to give a reasonably pleasant layout.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/profile')
-rw-r--r-- | qt-ui/profile/profilewidget2.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index 05ddeedbd..8374006bc 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -1301,7 +1301,7 @@ void ProfileWidget2::plotPictures() { qDeleteAll(pictures); pictures.clear(); - + double x, y, lastX = -1.0, lastY = -1.0; DivePictureModel *m = DivePictureModel::instance(); for (int i = 0; i < m->rowCount(); i++) { struct picture *pic = (struct picture*) m->index(i,1).data(Qt::UserRole).value<void*>(); @@ -1313,8 +1313,14 @@ void ProfileWidget2::plotPictures() item->setPixmap(m->index(i,0).data(Qt::DecorationRole).value<QPixmap>()); // let's put the picture at the correct time, but at a fixed "depth" on the profile // not sure this is ideal, but it seems to look right. - qreal x = timeAxis->posAtValue(pic->timestamp - current_dive->when); - qreal y = 10; + x = timeAxis->posAtValue(pic->timestamp - current_dive->when); + if (i == 0) + y = 10; + else + if (fabs(x - lastX) < 4) + y = lastY + 3; + lastX = x; + lastY = y; item->setPos(x, y); item->setFlag(QGraphicsItem::ItemIgnoresTransformations); scene()->addItem(item); |