diff options
author | Tomaz Canabrava <tcanabrava@kde.org> | 2014-01-16 15:02:32 -0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-01-17 06:17:09 +0700 |
commit | 1f8078828663f6bfff768cbc2fb36e6643eb3d0e (patch) | |
tree | 93437eb965759cb6b08ce2b92b6568c81d4559e7 /qt-ui/profile/profilewidget2.cpp | |
parent | 9cb5ea45d886c15b26b196bc292b7a4bbf359b20 (diff) | |
download | subsurface-1f8078828663f6bfff768cbc2fb36e6643eb3d0e.tar.gz |
Added a DiveEventItem that knows how to handle itself.
Simply pass a event to the item and it will know what
to do. The sad part is that this isn't true yet - there's
quite a bit of boilerplate that a lot of the items are needing,
but the good part is that the boolerplate is the same in
all of the items, which means that I can create a tiny bit
of abstraction to encapsulate it and the code will be
way smaller to setup the items on the canvas.
Right now the items are being correctly placed on the
right places. It doesn't supports hidding / showing yet.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/profile/profilewidget2.cpp')
-rw-r--r-- | qt-ui/profile/profilewidget2.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index 89f20eb9b..a3db75d4c 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -6,6 +6,7 @@ #include "diveprofileitem.h" #include "helpers.h" #include "profile.h" +#include "diveeventitem.h" #include <QStateMachine> #include <QSignalTransition> @@ -13,6 +14,7 @@ #include <QMenu> #include <QContextMenuEvent> + #ifndef QT_NO_DEBUG #include <QTableView> #endif @@ -262,6 +264,8 @@ void ProfileWidget2::plotDives(QList<dive*> dives) int maxtime = get_maxtime(&pInfo); int maxdepth = get_maxdepth(&pInfo); + // It seems that I'll have a lot of boilerplate setting the model / axis for + // each item, I'll mostly like to fix this in the future, but I'll keep at this for now. profileYAxis->setMaximum(qMax<long>(pInfo.maxdepth + M_OR_FT(10,30), maxdepth * 2 / 3)); profileYAxis->updateTicks(); timeAxis->setMaximum(maxtime); @@ -280,6 +284,21 @@ void ProfileWidget2::plotDives(QList<dive*> dives) diveProfileItem->setVerticalDataColumn(DivePlotDataModel::DEPTH); diveProfileItem->setHorizontalDataColumn(DivePlotDataModel::TIME); scene()->addItem(diveProfileItem); + + qDeleteAll(eventItems); + eventItems.clear(); + + struct event *event = currentdc->events; + while (event) { + DiveEventItem *item = new DiveEventItem(); + item->setHorizontalAxis(timeAxis); + item->setVerticalAxis(profileYAxis); + item->setModel(dataModel); + item->setEvent(event); + scene()->addItem(item); + eventItems.push_back(item); + event = event->next; + } emit startProfileState(); } |