mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Added the possibility to choose gases in the planner.
Added the possibility to choose gases in the planner, now the user should click on the name of the gas, a popup window will appear, asking the user to choose what gas he wants for that ascent / descent. now we need to hook that up with the createDecoStops method that calculates the decompression. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
This commit is contained in:
parent
83c73168b0
commit
67fec4da70
2 changed files with 34 additions and 5 deletions
|
@ -11,7 +11,10 @@
|
||||||
#include <QGraphicsSceneMouseEvent>
|
#include <QGraphicsSceneMouseEvent>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QStringListModel>
|
#include <QStringListModel>
|
||||||
#include <boost/graph/graph_concepts.hpp>
|
#include <QGraphicsProxyWidget>
|
||||||
|
#include <QListView>
|
||||||
|
#include <QDesktopWidget>
|
||||||
|
#include <QModelIndex>
|
||||||
|
|
||||||
#include "ui_diveplanner.h"
|
#include "ui_diveplanner.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
@ -136,8 +139,14 @@ DivePlannerGraphics::DivePlannerGraphics(QWidget* parent): QGraphicsView(parent)
|
||||||
ADD_ACTION(Qt::Key_Right, keyRightAction());
|
ADD_ACTION(Qt::Key_Right, keyRightAction());
|
||||||
#undef ADD_ACTION
|
#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);
|
setRenderHint(QPainter::Antialiasing);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -363,16 +372,28 @@ void DivePlannerGraphics::mouseDoubleClickEvent(QMouseEvent* event)
|
||||||
gasChooseBtn ->setText(tr("Air"));
|
gasChooseBtn ->setText(tr("Air"));
|
||||||
scene()->addItem(gasChooseBtn);
|
scene()->addItem(gasChooseBtn);
|
||||||
gasChooseBtn->setZValue(10);
|
gasChooseBtn->setZValue(10);
|
||||||
connect(gasChooseBtn, SIGNAL(clicked()), this, SLOT(selectGasClicked()));
|
connect(gasChooseBtn, SIGNAL(clicked()), this, SLOT(prepareSelectGas()));
|
||||||
|
|
||||||
gases << gasChooseBtn;
|
gases << gasChooseBtn;
|
||||||
createDecoStops();
|
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()
|
void DivePlannerGraphics::createDecoStops()
|
||||||
{
|
{
|
||||||
qDeleteAll(lines);
|
qDeleteAll(lines);
|
||||||
|
|
|
@ -5,6 +5,10 @@
|
||||||
#include <QGraphicsPathItem>
|
#include <QGraphicsPathItem>
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
|
class QListView;
|
||||||
|
class QStringListModel;
|
||||||
|
class QModelIndex;
|
||||||
|
|
||||||
class Button : public QObject, public QGraphicsRectItem {
|
class Button : public QObject, public QGraphicsRectItem {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
@ -86,7 +90,8 @@ private slots:
|
||||||
void decreaseDepth();;
|
void decreaseDepth();;
|
||||||
void okClicked();
|
void okClicked();
|
||||||
void cancelClicked();
|
void cancelClicked();
|
||||||
void selectGasClicked();
|
void prepareSelectGas();
|
||||||
|
void selectGas(const QModelIndex& index);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void moveActiveHandler(const QPointF& pos);
|
void moveActiveHandler(const QPointF& pos);
|
||||||
|
@ -102,6 +107,9 @@ private:
|
||||||
user cna click to choose a new gas.
|
user cna click to choose a new gas.
|
||||||
*/
|
*/
|
||||||
QList<Button*> gases;
|
QList<Button*> gases;
|
||||||
|
QListView *gasListView;
|
||||||
|
QStringListModel *gasChoices;
|
||||||
|
Button *currentGasChoice;
|
||||||
|
|
||||||
/* those are the lines that follows the mouse. */
|
/* those are the lines that follows the mouse. */
|
||||||
QGraphicsLineItem *verticalLine;
|
QGraphicsLineItem *verticalLine;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue