summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-07-21 12:56:21 -0300
committerGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-07-21 12:56:21 -0300
commit3e3d8b2210e19b36f94d85e90235d37e3ed2b37a (patch)
tree15f77889076558d85c7078d30cd986f9485f68f6 /qt-ui
parent9dde9b3d4cb1d96eae8f42ac9d7f6361d5702c95 (diff)
downloadsubsurface-3e3d8b2210e19b36f94d85e90235d37e3ed2b37a.tar.gz
Good code cleanup.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/diveplanner.cpp68
-rw-r--r--qt-ui/diveplanner.h1
2 files changed, 28 insertions, 41 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index 9115203f5..bc3e6c73d 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -10,6 +10,8 @@
#include <QPushButton>
#include <QGraphicsSceneMouseEvent>
#include <QMessageBox>
+#include <QStringListModel>
+#include <boost/graph/graph_concepts.hpp>
#include "ui_diveplanner.h"
#include "mainwindow.h"
@@ -96,46 +98,24 @@ DivePlannerGraphics::DivePlannerGraphics(QWidget* parent): QGraphicsView(parent)
diveBg->setPen(QPen(QBrush(),0));
scene()->addItem(diveBg);
- plusDepth = new Button();
- plusDepth->setPixmap(QPixmap(":plus"));
- plusDepth->setPos(fromPercent(5, Qt::Horizontal), fromPercent(5, Qt::Vertical));
- plusDepth->setToolTip("Increase maximum depth by 10m");
- scene()->addItem(plusDepth);
- connect(plusDepth, SIGNAL(clicked()), this, SLOT(increaseDepth()));
-
- plusTime = new Button();
- plusTime->setPixmap(QPixmap(":plus"));
- plusTime->setPos(fromPercent(95, Qt::Horizontal), fromPercent(95, Qt::Vertical));
- plusTime->setToolTip("Increase minimum dive time by 10m");
- scene()->addItem(plusTime);
- connect(plusTime, SIGNAL(clicked()), this, SLOT(increaseTime()));
-
- lessDepth = new Button();
- lessDepth->setPixmap(QPixmap(":minimum"));
- 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();
- lessTime->setPixmap(QPixmap(":minimum"));
- 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()));
+#define ADDBTN(obj, icon, text, horizontal, vertical, tooltip, slot) \
+ obj = new Button(); \
+ obj->setPixmap(QPixmap(icon)); \
+ obj->setPos(fromPercent(horizontal, Qt::Horizontal), fromPercent(vertical, Qt::Vertical)); \
+ obj->setToolTip(tooltip); \
+ scene()->addItem(obj); \
+ connect(obj, SIGNAL(clicked()), this, SLOT(slot));
+
+ ADDBTN(plusDepth, ":plus", "" , 5, 5, tr("Increase maximum depth by 10m"), increaseDepth());
+ ADDBTN(plusTime, ":plus", "" , 95, 5, tr("Increase minimum time by 10m"), increaseTime());
+ ADDBTN(lessDepth, ":minimum","" , 2, 5, tr("Decreases maximum depth by 10m"), decreaseDepth());
+ ADDBTN(lessTime, ":minimum","" , 92, 95, tr("Decreases minimum time by 10m"), decreaseTime());
+
+ ADDBTN(okBtn, "", tr("Ok"), 1, 95, "", okClicked());
+ ADDBTN(cancelBtn, "", tr("Cancel"), 0,0, "", cancelClicked());
+
+ cancelBtn->setPos(okBtn->pos().x() + okBtn->boundingRect().width()
+ + fromPercent(2, Qt::Horizontal), fromPercent(95, Qt::Vertical));
minMinutes = TIME_INITIAL_MAX;
@@ -156,6 +136,8 @@ 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"));
+
setRenderHint(QPainter::Antialiasing);
}
@@ -381,12 +363,16 @@ void DivePlannerGraphics::mouseDoubleClickEvent(QMouseEvent* event)
gasChooseBtn ->setText(tr("Air"));
scene()->addItem(gasChooseBtn);
gasChooseBtn->setZValue(10);
- connect(gasChooseBtn, SIGNAL(clicked()), this, SLOT(changeGas()));
+ connect(gasChooseBtn, SIGNAL(clicked()), this, SLOT(selectGasClicked()));
gases << gasChooseBtn;
createDecoStops();
}
+void DivePlannerGraphics::selectGasClicked()
+{
+}
+
void DivePlannerGraphics::createDecoStops()
{
qDeleteAll(lines);
diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h
index cab3773e8..cf8bb0c80 100644
--- a/qt-ui/diveplanner.h
+++ b/qt-ui/diveplanner.h
@@ -86,6 +86,7 @@ private slots:
void decreaseDepth();;
void okClicked();
void cancelClicked();
+ void selectGasClicked();
private:
void moveActiveHandler(const QPointF& pos);