summaryrefslogtreecommitdiffstats
path: root/qt-ui/profile
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-02-27 20:09:57 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-02-27 20:09:57 -0800
commit76e6420f6b3503b76bd3eec00ab0e53d6ea17a20 (patch)
tree8b50298f41bd29d55bbd6f4301f36ad31dc0b008 /qt-ui/profile
parent006265d7a088cff4fea665159dbb454956c2cd76 (diff)
downloadsubsurface-76e6420f6b3503b76bd3eec00ab0e53d6ea17a20.tar.gz
Massive automated whitespace cleanup
I know everyone will hate it. Go ahead. Complain. Call me names. At least now things are consistent and reproducible. If you want changes, have your complaint come with a patch to scripts/whitespace.pl so that we can automate it. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/profile')
-rw-r--r--qt-ui/profile/animationfunctions.cpp56
-rw-r--r--qt-ui/profile/animationfunctions.h5
-rw-r--r--qt-ui/profile/divecartesianaxis.cpp134
-rw-r--r--qt-ui/profile/divecartesianaxis.h41
-rw-r--r--qt-ui/profile/diveeventitem.cpp25
-rw-r--r--qt-ui/profile/diveeventitem.h10
-rw-r--r--qt-ui/profile/divelineitem.cpp1
-rw-r--r--qt-ui/profile/divepixmapitem.cpp3
-rw-r--r--qt-ui/profile/divepixmapitem.h4
-rw-r--r--qt-ui/profile/diveplotdatamodel.cpp134
-rw-r--r--qt-ui/profile/diveplotdatamodel.h54
-rw-r--r--qt-ui/profile/diveprofileitem.cpp143
-rw-r--r--qt-ui/profile/diveprofileitem.h74
-rw-r--r--qt-ui/profile/diverectitem.cpp3
-rw-r--r--qt-ui/profile/diverectitem.h2
-rw-r--r--qt-ui/profile/divetextitem.cpp22
-rw-r--r--qt-ui/profile/divetextitem.h11
-rw-r--r--qt-ui/profile/divetooltipitem.cpp52
-rw-r--r--qt-ui/profile/divetooltipitem.h34
-rw-r--r--qt-ui/profile/profilewidget2.cpp169
-rw-r--r--qt-ui/profile/profilewidget2.h44
-rw-r--r--qt-ui/profile/ruleritem.cpp20
-rw-r--r--qt-ui/profile/ruleritem.h19
23 files changed, 587 insertions, 473 deletions
diff --git a/qt-ui/profile/animationfunctions.cpp b/qt-ui/profile/animationfunctions.cpp
index f70468bde..8cccf616e 100644
--- a/qt-ui/profile/animationfunctions.cpp
+++ b/qt-ui/profile/animationfunctions.cpp
@@ -2,37 +2,37 @@
#include <QPropertyAnimation>
#include <QPointF>
-namespace Animations {
-
-void hide(QObject* obj)
+namespace Animations
{
- QPropertyAnimation *animation = new QPropertyAnimation(obj, "opacity");
- animation->setStartValue(1);
- animation->setEndValue(0);
- animation->start(QAbstractAnimation::DeleteWhenStopped);
-}
-void animDelete(QObject* obj)
-{
- QPropertyAnimation *animation = new QPropertyAnimation(obj, "opacity");
- obj->connect(animation, SIGNAL(finished()), SLOT(deleteLater()));
- animation->setStartValue(1);
- animation->setEndValue(0);
- animation->start(QAbstractAnimation::DeleteWhenStopped);
-}
+ void hide(QObject *obj)
+ {
+ QPropertyAnimation *animation = new QPropertyAnimation(obj, "opacity");
+ animation->setStartValue(1);
+ animation->setEndValue(0);
+ animation->start(QAbstractAnimation::DeleteWhenStopped);
+ }
-void moveTo(QObject* obj, qreal x, qreal y, int msecs)
-{
- QPropertyAnimation *animation = new QPropertyAnimation(obj, "pos");
- animation->setDuration(msecs);
- animation->setStartValue(obj->property("pos").toPointF());
- animation->setEndValue(QPointF(x, y));
- animation->start(QAbstractAnimation::DeleteWhenStopped);
-}
+ void animDelete(QObject *obj)
+ {
+ QPropertyAnimation *animation = new QPropertyAnimation(obj, "opacity");
+ obj->connect(animation, SIGNAL(finished()), SLOT(deleteLater()));
+ animation->setStartValue(1);
+ animation->setEndValue(0);
+ animation->start(QAbstractAnimation::DeleteWhenStopped);
+ }
-void moveTo(QObject* obj, const QPointF& pos, int msecs)
-{
- moveTo(obj, pos.x(), pos.y(), msecs);
-}
+ void moveTo(QObject *obj, qreal x, qreal y, int msecs)
+ {
+ QPropertyAnimation *animation = new QPropertyAnimation(obj, "pos");
+ animation->setDuration(msecs);
+ animation->setStartValue(obj->property("pos").toPointF());
+ animation->setEndValue(QPointF(x, y));
+ animation->start(QAbstractAnimation::DeleteWhenStopped);
+ }
+ void moveTo(QObject *obj, const QPointF &pos, int msecs)
+ {
+ moveTo(obj, pos.x(), pos.y(), msecs);
+ }
}
diff --git a/qt-ui/profile/animationfunctions.h b/qt-ui/profile/animationfunctions.h
index 2ab8c9e47..f6c93c7ae 100644
--- a/qt-ui/profile/animationfunctions.h
+++ b/qt-ui/profile/animationfunctions.h
@@ -6,10 +6,11 @@
class QObject;
-namespace Animations{
+namespace Animations
+{
void hide(QObject *obj);
void moveTo(QObject *obj, qreal x, qreal y, int msecs = 500);
- void moveTo(QObject *obj, const QPointF& pos, int msecs = 500);
+ void moveTo(QObject *obj, const QPointF &pos, int msecs = 500);
void animDelete(QObject *obj);
}
diff --git a/qt-ui/profile/divecartesianaxis.cpp b/qt-ui/profile/divecartesianaxis.cpp
index c2ccdebcd..2373b5f2f 100644
--- a/qt-ui/profile/divecartesianaxis.cpp
+++ b/qt-ui/profile/divecartesianaxis.cpp
@@ -12,7 +12,8 @@
#include <QStyleOption>
#include <QSettings>
-static QPen gridPen(){
+static QPen gridPen()
+{
QPen pen;
pen.setColor(getColor(TIME_GRID));
pen.setWidth(2);
@@ -50,7 +51,7 @@ void DiveCartesianAxis::setMinimum(double minimum)
min = minimum;
}
-void DiveCartesianAxis::setTextColor(const QColor& color)
+void DiveCartesianAxis::setTextColor(const QColor &color)
{
textColor = color;
}
@@ -73,7 +74,6 @@ DiveCartesianAxis::DiveCartesianAxis() : QObject(),
DiveCartesianAxis::~DiveCartesianAxis()
{
-
}
void DiveCartesianAxis::setLineSize(qreal lineSize)
@@ -93,31 +93,33 @@ QColor DiveCartesianAxis::colorForValue(double value)
void DiveCartesianAxis::setTextVisible(bool arg1)
{
- if(textVisibility == arg1){
+ if (textVisibility == arg1) {
return;
}
textVisibility = arg1;
- Q_FOREACH(DiveTextItem *item, labels){
+ Q_FOREACH(DiveTextItem * item, labels) {
item->setVisible(textVisibility);
}
}
void DiveCartesianAxis::setLinesVisible(bool arg1)
{
- if(lineVisibility == arg1){
+ if (lineVisibility == arg1) {
return;
}
- lineVisibility = arg1;
- Q_FOREACH(DiveLineItem *item, lines){
- item->setVisible(lineVisibility );
+ lineVisibility = arg1;
+ Q_FOREACH(DiveLineItem * item, lines) {
+ item->setVisible(lineVisibility);
}
}
-template<typename T> void emptyList( QList<T*>& list, double steps){
+template <typename T>
+void emptyList(QList<T *> &list, double steps)
+{
if (!list.isEmpty() && list.size() > steps) {
while (list.size() > steps) {
- T *removedItem = list.takeLast();
- Animations::animDelete(removedItem);
+ T *removedItem = list.takeLast();
+ Animations::animDelete(removedItem);
}
}
}
@@ -148,7 +150,7 @@ void DiveCartesianAxis::updateTicks()
} else if (orientation == BottomToTop) {
begin = m.y2();
stepSize = (m.y2() - m.y1());
- } else if (orientation == LeftToRight ) {
+ } else if (orientation == LeftToRight) {
begin = m.x1();
stepSize = (m.x2() - m.x1());
} else if (orientation == RightToLeft) {
@@ -159,11 +161,11 @@ void DiveCartesianAxis::updateTicks()
for (int i = 0, count = labels.size(); i < count; i++, currValueText += interval) {
qreal childPos = (orientation == TopToBottom || orientation == LeftToRight) ?
- begin + i * stepSize :
- begin - i * stepSize;
+ begin + i * stepSize :
+ begin - i * stepSize;
labels[i]->setText(textForValue(currValueText));
- if ( orientation == LeftToRight || orientation == RightToLeft) {
+ if (orientation == LeftToRight || orientation == RightToLeft) {
labels[i]->animateMoveTo(childPos, m.y1() + tick_size);
} else {
labels[i]->animateMoveTo(m.x1() - tick_size, childPos);
@@ -172,10 +174,10 @@ void DiveCartesianAxis::updateTicks()
for (int i = 0, count = lines.size(); i < count; i++, currValueLine += interval) {
qreal childPos = (orientation == TopToBottom || orientation == LeftToRight) ?
- begin + i * stepSize :
- begin - i * stepSize;
+ begin + i * stepSize :
+ begin - i * stepSize;
- if ( orientation == LeftToRight || orientation == RightToLeft) {
+ if (orientation == LeftToRight || orientation == RightToLeft) {
lines[i]->animateMoveTo(childPos, m.y1());
} else {
lines[i]->animateMoveTo(m.x1(), childPos);
@@ -183,10 +185,10 @@ void DiveCartesianAxis::updateTicks()
}
// Add's the rest of the needed Ticks / Text.
- for (int i = labels.size(); i < steps; i++, currValueText += interval) {
+ for (int i = labels.size(); i < steps; i++, currValueText += interval) {
qreal childPos;
if (orientation == TopToBottom || orientation == LeftToRight) {
- childPos = begin + i * stepSize;
+ childPos = begin + i * stepSize;
} else {
childPos = begin - i * stepSize;
}
@@ -202,17 +204,17 @@ void DiveCartesianAxis::updateTicks()
label->setPos(scene()->sceneRect().width() + 10, m.y1() + tick_size); // position it outside of the scene);
label->animateMoveTo(childPos, m.y1() + tick_size);
} else {
- label->setAlignment(Qt::AlignVCenter| Qt::AlignLeft);
+ label->setAlignment(Qt::AlignVCenter | Qt::AlignLeft);
label->setPos(m.x1() - tick_size, scene()->sceneRect().height() + 10);
label->animateMoveTo(m.x1() - tick_size, childPos);
}
}
// Add's the rest of the needed Ticks / Text.
- for (int i = lines.size(); i < steps; i++, currValueText += interval) {
+ for (int i = lines.size(); i < steps; i++, currValueText += interval) {
qreal childPos;
if (orientation == TopToBottom || orientation == LeftToRight) {
- childPos = begin + i * stepSize;
+ childPos = begin + i * stepSize;
} else {
childPos = begin - i * stepSize;
}
@@ -225,7 +227,7 @@ void DiveCartesianAxis::updateTicks()
line->setZValue(0);
lines.push_back(line);
if (orientation == RightToLeft || orientation == LeftToRight) {
- line->setLine(0,-line_size,0, 0);
+ line->setLine(0, -line_size, 0, 0);
line->animateMoveTo(childPos, m.y1());
} else {
QPointF p1 = mapFromScene(3, 0);
@@ -235,13 +237,13 @@ void DiveCartesianAxis::updateTicks()
}
}
- Q_FOREACH(DiveTextItem *item, labels)
- item->setVisible(textVisibility);
- Q_FOREACH(DiveLineItem *item, lines)
- item->setVisible(lineVisibility);
+ Q_FOREACH(DiveTextItem * item, labels)
+ item->setVisible(textVisibility);
+ Q_FOREACH(DiveLineItem * item, lines)
+ item->setVisible(lineVisibility);
}
-void DiveCartesianAxis::animateChangeLine(const QLineF& newLine)
+void DiveCartesianAxis::animateChangeLine(const QLineF &newLine)
{
setLine(newLine);
updateTicks();
@@ -263,15 +265,15 @@ void DiveCartesianAxis::setTickInterval(double i)
interval = i;
}
-qreal DiveCartesianAxis::valueAt(const QPointF& p) const
+qreal DiveCartesianAxis::valueAt(const QPointF &p) const
{
QLineF m = line();
QPointF relativePosition = p;
relativePosition -= pos(); // normalize p based on the axis' offset on screen
- double retValue = (orientation == LeftToRight || orientation == RightToLeft) ?
- max * (relativePosition.x() - m.x1()) / (m.x2() - m.x1()) :
- max * (relativePosition.y() - m.y1()) / (m.y2() - m.y1());
+ double retValue = (orientation == LeftToRight || orientation == RightToLeft) ?
+ max * (relativePosition.x() - m.x1()) / (m.x2() - m.x1()) :
+ max * (relativePosition.y() - m.y1()) / (m.y2() - m.y1());
return retValue;
}
@@ -283,12 +285,12 @@ qreal DiveCartesianAxis::posAtValue(qreal value)
double size = max - min;
// unused for now:
// double distanceFromOrigin = value - min;
- double percent = IS_FP_SAME(min,max) ? 0.0 : (value - min) / size;
+ double percent = IS_FP_SAME(min, max) ? 0.0 : (value - min) / size;
- double realSize = orientation == LeftToRight || orientation == RightToLeft?
- m.x2() - m.x1() :
- m.y2() - m.y1();
+ double realSize = orientation == LeftToRight || orientation == RightToLeft ?
+ m.x2() - m.x1() :
+ m.y2() - m.y1();
// Inverted axis, just invert the percentage.
if (orientation == RightToLeft || orientation == BottomToTop)
@@ -296,14 +298,14 @@ qreal DiveCartesianAxis::posAtValue(qreal value)
double retValue = realSize * percent;
double adjusted =
- orientation == LeftToRight ? retValue + m.x1() + p.x() :
- orientation == RightToLeft ? retValue + m.x1() + p.x() :
- orientation == TopToBottom ? retValue + m.y1() + p.y() :
- /* entation == BottomToTop */ retValue + m.y1() + p.y() ;
+ orientation == LeftToRight ? retValue + m.x1() + p.x() :
+ orientation == RightToLeft ? retValue + m.x1() + p.x() :
+ orientation == TopToBottom ? retValue + m.y1() + p.y() :
+ /* entation == BottomToTop */ retValue + m.y1() + p.y();
return adjusted;
}
-qreal DiveCartesianAxis::percentAt(const QPointF& p)
+qreal DiveCartesianAxis::percentAt(const QPointF &p)
{
qreal value = valueAt(p);
double size = max - min;
@@ -326,7 +328,7 @@ double DiveCartesianAxis::fontLabelScale() const
return labelScale;
}
-void DiveCartesianAxis::setColor(const QColor& color)
+void DiveCartesianAxis::setColor(const QColor &color)
{
QPen defaultPen(color);
defaultPen.setJoinStyle(Qt::RoundJoin);
@@ -361,24 +363,24 @@ DepthAxis::DepthAxis() : showWithPPGraph(false)
{
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged()));
- // force the correct size of the line.
+ // force the correct size of the line.
showWithPPGraph = !isPPGraphEnabled();
settingsChanged();
}
void DepthAxis::settingsChanged()
{
-// bool ppGraph = isPPGraphEnabled();
-// if ( ppGraph == showWithPPGraph){
-// return;
-// }
-//
-// if (ppGraph) {
-// animateChangeLine(shrinkedLine);
-// } else {
-// animateChangeLine(expandedLine);
-// }
-// showWithPPGraph = ppGraph;
+ // bool ppGraph = isPPGraphEnabled();
+ // if ( ppGraph == showWithPPGraph){
+ // return;
+ // }
+ //
+ // if (ppGraph) {
+ // animateChangeLine(shrinkedLine);
+ // } else {
+ // animateChangeLine(expandedLine);
+ // }
+ // showWithPPGraph = ppGraph;
}
QColor TimeAxis::colorForValue(double value)
@@ -390,16 +392,16 @@ QColor TimeAxis::colorForValue(double value)
QString TimeAxis::textForValue(double value)
{
int nr = value / 60;
- if (maximum() < 600 )
- return QString("%1:%2").arg(nr).arg( (int)value%60, 2, 10, QChar('0'));
- return QString::number(nr);
+ if (maximum() < 600)
+ return QString("%1:%2").arg(nr).arg((int)value % 60, 2, 10, QChar('0'));
+ return QString::number(nr);
}
void TimeAxis::updateTicks()
{
DiveCartesianAxis::updateTicks();
- if (maximum() > 600){
- for(int i = 0; i < labels.count(); i++){
+ if (maximum() > 600) {
+ for (int i = 0; i < labels.count(); i++) {
labels[i]->setVisible(i % 2);
}
}
@@ -407,7 +409,7 @@ void TimeAxis::updateTicks()
QString TemperatureAxis::textForValue(double value)
{
- return QString::number(mkelvin_to_C( (int) value));
+ return QString::number(mkelvin_to_C((int)value));
}
PartialGasPressureAxis::PartialGasPressureAxis()
@@ -415,7 +417,7 @@ PartialGasPressureAxis::PartialGasPressureAxis()
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), this, SLOT(preferencesChanged()));
}
-void PartialGasPressureAxis::setModel(DivePlotDataModel* m)
+void PartialGasPressureAxis::setModel(DivePlotDataModel *m)
{
model = m;
connect(model, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(preferencesChanged()));
@@ -435,8 +437,8 @@ void PartialGasPressureAxis::preferencesChanged()
double max = showPhe ? model->pheMax() : -1;
if (showPn2 && model->pn2Max() > max)
- max = model->pn2Max();
- if( showPo2 && model->po2Max() > max)
+ max = model->pn2Max();
+ if (showPo2 && model->po2Max() > max)
max = model->po2Max();
qreal pp = floor(max * 10.0) / 10.0 + 0.2;
@@ -444,6 +446,6 @@ void PartialGasPressureAxis::preferencesChanged()
return;
setMaximum(pp);
- setTickInterval( pp > 4 ? 0.5 : 0.25 );
+ setTickInterval(pp > 4 ? 0.5 : 0.25);
updateTicks();
}
diff --git a/qt-ui/profile/divecartesianaxis.h b/qt-ui/profile/divecartesianaxis.h
index 1bfb4b913..c430d4704 100644
--- a/qt-ui/profile/divecartesianaxis.h
+++ b/qt-ui/profile/divecartesianaxis.h
@@ -9,14 +9,19 @@ class DiveTextItem;
class DiveLineItem;
class DivePlotDataModel;
-class DiveCartesianAxis : public QObject, public QGraphicsLineItem{
+class DiveCartesianAxis : public QObject, public QGraphicsLineItem {
Q_OBJECT
Q_PROPERTY(QLineF line WRITE setLine READ line)
Q_PROPERTY(QPointF pos WRITE setPos READ pos)
Q_PROPERTY(qreal x WRITE setX READ x)
Q_PROPERTY(qreal y WRITE setY READ y)
public:
- enum Orientation{TopToBottom, BottomToTop, LeftToRight, RightToLeft};
+ enum Orientation {
+ TopToBottom,
+ BottomToTop,
+ LeftToRight,
+ RightToLeft
+ };
DiveCartesianAxis();
virtual ~DiveCartesianAxis();
void setMinimum(double minimum);
@@ -30,28 +35,30 @@ public:
double tickInterval() const;
double tickSize() const;
double fontLabelScale() const;
- qreal valueAt(const QPointF& p) const;
- qreal percentAt(const QPointF& p);
+ qreal valueAt(const QPointF &p) const;
+ qreal percentAt(const QPointF &p);
qreal posAtValue(qreal value);
- void setColor(const QColor& color);
- void setTextColor(const QColor& color);
- void animateChangeLine(const QLineF& newLine);
+ void setColor(const QColor &color);
+ void setTextColor(const QColor &color);
+ void animateChangeLine(const QLineF &newLine);
void setTextVisible(bool arg1);
void setLinesVisible(bool arg1);
void setLineSize(qreal lineSize);
int unitSystem;
-public slots:
+public
+slots:
virtual void updateTicks();
signals:
void sizeChanged();
void maxChanged();
+
protected:
virtual QString textForValue(double value);
virtual QColor colorForValue(double value);
Orientation orientation;
- QList<DiveTextItem*> labels;
- QList<DiveLineItem*> lines;
+ QList<DiveTextItem *> labels;
+ QList<DiveLineItem *> lines;
double min;
double max;
double interval;
@@ -67,11 +74,14 @@ class DepthAxis : public DiveCartesianAxis {
Q_OBJECT
public:
DepthAxis();
+
protected:
QString textForValue(double value);
QColor colorForValue(double value);
-private slots:
+private
+slots:
void settingsChanged();
+
private:
bool showWithPPGraph;
};
@@ -80,24 +90,27 @@ class TimeAxis : public DiveCartesianAxis {
Q_OBJECT
public:
virtual void updateTicks();
+
protected:
QString textForValue(double value);
QColor colorForValue(double value);
};
-class TemperatureAxis : public DiveCartesianAxis{
+class TemperatureAxis : public DiveCartesianAxis {
Q_OBJECT
protected:
QString textForValue(double value);
};
-class PartialGasPressureAxis : public DiveCartesianAxis{
+class PartialGasPressureAxis : public DiveCartesianAxis {
Q_OBJECT
public:
PartialGasPressureAxis();
void setModel(DivePlotDataModel *model);
-public slots:
+public
+slots:
void preferencesChanged();
+
private:
DivePlotDataModel *model;
};
diff --git a/qt-ui/profile/diveeventitem.cpp b/qt-ui/profile/diveeventitem.cpp
index f3740ef08..40d9e7263 100644
--- a/qt-ui/profile/diveeventitem.cpp
+++ b/qt-ui/profile/diveeventitem.cpp
@@ -6,26 +6,29 @@
#include "dive.h"
#include <QDebug>
-DiveEventItem::DiveEventItem(QObject* parent): DivePixmapItem(parent),
- vAxis(NULL), hAxis(NULL), dataModel(NULL), internalEvent(NULL)
+DiveEventItem::DiveEventItem(QObject *parent) : DivePixmapItem(parent),
+ vAxis(NULL),
+ hAxis(NULL),
+ dataModel(NULL),
+ internalEvent(NULL)
{
setFlag(ItemIgnoresTransformations);
}
-void DiveEventItem::setHorizontalAxis(DiveCartesianAxis* axis)
+void DiveEventItem::setHorizontalAxis(DiveCartesianAxis *axis)
{
hAxis = axis;
recalculatePos(true);
}
-void DiveEventItem::setModel(DivePlotDataModel* model)
+void DiveEventItem::setModel(DivePlotDataModel *model)
{
dataModel = model;
recalculatePos(true);
}
-void DiveEventItem::setVerticalAxis(DiveCartesianAxis* axis)
+void DiveEventItem::setVerticalAxis(DiveCartesianAxis *axis)
{
vAxis = axis;
recalculatePos(true);
@@ -37,7 +40,7 @@ struct event *DiveEventItem::getEvent()
return internalEvent;
}
-void DiveEventItem::setEvent(struct event* ev)
+void DiveEventItem::setEvent(struct event *ev)
{
if (!ev)
return;
@@ -49,7 +52,7 @@ void DiveEventItem::setEvent(struct event* ev)
void DiveEventItem::setupPixmap()
{
-#define EVENT_PIXMAP( PIX ) QPixmap(QString(PIX)).scaled(20, 20, Qt::KeepAspectRatio, Qt::SmoothTransformation)
+#define EVENT_PIXMAP(PIX) QPixmap(QString(PIX)).scaled(20, 20, Qt::KeepAspectRatio, Qt::SmoothTransformation)
if (!internalEvent->name) {
setPixmap(EVENT_PIXMAP(":warning"));
} else if ((strcmp(internalEvent->name, "bookmark") == 0)) {
@@ -84,7 +87,7 @@ void DiveEventItem::setupToolTipString()
else
name += QString(tr("EAN%1")).arg(o2);
} else if (name == "SP change") {
- name += QString(":%1").arg((double) value / 1000);
+ name += QString(":%1").arg((double)value / 1000);
} else {
name += QString(":%1").arg(value);
}
@@ -98,7 +101,7 @@ void DiveEventItem::setupToolTipString()
setToolTip(name);
}
-void DiveEventItem::eventVisibilityChanged(const QString& eventName, bool visible)
+void DiveEventItem::eventVisibilityChanged(const QString &eventName, bool visible)
{
}
@@ -107,7 +110,7 @@ void DiveEventItem::recalculatePos(bool instant)
if (!vAxis || !hAxis || !internalEvent || !dataModel)
return;
- QModelIndexList result = dataModel->match(dataModel->index(0,DivePlotDataModel::TIME), Qt::DisplayRole, internalEvent->time.seconds );
+ QModelIndexList result = dataModel->match(dataModel->index(0, DivePlotDataModel::TIME), Qt::DisplayRole, internalEvent->time.seconds);
if (result.isEmpty()) {
Q_ASSERT("can't find a spot in the dataModel");
hide();
@@ -122,5 +125,5 @@ void DiveEventItem::recalculatePos(bool instant)
if (!instant)
Animations::moveTo(this, x, y, 500);
else
- setPos(x,y);
+ setPos(x, y);
}
diff --git a/qt-ui/profile/diveeventitem.h b/qt-ui/profile/diveeventitem.h
index d2efb2dc4..1b138163c 100644
--- a/qt-ui/profile/diveeventitem.h
+++ b/qt-ui/profile/diveeventitem.h
@@ -10,22 +10,24 @@ struct event;
class DiveEventItem : public DivePixmapItem {
Q_OBJECT
public:
- DiveEventItem(QObject* parent = 0);
+ DiveEventItem(QObject *parent = 0);
void setEvent(struct event *ev);
struct event *getEvent();
- void eventVisibilityChanged(const QString& eventName, bool visible);
+ void eventVisibilityChanged(const QString &eventName, bool visible);
void setVerticalAxis(DiveCartesianAxis *axis);
void setHorizontalAxis(DiveCartesianAxis *axis);
void setModel(DivePlotDataModel *model);
-public slots:
+public
+slots:
void recalculatePos(bool instant = false);
+
private:
void setupToolTipString();
void setupPixmap();
DiveCartesianAxis *vAxis;
DiveCartesianAxis *hAxis;
DivePlotDataModel *dataModel;
- struct event* internalEvent;
+ struct event *internalEvent;
};
#endif // DIVEEVENTITEM_H
diff --git a/qt-ui/profile/divelineitem.cpp b/qt-ui/profile/divelineitem.cpp
index 834c1b8e3..eb3d1db9c 100644
--- a/qt-ui/profile/divelineitem.cpp
+++ b/qt-ui/profile/divelineitem.cpp
@@ -4,7 +4,6 @@
DiveLineItem::DiveLineItem(QGraphicsItem *parent) : QGraphicsLineItem(parent)
{
-
}
void DiveLineItem::animatedHide()
diff --git a/qt-ui/profile/divepixmapitem.cpp b/qt-ui/profile/divepixmapitem.cpp
index c62a7a20b..d27d77cba 100644
--- a/qt-ui/profile/divepixmapitem.cpp
+++ b/qt-ui/profile/divepixmapitem.cpp
@@ -1,6 +1,5 @@
#include "divepixmapitem.h"
-DivePixmapItem::DivePixmapItem(QObject* parent): QObject(parent), QGraphicsPixmapItem()
+DivePixmapItem::DivePixmapItem(QObject *parent) : QObject(parent), QGraphicsPixmapItem()
{
-
}
diff --git a/qt-ui/profile/divepixmapitem.h b/qt-ui/profile/divepixmapitem.h
index 855a0d2d7..aa2563877 100644
--- a/qt-ui/profile/divepixmapitem.h
+++ b/qt-ui/profile/divepixmapitem.h
@@ -4,14 +4,14 @@
#include <QObject>
#include <QGraphicsPixmapItem>
-class DivePixmapItem : public QObject, public QGraphicsPixmapItem{
+class DivePixmapItem : public QObject, public QGraphicsPixmapItem {
Q_OBJECT
Q_PROPERTY(qreal opacity WRITE setOpacity READ opacity)
Q_PROPERTY(QPointF pos WRITE setPos READ pos)
Q_PROPERTY(qreal x WRITE setX READ x)
Q_PROPERTY(qreal y WRITE setY READ y)
public:
- DivePixmapItem(QObject* parent = 0);
+ DivePixmapItem(QObject *parent = 0);
};
#endif // DIVEPIXMAPITEM_H
diff --git a/qt-ui/profile/diveplotdatamodel.cpp b/qt-ui/profile/diveplotdatamodel.cpp
index f7a0e231b..7412a7764 100644
--- a/qt-ui/profile/diveplotdatamodel.cpp
+++ b/qt-ui/profile/diveplotdatamodel.cpp
@@ -8,60 +8,76 @@
#include "divelist.h"
#include <QDebug>
-DivePlotDataModel::DivePlotDataModel(QObject* parent) : QAbstractTableModel(parent) , diveId(0)
+DivePlotDataModel::DivePlotDataModel(QObject *parent) : QAbstractTableModel(parent), diveId(0)
{
memset(&pInfo, 0, sizeof(pInfo));
}
-int DivePlotDataModel::columnCount(const QModelIndex& parent) const
+int DivePlotDataModel::columnCount(const QModelIndex &parent) const
{
return COLUMNS;
}
-QVariant DivePlotDataModel::data(const QModelIndex& index, int role) const
+QVariant DivePlotDataModel::data(const QModelIndex &index, int role) const
{
- if ((!index.isValid())||(index.row() >= pInfo.nr))
+ if ((!index.isValid()) || (index.row() >= pInfo.nr))
return QVariant();
plot_data item = pInfo.entry[index.row()];
if (role == Qt::DisplayRole) {
switch (index.column()) {
- case DEPTH: return item.depth;
- case TIME: return item.sec;
- case PRESSURE: return item.pressure[0];
- case TEMPERATURE: return item.temperature;
- case COLOR: return item.velocity;
- case USERENTERED: return false;
- case CYLINDERINDEX: return item.cylinderindex;
- case SENSOR_PRESSURE: return item.pressure[0];
- case INTERPOLATED_PRESSURE: return item.pressure[1];
- case CEILING: return item.ceiling;
- case SAC: return item.sac;
- case PN2: return item.pn2;
- case PHE: return item.phe;
- case PO2: return item.po2;
- case HEARTBEAT: return item.heartbeat;
+ case DEPTH:
+ return item.depth;
+ case TIME:
+ return item.sec;
+ case PRESSURE:
+ return item.pressure[0];
+ case TEMPERATURE:
+ return item.temperature;
+ case COLOR:
+ return item.velocity;
+ case USERENTERED:
+ return false;
+ case CYLINDERINDEX:
+ return item.cylinderindex;
+ case SENSOR_PRESSURE:
+ return item.pressure[0];
+ case INTERPOLATED_PRESSURE:
+ return item.pressure[1];
+ case CEILING:
+ return item.ceiling;
+ case SAC:
+ return item.sac;
+ case PN2:
+ return item.pn2;
+ case PHE:
+ return item.phe;
+ case PO2:
+ return item.po2;
+ case HEARTBEAT:
+ return item.heartbeat;
}
}
- if (role == Qt::DisplayRole && index.column() >= TISSUE_1 && index.column() <= TISSUE_16){
- return item.ceilings[ index.column() - TISSUE_1];
+ if (role == Qt::DisplayRole && index.column() >= TISSUE_1 && index.column() <= TISSUE_16) {
+ return item.ceilings[index.column() - TISSUE_1];
}
if (role == Qt::BackgroundRole) {
switch (index.column()) {
- case COLOR: return getColor((color_indice_t)(VELOCITY_COLORS_START_IDX + item.velocity));
+ case COLOR:
+ return getColor((color_indice_t)(VELOCITY_COLORS_START_IDX + item.velocity));
}
}
return QVariant();
}
-const plot_info& DivePlotDataModel::data() const
+const plot_info &DivePlotDataModel::data() const
{
return pInfo;
}
-int DivePlotDataModel::rowCount(const QModelIndex& parent) const
+int DivePlotDataModel::rowCount(const QModelIndex &parent) const
{
return pInfo.nr;
}
@@ -75,22 +91,36 @@ QVariant DivePlotDataModel::headerData(int section, Qt::Orientation orientation,
return QVariant();
switch (section) {
- case DEPTH: return tr("Depth");
- case TIME: return tr("Time");
- case PRESSURE: return tr("Pressure");
- case TEMPERATURE: return tr("Temperature");
- case COLOR: return tr("Color");
- case USERENTERED: return tr("User Entered");
- case CYLINDERINDEX: return tr("Cylinder Index");
- case SENSOR_PRESSURE: return tr("Pressure S");
- case INTERPOLATED_PRESSURE: return tr("Pressure I");
- case CEILING: return tr("Ceiling");
- case SAC: return tr("SAC");
- case PN2: return tr("PN2");
- case PHE: return tr("PHE");
- case PO2: return tr("PO2");
+ case DEPTH:
+ return tr("Depth");
+ case TIME:
+ return tr("Time");
+ case PRESSURE:
+ return tr("Pressure");
+ case TEMPERATURE:
+ return tr("Temperature");
+ case COLOR:
+ return tr("Color");
+ case USERENTERED:
+ return tr("User Entered");
+ case CYLINDERINDEX:
+ return tr("Cylinder Index");
+ case SENSOR_PRESSURE:
+ return tr("Pressure S");
+ case INTERPOLATED_PRESSURE:
+ return tr("Pressure I");
+ case CEILING:
+ return tr("Ceiling");
+ case SAC:
+ return tr("SAC");
+ case PN2:
+ return tr("PN2");
+ case PHE:
+ return tr("PHE");
+ case PO2:
+ return tr("PO2");
}
- if (role == Qt::DisplayRole && section >= TISSUE_1 && section <= TISSUE_16){
+ if (role == Qt::DisplayRole && section >= TISSUE_1 && section <= TISSUE_16) {
return QString("Ceiling: %1").arg(section - TISSUE_1);
}
return QVariant();
@@ -107,14 +137,14 @@ void DivePlotDataModel::clear()
}
}
-void DivePlotDataModel::setDive(dive* d, const plot_info& info)
+void DivePlotDataModel::setDive(dive *d, const plot_info &info)
{
clear();
Q_ASSERT(d != NULL);
diveId = d->id;
dcNr = dc_number;
pInfo = info;
- beginInsertRows(QModelIndex(), 0, pInfo.nr-1);
+ beginInsertRows(QModelIndex(), 0, pInfo.nr - 1);
endInsertRows();
}
@@ -128,16 +158,16 @@ int DivePlotDataModel::dcShown() const
return dcNr;
}
-#define MAX_PPGAS_FUNC( GAS, GASFUNC ) \
-double DivePlotDataModel::GASFUNC() \
-{ \
- double ret = -1; \
- for(int i = 0, count = rowCount(); i < count; i++){ \
- if (pInfo.entry[i].GAS > ret) \
- ret = pInfo.entry[i].GAS; \
- } \
- return ret; \
-}
+#define MAX_PPGAS_FUNC(GAS, GASFUNC) \
+ double DivePlotDataModel::GASFUNC() \
+ { \
+ double ret = -1; \
+ for (int i = 0, count = rowCount(); i < count; i++) { \
+ if (pInfo.entry[i].GAS > ret) \
+ ret = pInfo.entry[i].GAS; \
+ } \
+ return ret; \
+ }
MAX_PPGAS_FUNC(phe, pheMax);
MAX_PPGAS_FUNC(pn2, pn2Max);
@@ -156,5 +186,5 @@ void DivePlotDataModel::calculateDecompression()
struct divecomputer *dc = select_dc(&d->dc);
init_decompression(d);
calculate_deco_information(d, dc, &pInfo, false);
- dataChanged(index(0, CEILING), index(pInfo.nr-1, TISSUE_16));
+ dataChanged(index(0, CEILING), index(pInfo.nr - 1, TISSUE_16));
}
diff --git a/qt-ui/profile/diveplotdatamodel.h b/qt-ui/profile/diveplotdatamodel.h
index 0a64a6a89..272c0d1c3 100644
--- a/qt-ui/profile/diveplotdatamodel.h
+++ b/qt-ui/profile/diveplotdatamodel.h
@@ -9,20 +9,51 @@ struct dive;
struct plot_data;
struct plot_info;
-class DivePlotDataModel : public QAbstractTableModel{
-Q_OBJECT
+class DivePlotDataModel : public QAbstractTableModel {
+ Q_OBJECT
public:
- enum {DEPTH, TIME, PRESSURE, TEMPERATURE, USERENTERED, COLOR, CYLINDERINDEX, SENSOR_PRESSURE, INTERPOLATED_PRESSURE,
- SAC, CEILING, TISSUE_1,TISSUE_2,TISSUE_3,TISSUE_4,TISSUE_5,TISSUE_6,TISSUE_7,TISSUE_8,TISSUE_9,TISSUE_10,
- TISSUE_11,TISSUE_12,TISSUE_13,TISSUE_14,TISSUE_15,TISSUE_16, PN2,PHE,PO2, HEARTBEAT, COLUMNS};
- explicit DivePlotDataModel(QObject* parent = 0);
- virtual int columnCount(const QModelIndex& parent = QModelIndex()) const;
+ enum {
+ DEPTH,
+ TIME,
+ PRESSURE,
+ TEMPERATURE,
+ USERENTERED,
+ COLOR,
+ CYLINDERINDEX,
+ SENSOR_PRESSURE,
+ INTERPOLATED_PRESSURE,
+ SAC,
+ CEILING,
+ TISSUE_1,
+ TISSUE_2,
+ TISSUE_3,
+ TISSUE_4,
+ TISSUE_5,
+ TISSUE_6,
+ TISSUE_7,
+ TISSUE_8,
+ TISSUE_9,
+ TISSUE_10,
+ TISSUE_11,
+ TISSUE_12,
+ TISSUE_13,
+ TISSUE_14,
+ TISSUE_15,
+ TISSUE_16,
+ PN2,
+ PHE,
+ PO2,
+ HEARTBEAT,
+ COLUMNS
+ };
+ explicit DivePlotDataModel(QObject *parent = 0);
+ virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
- virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
- virtual int rowCount(const QModelIndex& parent = QModelIndex()) const;
+ virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+ virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
void clear();
- void setDive(struct dive *d, const plot_info& pInfo);
- const plot_info& data() const;
+ void setDive(struct dive *d, const plot_info &pInfo);
+ const plot_info &data() const;
int id() const;
int dcShown() const;
double pheMax();
@@ -30,6 +61,7 @@ public:
double po2Max();
void emitDataChanged();
void calculateDecompression();
+
private:
plot_info pInfo;
int diveId;
diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp
index fe47e7b5f..8bfad9b40 100644
--- a/qt-ui/profile/diveprofileitem.cpp
+++ b/qt-ui/profile/diveprofileitem.cpp
@@ -17,8 +17,7 @@
#include <QGraphicsItem>
#include <QSettings>
-AbstractProfilePolygonItem::AbstractProfilePolygonItem(): QObject(), QGraphicsPolygonItem(),
- hAxis(NULL), vAxis(NULL), dataModel(NULL), hDataColumn(-1), vDataColumn(-1)
+AbstractProfilePolygonItem::AbstractProfilePolygonItem() : QObject(), QGraphicsPolygonItem(), hAxis(NULL), vAxis(NULL), dataModel(NULL), hDataColumn(-1), vDataColumn(-1)
{
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), this, SLOT(preferencesChanged()));
}
@@ -27,7 +26,7 @@ void AbstractProfilePolygonItem::preferencesChanged()
{
}
-void AbstractProfilePolygonItem::setHorizontalAxis(DiveCartesianAxis* horizontal)
+void AbstractProfilePolygonItem::setHorizontalAxis(DiveCartesianAxis *horizontal)
{
hAxis = horizontal;
connect(hAxis, SIGNAL(sizeChanged()), this, SLOT(modelDataChanged()));
@@ -40,22 +39,22 @@ void AbstractProfilePolygonItem::setHorizontalDataColumn(int column)
modelDataChanged();
}
-void AbstractProfilePolygonItem::setModel(DivePlotDataModel* model)
+void AbstractProfilePolygonItem::setModel(DivePlotDataModel *model)
{
dataModel = model;
- connect(dataModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(modelDataChanged(QModelIndex, QModelIndex)));
- connect(dataModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), this, SLOT(modelDataRemoved(QModelIndex, int, int)));
+ connect(dataModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(modelDataChanged(QModelIndex, QModelIndex)));
+ connect(dataModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex, int, int)), this, SLOT(modelDataRemoved(QModelIndex, int, int)));
modelDataChanged();
}
-void AbstractProfilePolygonItem::modelDataRemoved(const QModelIndex& parent, int from, int to)
+void AbstractProfilePolygonItem::modelDataRemoved(const QModelIndex &parent, int from, int to)
{
setPolygon(QPolygonF());
qDeleteAll(texts);
texts.clear();
}
-void AbstractProfilePolygonItem::setVerticalAxis(DiveCartesianAxis* vertical)
+void AbstractProfilePolygonItem::setVerticalAxis(DiveCartesianAxis *vertical)
{
vAxis = vertical;
connect(vAxis, SIGNAL(sizeChanged()), this, SLOT(modelDataChanged()));
@@ -69,7 +68,7 @@ void AbstractProfilePolygonItem::setVerticalDataColumn(int column)
modelDataChanged();
}
-bool AbstractProfilePolygonItem::shouldCalculateStuff(const QModelIndex& topLeft, const QModelIndex& bottomRight)
+bool AbstractProfilePolygonItem::shouldCalculateStuff(const QModelIndex &topLeft, const QModelIndex &bottomRight)
{
if (!hAxis || !vAxis)
return false;
@@ -77,16 +76,16 @@ bool AbstractProfilePolygonItem::shouldCalculateStuff(const QModelIndex& topLeft
return false;
if (hDataColumn == -1 || vDataColumn == -1)
return false;
- if ( topLeft.isValid() && bottomRight.isValid()){
- if ((topLeft.column() >= vDataColumn || topLeft.column() >= hDataColumn ) &&
- (bottomRight.column() <= vDataColumn || topLeft.column() <= hDataColumn )){
+ if (topLeft.isValid() && bottomRight.isValid()) {
+ if ((topLeft.column() >= vDataColumn || topLeft.column() >= hDataColumn) &&
+ (bottomRight.column() <= vDataColumn || topLeft.column() <= hDataColumn)) {
return true;
}
}
return true;
}
-void AbstractProfilePolygonItem::modelDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight)
+void AbstractProfilePolygonItem::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
{
// We don't have enougth data to calculate things, quit.
@@ -99,7 +98,7 @@ void AbstractProfilePolygonItem::modelDataChanged(const QModelIndex& topLeft, co
for (int i = 0, modelDataCount = dataModel->rowCount(); i < modelDataCount; i++) {
qreal horizontalValue = dataModel->index(i, hDataColumn).data().toReal();
qreal verticalValue = dataModel->index(i, vDataColumn).data().toReal();
- QPointF point( hAxis->posAtValue(horizontalValue), vAxis->posAtValue(verticalValue));
+ QPointF point(hAxis->posAtValue(horizontalValue), vAxis->posAtValue(verticalValue));
poly.append(point);
}
setPolygon(poly);
@@ -110,12 +109,12 @@ void AbstractProfilePolygonItem::modelDataChanged(const QModelIndex& topLeft, co
DiveProfileItem::DiveProfileItem() : show_reported_ceiling(0), reported_ceiling_in_red(0)
{
-
}
-void DiveProfileItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) {
+void DiveProfileItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+{
Q_UNUSED(widget);
- if(polygon().isEmpty())
+ if (polygon().isEmpty())
return;
// This paints the Polygon + Background. I'm setting the pen to QPen() so we don't get a black line here,
@@ -134,13 +133,13 @@ void DiveProfileItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* o
QModelIndex colorIndex = dataModel->index(i, DivePlotDataModel::COLOR);
pen.setBrush(QBrush(colorIndex.data(Qt::BackgroundRole).value<QColor>()));
painter->setPen(pen);
- painter->drawLine(poly[i-1],poly[i]);
+ painter->drawLine(poly[i - 1], poly[i]);
}
}
-void DiveProfileItem::modelDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight)
+void DiveProfileItem::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
{
- if(!shouldCalculateStuff(topLeft, bottomRight))
+ if (!shouldCalculateStuff(topLeft, bottomRight))
return;
AbstractProfilePolygonItem::modelDataChanged(topLeft, bottomRight);
@@ -153,7 +152,7 @@ void DiveProfileItem::modelDataChanged(const QModelIndex& topLeft, const QModelI
/* Show any ceiling we may have encountered */
if (prefs.profile_dc_ceiling && !prefs.profile_red_ceiling) {
QPolygonF p = polygon();
- plot_data *entry = dataModel->data().entry + dataModel->rowCount()-1;
+ plot_data *entry = dataModel->data().entry + dataModel->rowCount() - 1;
for (int i = dataModel->rowCount() - 1; i >= 0; i--, entry--) {
if (!entry->in_deco) {
/* not in deco implies this is a safety stop, no ceiling */
@@ -167,7 +166,7 @@ void DiveProfileItem::modelDataChanged(const QModelIndex& topLeft, const QModelI
setPolygon(p);
}
- // This is the blueish gradient that the Depth Profile should have.
+ // This is the blueish gradient that the Depth Profile should have.
// It's a simple QLinearGradient with 2 stops, starting from top to bottom.
QLinearGradient pat(0, polygon().boundingRect().top(), 0, polygon().boundingRect().bottom());
pat.setColorAt(1, getColor(DEPTH_BOTTOM));
@@ -175,9 +174,9 @@ void DiveProfileItem::modelDataChanged(const QModelIndex& topLeft, const QModelI
setBrush(QBrush(pat));
int last = -1;
- for (int i = 0, count = dataModel->rowCount(); i < count; i++) {
+ for (int i = 0, count = dataModel->rowCount(); i < count; i++) {
- struct plot_data *entry = dataModel->data().entry+i;
+ struct plot_data *entry = dataModel->data().entry + i;
if (entry->depth < 2000)
continue;
@@ -201,10 +200,10 @@ void DiveProfileItem::preferencesChanged()
//TODO: Only modelDataChanged() here if we need to rebuild the graph ( for instance,
// if the prefs.profile_dc_ceiling are enabled, but prefs.profile_red_ceiling is disabled
// and only if it changed something. let's not waste cpu cycles repoloting something we don't need to.
- modelDataChanged();
+ modelDataChanged();
}
-void DiveProfileItem::plot_depth_sample(struct plot_data *entry,QFlags<Qt::AlignmentFlag> flags,const QColor& color)
+void DiveProfileItem::plot_depth_sample(struct plot_data *entry, QFlags<Qt::AlignmentFlag> flags, const QColor &color)
{
int decimals;
double d = get_depth_units(entry->depth, &decimals, NULL);
@@ -231,7 +230,7 @@ void DiveHeartrateItem::modelDataChanged(const QModelIndex &topLeft, const QMode
struct {
int sec;
int hr;
- } hist[3] = {0};
+ } hist[3] = { 0 };
// We don't have enougth data to calculate things, quit.
if (!shouldCalculateStuff(topLeft, bottomRight))
@@ -246,7 +245,7 @@ void DiveHeartrateItem::modelDataChanged(const QModelIndex &topLeft, const QMode
if (!hr)
continue;
sec = dataModel->index(i, hDataColumn).data().toInt();
- QPointF point( hAxis->posAtValue(sec), vAxis->posAtValue(hr));
+ QPointF point(hAxis->posAtValue(sec), vAxis->posAtValue(hr));
poly.append(point);
if (hr == hist[2].hr)
// same as last one, no point in looking at printing
@@ -276,7 +275,7 @@ void DiveHeartrateItem::modelDataChanged(const QModelIndex &topLeft, const QMode
}
setPolygon(poly);
- if( texts.count())
+ if (texts.count())
texts.last()->setAlignment(Qt::AlignLeft | Qt::AlignBottom);
}
@@ -291,9 +290,9 @@ void DiveHeartrateItem::createTextItem(int sec, int hr)
texts.append(text);
}
-void DiveHeartrateItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
+void DiveHeartrateItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
- if(polygon().isEmpty())
+ if (polygon().isEmpty())
return;
painter->setPen(pen());
painter->drawPolyline(polygon());
@@ -308,7 +307,7 @@ DiveTemperatureItem::DiveTemperatureItem()
setPen(pen);
}
-void DiveTemperatureItem::modelDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight)
+void DiveTemperatureItem::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
{
int last = -300, last_printed_temp = 0, sec = 0, last_valid_temp = 0;
// We don't have enougth data to calculate things, quit.
@@ -325,7 +324,7 @@ void DiveTemperatureItem::modelDataChanged(const QModelIndex& topLeft, const QMo
continue;
last_valid_temp = mkelvin;
sec = dataModel->index(i, hDataColumn).data().toInt();
- QPointF point( hAxis->posAtValue(sec), vAxis->posAtValue(mkelvin));
+ QPointF point(hAxis->posAtValue(sec), vAxis->posAtValue(mkelvin));
poly.append(point);
/* don't print a temperature
@@ -338,7 +337,7 @@ void DiveTemperatureItem::modelDataChanged(const QModelIndex& topLeft, const QMo
continue;
last = sec;
if (mkelvin > 200000)
- createTextItem(sec,mkelvin);
+ createTextItem(sec, mkelvin);
last_printed_temp = mkelvin;
}
setPolygon(poly);
@@ -350,7 +349,7 @@ void DiveTemperatureItem::modelDataChanged(const QModelIndex& topLeft, const QMo
((abs(last_valid_temp - last_printed_temp) > 500) || ((double)last / (double)sec < 0.75))) {
createTextItem(sec, last_valid_temp);
}
- if( texts.count())
+ if (texts.count())
texts.last()->setAlignment(Qt::AlignLeft | Qt::AlignBottom);
}
@@ -369,15 +368,15 @@ void DiveTemperatureItem::createTextItem(int sec, int mkelvin)
texts.append(text);
}
-void DiveTemperatureItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
+void DiveTemperatureItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
- if(polygon().isEmpty())
+ if (polygon().isEmpty())
return;
painter->setPen(pen());
painter->drawPolyline(polygon());
}
-void DiveGasPressureItem::modelDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight)
+void DiveGasPressureItem::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
{
// We don't have enougth data to calculate things, quit.
if (!shouldCalculateStuff(topLeft, bottomRight))
@@ -387,7 +386,7 @@ void DiveGasPressureItem::modelDataChanged(const QModelIndex& topLeft, const QMo
polygons.clear();
for (int i = 0, count = dataModel->rowCount(); i < count; i++) {
- plot_data* entry = dataModel->data().entry + i;
+ plot_data *entry = dataModel->data().entry + i;
int mbar = GET_PRESSURE(entry);
if (entry->cylinderindex != last_index) {
@@ -399,7 +398,7 @@ void DiveGasPressureItem::modelDataChanged(const QModelIndex& topLeft, const QMo
}
QPointF point(hAxis->posAtValue(entry->sec), vAxis->posAtValue(mbar));
- boundingPoly.push_back(point); // The BoundingRect
+ boundingPoly.push_back(point); // The BoundingRect
polygons.last().push_back(point); // The polygon thta will be plotted.
}
setPolygon(boundingPoly);
@@ -425,8 +424,8 @@ void DiveGasPressureItem::modelDataChanged(const QModelIndex& topLeft, const QMo
if (!seen_cyl[cyl]) {
plot_pressure_value(mbar, entry->sec, Qt::AlignRight | Qt::AlignTop);
plot_gas_value(mbar, entry->sec, Qt::AlignRight | Qt::AlignBottom,
- get_o2(&dive->cylinder[cyl].gasmix),
- get_he(&dive->cylinder[cyl].gasmix));
+ get_o2(&dive->cylinder[cyl].gasmix),
+ get_he(&dive->cylinder[cyl].gasmix));
seen_cyl[cyl] = true;
}
}
@@ -446,7 +445,7 @@ void DiveGasPressureItem::plot_pressure_value(int mbar, int sec, QFlags<Qt::Alig
const char *unit;
int pressure = get_pressure_units(mbar, &unit);
DiveTextItem *text = new DiveTextItem(this);
- text->setPos(hAxis->posAtValue(sec), vAxis->posAtValue(mbar)-0.5);
+ text->setPos(hAxis->posAtValue(sec), vAxis->posAtValue(mbar) - 0.5);
text->setText(QString("%1 %2").arg(pressure).arg(unit));
text->setAlignment(flags);
text->setBrush(getColor(PRESSURE_TEXT));
@@ -455,9 +454,9 @@ void DiveGasPressureItem::plot_pressure_value(int mbar, int sec, QFlags<Qt::Alig
void DiveGasPressureItem::plot_gas_value(int mbar, int sec, QFlags<Qt::AlignmentFlag> flags, int o2, int he)
{
- QString gas = (is_air(o2, he)) ? tr("air") :
- (he == 0) ? QString(tr("EAN%1")).arg((o2 + 5) / 10) :
- QString("%1/%2").arg((o2 + 5) / 10).arg((he + 5) / 10);
+ QString gas = (is_air(o2, he)) ? tr("air") :
+ (he == 0) ? QString(tr("EAN%1")).arg((o2 + 5) / 10) :
+ QString("%1/%2").arg((o2 + 5) / 10).arg((he + 5) / 10);
DiveTextItem *text = new DiveTextItem(this);
text->setPos(hAxis->posAtValue(sec), vAxis->posAtValue(mbar));
text->setText(gas);
@@ -466,9 +465,9 @@ void DiveGasPressureItem::plot_gas_value(int mbar, int sec, QFlags<Qt::Alignment
texts.push_back(text);
}
-void DiveGasPressureItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
+void DiveGasPressureItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
- if(polygon().isEmpty())
+ if (polygon().isEmpty())
return;
QPen pen;
pen.setCosmetic(true);
@@ -477,11 +476,11 @@ void DiveGasPressureItem::paint(QPainter* painter, const QStyleOptionGraphicsIte
if (!d)
return;
struct plot_data *entry = dataModel->data().entry;
- Q_FOREACH(const QPolygonF& poly, polygons) {
+ Q_FOREACH(const QPolygonF & poly, polygons) {
for (int i = 1, count = poly.count(); i < count; i++, entry++) {
pen.setBrush(getSacColor(entry->sac, d->sac));
painter->setPen(pen);
- painter->drawLine(poly[i-1],poly[i]);
+ painter->drawLine(poly[i - 1], poly[i]);
}
}
}
@@ -494,7 +493,7 @@ DiveCalculatedCeiling::DiveCalculatedCeiling() : is3mIncrement(false), gradientF
preferencesChanged();
}
-void DiveCalculatedCeiling::modelDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight)
+void DiveCalculatedCeiling::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
{
// We don't have enougth data to calculate things, quit.
if (!shouldCalculateStuff(topLeft, bottomRight))
@@ -514,16 +513,16 @@ void DiveCalculatedCeiling::modelDataChanged(const QModelIndex& topLeft, const Q
QLinearGradient pat(0, polygon().boundingRect().top(), 0, polygon().boundingRect().bottom());
pat.setColorAt(0, getColor(CALC_CEILING_SHALLOW));
pat.setColorAt(1, getColor(CALC_CEILING_DEEP));
- setPen(QPen(QBrush(Qt::NoBrush),0));
+ setPen(QPen(QBrush(Qt::NoBrush), 0));
setBrush(pat);
- gradientFactor->setX(poly.boundingRect().width()/2 + poly.boundingRect().x());
+ gradientFactor->setX(poly.boundingRect().width() / 2 + poly.boundingRect().x());
gradientFactor->setText(QString("GF %1/%2").arg(prefs.gflow).arg(prefs.gfhigh));
}
-void DiveCalculatedCeiling::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
+void DiveCalculatedCeiling::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
- if(polygon().isEmpty())
+ if (polygon().isEmpty())
return;
QGraphicsPolygonItem::paint(painter, option, widget);
}
@@ -540,9 +539,9 @@ void DiveCalculatedTissue::preferencesChanged()
setVisible(s.value("calcalltissues").toBool() && s.value("calcceiling").toBool());
}
-void DiveReportedCeiling::modelDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight)
+void DiveReportedCeiling::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
{
- if(!shouldCalculateStuff(topLeft, bottomRight))
+ if (!shouldCalculateStuff(topLeft, bottomRight))
return;
QPolygonF p;
@@ -563,7 +562,7 @@ void DiveReportedCeiling::modelDataChanged(const QModelIndex& topLeft, const QMo
QLinearGradient pat(0, p.boundingRect().top(), 0, p.boundingRect().bottom());
pat.setColorAt(0, getColor(CEILING_SHALLOW));
pat.setColorAt(1, getColor(CEILING_DEEP));
- setPen(QPen(QBrush(Qt::NoBrush),0));
+ setPen(QPen(QBrush(Qt::NoBrush), 0));
setBrush(pat);
}
@@ -573,7 +572,7 @@ void DiveCalculatedCeiling::preferencesChanged()
s.beginGroup("TecDetails");
bool shouldShow3mIncrement = s.value("calcceiling3m").toBool();
- if ( dataModel && is3mIncrement != shouldShow3mIncrement){
+ if (dataModel && is3mIncrement != shouldShow3mIncrement) {
// recalculate that part.
dataModel->calculateDecompression();
}
@@ -588,9 +587,9 @@ void DiveReportedCeiling::preferencesChanged()
setVisible(s.value("redceiling").toBool());
}
-void DiveReportedCeiling::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
+void DiveReportedCeiling::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
- if(polygon().isEmpty())
+ if (polygon().isEmpty())
return;
QGraphicsPolygonItem::paint(painter, option, widget);
}
@@ -619,18 +618,18 @@ void MeanDepthLine::setMeanDepth(int value)
meanDepth = value;
}
-void MeanDepthLine::setAxis(DiveCartesianAxis* a)
+void MeanDepthLine::setAxis(DiveCartesianAxis *a)
{
connect(a, SIGNAL(sizeChanged()), this, SLOT(axisLineChanged()));
}
void MeanDepthLine::axisLineChanged()
{
- DiveCartesianAxis *axis = qobject_cast<DiveCartesianAxis*>(sender());
- animateMoveTo(x(),axis->posAtValue(meanDepth));
+ DiveCartesianAxis *axis = qobject_cast<DiveCartesianAxis *>(sender());
+ animateMoveTo(x(), axis->posAtValue(meanDepth));
}
-void PartialPressureGasItem::modelDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight)
+void PartialPressureGasItem::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
{
//AbstractProfilePolygonItem::modelDataChanged();
if (!shouldCalculateStuff(topLeft, bottomRight))
@@ -642,11 +641,11 @@ void PartialPressureGasItem::modelDataChanged(const QModelIndex& topLeft, const
QSettings s;
s.beginGroup("TecDetails");
double threshould = s.value(threshouldKey).toDouble();
- for(int i = 0; i < dataModel->rowCount(); i++, entry++){
+ for (int i = 0; i < dataModel->rowCount(); i++, entry++) {
double value = dataModel->index(i, vDataColumn).data().toDouble();
int time = dataModel->index(i, hDataColumn).data().toInt();
QPointF point(hAxis->posAtValue(time), vAxis->posAtValue(value));
- poly.push_back( point );
+ poly.push_back(point);
if (value >= threshould)
alertPoly.push_back(point);
}
@@ -656,7 +655,7 @@ void PartialPressureGasItem::modelDataChanged(const QModelIndex& topLeft, const
*/
}
-void PartialPressureGasItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
+void PartialPressureGasItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
painter->setPen(normalColor);
painter->drawPolyline(polygon());
@@ -664,7 +663,7 @@ void PartialPressureGasItem::paint(QPainter* painter, const QStyleOptionGraphics
painter->drawPolyline(alertPoly);
}
-void PartialPressureGasItem::setThreshouldSettingsKey(const QString& threshouldSettingsKey)
+void PartialPressureGasItem::setThreshouldSettingsKey(const QString &threshouldSettingsKey)
{
threshouldKey = threshouldSettingsKey;
}
@@ -677,15 +676,15 @@ void PartialPressureGasItem::preferencesChanged()
{
QSettings s;
s.beginGroup("TecDetails");
- setVisible( s.value(visibilityKey).toBool() );
+ setVisible(s.value(visibilityKey).toBool());
}
-void PartialPressureGasItem::setVisibilitySettingsKey(const QString& key)
+void PartialPressureGasItem::setVisibilitySettingsKey(const QString &key)
{
visibilityKey = key;
}
-void PartialPressureGasItem::setColors(const QColor& normal, const QColor& alert)
+void PartialPressureGasItem::setColors(const QColor &normal, const QColor &alert)
{
normalColor = normal;
alertColor = alert;
diff --git a/qt-ui/profile/diveprofileitem.h b/qt-ui/profile/diveprofileitem.h
index 86ea01c64..ee7132c40 100644
--- a/qt-ui/profile/diveprofileitem.h
+++ b/qt-ui/profile/diveprofileitem.h
@@ -28,7 +28,7 @@ class DiveCartesianAxis;
class QAbstractTableModel;
struct plot_data;
-class AbstractProfilePolygonItem : public QObject, public QGraphicsPolygonItem{
+class AbstractProfilePolygonItem : public QObject, public QGraphicsPolygonItem {
Q_OBJECT
Q_PROPERTY(QPointF pos WRITE setPos READ pos)
Q_PROPERTY(qreal x WRITE setX READ x)
@@ -40,12 +40,16 @@ public:
void setModel(DivePlotDataModel *model);
void setHorizontalDataColumn(int column);
void setVerticalDataColumn(int column);
- virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0) = 0;
- virtual void clear(){}
-public slots:
+ virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) = 0;
+ virtual void clear()
+ {
+ }
+public
+slots:
virtual void preferencesChanged();
- virtual void modelDataChanged(const QModelIndex& topLeft = QModelIndex(), const QModelIndex& bottomRight = QModelIndex());
- virtual void modelDataRemoved(const QModelIndex& parent, int from, int to);
+ virtual void modelDataChanged(const QModelIndex &topLeft = QModelIndex(), const QModelIndex &bottomRight = QModelIndex());
+ virtual void modelDataRemoved(const QModelIndex &parent, int from, int to);
+
protected:
/* when the model emits a 'datachanged' signal, this method below should be used to check if the
* modified data affects this particular item ( for example, when setting the '3m increment'
@@ -54,36 +58,38 @@ protected:
* into consideration when returning 'true' for "yes, continue the calculation', and 'false' for
* 'do not recalculate, we already have the right data.
*/
- bool shouldCalculateStuff(const QModelIndex& topLeft, const QModelIndex& bottomRight);
+ bool shouldCalculateStuff(const QModelIndex &topLeft, const QModelIndex &bottomRight);
DiveCartesianAxis *hAxis;
DiveCartesianAxis *vAxis;
DivePlotDataModel *dataModel;
int hDataColumn;
int vDataColumn;
- QList<DiveTextItem*> texts;
+ QList<DiveTextItem *> texts;
};
-class DiveProfileItem : public AbstractProfilePolygonItem{
+class DiveProfileItem : public AbstractProfilePolygonItem {
Q_OBJECT
public:
DiveProfileItem();
- virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
- virtual void modelDataChanged(const QModelIndex& topLeft = QModelIndex(), const QModelIndex& bottomRight = QModelIndex());
+ virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
+ virtual void modelDataChanged(const QModelIndex &topLeft = QModelIndex(), const QModelIndex &bottomRight = QModelIndex());
virtual void preferencesChanged();
- void plot_depth_sample(struct plot_data *entry,QFlags<Qt::AlignmentFlag> flags,const QColor& color);
+ void plot_depth_sample(struct plot_data *entry, QFlags<Qt::AlignmentFlag> flags, const QColor &color);
+
private:
unsigned int show_reported_ceiling;
unsigned int reported_ceiling_in_red;
};
-class DiveTemperatureItem : public AbstractProfilePolygonItem{
+class DiveTemperatureItem : public AbstractProfilePolygonItem {
Q_OBJECT
public:
DiveTemperatureItem();
- virtual void modelDataChanged(const QModelIndex& topLeft = QModelIndex(), const QModelIndex& bottomRight = QModelIndex());
- virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
+ virtual void modelDataChanged(const QModelIndex &topLeft = QModelIndex(), const QModelIndex &bottomRight = QModelIndex());
+ virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
+
private:
void createTextItem(int seconds, int mkelvin);
};
@@ -94,41 +100,44 @@ public:
DiveHeartrateItem();
virtual void modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
+
private:
void createTextItem(int seconds, int hr);
};
-class DiveGasPressureItem : public AbstractProfilePolygonItem{
+class DiveGasPressureItem : public AbstractProfilePolygonItem {
Q_OBJECT
public:
- virtual void modelDataChanged(const QModelIndex& topLeft = QModelIndex(), const QModelIndex& bottomRight = QModelIndex());
- virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
+ virtual void modelDataChanged(const QModelIndex &topLeft = QModelIndex(), const QModelIndex &bottomRight = QModelIndex());
+ virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
+
private:
void plot_pressure_value(int mbar, int sec, QFlags<Qt::AlignmentFlag> align);
void plot_gas_value(int mbar, int sec, QFlags<Qt::AlignmentFlag> align, int o2, int he);
QVector<QPolygonF> polygons;
};
-class DiveCalculatedCeiling : public AbstractProfilePolygonItem{
+class DiveCalculatedCeiling : public AbstractProfilePolygonItem {
Q_OBJECT
public:
DiveCalculatedCeiling();
- virtual void modelDataChanged(const QModelIndex& topLeft = QModelIndex(), const QModelIndex& bottomRight = QModelIndex());
- virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
+ virtual void modelDataChanged(const QModelIndex &topLeft = QModelIndex(), const QModelIndex &bottomRight = QModelIndex());
+ virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
virtual void preferencesChanged();
+
private:
bool is3mIncrement;
DiveTextItem *gradientFactor;
};
-class DiveReportedCeiling : public AbstractProfilePolygonItem{
+class DiveReportedCeiling : public AbstractProfilePolygonItem {
Q_OBJECT
public:
- virtual void modelDataChanged(const QModelIndex& topLeft = QModelIndex(), const QModelIndex& bottomRight = QModelIndex());
- virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
+ virtual void modelDataChanged(const QModelIndex &topLeft = QModelIndex(), const QModelIndex &bottomRight = QModelIndex());
+ virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
virtual void preferencesChanged();
};
@@ -146,24 +155,27 @@ public:
void setMeanDepth(int value);
void setLine(qreal x1, qreal y1, qreal x2, qreal y2);
void setAxis(DiveCartesianAxis *a);
-public slots:
+public
+slots:
void axisLineChanged();
+
private:
int meanDepth;
DiveTextItem *leftText;
DiveTextItem *rightText;
};
-class PartialPressureGasItem : public AbstractProfilePolygonItem{
+class PartialPressureGasItem : public AbstractProfilePolygonItem {
Q_OBJECT
public:
PartialPressureGasItem();
- virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
- virtual void modelDataChanged(const QModelIndex& topLeft = QModelIndex(), const QModelIndex& bottomRight = QModelIndex());
+ virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
+ virtual void modelDataChanged(const QModelIndex &topLeft = QModelIndex(), const QModelIndex &bottomRight = QModelIndex());
virtual void preferencesChanged();
- void setThreshouldSettingsKey(const QString& threshouldSettingsKey);
- void setVisibilitySettingsKey(const QString& setVisibilitySettingsKey);
- void setColors(const QColor& normalColor, const QColor& alertColor);
+ void setThreshouldSettingsKey(const QString &threshouldSettingsKey);
+ void setVisibilitySettingsKey(const QString &setVisibilitySettingsKey);
+ void setColors(const QColor &normalColor, const QColor &alertColor);
+
private:
QPolygonF alertPoly;
QString threshouldKey;
diff --git a/qt-ui/profile/diverectitem.cpp b/qt-ui/profile/diverectitem.cpp
index 6bdad1142..8cb60c3f5 100644
--- a/qt-ui/profile/diverectitem.cpp
+++ b/qt-ui/profile/diverectitem.cpp
@@ -1,6 +1,5 @@
#include "diverectitem.h"
-DiveRectItem::DiveRectItem(QObject* parent, QGraphicsItem* parentItem): QObject(parent), QGraphicsRectItem(parentItem )
+DiveRectItem::DiveRectItem(QObject *parent, QGraphicsItem *parentItem) : QObject(parent), QGraphicsRectItem(parentItem)
{
-
}
diff --git a/qt-ui/profile/diverectitem.h b/qt-ui/profile/diverectitem.h
index 9216fe9a1..e616cf591 100644
--- a/qt-ui/profile/diverectitem.h
+++ b/qt-ui/profile/diverectitem.h
@@ -4,7 +4,7 @@
#include <QObject>
#include <QGraphicsRectItem>
-class DiveRectItem : public QObject, public QGraphicsRectItem{
+class DiveRectItem : public QObject, public QGraphicsRectItem {
Q_OBJECT
Q_PROPERTY(QRectF rect WRITE setRect READ rect)
Q_PROPERTY(QPointF pos WRITE setPos READ pos)
diff --git a/qt-ui/profile/divetextitem.cpp b/qt-ui/profile/divetextitem.cpp
index 10116e19f..582cc4070 100644
--- a/qt-ui/profile/divetextitem.cpp
+++ b/qt-ui/profile/divetextitem.cpp
@@ -9,7 +9,7 @@
#include <QPen>
#include <QDebug>
-DiveTextItem::DiveTextItem(QGraphicsItem* parent): QGraphicsItemGroup(parent),
+DiveTextItem::DiveTextItem(QGraphicsItem *parent) : QGraphicsItemGroup(parent),
internalAlignFlags(Qt::AlignHCenter | Qt::AlignVCenter),
textBackgroundItem(NULL),
textItem(NULL),
@@ -25,7 +25,7 @@ void DiveTextItem::setAlignment(int alignFlags)
updateText();
}
-void DiveTextItem::setBrush(const QBrush& b)
+void DiveTextItem::setBrush(const QBrush &b)
{
brush = b;
updateText();
@@ -36,13 +36,13 @@ void DiveTextItem::setScale(double newscale)
scale = newscale;
}
-void DiveTextItem::setText(const QString& t)
+void DiveTextItem::setText(const QString &t)
{
internalText = t;
updateText();
}
-const QString& DiveTextItem::text()
+const QString &DiveTextItem::text()
{
return internalText;
}
@@ -54,7 +54,7 @@ void DiveTextItem::updateText()
textItem = NULL;
delete textBackgroundItem;
textBackgroundItem = NULL;
- if(internalText.isEmpty()){
+ if (internalText.isEmpty()) {
return;
}
@@ -75,14 +75,14 @@ void DiveTextItem::updateText()
QRectF rect = fm.boundingRect(internalText);
yPos = (internalAlignFlags & Qt::AlignTop) ? 0 :
- (internalAlignFlags & Qt::AlignBottom) ? +rect.height() :
- /*(internalAlignFlags & Qt::AlignVCenter ? */ +rect.height() / 4;
+ (internalAlignFlags & Qt::AlignBottom) ? +rect.height() :
+ /*(internalAlignFlags & Qt::AlignVCenter ? */ +rect.height() / 4;
- xPos = (internalAlignFlags & Qt::AlignLeft ) ? -rect.width() :
- (internalAlignFlags & Qt::AlignHCenter) ? -rect.width()/2 :
- /* (internalAlignFlags & Qt::AlignRight) */ 0;
+ xPos = (internalAlignFlags & Qt::AlignLeft) ? -rect.width() :
+ (internalAlignFlags & Qt::AlignHCenter) ? -rect.width() / 2 :
+ /* (internalAlignFlags & Qt::AlignRight) */ 0;
- textPath.addText( xPos, yPos, fnt, internalText);
+ textPath.addText(xPos, yPos, fnt, internalText);
QPainterPathStroker stroker;
stroker.setWidth(3);
textBackgroundItem = new QGraphicsPathItem(stroker.createStroke(textPath), this);
diff --git a/qt-ui/profile/divetextitem.h b/qt-ui/profile/divetextitem.h
index e0aa3e9b1..19bf00a73 100644
--- a/qt-ui/profile/divetextitem.h
+++ b/qt-ui/profile/divetextitem.h
@@ -7,19 +7,20 @@
#include <QBrush>
/* A Line Item that has animated-properties. */
-class DiveTextItem :public QObject, public QGraphicsItemGroup{
+class DiveTextItem : public QObject, public QGraphicsItemGroup {
Q_OBJECT
Q_PROPERTY(QPointF pos READ pos WRITE setPos)
Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity)
public:
- DiveTextItem(QGraphicsItem* parent = 0);
- void setText(const QString& text);
+ DiveTextItem(QGraphicsItem *parent = 0);
+ void setText(const QString &text);
void setAlignment(int alignFlags);
void setScale(double newscale);
- void setBrush(const QBrush& brush);
+ void setBrush(const QBrush &brush);
void animatedHide();
void animateMoveTo(qreal x, qreal y);
- const QString& text();
+ const QString &text();
+
private:
void updateText();
int internalAlignFlags;
diff --git a/qt-ui/profile/divetooltipitem.cpp b/qt-ui/profile/divetooltipitem.cpp
index 7171a8a2c..0442f0793 100644
--- a/qt-ui/profile/divetooltipitem.cpp
+++ b/qt-ui/profile/divetooltipitem.cpp
@@ -17,7 +17,7 @@
#include "display.h"
#endif
-void ToolTipItem::addToolTip(const QString& toolTip, const QIcon& icon)
+void ToolTipItem::addToolTip(const QString &toolTip, const QIcon &icon)
{
QGraphicsPixmapItem *iconItem = 0;
double yValue = title->boundingRect().height() + SPACING;
@@ -25,7 +25,7 @@ void ToolTipItem::addToolTip(const QString& toolTip, const QIcon& icon)
yValue += t.second->boundingRect().height();
}
if (!icon.isNull()) {
- iconItem = new QGraphicsPixmapItem(icon.pixmap(ICON_SMALL,ICON_SMALL), this);
+ iconItem = new QGraphicsPixmapItem(icon.pixmap(ICON_SMALL, ICON_SMALL), this);
iconItem->setPos(SPACING, yValue);
}
@@ -47,8 +47,8 @@ void ToolTipItem::refresh(struct graphics_context *gc, QPointF pos)
addToolTip(QString::fromUtf8(mb.buffer, mb.len));
free_buffer(&mb);
- QList<QGraphicsItem*> items = scene()->items(pos, Qt::IntersectsItemShape, Qt::DescendingOrder, transform());
- Q_FOREACH(QGraphicsItem *item, items) {
+ QList<QGraphicsItem *> items = scene()->items(pos, Qt::IntersectsItemShape, Qt::DescendingOrder, transform());
+ Q_FOREACH(QGraphicsItem * item, items) {
if (!item->toolTip().isEmpty())
addToolTip(item->toolTip());
}
@@ -63,7 +63,7 @@ void ToolTipItem::clear()
toolTips.clear();
}
-void ToolTipItem::setRect(const QRectF& r)
+void ToolTipItem::setRect(const QRectF &r)
{
// qDeleteAll(childItems());
delete background;
@@ -74,8 +74,8 @@ void ToolTipItem::setRect(const QRectF& r)
// Creates a 2pixels border
QPainterPath border;
- border.addRoundedRect(-4, -4, rectangle.width() + 8, rectangle.height() + 10, 3, 3);
- border.addRoundedRect(-1, -1, rectangle.width() + 3, rectangle.height() + 4, 3, 3);
+ border.addRoundedRect(-4, -4, rectangle.width() + 8, rectangle.height() + 10, 3, 3);
+ border.addRoundedRect(-1, -1, rectangle.width() + 3, rectangle.height() + 4, 3, 3);
setPath(border);
QPainterPath bg;
@@ -119,10 +119,10 @@ void ToolTipItem::expand()
height += t.second->boundingRect().height();
}
/* Left padding, Icon Size, space, right padding */
- width += SPACING + ICON_SMALL + SPACING + SPACING;
+ width += SPACING + ICON_SMALL + SPACING + SPACING;
- if (width < title->boundingRect().width() + SPACING*2)
- width = title->boundingRect().width() + SPACING*2;
+ if (width < title->boundingRect().width() + SPACING * 2)
+ width = title->boundingRect().width() + SPACING * 2;
if (height < ICON_SMALL)
height = ICON_SMALL;
@@ -139,7 +139,7 @@ void ToolTipItem::expand()
status = EXPANDED;
}
-ToolTipItem::ToolTipItem(QGraphicsItem* parent) : QGraphicsPathItem(parent),
+ToolTipItem::ToolTipItem(QGraphicsItem *parent) : QGraphicsPathItem(parent),
background(0),
separator(new QGraphicsLineItem(this)),
title(new QGraphicsSimpleTextItem(tr("Information"), this)),
@@ -161,21 +161,21 @@ ToolTipItem::~ToolTipItem()
void ToolTipItem::updateTitlePosition()
{
- if (rectangle.width() < title->boundingRect().width() + SPACING*4) {
+ if (rectangle.width() < title->boundingRect().width() + SPACING * 4) {
QRectF newRect = rectangle;
- newRect.setWidth(title->boundingRect().width() + SPACING*4);
+ newRect.setWidth(title->boundingRect().width() + SPACING * 4);
newRect.setHeight((newRect.height() && isExpanded()) ? newRect.height() : ICON_SMALL);
setRect(newRect);
}
- title->setPos(boundingRect().width()/2 - title->boundingRect().width()/2 -1, 0);
+ title->setPos(boundingRect().width() / 2 - title->boundingRect().width() / 2 - 1, 0);
title->setFlag(ItemIgnoresTransformations);
title->setPen(QPen(Qt::white, 1));
title->setBrush(Qt::white);
if (toolTips.size() > 0) {
double x1 = 3;
- double y1 = title->pos().y() + SPACING/2 + title->boundingRect().height();
+ double y1 = title->pos().y() + SPACING / 2 + title->boundingRect().height();
double x2 = boundingRect().width() - 10;
double y2 = y1;
@@ -188,11 +188,12 @@ void ToolTipItem::updateTitlePosition()
}
}
-bool ToolTipItem::isExpanded() const {
+bool ToolTipItem::isExpanded() const
+{
return status == EXPANDED;
}
-void ToolTipItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
+void ToolTipItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
persistPos();
QGraphicsPathItem::mouseReleaseEvent(event);
@@ -212,27 +213,26 @@ void ToolTipItem::readPos()
QSettings s;
s.beginGroup("ProfileMap");
QPointF value = scene()->views().at(0)->mapToScene(
- s.value("tooltip_position").toPoint()
- );
+ s.value("tooltip_position").toPoint());
if (!scene()->sceneRect().contains(value)) {
- value = QPointF(0,0);
+ value = QPointF(0, 0);
}
setPos(value);
}
-void ToolTipItem::setPlotInfo(const plot_info& plot)
+void ToolTipItem::setPlotInfo(const plot_info &plot)
{
pInfo = plot;
}
-void ToolTipItem::setTimeAxis(DiveCartesianAxis* axis)
+void ToolTipItem::setTimeAxis(DiveCartesianAxis *axis)
{
timeAxis = axis;
}
-void ToolTipItem::refresh(const QPointF& pos)
+void ToolTipItem::refresh(const QPointF &pos)
{
- int time = timeAxis->valueAt( pos );
+ int time = timeAxis->valueAt(pos);
if (time == lastTime)
return;
@@ -244,8 +244,8 @@ void ToolTipItem::refresh(const QPointF& pos)
addToolTip(QString::fromUtf8(mb.buffer, mb.len));
free_buffer(&mb);
- QList<QGraphicsItem*> items = scene()->items(pos, Qt::IntersectsItemShape, Qt::DescendingOrder, scene()->views().first()->transform());
- Q_FOREACH(QGraphicsItem *item, items) {
+ QList<QGraphicsItem *> items = scene()->items(pos, Qt::IntersectsItemShape, Qt::DescendingOrder, scene()->views().first()->transform());
+ Q_FOREACH(QGraphicsItem * item, items) {
if (!item->toolTip().isEmpty())
addToolTip(item->toolTip());
}
diff --git a/qt-ui/profile/divetooltipitem.h b/qt-ui/profile/divetooltipitem.h
index 5deb0001a..566b21770 100644
--- a/qt-ui/profile/divetooltipitem.h
+++ b/qt-ui/profile/divetooltipitem.h
@@ -17,36 +17,44 @@ struct graphics_context;
/* To use a tooltip, simply ->setToolTip on the QGraphicsItem that you want
* or, if it's a "global" tooltip, set it on the mouseMoveEvent of the ProfileGraphicsView.
*/
-class ToolTipItem :public QObject, public QGraphicsPathItem
-{
+class ToolTipItem : public QObject, public QGraphicsPathItem {
Q_OBJECT
void updateTitlePosition();
Q_PROPERTY(QRectF rect READ boundingRect WRITE setRect)
public:
- enum Status{COLLAPSED, EXPANDED};
- enum {ICON_SMALL = 16, ICON_MEDIUM = 24, ICON_BIG = 32, SPACING=4};
+ enum Status {
+ COLLAPSED,
+ EXPANDED
+ };
+ enum {
+ ICON_SMALL = 16,
+ ICON_MEDIUM = 24,
+ ICON_BIG = 32,
+ SPACING = 4
+ };
- explicit ToolTipItem(QGraphicsItem* parent = 0);
+ explicit ToolTipItem(QGraphicsItem *parent = 0);
virtual ~ToolTipItem();
void collapse();
void expand();
void clear();
- void addToolTip(const QString& toolTip, const QIcon& icon = QIcon());
- void refresh(struct graphics_context* gc, QPointF pos);
- void refresh(const QPointF& pos);
+ void addToolTip(const QString &toolTip, const QIcon &icon = QIcon());
+ void refresh(struct graphics_context *gc, QPointF pos);
+ void refresh(const QPointF &pos);
bool isExpanded() const;
void persistPos();
void readPos();
- void mouseReleaseEvent(QGraphicsSceneMouseEvent* event);
+ void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
void setTimeAxis(DiveCartesianAxis *axis);
- void setPlotInfo(const plot_info& plot);
-public slots:
- void setRect(const QRectF& rect);
+ void setPlotInfo(const plot_info &plot);
+public
+slots:
+ void setRect(const QRectF &rect);
private:
- typedef QPair<QGraphicsPixmapItem*, QGraphicsSimpleTextItem*> ToolTip;
+ typedef QPair<QGraphicsPixmapItem *, QGraphicsSimpleTextItem *> ToolTip;
QVector<ToolTip> toolTips;
QGraphicsPathItem *background;
QGraphicsLineItem *separator;
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index ee9e80be6..1cbc6c1a5 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -35,15 +35,15 @@
* hard coding the item on the scene with a random
* value.
*/
-static struct _ItemPos{
- struct _Pos{
+static struct _ItemPos {
+ struct _Pos {
QPointF on;
QPointF off;
};
- struct _Axis{
- _Pos pos;
- QLineF shrinked;
- QLineF expanded;
+ struct _Axis {
+ _Pos pos;
+ QLineF shrinked;
+ QLineF expanded;
};
_Pos background;
_Pos dcLabel;
@@ -55,12 +55,11 @@ static struct _ItemPos{
_Axis heartBeat;
} itemPos;
-ProfileWidget2::ProfileWidget2(QWidget *parent) :
- QGraphicsView(parent),
+ProfileWidget2::ProfileWidget2(QWidget *parent) : QGraphicsView(parent),
dataModel(new DivePlotDataModel(this)),
currentState(INVALID),
zoomLevel(0),
- background (new DivePixmapItem()),
+ background(new DivePixmapItem()),
toolTipItem(new ToolTipItem()),
profileYAxis(new DepthAxis()),
gasYAxis(new PartialGasPressureAxis()),
@@ -74,9 +73,9 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) :
diveComputerText(new DiveTextItem()),
diveCeiling(new DiveCalculatedCeiling()),
reportedCeiling(new DiveReportedCeiling()),
- pn2GasItem( new PartialPressureGasItem()),
- pheGasItem( new PartialPressureGasItem()),
- po2GasItem( new PartialPressureGasItem()),
+ pn2GasItem(new PartialPressureGasItem()),
+ pheGasItem(new PartialPressureGasItem()),
+ po2GasItem(new PartialPressureGasItem()),
heartBeatAxis(new DiveCartesianAxis()),
heartBeatItem(new DiveHeartrateItem()),
isPlotZoomed(prefs.zoomed_plot),
@@ -123,7 +122,7 @@ void ProfileWidget2::addItemsToScene()
scene()->addItem(rulerItem);
scene()->addItem(rulerItem->sourceNode());
scene()->addItem(rulerItem->destNode());
- Q_FOREACH(DiveCalculatedTissue *tissue, allTissues){
+ Q_FOREACH(DiveCalculatedTissue * tissue, allTissues) {
scene()->addItem(tissue);
}
}
@@ -135,7 +134,7 @@ void ProfileWidget2::setupItemOnScene()
profileYAxis->setOrientation(DiveCartesianAxis::TopToBottom);
profileYAxis->setMinimum(0);
- profileYAxis->setTickInterval(M_OR_FT(10,30));
+ profileYAxis->setTickInterval(M_OR_FT(10, 30));
profileYAxis->setTickSize(1);
profileYAxis->setLineSize(96);
@@ -163,7 +162,7 @@ void ProfileWidget2::setupItemOnScene()
cylinderPressureAxis->setTickSize(2);
cylinderPressureAxis->setTickInterval(30000);
- meanDepth->setLine(0,0,96,0);
+ meanDepth->setLine(0, 0, 96, 0);
meanDepth->setX(3);
meanDepth->setPen(QPen(QBrush(Qt::red), 0, Qt::SolidLine));
meanDepth->setZValue(1);
@@ -176,9 +175,9 @@ void ProfileWidget2::setupItemOnScene()
setupItem(reportedCeiling, timeAxis, profileYAxis, dataModel, DivePlotDataModel::CEILING, DivePlotDataModel::TIME, 1);
setupItem(diveCeiling, timeAxis, profileYAxis, dataModel, DivePlotDataModel::CEILING, DivePlotDataModel::TIME, 1);
- for(int i = 0; i < 16; i++){
+ for (int i = 0; i < 16; i++) {
DiveCalculatedTissue *tissueItem = new DiveCalculatedTissue();
- setupItem(tissueItem, timeAxis, profileYAxis, dataModel, DivePlotDataModel::TISSUE_1 + i, DivePlotDataModel::TIME, 1+i);
+ setupItem(tissueItem, timeAxis, profileYAxis, dataModel, DivePlotDataModel::TISSUE_1 + i, DivePlotDataModel::TIME, 1 + i);
allTissues.append(tissueItem);
}
setupItem(gasPressureItem, timeAxis, cylinderPressureAxis, dataModel, DivePlotDataModel::TEMPERATURE, DivePlotDataModel::TIME, 1);
@@ -186,17 +185,17 @@ void ProfileWidget2::setupItemOnScene()
setupItem(heartBeatItem, timeAxis, heartBeatAxis, dataModel, DivePlotDataModel::HEARTBEAT, DivePlotDataModel::TIME, 1);
setupItem(diveProfileItem, timeAxis, profileYAxis, dataModel, DivePlotDataModel::DEPTH, DivePlotDataModel::TIME, 0);
-#define CREATE_PP_GAS( ITEM, VERTICAL_COLUMN, COLOR, COLOR_ALERT, THRESHOULD_SETTINGS, VISIBILITY_SETTINGS ) \
+#define CREATE_PP_GAS(ITEM, VERTICAL_COLUMN, COLOR, COLOR_ALERT, THRESHOULD_SETTINGS, VISIBILITY_SETTINGS) \
setupItem(ITEM, timeAxis, gasYAxis, dataModel, DivePlotDataModel::VERTICAL_COLUMN, DivePlotDataModel::TIME, 0); \
- ITEM->setThreshouldSettingsKey(THRESHOULD_SETTINGS); \
- ITEM->setVisibilitySettingsKey(VISIBILITY_SETTINGS); \
- ITEM->setColors(getColor(COLOR), getColor(COLOR_ALERT)); \
- ITEM->preferencesChanged(); \
+ ITEM->setThreshouldSettingsKey(THRESHOULD_SETTINGS); \
+ ITEM->setVisibilitySettingsKey(VISIBILITY_SETTINGS); \
+ ITEM->setColors(getColor(COLOR), getColor(COLOR_ALERT)); \
+ ITEM->preferencesChanged(); \
ITEM->setZValue(99);
- CREATE_PP_GAS( pn2GasItem, PN2, PN2, PN2_ALERT, "pn2threshold", "pn2graph");
- CREATE_PP_GAS( pheGasItem, PHE, PHE, PHE_ALERT, "phethreshold", "phegraph");
- CREATE_PP_GAS( po2GasItem, PO2, PO2, PO2_ALERT, "po2threshold", "po2graph");
+ CREATE_PP_GAS(pn2GasItem, PN2, PN2, PN2_ALERT, "pn2threshold", "pn2graph");
+ CREATE_PP_GAS(pheGasItem, PHE, PHE, PHE_ALERT, "phethreshold", "phegraph");
+ CREATE_PP_GAS(po2GasItem, PO2, PO2, PO2_ALERT, "po2threshold", "po2graph");
#undef CREATE_PP_GAS
temperatureAxis->setTextVisible(false);
@@ -205,7 +204,7 @@ void ProfileWidget2::setupItemOnScene()
cylinderPressureAxis->setLinesVisible(false);
timeAxis->setLinesVisible(true);
profileYAxis->setLinesVisible(true);
- gasYAxis->setZValue(timeAxis->zValue()+1);
+ gasYAxis->setZValue(timeAxis->zValue() + 1);
heartBeatAxis->setTextVisible(true);
heartBeatAxis->setLinesVisible(true);
}
@@ -229,51 +228,51 @@ void ProfileWidget2::setupItemSizes()
itemPos.depth.pos.on.setY(3);
itemPos.depth.pos.off.setX(-2);
itemPos.depth.pos.off.setY(3);
- itemPos.depth.expanded.setP1(QPointF(0,0));
- itemPos.depth.expanded.setP2(QPointF(0,86));
- itemPos.depth.shrinked.setP1(QPointF(0,0));
- itemPos.depth.shrinked.setP2(QPointF(0,60));
+ itemPos.depth.expanded.setP1(QPointF(0, 0));
+ itemPos.depth.expanded.setP2(QPointF(0, 86));
+ itemPos.depth.shrinked.setP1(QPointF(0, 0));
+ itemPos.depth.shrinked.setP2(QPointF(0, 60));
// Time Axis Config
itemPos.time.pos.on.setX(3);
itemPos.time.pos.on.setY(95);
itemPos.time.pos.off.setX(3);
itemPos.time.pos.off.setY(110);
- itemPos.time.expanded.setP1(QPointF(0,0));
- itemPos.time.expanded.setP2(QPointF(94,0));
+ itemPos.time.expanded.setP1(QPointF(0, 0));
+ itemPos.time.expanded.setP2(QPointF(94, 0));
// Partial Gas Axis Config
itemPos.partialPressure.pos.on.setX(97);
itemPos.partialPressure.pos.on.setY(65);
itemPos.partialPressure.pos.off.setX(110);
itemPos.partialPressure.pos.off.setY(63);
- itemPos.partialPressure.expanded.setP1(QPointF(0,0));
- itemPos.partialPressure.expanded.setP2(QPointF(0,30));
+ itemPos.partialPressure.expanded.setP1(QPointF(0, 0));
+ itemPos.partialPressure.expanded.setP2(QPointF(0, 30));
// cylinder axis config
itemPos.cylinder.pos.on.setX(3);
itemPos.cylinder.pos.on.setY(20);
itemPos.cylinder.pos.off.setX(-10);
itemPos.cylinder.pos.off.setY(20);
- itemPos.cylinder.expanded.setP1(QPointF(0,15));
- itemPos.cylinder.expanded.setP2(QPointF(0,50));
- itemPos.cylinder.shrinked.setP1(QPointF(0,0));
- itemPos.cylinder.shrinked.setP2(QPointF(0,20));
+ itemPos.cylinder.expanded.setP1(QPointF(0, 15));
+ itemPos.cylinder.expanded.setP2(QPointF(0, 50));
+ itemPos.cylinder.shrinked.setP1(QPointF(0, 0));
+ itemPos.cylinder.shrinked.setP2(QPointF(0, 20));
// Temperature axis config
itemPos.temperature.pos.on.setX(3);
itemPos.temperature.pos.on.setY(40);
itemPos.temperature.pos.off.setX(-10);
itemPos.temperature.pos.off.setY(40);
- itemPos.temperature.expanded.setP1(QPointF(0,30));
- itemPos.temperature.expanded.setP2(QPointF(0,50));
- itemPos.temperature.shrinked.setP1(QPointF(0,5));
- itemPos.temperature.shrinked.setP2(QPointF(0,15));
+ itemPos.temperature.expanded.setP1(QPointF(0, 30));
+ itemPos.temperature.expanded.setP2(QPointF(0, 50));
+ itemPos.temperature.shrinked.setP1(QPointF(0, 5));
+ itemPos.temperature.shrinked.setP2(QPointF(0, 15));
itemPos.heartBeat.pos.on.setX(3);
itemPos.heartBeat.pos.on.setY(60);
- itemPos.heartBeat.expanded.setP1(QPointF(0,0));
- itemPos.heartBeat.expanded.setP2(QPointF(0,20));
+ itemPos.heartBeat.expanded.setP1(QPointF(0, 0));
+ itemPos.heartBeat.expanded.setP2(QPointF(0, 20));
itemPos.dcLabel.on.setX(3);
itemPos.dcLabel.on.setY(100);
@@ -281,7 +280,7 @@ void ProfileWidget2::setupItemSizes()
itemPos.dcLabel.off.setY(100);
}
-void ProfileWidget2::setupItem(AbstractProfilePolygonItem* item, DiveCartesianAxis* hAxis, DiveCartesianAxis* vAxis, DivePlotDataModel* model, int vData, int hData, int zValue)
+void ProfileWidget2::setupItem(AbstractProfilePolygonItem *item, DiveCartesianAxis *hAxis, DiveCartesianAxis *vAxis, DivePlotDataModel *model, int vData, int hData, int zValue)
{
item->setHorizontalAxis(hAxis);
item->setVerticalAxis(vAxis);
@@ -306,7 +305,7 @@ void ProfileWidget2::setupSceneAndFlags()
}
// Currently just one dive, but the plan is to enable All of the selected dives.
-void ProfileWidget2::plotDives(QList<dive*> dives)
+void ProfileWidget2::plotDives(QList<dive *> dives)
{
// I Know that it's a list, but currently we are
// using just the first.
@@ -368,7 +367,7 @@ void ProfileWidget2::plotDives(QList<dive*> dives)
timeAxis->setMaximum(maxtime);
rulerItem->setPlotInfo(pInfo);
int i, incr;
- static int increments[8] = { 10, 20, 30, 60, 5*60, 10*60, 15*60, 30*60 };
+ static int increments[8] = { 10, 20, 30, 60, 5 * 60, 10 * 60, 15 * 60, 30 * 60 };
/* Time markers: at most every 10 seconds, but no more than 12 markers.
* We start out with 10 seconds and increment up to 30 minutes,
* depending on the dive time.
@@ -387,7 +386,7 @@ void ProfileWidget2::plotDives(QList<dive*> dives)
cylinderPressureAxis->setMinimum(pInfo.minpressure);
cylinderPressureAxis->setMaximum(pInfo.maxpressure);
meanDepth->setMeanDepth(pInfo.meandepth);
- meanDepth->setLine(0,0,timeAxis->posAtValue(d->duration.seconds),0);
+ meanDepth->setLine(0, 0, timeAxis->posAtValue(d->duration.seconds), 0);
meanDepth->animateMoveTo(3, profileYAxis->posAtValue(pInfo.meandepth));
dataModel->emitDataChanged();
@@ -409,7 +408,7 @@ void ProfileWidget2::plotDives(QList<dive*> dives)
event = event->next;
}
// Only set visible the ones that should be visible, but how?
- Q_FOREACH(DiveEventItem *event, eventItems){
+ Q_FOREACH(DiveEventItem * event, eventItems) {
event->setVisible(true);
// qDebug() << event->getEvent()->name << "@" << event->getEvent()->time.seconds;
}
@@ -420,35 +419,35 @@ void ProfileWidget2::settingsChanged()
{
QSettings s;
s.beginGroup("TecDetails");
- if(s.value("phegraph").toBool()|| s.value("po2graph").toBool()|| s.value("pn2graph").toBool()){
+ if (s.value("phegraph").toBool() || s.value("po2graph").toBool() || s.value("pn2graph").toBool()) {
profileYAxis->animateChangeLine(itemPos.depth.shrinked);
temperatureAxis->animateChangeLine(itemPos.temperature.shrinked);
cylinderPressureAxis->animateChangeLine(itemPos.cylinder.shrinked);
- }else{
+ } else {
profileYAxis->animateChangeLine(itemPos.depth.expanded);
temperatureAxis->animateChangeLine(itemPos.temperature.expanded);
cylinderPressureAxis->animateChangeLine(itemPos.cylinder.expanded);
}
- if(s.value("zoomed_plot").toBool() != isPlotZoomed){
+ if (s.value("zoomed_plot").toBool() != isPlotZoomed) {
isPlotZoomed = s.value("zoomed_plot").toBool();
int diveId = dataModel->id();
dataModel->clear();
- plotDives(QList<dive*>() << getDiveById(diveId));
+ plotDives(QList<dive *>() << getDiveById(diveId));
}
- if(currentState == PROFILE){
+ if (currentState == PROFILE) {
bool rulerVisible = s.value("rulergraph", false).toBool();
rulerItem->setVisible(rulerVisible);
- rulerItem->destNode()->setVisible(rulerVisible );
- rulerItem->sourceNode()->setVisible(rulerVisible );
- }else{
+ rulerItem->destNode()->setVisible(rulerVisible);
+ rulerItem->sourceNode()->setVisible(rulerVisible);
+ } else {
rulerItem->setVisible(false);
rulerItem->destNode()->setVisible(false);
rulerItem->sourceNode()->setVisible(false);
}
}
-void ProfileWidget2::resizeEvent(QResizeEvent* event)
+void ProfileWidget2::resizeEvent(QResizeEvent *event)
{
QGraphicsView::resizeEvent(event);
fitInView(sceneRect(), Qt::IgnoreAspectRatio);
@@ -457,10 +456,10 @@ void ProfileWidget2::resizeEvent(QResizeEvent* event)
void ProfileWidget2::fixBackgroundPos()
{
- if(currentState != EMPTY)
+ if (currentState != EMPTY)
return;
QPixmap toBeScaled;
- if (!backgrounds.keys().contains(backgroundFile)){
+ if (!backgrounds.keys().contains(backgroundFile)) {
backgrounds[backgroundFile] = QPixmap(backgroundFile);
}
toBeScaled = backgrounds[backgroundFile];
@@ -470,7 +469,7 @@ void ProfileWidget2::fixBackgroundPos()
background->setX(mapToScene(x, 0).x());
}
-void ProfileWidget2::wheelEvent(QWheelEvent* event)
+void ProfileWidget2::wheelEvent(QWheelEvent *event)
{
QPoint toolTipPos = mapFromScene(toolTipItem->pos());
double scaleFactor = 1.15;
@@ -486,9 +485,9 @@ void ProfileWidget2::wheelEvent(QWheelEvent* event)
toolTipItem->setPos(mapToScene(toolTipPos));
}
-void ProfileWidget2::scrollViewTo(const QPoint& pos)
+void ProfileWidget2::scrollViewTo(const QPoint &pos)
{
-/* since we cannot use translate() directly on the scene we hack on
+ /* since we cannot use translate() directly on the scene we hack on
* the scroll bars (hidden) functionality */
if (!zoomLevel)
return;
@@ -500,7 +499,7 @@ void ProfileWidget2::scrollViewTo(const QPoint& pos)
hs->setValue(xRat * hs->maximum());
}
-void ProfileWidget2::mouseMoveEvent(QMouseEvent* event)
+void ProfileWidget2::mouseMoveEvent(QMouseEvent *event)
{
toolTipItem->refresh(mapToScene(event->pos()));
QPoint toolTipPos = mapFromScene(toolTipItem->pos());
@@ -514,8 +513,8 @@ void ProfileWidget2::mouseMoveEvent(QMouseEvent* event)
bool ProfileWidget2::eventFilter(QObject *object, QEvent *event)
{
- QGraphicsScene *s = qobject_cast<QGraphicsScene*>(object);
- if (s && event->type() == QEvent::GraphicsSceneHelp){
+ QGraphicsScene *s = qobject_cast<QGraphicsScene *>(object);
+ if (s && event->type() == QEvent::GraphicsSceneHelp) {
event->ignore();
return true;
}
@@ -529,13 +528,13 @@ void ProfileWidget2::setEmptyState()
return;
dataModel->clear();
- backgroundFile = QString(":poster%1").arg( rand()%3 +1);
+ backgroundFile = QString(":poster%1").arg(rand() % 3 + 1);
currentState = EMPTY;
fixBackgroundPos();
profileYAxis->setPos(itemPos.depth.pos.off);
gasYAxis->setPos(itemPos.partialPressure.pos.off);
timeAxis->setPos(itemPos.time.pos.off);
- background->setY( itemPos.background.on.y());
+ background->setY(itemPos.background.on.y());
background->setVisible(true);
toolTipItem->setVisible(false);
temperatureAxis->setPos(itemPos.temperature.pos.off);
@@ -547,10 +546,10 @@ void ProfileWidget2::setEmptyState()
rulerItem->setVisible(false);
rulerItem->destNode()->setVisible(false);
rulerItem->sourceNode()->setVisible(false);
- Q_FOREACH(DiveCalculatedTissue *tissue, allTissues){
+ Q_FOREACH(DiveCalculatedTissue * tissue, allTissues) {
tissue->setVisible(false);
}
- Q_FOREACH(DiveEventItem *event, eventItems){
+ Q_FOREACH(DiveEventItem * event, eventItems) {
event->setVisible(false);
}
}
@@ -570,11 +569,11 @@ void ProfileWidget2::setProfileState()
profileYAxis->setPos(itemPos.depth.pos.on);
QSettings s;
s.beginGroup("TecDetails");
- if(s.value("phegraph").toBool()|| s.value("po2graph").toBool()|| s.value("pn2graph").toBool()){
+ if (s.value("phegraph").toBool() || s.value("po2graph").toBool() || s.value("pn2graph").toBool()) {
profileYAxis->setLine(itemPos.depth.shrinked);
temperatureAxis->setLine(itemPos.temperature.shrinked);
cylinderPressureAxis->setLine(itemPos.cylinder.shrinked);
- }else{
+ } else {
profileYAxis->setLine(itemPos.depth.expanded);
temperatureAxis->setLine(itemPos.temperature.expanded);
cylinderPressureAxis->setLine(itemPos.cylinder.expanded);
@@ -598,23 +597,23 @@ void ProfileWidget2::setProfileState()
diveCeiling->setVisible(s.value("calcceiling").toBool());
reportedCeiling->setVisible(s.value("dcceiling").toBool());
- if(s.value("calcalltissues").toBool()){
- Q_FOREACH(DiveCalculatedTissue *tissue, allTissues){
+ if (s.value("calcalltissues").toBool()) {
+ Q_FOREACH(DiveCalculatedTissue * tissue, allTissues) {
tissue->setVisible(true);
}
}
bool rulerVisible = s.value("rulergraph", false).toBool();
rulerItem->setVisible(rulerVisible);
- rulerItem->destNode()->setVisible(rulerVisible );
- rulerItem->sourceNode()->setVisible(rulerVisible );
+ rulerItem->destNode()->setVisible(rulerVisible);
+ rulerItem->sourceNode()->setVisible(rulerVisible);
}
extern struct ev_select *ev_namelist;
extern int evn_allocated;
extern int evn_used;
-void ProfileWidget2::contextMenuEvent(QContextMenuEvent* event)
+void ProfileWidget2::contextMenuEvent(QContextMenuEvent *event)
{
if (selected_dive == -1)
return;
@@ -625,26 +624,26 @@ void ProfileWidget2::contextMenuEvent(QContextMenuEvent* event)
int rowCount = model->rowCount();
for (int i = 0; i < rowCount; i++) {
QAction *action = new QAction(&m);
- action->setText( model->data(model->index(i, 0),Qt::DisplayRole).toString());
+ action->setText(model->data(model->index(i, 0), Qt::DisplayRole).toString());
connect(action, SIGNAL(triggered(bool)), this, SLOT(changeGas()));
action->setData(event->globalPos());
gasChange->addAction(action);
}
QAction *action = m.addAction(tr("Add Bookmark"), this, SLOT(addBookmark()));
action->setData(event->globalPos());
- QList<QGraphicsItem*> itemsAtPos = scene()->items(mapToScene(mapFromGlobal(event->globalPos())));
- Q_FOREACH(QGraphicsItem *i, itemsAtPos) {
- EventItem *item = dynamic_cast<EventItem*>(i);
+ QList<QGraphicsItem *> itemsAtPos = scene()->items(mapToScene(mapFromGlobal(event->globalPos())));
+ Q_FOREACH(QGraphicsItem * i, itemsAtPos) {
+ EventItem *item = dynamic_cast<EventItem *>(i);
if (!item)
continue;
action = new QAction(&m);
action->setText(tr("Remove Event"));
- action->setData(QVariant::fromValue<void*>(item)); // so we know what to remove.
+ action->setData(QVariant::fromValue<void *>(item)); // so we know what to remove.
connect(action, SIGNAL(triggered(bool)), this, SLOT(removeEvent()));
m.addAction(action);
action = new QAction(&m);
action->setText(tr("Hide similar events"));
- action->setData(QVariant::fromValue<void*>(item));
+ action->setData(QVariant::fromValue<void *>(item));
connect(action, SIGNAL(triggered(bool)), this, SLOT(hideEvents()));
m.addAction(action);
break;
@@ -665,7 +664,7 @@ void ProfileWidget2::contextMenuEvent(QContextMenuEvent* event)
void ProfileWidget2::changeGas()
{
- QAction *action = qobject_cast<QAction*>(sender());
+ QAction *action = qobject_cast<QAction *>(sender());
QPointF scenePos = mapToScene(mapFromGlobal(action->data().toPoint()));
QString gas = action->text();
// backup the things on the dataModel, since we will clear that out.
@@ -684,5 +683,5 @@ void ProfileWidget2::changeGas()
// force the redraw of the dive.
//TODO: find a way to make this do not need a full redraw
dataModel->clear();
- plotDives(QList<dive*>() << getDiveById(diveId));
+ plotDives(QList<dive *>() << getDiveById(diveId));
}
diff --git a/qt-ui/profile/profilewidget2.h b/qt-ui/profile/profilewidget2.h
index e8246980d..9393f4f03 100644
--- a/qt-ui/profile/profilewidget2.h
+++ b/qt-ui/profile/profilewidget2.h
@@ -44,32 +44,50 @@ class AbstractProfilePolygonItem;
class ProfileWidget2 : public QGraphicsView {
Q_OBJECT
public:
- enum State{ EMPTY, PROFILE, EDIT, ADD, PLAN, INVALID };
- enum Items{BACKGROUND, PROFILE_Y_AXIS, GAS_Y_AXIS, TIME_AXIS, DEPTH_CONTROLLER, TIME_CONTROLLER, COLUMNS};
+ enum State {
+ EMPTY,
+ PROFILE,
+ EDIT,
+ ADD,
+ PLAN,
+ INVALID
+ };
+ enum Items {
+ BACKGROUND,
+ PROFILE_Y_AXIS,
+ GAS_Y_AXIS,
+ TIME_AXIS,
+ DEPTH_CONTROLLER,
+ TIME_CONTROLLER,
+ COLUMNS
+ };
ProfileWidget2(QWidget *parent);
- void plotDives(QList<dive*> dives);
- virtual bool eventFilter(QObject*, QEvent*);
- void setupItem( AbstractProfilePolygonItem *item, DiveCartesianAxis *hAxis, DiveCartesianAxis *vAxis, DivePlotDataModel *model, int vData, int hData, int zValue);
+ void plotDives(QList<dive *> dives);
+ virtual bool eventFilter(QObject *, QEvent *);
+ void setupItem(AbstractProfilePolygonItem *item, DiveCartesianAxis *hAxis, DiveCartesianAxis *vAxis, DivePlotDataModel *model, int vData, int hData, int zValue);
-public slots: // Necessary to call from QAction's signals.
+public
+slots: // Necessary to call from QAction's signals.
void settingsChanged();
void setEmptyState();
void setProfileState();
void changeGas();
+
protected:
- virtual void resizeEvent(QResizeEvent* event);
- virtual void wheelEvent(QWheelEvent* event);
- virtual void mouseMoveEvent(QMouseEvent* event);
- virtual void contextMenuEvent(QContextMenuEvent* event);
+ virtual void resizeEvent(QResizeEvent *event);
+ virtual void wheelEvent(QWheelEvent *event);
+ virtual void mouseMoveEvent(QMouseEvent *event);
+ virtual void contextMenuEvent(QContextMenuEvent *event);
private: /*methods*/
void fixBackgroundPos();
- void scrollViewTo(const QPoint& pos);
+ void scrollViewTo(const QPoint &pos);
void setupSceneAndFlags();
void setupItemSizes();
void addItemsToScene();
void setupItemOnScene();
+
private:
DivePlotDataModel *dataModel;
State currentState;
@@ -92,10 +110,10 @@ private:
DiveCartesianAxis *cylinderPressureAxis;
DiveGasPressureItem *gasPressureItem;
MeanDepthLine *meanDepth;
- QList<DiveEventItem*> eventItems;
+ QList<DiveEventItem *> eventItems;
DiveTextItem *diveComputerText;
DiveCalculatedCeiling *diveCeiling;
- QList<DiveCalculatedTissue*> allTissues;
+ QList<DiveCalculatedTissue *> allTissues;
DiveReportedCeiling *reportedCeiling;
PartialPressureGasItem *pn2GasItem;
PartialPressureGasItem *pheGasItem;
diff --git a/qt-ui/profile/ruleritem.cpp b/qt-ui/profile/ruleritem.cpp
index 04b7fd996..042742a23 100644
--- a/qt-ui/profile/ruleritem.cpp
+++ b/qt-ui/profile/ruleritem.cpp
@@ -13,9 +13,9 @@
#include "profile.h"
#include "display.h"
-RulerNodeItem2::RulerNodeItem2(struct plot_info& info) : pInfo(info), entry(NULL) , ruler(NULL)
+RulerNodeItem2::RulerNodeItem2(struct plot_info &info) : pInfo(info), entry(NULL), ruler(NULL)
{
- setRect(QRect(QPoint(-8,8),QPoint(8,-8)));
+ setRect(QRect(QPoint(-8, 8), QPoint(8, -8)));
setBrush(QColor(0xff, 0, 0, 127));
setPen(QColor("#FF0000"));
setFlag(QGraphicsItem::ItemIsMovable);
@@ -30,7 +30,7 @@ void RulerNodeItem2::setRuler(RulerItem2 *r)
void RulerNodeItem2::recalculate()
{
- struct plot_data *data = pInfo.entry+(pInfo.nr-1);
+ struct plot_data *data = pInfo.entry + (pInfo.nr - 1);
uint16_t count = 0;
if (x() < 0) {
setPos(0, y());
@@ -38,13 +38,13 @@ void RulerNodeItem2::recalculate()
setPos(timeAxis->posAtValue(data->sec), y());
} else {
data = pInfo.entry;
- count=0;
+ count = 0;
while (timeAxis->posAtValue(data->sec) < x() && count < pInfo.nr) {
- data = pInfo.entry+count;
+ data = pInfo.entry + count;
count++;
}
setPos(timeAxis->posAtValue(data->sec), depthAxis->posAtValue(data->depth));
- entry=data;
+ entry = data;
}
}
@@ -61,8 +61,7 @@ QVariant RulerNodeItem2::itemChange(GraphicsItemChange change, const QVariant &v
return QGraphicsEllipseItem::itemChange(change, value);
}
-RulerItem2::RulerItem2():
- timeAxis(NULL),
+RulerItem2::RulerItem2() : timeAxis(NULL),
depthAxis(NULL),
source(new RulerNodeItem2(pInfo)),
dest(new RulerNodeItem2(pInfo)),
@@ -112,7 +111,6 @@ void RulerItem2::recalculate()
textItem->resetTransform();
textItem->setPos(startPoint);
textItem->rotate(globalLine.angle() * -1);
-
}
RulerNodeItem2 *RulerItem2::sourceNode() const
@@ -147,7 +145,7 @@ QPainterPath RulerItem2::shape() const
QLineF line_n = line.normalVector();
line_n.setLength(height);
if (paint_direction == 1)
- line_n.setAngle(line_n.angle()+180);
+ line_n.setAngle(line_n.angle() + 180);
path.moveTo(startPoint);
path.lineTo(line_n.p2());
path.lineTo(line_n.p2() + QPointF(line.dx(), line.dy()));
@@ -164,7 +162,7 @@ void RulerItem2::setPlotInfo(plot_info info)
source->recalculate();
}
-void RulerItem2::setAxis(DiveCartesianAxis* time, DiveCartesianAxis* depth)
+void RulerItem2::setAxis(DiveCartesianAxis *time, DiveCartesianAxis *depth)
{
timeAxis = time;
depthAxis = depth;
diff --git a/qt-ui/profile/ruleritem.h b/qt-ui/profile/ruleritem.h
index f9cc98577..f2ff61c09 100644
--- a/qt-ui/profile/ruleritem.h
+++ b/qt-ui/profile/ruleritem.h
@@ -10,37 +10,36 @@
struct plot_data;
class RulerItem2;
-class RulerNodeItem2 : public QObject, public QGraphicsEllipseItem
-{
+class RulerNodeItem2 : public QObject, public QGraphicsEllipseItem {
Q_OBJECT
friend class RulerItem2;
+
public:
- explicit RulerNodeItem2(struct plot_info& info);
+ explicit RulerNodeItem2(struct plot_info &info);
void setRuler(RulerItem2 *r);
void recalculate();
protected:
- QVariant itemChange(GraphicsItemChange change, const QVariant & value );
+ QVariant itemChange(GraphicsItemChange change, const QVariant &value);
private:
struct plot_info &pInfo;
struct plot_data *entry;
- RulerItem2* ruler;
+ RulerItem2 *ruler;
DiveCartesianAxis *timeAxis;
DiveCartesianAxis *depthAxis;
};
-class RulerItem2 : public QGraphicsObject
-{
+class RulerItem2 : public QGraphicsObject {
Q_OBJECT
public:
explicit RulerItem2();
void recalculate();
void setPlotInfo(struct plot_info pInfo);
- RulerNodeItem2* sourceNode() const;
- RulerNodeItem2* destNode() const;
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget * widget = 0);
+ RulerNodeItem2 *sourceNode() const;
+ RulerNodeItem2 *destNode() const;
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
QRectF boundingRect() const;
QPainterPath shape() const;
void setAxis(DiveCartesianAxis *time, DiveCartesianAxis *depth);