From 3b9bceacb6efcd3e97c95077a2295c931c834514 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Tue, 29 Jul 2014 23:03:32 -0300 Subject: Implement the functionality of remove_picture. Added the remove_picture functionality, with code shamelessy stolen from remove_event, and hoock it up with the interface. Fixes #650 Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/profile/divepixmapitem.cpp | 4 +--- qt-ui/profile/profilewidget2.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'qt-ui/profile') diff --git a/qt-ui/profile/divepixmapitem.cpp b/qt-ui/profile/divepixmapitem.cpp index 3fb06adb9..41541c21e 100644 --- a/qt-ui/profile/divepixmapitem.cpp +++ b/qt-ui/profile/divepixmapitem.cpp @@ -119,9 +119,7 @@ void DivePictureItem::mousePressEvent(QGraphicsSceneMouseEvent *event) void DivePictureItem::removePicture() { - /* this is a WIP, it doesn't really *removes* anything, merely hides it. - * good workaround, I still need to figure out how to activelly remove - * it from the model. */ button->hide(); hide(); + DivePictureModel::instance()->removePicture(fileUrl); } diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index 21f0cb4e4..8f0d1584f 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -1352,7 +1352,9 @@ void ProfileWidget2::keyEscAction() void ProfileWidget2::plotPictures() { - qDeleteAll(pictures); + Q_FOREACH(DivePictureItem *item, pictures){ + item->deleteLater(); + } pictures.clear(); if (printMode) @@ -1368,7 +1370,7 @@ void ProfileWidget2::plotPictures() continue; DivePictureItem *item = new DivePictureItem(); item->setPixmap(m->index(i,0).data(Qt::DecorationRole).value()); - item->setFileUrl(m->index(i,0).data(Qt::DisplayPropertyRole).toString()); + 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); -- cgit v1.2.3-70-g09d2