mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-07 20:23:24 +00:00
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>
This commit is contained in:
parent
a55411c558
commit
3a14076b1d
1 changed files with 9 additions and 3 deletions
|
@ -1301,7 +1301,7 @@ void ProfileWidget2::plotPictures()
|
||||||
{
|
{
|
||||||
qDeleteAll(pictures);
|
qDeleteAll(pictures);
|
||||||
pictures.clear();
|
pictures.clear();
|
||||||
|
double x, y, lastX = -1.0, lastY = -1.0;
|
||||||
DivePictureModel *m = DivePictureModel::instance();
|
DivePictureModel *m = DivePictureModel::instance();
|
||||||
for (int i = 0; i < m->rowCount(); i++) {
|
for (int i = 0; i < m->rowCount(); i++) {
|
||||||
struct picture *pic = (struct picture*) m->index(i,1).data(Qt::UserRole).value<void*>();
|
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>());
|
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
|
// 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.
|
// not sure this is ideal, but it seems to look right.
|
||||||
qreal x = timeAxis->posAtValue(pic->timestamp - current_dive->when);
|
x = timeAxis->posAtValue(pic->timestamp - current_dive->when);
|
||||||
qreal y = 10;
|
if (i == 0)
|
||||||
|
y = 10;
|
||||||
|
else
|
||||||
|
if (fabs(x - lastX) < 4)
|
||||||
|
y = lastY + 3;
|
||||||
|
lastX = x;
|
||||||
|
lastY = y;
|
||||||
item->setPos(x, y);
|
item->setPos(x, y);
|
||||||
item->setFlag(QGraphicsItem::ItemIgnoresTransformations);
|
item->setFlag(QGraphicsItem::ItemIgnoresTransformations);
|
||||||
scene()->addItem(item);
|
scene()->addItem(item);
|
||||||
|
|
Loading…
Add table
Reference in a new issue