Whitespace cleanup

Quite a bit of wild white space going on...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2015-01-01 16:28:37 -08:00
parent b6f47883c3
commit c4954d90a1
4 changed files with 53 additions and 52 deletions

View file

@ -592,7 +592,7 @@ void DiveMeanDepthItem::modelDataChanged(const QModelIndex &topLeft, const QMode
if (entry->running_sum == 0 || entry->sec == 0) if (entry->running_sum == 0 || entry->sec == 0)
continue; continue;
meandepthvalue = entry->running_sum / entry->sec ; meandepthvalue = entry->running_sum / entry->sec;
QPointF point(hAxis->posAtValue(entry->sec), vAxis->posAtValue(meandepthvalue)); QPointF point(hAxis->posAtValue(entry->sec), vAxis->posAtValue(meandepthvalue));
poly.append(point); poly.append(point);
} }
@ -869,7 +869,8 @@ MeanDepthLine::MeanDepthLine() : meanDepth(0), leftText(new DiveTextItem(this)),
rightText->setPos(line().length(), 0); rightText->setPos(line().length(), 0);
} }
void MeanDepthLine::setModel(DivePlotDataModel *m){ void MeanDepthLine::setModel(DivePlotDataModel *m)
{
model = m; model = m;
} }
@ -977,9 +978,8 @@ void PartialPressureGasItem::setColors(const QColor &normal, const QColor &alert
alertColor = alert; alertColor = alert;
} }
InstantMeanDepthLine::InstantMeanDepthLine(): vAxis(NULL), hAxis(NULL) InstantMeanDepthLine::InstantMeanDepthLine() : vAxis(NULL), hAxis(NULL)
{ {
} }
void InstantMeanDepthLine::mouseMoved(int time, int depth) void InstantMeanDepthLine::mouseMoved(int time, int depth)
@ -988,7 +988,7 @@ void InstantMeanDepthLine::mouseMoved(int time, int depth)
return; return;
int count = model->data().nr; int count = model->data().nr;
for(int i = 0; i < count; i++){ for (int i = 0; i < count; i++) {
struct plot_data pI = model->data().entry[i]; struct plot_data pI = model->data().entry[i];
if (pI.sec == time && pI.sec != 0) { if (pI.sec == time && pI.sec != 0) {
setMeanDepth(pI.running_sum / time); setMeanDepth(pI.running_sum / time);

View file

@ -78,6 +78,7 @@ public:
virtual void settingsChanged(); virtual void settingsChanged();
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);
int maxCeiling(int row); int maxCeiling(int row);
private: private:
unsigned int show_reported_ceiling; unsigned int show_reported_ceiling;
unsigned int reported_ceiling_in_red; unsigned int reported_ceiling_in_red;
@ -91,9 +92,9 @@ public:
virtual void modelDataChanged(const QModelIndex &topLeft = QModelIndex(), const QModelIndex &bottomRight = QModelIndex()); virtual void modelDataChanged(const QModelIndex &topLeft = QModelIndex(), const QModelIndex &bottomRight = QModelIndex());
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
virtual void settingsChanged(); virtual void settingsChanged();
private: private:
QString visibilityKey; QString visibilityKey;
}; };
class DiveTemperatureItem : public AbstractProfilePolygonItem { class DiveTemperatureItem : public AbstractProfilePolygonItem {
@ -114,6 +115,7 @@ public:
virtual void modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight); virtual void modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
virtual void settingsChanged(); virtual void settingsChanged();
private: private:
void createTextItem(int seconds, int hr); void createTextItem(int seconds, int hr);
QString visibilityKey; QString visibilityKey;
@ -126,6 +128,7 @@ public:
virtual void modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight); virtual void modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
virtual void settingsChanged(); virtual void settingsChanged();
private: private:
QString visibilityKey; QString visibilityKey;
}; };
@ -137,6 +140,7 @@ public:
virtual void modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight); virtual void modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
virtual void settingsChanged(); virtual void settingsChanged();
private: private:
QString visibilityKey; QString visibilityKey;
}; };
@ -148,6 +152,7 @@ public:
virtual void modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight); virtual void modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
virtual void settingsChanged(); virtual void settingsChanged();
private: private:
QString visibilityKey; QString visibilityKey;
}; };
@ -224,7 +229,8 @@ public:
DiveCartesianAxis *hAxis; DiveCartesianAxis *hAxis;
DiveCartesianAxis *vAxis; DiveCartesianAxis *vAxis;
InstantMeanDepthLine(); InstantMeanDepthLine();
public slots: public
slots:
void mouseMoved(int time, int depth); void mouseMoved(int time, int depth);
}; };

View file

@ -117,7 +117,7 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) : QGraphicsView(parent),
addItemsToScene(); addItemsToScene();
scene()->installEventFilter(this); scene()->installEventFilter(this);
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged())); connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged()));
connect(this, SIGNAL(mouseMoved(int,int)), instantMeanDepth, SLOT(mouseMoved(int,int))); connect(this, SIGNAL(mouseMoved(int, int)), instantMeanDepth, SLOT(mouseMoved(int, int)));
QAction *action = NULL; QAction *action = NULL;
#define ADD_ACTION(SHORTCUT, Slot) \ #define ADD_ACTION(SHORTCUT, Slot) \
action = new QAction(this); \ action = new QAction(this); \
@ -302,7 +302,6 @@ void ProfileWidget2::setupItemOnScene()
setupItem(meanDepthItem, timeAxis, profileYAxis, dataModel, DivePlotDataModel::INSTANT_MEANDEPTH, DivePlotDataModel::TIME, 1); setupItem(meanDepthItem, timeAxis, profileYAxis, dataModel, DivePlotDataModel::INSTANT_MEANDEPTH, DivePlotDataModel::TIME, 1);
#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); \ setupItem(ITEM, timeAxis, gasYAxis, dataModel, DivePlotDataModel::VERTICAL_COLUMN, DivePlotDataModel::TIME, 0); \
ITEM->setThreshouldSettingsKey(THRESHOULD_SETTINGS); \ ITEM->setThreshouldSettingsKey(THRESHOULD_SETTINGS); \
@ -537,7 +536,7 @@ void ProfileWidget2::plotDive(struct dive *d, bool force)
*/ */
plotInfo = calculate_max_limits_new(&displayed_dive, currentdc); plotInfo = calculate_max_limits_new(&displayed_dive, currentdc);
create_plot_info_new(&displayed_dive, currentdc, &plotInfo, !shouldCalculateMaxDepth); create_plot_info_new(&displayed_dive, currentdc, &plotInfo, !shouldCalculateMaxDepth);
if(shouldCalculateMaxTime) if (shouldCalculateMaxTime)
maxtime = get_maxtime(&plotInfo); maxtime = get_maxtime(&plotInfo);
/* Only update the max depth if it's bigger than the current ones /* Only update the max depth if it's bigger than the current ones
@ -545,7 +544,7 @@ void ProfileWidget2::plotDive(struct dive *d, bool force)
* otherwhise, update normally. * otherwhise, update normally.
*/ */
int newMaxDepth = get_maxdepth(&plotInfo); int newMaxDepth = get_maxdepth(&plotInfo);
if(!shouldCalculateMaxDepth) { if (!shouldCalculateMaxDepth) {
if (maxdepth < newMaxDepth) { if (maxdepth < newMaxDepth) {
maxdepth = newMaxDepth; maxdepth = newMaxDepth;
} }
@ -727,7 +726,7 @@ void ProfileWidget2::resizeEvent(QResizeEvent *event)
void ProfileWidget2::mousePressEvent(QMouseEvent *event) void ProfileWidget2::mousePressEvent(QMouseEvent *event)
{ {
QGraphicsView::mousePressEvent(event); QGraphicsView::mousePressEvent(event);
if(currentState == PLAN) if (currentState == PLAN)
shouldCalculateMaxTime = false; shouldCalculateMaxTime = false;
} }
@ -746,7 +745,7 @@ void ProfileWidget2::divePlannerHandlerReleased()
void ProfileWidget2::mouseReleaseEvent(QMouseEvent *event) void ProfileWidget2::mouseReleaseEvent(QMouseEvent *event)
{ {
QGraphicsView::mouseReleaseEvent(event); QGraphicsView::mouseReleaseEvent(event);
if(currentState == PLAN){ if (currentState == PLAN) {
shouldCalculateMaxTime = true; shouldCalculateMaxTime = true;
replot(); replot();
} }
@ -770,7 +769,7 @@ void ProfileWidget2::wheelEvent(QWheelEvent *event)
if (currentState == EMPTY) if (currentState == EMPTY)
return; return;
QPoint toolTipPos = mapFromScene(toolTipItem->pos()); QPoint toolTipPos = mapFromScene(toolTipItem->pos());
if(event->buttons() == Qt::LeftButton) if (event->buttons() == Qt::LeftButton)
return; return;
if (event->delta() > 0 && zoomLevel < 20) { if (event->delta() > 0 && zoomLevel < 20) {
scale(zoomFactor, zoomFactor); scale(zoomFactor, zoomFactor);
@ -836,18 +835,13 @@ void ProfileWidget2::mouseMoveEvent(QMouseEvent *event)
QPointF pos = mapToScene(event->pos()); QPointF pos = mapToScene(event->pos());
qreal vValue = profileYAxis->valueAt(pos); qreal vValue = profileYAxis->valueAt(pos);
qreal hValue = timeAxis->valueAt(pos); qreal hValue = timeAxis->valueAt(pos);
if ( profileYAxis->maximum() >= vValue if (profileYAxis->maximum() >= vValue && profileYAxis->minimum() <= vValue) {
&& profileYAxis->minimum() <= vValue){
mouseFollowerHorizontal->setPos(timeAxis->pos().x(), pos.y()); mouseFollowerHorizontal->setPos(timeAxis->pos().x(), pos.y());
} }
if ( timeAxis->maximum() >= hValue if (timeAxis->maximum() >= hValue && timeAxis->minimum() <= hValue) {
&& timeAxis->minimum() <= hValue){
mouseFollowerVertical->setPos(pos.x(), profileYAxis->line().y1()); mouseFollowerVertical->setPos(pos.x(), profileYAxis->line().y1());
} }
if ( timeAxis->maximum() >= hValue if (timeAxis->maximum() >= hValue && timeAxis->minimum() <= hValue && profileYAxis->maximum() >= vValue && profileYAxis->minimum() <= vValue)
&& timeAxis->minimum() <= hValue
&& profileYAxis->maximum() >= vValue
&& profileYAxis->minimum() <= vValue )
emit mouseMoved(hValue, vValue); emit mouseMoved(hValue, vValue);
} }
@ -895,14 +889,14 @@ void ProfileWidget2::setEmptyState()
mouseFollowerHorizontal->setVisible(false); mouseFollowerHorizontal->setVisible(false);
mouseFollowerVertical->setVisible(false); mouseFollowerVertical->setVisible(false);
#define HIDE_ALL(TYPE, CONTAINER) \ #define HIDE_ALL(TYPE, CONTAINER) \
Q_FOREACH (TYPE *item, CONTAINER) item->setVisible(false); Q_FOREACH (TYPE *item, CONTAINER) item->setVisible(false);
HIDE_ALL(DiveCalculatedTissue, allTissues); HIDE_ALL(DiveCalculatedTissue, allTissues);
HIDE_ALL(DivePercentageItem, allPercentages); HIDE_ALL(DivePercentageItem, allPercentages);
HIDE_ALL(DiveEventItem, eventItems); HIDE_ALL(DiveEventItem, eventItems);
HIDE_ALL(DiveHandler, handles); HIDE_ALL(DiveHandler, handles);
HIDE_ALL(QGraphicsSimpleTextItem, gases); HIDE_ALL(QGraphicsSimpleTextItem, gases);
#undef HIDE_ALL #undef HIDE_ALL
} }
void ProfileWidget2::setProfileState() void ProfileWidget2::setProfileState()
@ -913,8 +907,8 @@ void ProfileWidget2::setProfileState()
disconnectTemporaryConnections(); disconnectTemporaryConnections();
connect(DivePictureModel::instance(), SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(plotPictures())); connect(DivePictureModel::instance(), SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(plotPictures()));
connect(DivePictureModel::instance(), SIGNAL(rowsInserted(const QModelIndex &, int, int)),this, SLOT(plotPictures())); connect(DivePictureModel::instance(), SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SLOT(plotPictures()));
connect(DivePictureModel::instance(), SIGNAL(rowsRemoved(const QModelIndex &, int, int)),this, SLOT(plotPictures())); connect(DivePictureModel::instance(), SIGNAL(rowsRemoved(const QModelIndex &, int, int)), this, SLOT(plotPictures()));
/* show the same stuff that the profile shows. */ /* show the same stuff that the profile shows. */
//TODO: Move the DC handling to another method. //TODO: Move the DC handling to another method.
@ -1021,11 +1015,11 @@ void ProfileWidget2::setProfileState()
tankItem->setVisible(prefs.tankbar); tankItem->setVisible(prefs.tankbar);
tankItem->setPos(itemPos.tankBar.on); tankItem->setPos(itemPos.tankBar.on);
#define HIDE_ALL(TYPE, CONTAINER) \ #define HIDE_ALL(TYPE, CONTAINER) \
Q_FOREACH (TYPE *item, CONTAINER) item->setVisible(false); Q_FOREACH (TYPE *item, CONTAINER) item->setVisible(false);
HIDE_ALL(DiveHandler, handles); HIDE_ALL(DiveHandler, handles);
HIDE_ALL(QGraphicsSimpleTextItem, gases); HIDE_ALL(QGraphicsSimpleTextItem, gases);
#undef HIDE_ALL #undef HIDE_ALL
mouseFollowerHorizontal->setVisible(false); mouseFollowerHorizontal->setVisible(false);
mouseFollowerVertical->setVisible(false); mouseFollowerVertical->setVisible(false);
} }
@ -1399,8 +1393,8 @@ void ProfileWidget2::setPrintMode(bool mode, bool grayscale)
{ {
printMode = mode; printMode = mode;
isGrayscale = mode ? grayscale : false; isGrayscale = mode ? grayscale : false;
mouseFollowerHorizontal->setVisible( !mode ); mouseFollowerHorizontal->setVisible(!mode);
mouseFollowerVertical->setVisible( !mode ); mouseFollowerVertical->setVisible(!mode);
} }
void ProfileWidget2::setFontPrintScale(double scale) void ProfileWidget2::setFontPrintScale(double scale)
@ -1704,7 +1698,7 @@ void ProfileWidget2::keyEscAction()
void ProfileWidget2::plotPictures() void ProfileWidget2::plotPictures()
{ {
Q_FOREACH(DivePictureItem *item, pictures){ Q_FOREACH (DivePictureItem *item, pictures) {
item->hide(); item->hide();
item->deleteLater(); item->deleteLater();
} }
@ -1716,14 +1710,14 @@ void ProfileWidget2::plotPictures()
double x, y, lastX = -1.0, lastY = -1.0; double x, y, lastX = -1.0, lastY = -1.0;
DivePictureModel *m = DivePictureModel::instance(); DivePictureModel *m = DivePictureModel::instance();
for (int i = 0; i < m->rowCount(); i++) { for (int i = 0; i < m->rowCount(); i++) {
int offsetSeconds = m->index(i,1).data(Qt::UserRole).value<int>(); int offsetSeconds = m->index(i, 1).data(Qt::UserRole).value<int>();
// it's a correct picture, but doesn't have a timestamp: only show on the widget near the // it's a correct picture, but doesn't have a timestamp: only show on the widget near the
// information area. // information area.
if (!offsetSeconds) if (!offsetSeconds)
continue; continue;
DivePictureItem *item = new DivePictureItem(); DivePictureItem *item = new DivePictureItem();
item->setPixmap(m->index(i,0).data(Qt::DecorationRole).value<QPixmap>()); item->setPixmap(m->index(i, 0).data(Qt::DecorationRole).value<QPixmap>());
item->setFileUrl(m->index(i,1).data().toString()); item->setFileUrl(m->index(i, 1).data().toString());
// let's put the picture at the correct time, but at a fixed "depth" on the profile // let's put the picture at the correct time, but at a fixed "depth" on the profile
// not sure this is ideal, but it seems to look right. // not sure this is ideal, but it seems to look right.
x = timeAxis->posAtValue(offsetSeconds); x = timeAxis->posAtValue(offsetSeconds);

View file

@ -123,6 +123,7 @@ slots: // Necessary to call from QAction's signals.
void divePlannerHandlerClicked(); void divePlannerHandlerClicked();
void divePlannerHandlerReleased(); void divePlannerHandlerReleased();
protected: protected:
virtual ~ProfileWidget2(); virtual ~ProfileWidget2();
virtual void resizeEvent(QResizeEvent *event); virtual void resizeEvent(QResizeEvent *event);
@ -190,7 +191,7 @@ private:
//specifics for ADD and PLAN //specifics for ADD and PLAN
QList<DiveHandler *> handles; QList<DiveHandler *> handles;
QList<QGraphicsSimpleTextItem *> gases; QList<QGraphicsSimpleTextItem *> gases;
QList<DivePictureItem*> pictures; QList<DivePictureItem *> pictures;
void repositionDiveHandlers(); void repositionDiveHandlers();
int fixHandlerIndex(DiveHandler *activeHandler); int fixHandlerIndex(DiveHandler *activeHandler);
friend class DiveHandler; friend class DiveHandler;