From 4583cd8e09944e61aa59baa58e74abee0af0d268 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Tue, 5 Aug 2014 12:37:14 -0700 Subject: Picture handling: cleaning up the mess We had pointers to data structures on the stack which we frequently reallocated. These data structure contain basically a filename and an offset. We then create a hash of the pointers to those datastructures with the filename being the key. And then we passed those pointers around through a Qt model(!!!) only in order to then later look up by filename what the offset might be. I am at a loss for words for the lunacy behind this design. How about we just remember the offsets and pass the integers around? Signed-off-by: Dirk Hohndel --- qt-ui/profile/profilewidget2.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'qt-ui/profile') diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index 3b37e4115..c3a289dfa 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -1360,17 +1360,17 @@ void ProfileWidget2::plotPictures() 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(); + int offsetSeconds = m->index(i,1).data(Qt::UserRole).value(); // it's a correct picture, but doesn't have a timestamp: only show on the widget near the // information area. - if (!pic->offset.seconds) + if (!offsetSeconds) continue; DivePictureItem *item = new DivePictureItem(); item->setPixmap(m->index(i,0).data(Qt::DecorationRole).value()); item->setFileUrl(m->index(i,1).data().toString()); // 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. - x = timeAxis->posAtValue(pic->offset.seconds); + x = timeAxis->posAtValue(offsetSeconds); if (i == 0) y = 10; else if (fabs(x - lastX) < 4) -- cgit v1.2.3-70-g09d2