From 3a14076b1d1cbf78587305cc83802a1a9ae4c38c Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sun, 8 Jun 2014 12:36:27 -0700 Subject: 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 --- qt-ui/profile/profilewidget2.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'qt-ui/profile') 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(); @@ -1313,8 +1313,14 @@ void ProfileWidget2::plotPictures() item->setPixmap(m->index(i,0).data(Qt::DecorationRole).value()); // 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); -- cgit v1.2.3-70-g09d2