Whitespace and coding style updates

Another futile attempt to cleanup the code and make coding style and
whitespace consistent. I tried to add a file that describes the key points
of our coding style. I have no illusions that this will help the least
bit...

This commit should ONLY change whitespace

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2014-01-16 11:50:56 +07:00
parent 3387ccc6f6
commit a27f67c026
28 changed files with 387 additions and 323 deletions

View file

@ -2,7 +2,7 @@
#include <QPropertyAnimation>
#include <QPointF>
namespace Animations{
namespace Animations {
void hide(QObject* obj)
{

View file

@ -27,6 +27,7 @@ void DiveCartesianAxis::setTextColor(const QColor& color)
DiveCartesianAxis::DiveCartesianAxis() : orientation(Qt::Horizontal)
{
}
DiveCartesianAxis::~DiveCartesianAxis()
@ -50,8 +51,8 @@ void DiveCartesianAxis::updateTicks()
double currValue = min;
// Remove the uneeded Ticks / Texts.
if (ticks.size() > steps){
while (ticks.size() > steps){
if (ticks.size() > steps) {
while (ticks.size() > steps) {
DiveLineItem *removedLine = ticks.takeLast();
removedLine->animatedHide();
DiveTextItem *removedText = labels.takeLast();
@ -65,21 +66,20 @@ void DiveCartesianAxis::updateTicks()
qreal end = orientation == Qt::Horizontal ? m.x2() : m.y2();
double stepSize = orientation == Qt::Horizontal ? (m.x2() - m.x1()) : (m.y2() - m.y1());
stepSize = stepSize / steps;
for(int i = 0, count = ticks.size(); i < count; i++, currValue += interval){
for (int i = 0, count = ticks.size(); i < count; i++, currValue += interval) {
qreal childPos = begin + i * stepSize;
labels[i]->setText(textForValue(currValue));
if ( orientation == Qt::Horizontal ){
if ( orientation == Qt::Horizontal ) {
ticks[i]->animateMoveTo(childPos, m.y1() + tickSize);
labels[i]->animateMoveTo(childPos, m.y1() + tickSize);
}
else{
} else {
ticks[i]->animateMoveTo(m.x1() - tickSize, childPos);
labels[i]->animateMoveTo(m.x1() - tickSize, childPos);
}
}
// Add's the rest of the needed Ticks / Text.
for(int i = ticks.size(); i < steps; i++, currValue += interval){
for (int i = ticks.size(); i < steps; i++, currValue += interval) {
qreal childPos = begin + i * stepSize;
DiveLineItem *item = new DiveLineItem(this);
item->setPen(pen());
@ -90,15 +90,14 @@ void DiveCartesianAxis::updateTicks()
label->setBrush(QBrush(textColor));
labels.push_back(label);
if(orientation == Qt::Horizontal){
if (orientation == Qt::Horizontal) {
item->setLine(0, 0, 0, tickSize);
item->setPos(scene()->sceneRect().width() + 10, m.y1() + tickSize); // position it outside of the scene
item->animateMoveTo(childPos, m.y1() + tickSize); // anim it to scene.
label->setAlignment(Qt::AlignBottom | Qt::AlignHCenter);
label->setPos(scene()->sceneRect().width() + 10, m.y1() + tickSize); // position it outside of the scene);
label->animateMoveTo(childPos, m.y1() + tickSize);
}
else{
} else {
item->setLine(0, 0, tickSize, 0);
item->setPos(m.x1() - tickSize, scene()->sceneRect().height() + 10);
item->animateMoveTo(m.x1() - tickSize, childPos);
@ -146,7 +145,7 @@ qreal DiveCartesianAxis::posAtValue(qreal value)
m.y2() - m.y1();
double retValue = realSize * percent;
retValue = (orientation == Qt::Horizontal) ?
retValue + m.x1() + p.x():
retValue + m.x1() + p.x() :
retValue + m.y1() + p.y();
return retValue;
}
@ -186,5 +185,5 @@ QString DepthAxis::textForValue(double value)
QString TimeAxis::textForValue(double value)
{
return QString::number(value / 60);
}
return QString::number(value / 60);
}

View file

@ -2,4 +2,5 @@
DivePixmapItem::DivePixmapItem(QObject* parent): QObject(parent), QGraphicsPixmapItem()
{
}
}

View file

@ -23,19 +23,19 @@ QVariant DivePlotDataModel::data(const QModelIndex& index, int role) const
return QVariant();
plot_data item = plotData[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;
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;
}
}
if (role == Qt::BackgroundRole){
switch(index.column()){
case COLOR: return getColor((color_indice_t)(VELOCITY_COLORS_START_IDX + item.velocity));
if (role == Qt::BackgroundRole) {
switch (index.column()) {
case COLOR: return getColor((color_indice_t)(VELOCITY_COLORS_START_IDX + item.velocity));
}
}
return QVariant();
@ -54,20 +54,20 @@ QVariant DivePlotDataModel::headerData(int section, Qt::Orientation orientation,
if (role != Qt::DisplayRole)
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");
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");
}
return QVariant();
}
void DivePlotDataModel::clear()
{
if(rowCount() != 0){
if (rowCount() != 0) {
beginRemoveRows(QModelIndex(), 0, rowCount() - 1);
endRemoveRows();
}

View file

@ -10,6 +10,7 @@
DiveProfileItem::DiveProfileItem(): QObject(), QGraphicsPolygonItem(),
hAxis(NULL), hDataColumn(-1), dataModel(NULL), vAxis(NULL), vDataColumn(-1)
{
}
void DiveProfileItem::setHorizontalAxis(DiveCartesianAxis* horizontal)
@ -54,7 +55,7 @@ void DiveProfileItem::modelDataChanged()
// is an array of QPointF's, so we basically get the point from the model, convert
// to our coordinates, store. no painting is done here.
QPolygonF poly;
for(int i = 0, modelDataCount = dataModel->rowCount(); i < modelDataCount; i++){
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));
@ -70,7 +71,7 @@ void DiveProfileItem::modelDataChanged()
setBrush(QBrush(pat));
}
void DiveProfileItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget){
void DiveProfileItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) {
Q_UNUSED(widget);
// This paints the Polygon + Background. I'm setting the pen to QPen() so we don't get a black line here,
@ -84,7 +85,7 @@ void DiveProfileItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* o
pen.setCosmetic(true);
pen.setWidth(2);
// This paints the colors of the velocities.
for(int i = 1, count = dataModel->rowCount(); i < count; i++){
for (int i = 1, count = dataModel->rowCount(); i < count; i++) {
QModelIndex colorIndex = dataModel->index(i, DivePlotDataModel::COLOR);
pen.setBrush(QBrush(colorIndex.data(Qt::BackgroundRole).value<QColor>()));
painter->setPen(pen);

View file

@ -2,4 +2,5 @@
DiveRectItem::DiveRectItem(QObject* parent, QGraphicsItem* parentItem): QObject(parent), QGraphicsRectItem(parentItem )
{
}

View file

@ -29,9 +29,9 @@ void DiveTextItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* opti
//
// // if (internalAlignFlags & Qt::AlignLeft )
// // painter->translate(); // This is the default, uneeded.
// if(internalAlignFlags & Qt::AlignHCenter)
// if (internalAlignFlags & Qt::AlignHCenter)
// painter->translate(-rect.width()/2, 0);
// else if(internalAlignFlags & Qt::AlignRight)
// else if (internalAlignFlags & Qt::AlignRight)
// painter->translate(-rect.width(), 0);
QGraphicsSimpleTextItem::paint(painter, option, widget);
@ -45,4 +45,4 @@ void DiveTextItem::animatedHide()
void DiveTextItem::animateMoveTo(qreal x, qreal y)
{
Animations::moveTo(this, x, y);
}
}

View file

@ -46,7 +46,7 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) :
gasYAxis->setOrientation(Qt::Vertical);
timeAxis->setOrientation(Qt::Horizontal);
// Defaults of the Axis Coordinates:
// Defaults of the Axis Coordinates:
profileYAxis->setMinimum(0);
profileYAxis->setTickInterval(M_OR_FT(10,30)); //TODO: This one should be also hooked up on the Settings change.
timeAxis->setMinimum(0);
@ -65,15 +65,15 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) :
timeController->setX(sceneRect().width() - timeController->boundingRect().width()); // Position it on the right spot.
// insert in the same way it's declared on the Enum. This is needed so we don't use an map.
QList<QGraphicsItem*> stateItems; stateItems << background << profileYAxis << gasYAxis
<< timeAxis << depthController << timeController;
Q_FOREACH(QGraphicsItem *item, stateItems){
QList<QGraphicsItem*> stateItems; stateItems << background << profileYAxis << gasYAxis <<
timeAxis << depthController << timeController;
Q_FOREACH(QGraphicsItem *item, stateItems) {
scene()->addItem(item);
}
background->setFlag(QGraphicsItem::ItemIgnoresTransformations);
//enum State{ EMPTY, PROFILE, EDIT, ADD, PLAN, INVALID };
//enum State{ EMPTY, PROFILE, EDIT, ADD, PLAN, INVALID };
stateMachine = new QStateMachine(this);
// TopLevel States
@ -135,7 +135,7 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) :
const QLineF profileYAxisExpanded = QLineF(0,0,0,timeAxisOnCanvas);
const QLineF timeAxisLine = QLineF(0, 0, 96, 0);
// State Defaults:
// State Defaults:
// Empty State, everything but the background is hidden.
emptyState->assignProperty(this, "backgroundBrush", QBrush(Qt::white));
emptyState->assignProperty(background, "y", backgroundOnCanvas);
@ -145,7 +145,7 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) :
emptyState->assignProperty(depthController, "y", depthControllerOffCanvas);
emptyState->assignProperty(timeController, "y", timeControllerOffCanvas);
// Profile, everything but the background, depthController and timeController are shown.
// Profile, everything but the background, depthController and timeController are shown.
profileState->assignProperty(this, "backgroundBrush", getColor(::BACKGROUND));
profileState->assignProperty(background, "y", backgroundOffCanvas);
profileState->assignProperty(profileYAxis, "x", profileYAxisOnCanvas);
@ -196,10 +196,10 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) :
// Animations
QList<QSignalTransition*> transitions;
transitions << tAddToEmpty << tAddToPlan << tAddToProfile << tEditToAdd << tEditToEmpty << tEditToPlan
<< tEditToProfile << tEmptyToAdd << tEmptyToPlan << tEmptyToProfile << tProfileToAdd << tProfileToEdit
<< tProfileToEmpty << tProfileToPlan << tPlanToAdd << tPlanToEmpty << tPlanToProfile;
Q_FOREACH(QSignalTransition *s, transitions){
transitions << tAddToEmpty << tAddToPlan << tAddToProfile << tEditToAdd << tEditToEmpty << tEditToPlan <<
tEditToProfile << tEmptyToAdd << tEmptyToPlan << tEmptyToProfile << tProfileToAdd <<
tProfileToEdit << tProfileToEmpty << tProfileToPlan << tPlanToAdd << tPlanToEmpty << tPlanToProfile;
Q_FOREACH(QSignalTransition *s, transitions) {
s->addAnimation(backgroundYAnim);
s->addAnimation(depthAxisAnim);
s->addAnimation(gasAxisanim);
@ -232,7 +232,7 @@ void ProfileWidget2::plotDives(QList<dive*> dives)
// I Know that it's a list, but currently we are
// using just the first.
struct dive *d = dives.first();
if(!d)
if (!d)
return;
// Here we need to probe for the limits of the dive.
@ -257,7 +257,7 @@ void ProfileWidget2::plotDives(QList<dive*> dives)
timeAxis->updateTicks();
dataModel->setDive(current_dive, pInfo);
if(diveProfileItem){
if (diveProfileItem) {
//diveProfileItem->animateDelete();
scene()->removeItem(diveProfileItem);
delete diveProfileItem;
@ -294,10 +294,10 @@ void ProfileWidget2::resizeEvent(QResizeEvent* event)
QGraphicsView::resizeEvent(event);
fitInView(sceneRect(), Qt::IgnoreAspectRatio);
if(!stateMachine->configuration().count())
if (!stateMachine->configuration().count())
return;
if ((*stateMachine->configuration().begin())->objectName() == "Empty State"){
if ((*stateMachine->configuration().begin())->objectName() == "Empty State") {
fixBackgroundPos();
}
}
@ -305,7 +305,7 @@ void ProfileWidget2::resizeEvent(QResizeEvent* event)
void ProfileWidget2::fixBackgroundPos()
{
QPixmap p = QPixmap(":background").scaledToHeight(viewport()->height());
int x = viewport()->width()/2 - p.width()/2;
int x = viewport()->width() / 2 - p.width() / 2;
DivePixmapItem *bg = background;
bg->setPixmap(p);
bg->setX(mapToScene(x, 0).x());