Make the increase time button to work.

Makes the increase time button to work, it will
increase the minimum time, not the correct time of the
dive. the total time is calculated by the deco, and
does not come from this, unless the deco is smaller
than the minimum time.

This patch also fixes the problem where a button
would only click once - I was holding the first
clicked button as the 'mouse grabber', bad tomaz.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
This commit is contained in:
Tomaz Canabrava 2013-07-02 14:36:52 -03:00
parent 6e6a1c08c3
commit 7c8bdf70d5
2 changed files with 11 additions and 3 deletions

View file

@ -8,6 +8,7 @@
#include <QGraphicsWidget>
#include <QGraphicsProxyWidget>
#include <QPushButton>
#include <QGraphicsSceneMouseEvent>
#include "ui_diveplanner.h"
#include "mainwindow.h"
@ -119,6 +120,7 @@ DivePlannerGraphics::DivePlannerGraphics(QWidget* parent): QGraphicsView(parent)
scene()->addItem(cancelBtn);
connect(cancelBtn, SIGNAL(clicked()), this, SLOT(cancelClicked()));
minMinutes = TIME_INITIAL_MAX;
setRenderHint(QPainter::Antialiasing);
}
@ -151,7 +153,10 @@ void DivePlannerGraphics::increaseDepth()
void DivePlannerGraphics::increaseTime()
{
qDebug() << "Increase Time Clicked";
minMinutes += 10;
timeLine->setMaximum( minMinutes );
timeLine->updateTicks();
createDecoStops();
}
void DivePlannerGraphics::mouseDoubleClickEvent(QMouseEvent* event)
@ -222,7 +227,7 @@ void DivePlannerGraphics::createDecoStops()
if (timeLine->maximum() < dp->time / 60.0 + 5 ||
dp->time / 60.0 + 15 < timeLine->maximum()) {
double newMax = fmax(dp->time / 60.0 + 5, TIME_INITIAL_MAX);
double newMax = fmax(dp->time / 60.0 + 5, minMinutes);
timeLine->setMaximum(newMax);
timeLine->updateTicks();
}
@ -553,5 +558,6 @@ void Button::setText(const QString& t)
void Button::mousePressEvent(QGraphicsSceneMouseEvent* event)
{
event->ignore();
emit clicked();
}

View file

@ -72,8 +72,8 @@ protected:
void createDecoStops();
bool isPointOutOfBoundaries(const QPointF& point);
void deleteTemporaryDivePlan(struct divedatapoint* dp);
qreal fromPercent(qreal percent, Qt::Orientation orientation);
private slots:
void increaseTime();
void increaseDepth();
@ -117,6 +117,8 @@ private:
Button *lessDepth; // remove 10 meters to the depth ruler.
Button *okBtn; // accepts, and creates a new dive based on the plan.
Button *cancelBtn; // rejects, and clears the dive plan.
int minMinutes; // this holds the minimum duration of the dive.
};
#endif