mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Good code cleanup.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
This commit is contained in:
parent
9dde9b3d4c
commit
3e3d8b2210
2 changed files with 25 additions and 38 deletions
|
@ -10,6 +10,8 @@
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QGraphicsSceneMouseEvent>
|
#include <QGraphicsSceneMouseEvent>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QStringListModel>
|
||||||
|
#include <boost/graph/graph_concepts.hpp>
|
||||||
|
|
||||||
#include "ui_diveplanner.h"
|
#include "ui_diveplanner.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
@ -96,46 +98,24 @@ DivePlannerGraphics::DivePlannerGraphics(QWidget* parent): QGraphicsView(parent)
|
||||||
diveBg->setPen(QPen(QBrush(),0));
|
diveBg->setPen(QPen(QBrush(),0));
|
||||||
scene()->addItem(diveBg);
|
scene()->addItem(diveBg);
|
||||||
|
|
||||||
plusDepth = new Button();
|
#define ADDBTN(obj, icon, text, horizontal, vertical, tooltip, slot) \
|
||||||
plusDepth->setPixmap(QPixmap(":plus"));
|
obj = new Button(); \
|
||||||
plusDepth->setPos(fromPercent(5, Qt::Horizontal), fromPercent(5, Qt::Vertical));
|
obj->setPixmap(QPixmap(icon)); \
|
||||||
plusDepth->setToolTip("Increase maximum depth by 10m");
|
obj->setPos(fromPercent(horizontal, Qt::Horizontal), fromPercent(vertical, Qt::Vertical)); \
|
||||||
scene()->addItem(plusDepth);
|
obj->setToolTip(tooltip); \
|
||||||
connect(plusDepth, SIGNAL(clicked()), this, SLOT(increaseDepth()));
|
scene()->addItem(obj); \
|
||||||
|
connect(obj, SIGNAL(clicked()), this, SLOT(slot));
|
||||||
|
|
||||||
plusTime = new Button();
|
ADDBTN(plusDepth, ":plus", "" , 5, 5, tr("Increase maximum depth by 10m"), increaseDepth());
|
||||||
plusTime->setPixmap(QPixmap(":plus"));
|
ADDBTN(plusTime, ":plus", "" , 95, 5, tr("Increase minimum time by 10m"), increaseTime());
|
||||||
plusTime->setPos(fromPercent(95, Qt::Horizontal), fromPercent(95, Qt::Vertical));
|
ADDBTN(lessDepth, ":minimum","" , 2, 5, tr("Decreases maximum depth by 10m"), decreaseDepth());
|
||||||
plusTime->setToolTip("Increase minimum dive time by 10m");
|
ADDBTN(lessTime, ":minimum","" , 92, 95, tr("Decreases minimum time by 10m"), decreaseTime());
|
||||||
scene()->addItem(plusTime);
|
|
||||||
connect(plusTime, SIGNAL(clicked()), this, SLOT(increaseTime()));
|
|
||||||
|
|
||||||
lessDepth = new Button();
|
ADDBTN(okBtn, "", tr("Ok"), 1, 95, "", okClicked());
|
||||||
lessDepth->setPixmap(QPixmap(":minimum"));
|
ADDBTN(cancelBtn, "", tr("Cancel"), 0,0, "", cancelClicked());
|
||||||
lessDepth->setPos(fromPercent(2, Qt::Horizontal), fromPercent(5, Qt::Vertical));
|
|
||||||
lessDepth->setToolTip("Decreases maximum depth by 10m");
|
|
||||||
scene()->addItem(lessDepth);
|
|
||||||
connect(lessDepth, SIGNAL(clicked()), this, SLOT(decreaseDepth()));
|
|
||||||
|
|
||||||
lessTime = new Button();
|
cancelBtn->setPos(okBtn->pos().x() + okBtn->boundingRect().width()
|
||||||
lessTime->setPixmap(QPixmap(":minimum"));
|
+ fromPercent(2, Qt::Horizontal), fromPercent(95, Qt::Vertical));
|
||||||
lessTime->setPos(fromPercent(92, Qt::Horizontal), fromPercent(95, Qt::Vertical));
|
|
||||||
lessTime->setToolTip("Decreases minimum dive time by 10m");
|
|
||||||
scene()->addItem(lessTime);
|
|
||||||
connect(lessTime, SIGNAL(clicked()), this, SLOT(decreaseTime()));
|
|
||||||
|
|
||||||
okBtn = new Button();
|
|
||||||
okBtn->setText(tr("Ok"));
|
|
||||||
okBtn->setPos(fromPercent(1, Qt::Horizontal), fromPercent(95, Qt::Vertical));
|
|
||||||
scene()->addItem(okBtn);
|
|
||||||
connect(okBtn, SIGNAL(clicked()), this, SLOT(okClicked()));
|
|
||||||
|
|
||||||
cancelBtn = new Button();
|
|
||||||
cancelBtn->setText(tr("Cancel"));
|
|
||||||
cancelBtn->setPos(okBtn->pos().x() + okBtn->boundingRect().width() + fromPercent(2, Qt::Horizontal),
|
|
||||||
fromPercent(95, Qt::Vertical));
|
|
||||||
scene()->addItem(cancelBtn);
|
|
||||||
connect(cancelBtn, SIGNAL(clicked()), this, SLOT(cancelClicked()));
|
|
||||||
|
|
||||||
minMinutes = TIME_INITIAL_MAX;
|
minMinutes = TIME_INITIAL_MAX;
|
||||||
|
|
||||||
|
@ -156,6 +136,8 @@ 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"));
|
||||||
|
|
||||||
setRenderHint(QPainter::Antialiasing);
|
setRenderHint(QPainter::Antialiasing);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -381,12 +363,16 @@ 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(changeGas()));
|
connect(gasChooseBtn, SIGNAL(clicked()), this, SLOT(selectGasClicked()));
|
||||||
|
|
||||||
gases << gasChooseBtn;
|
gases << gasChooseBtn;
|
||||||
createDecoStops();
|
createDecoStops();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DivePlannerGraphics::selectGasClicked()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void DivePlannerGraphics::createDecoStops()
|
void DivePlannerGraphics::createDecoStops()
|
||||||
{
|
{
|
||||||
qDeleteAll(lines);
|
qDeleteAll(lines);
|
||||||
|
|
|
@ -86,6 +86,7 @@ private slots:
|
||||||
void decreaseDepth();;
|
void decreaseDepth();;
|
||||||
void okClicked();
|
void okClicked();
|
||||||
void cancelClicked();
|
void cancelClicked();
|
||||||
|
void selectGasClicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void moveActiveHandler(const QPointF& pos);
|
void moveActiveHandler(const QPointF& pos);
|
||||||
|
|
Loading…
Add table
Reference in a new issue