summaryrefslogtreecommitdiffstats
path: root/qt-ui/diveplanner.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'qt-ui/diveplanner.cpp')
-rw-r--r--qt-ui/diveplanner.cpp29
1 files changed, 25 insertions, 4 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index fa959cf97..25d5df11d 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -11,7 +11,10 @@
#include <QGraphicsSceneMouseEvent>
#include <QMessageBox>
#include <QStringListModel>
-#include <boost/graph/graph_concepts.hpp>
+#include <QGraphicsProxyWidget>
+#include <QListView>
+#include <QDesktopWidget>
+#include <QModelIndex>
#include "ui_diveplanner.h"
#include "mainwindow.h"
@@ -136,8 +139,14 @@ DivePlannerGraphics::DivePlannerGraphics(QWidget* parent): QGraphicsView(parent)
ADD_ACTION(Qt::Key_Right, keyRightAction());
#undef ADD_ACTION
- QStringListModel *model = new QStringListModel(QStringList() << tr("AIR") << tr("EAN32") << tr("EAN36"));
+ // Prepare the stuff for the gas-choices.
+ gasChoices = new QStringListModel(QStringList() << tr("AIR") << tr("EAN32") << tr("EAN36"));
+ gasListView = new QListView();
+ gasListView->setWindowFlags(Qt::FramelessWindowHint);
+ gasListView->setModel(gasChoices);
+ gasListView->hide();
+ connect(gasListView, SIGNAL(activated(QModelIndex)), this, SLOT(selectGas(QModelIndex)));
setRenderHint(QPainter::Antialiasing);
}
@@ -363,16 +372,28 @@ void DivePlannerGraphics::mouseDoubleClickEvent(QMouseEvent* event)
gasChooseBtn ->setText(tr("Air"));
scene()->addItem(gasChooseBtn);
gasChooseBtn->setZValue(10);
- connect(gasChooseBtn, SIGNAL(clicked()), this, SLOT(selectGasClicked()));
+ connect(gasChooseBtn, SIGNAL(clicked()), this, SLOT(prepareSelectGas()));
gases << gasChooseBtn;
createDecoStops();
}
-void DivePlannerGraphics::selectGasClicked()
+void DivePlannerGraphics::prepareSelectGas()
{
+ currentGasChoice = static_cast<Button*>(sender());
+ QPoint c = QCursor::pos();
+ gasListView->setGeometry(c.x(), c.y(), 150, 100);
+ gasListView->show();
}
+void DivePlannerGraphics::selectGas(const QModelIndex& index)
+{
+ QString gasSelected = gasListView->model()->data(index, Qt::DisplayRole).toString();
+ currentGasChoice->setText(gasSelected);
+ gasListView->hide();
+}
+
+
void DivePlannerGraphics::createDecoStops()
{
qDeleteAll(lines);