mirror of
https://github.com/subsurface/subsurface.git
synced 2024-12-02 23:20:20 +00:00
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:
parent
3387ccc6f6
commit
a27f67c026
28 changed files with 387 additions and 323 deletions
63
CodingStyle
Normal file
63
CodingStyle
Normal file
|
@ -0,0 +1,63 @@
|
|||
- all indentation is tabs (set to 8 char) with the exception of
|
||||
continuation lines that are alligned with tabs and then spaces
|
||||
|
||||
- all keywords followed by a '(' have a space in between
|
||||
|
||||
if (condition)
|
||||
|
||||
for (i = 0; i < 5; i++)
|
||||
|
||||
- function calls do NOT have a space between their name and argument
|
||||
|
||||
i = some_function(argument);
|
||||
|
||||
- usually there is no space on the inside of parenthesis (see examples
|
||||
above)
|
||||
|
||||
- function / method implementations have their opening curly braces in
|
||||
column 1
|
||||
|
||||
- all other opening curly braces follow at the end of the line, with a
|
||||
space separating them:
|
||||
|
||||
if (condition) {
|
||||
dosomething();
|
||||
}
|
||||
|
||||
- both sides of an if / else clause either use or do not use curly braces:
|
||||
|
||||
if (condition)
|
||||
i = 4;
|
||||
else
|
||||
j = 6;
|
||||
|
||||
if (condition) {
|
||||
i = 6;
|
||||
} else {
|
||||
i = 4;
|
||||
j = 6;
|
||||
}
|
||||
|
||||
- use space to make visual separation easier
|
||||
|
||||
a = b + 3 + e / 4;
|
||||
|
||||
- continuation lines have the operator / comma at the end
|
||||
|
||||
if (very_long_conditiont_1 ||
|
||||
condition_2)
|
||||
|
||||
b = a + (c + d +
|
||||
f + z);
|
||||
|
||||
- unfortunate inconsistency:
|
||||
-- C code usually uses underscores to structure names
|
||||
|
||||
variable_in_C
|
||||
|
||||
-- C++ code usually uses camelCase
|
||||
|
||||
variableInCPlusPlus
|
||||
|
||||
where the two meet, use your best judgment and go for best consistency
|
||||
(i.e., where does the variable "originate")
|
|
@ -65,7 +65,8 @@ DiveListView::~DiveListView()
|
|||
settings.endGroup();
|
||||
}
|
||||
|
||||
void DiveListView::setupUi(){
|
||||
void DiveListView::setupUi()
|
||||
{
|
||||
QSettings settings;
|
||||
static bool firstRun = true;
|
||||
if (firstRun)
|
||||
|
@ -103,14 +104,16 @@ int DiveListView::lastVisibleColumn()
|
|||
return lastColumn;
|
||||
}
|
||||
|
||||
void DiveListView::backupExpandedRows(){
|
||||
void DiveListView::backupExpandedRows()
|
||||
{
|
||||
expandedRows.clear();
|
||||
for(int i = 0; i < model()->rowCount(); i++)
|
||||
if (isExpanded( model()->index(i, 0) ))
|
||||
expandedRows.push_back(i);
|
||||
}
|
||||
|
||||
void DiveListView::restoreExpandedRows(){
|
||||
void DiveListView::restoreExpandedRows()
|
||||
{
|
||||
setAnimated(false);
|
||||
Q_FOREACH(const int &i, expandedRows)
|
||||
setExpanded( model()->index(i, 0), true );
|
||||
|
|
|
@ -665,8 +665,7 @@ bool DivePlannerGraphics::isPointOutOfBoundaries(const QPointF& point)
|
|||
if (xpos > timeLine->maximum() ||
|
||||
xpos < timeLine->minimum() ||
|
||||
ypos > depthLine->maximum() ||
|
||||
ypos < depthLine->minimum())
|
||||
{
|
||||
ypos < depthLine->minimum()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -125,7 +125,8 @@ void MainWindow::on_actionOpen_triggered()
|
|||
loadFiles( QStringList() << filename );
|
||||
}
|
||||
|
||||
QTabWidget *MainWindow::tabWidget(){
|
||||
QTabWidget *MainWindow::tabWidget()
|
||||
{
|
||||
return ui.tabWidget;
|
||||
}
|
||||
void MainWindow::on_actionSave_triggered()
|
||||
|
@ -481,8 +482,7 @@ void MainWindow::on_actionFullScreen_triggered(bool checked)
|
|||
{
|
||||
if (checked) {
|
||||
setWindowState(windowState() | Qt::WindowFullScreen);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
setWindowState(windowState() & ~Qt::WindowFullScreen);
|
||||
}
|
||||
}
|
||||
|
@ -693,9 +693,8 @@ void MainWindow::writeSettings()
|
|||
settings.setValue("maximized", isMaximized());
|
||||
if (!isMaximized())
|
||||
settings.setValue("size", size());
|
||||
if (state == VIEWALL){
|
||||
if (state == VIEWALL)
|
||||
saveSplitterSizes();
|
||||
}
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
|
@ -900,8 +899,7 @@ void MainWindow::editCurrentDive()
|
|||
ui.infoPane->setCurrentIndex(MAINTAB);
|
||||
DivePlannerPointsModel::instance()->loadFromDive(d);
|
||||
ui.InfoWidget->enableEdition(MainTab::MANUALLY_ADDED_DIVE);
|
||||
}
|
||||
else if (defaultDC == "planned dive"){
|
||||
} else if (defaultDC == "planned dive") {
|
||||
disableDcShortcuts();
|
||||
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::PLAN);
|
||||
ui.stackedWidget->setCurrentIndex(PLANNERPROFILE); // Planner.
|
||||
|
|
|
@ -26,13 +26,14 @@ QSize DiveListDelegate::sizeHint(const QStyleOptionViewItem& option, const QMode
|
|||
|
||||
// Gets the index of the model in the currentRow and column.
|
||||
// currCombo is defined below.
|
||||
#define IDX( XX ) mymodel->index(currCombo.currRow, XX)
|
||||
#define IDX(_XX) mymodel->index(currCombo.currRow, (_XX))
|
||||
static bool keyboardFinished = false;
|
||||
|
||||
StarWidgetsDelegate::StarWidgetsDelegate(QWidget* parent):
|
||||
QStyledItemDelegate(parent),
|
||||
parentWidget(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void StarWidgetsDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
|
||||
|
@ -169,12 +170,11 @@ bool ComboBoxDelegate::eventFilter(QObject* object, QEvent* event)
|
|||
currCombo.activeText = currCombo.comboEditor->currentText();
|
||||
keyboardFinished = true;
|
||||
}
|
||||
}
|
||||
else{ // the 'Drop Down Menu' part.
|
||||
} else { // the 'Drop Down Menu' part.
|
||||
QKeyEvent *ev = static_cast<QKeyEvent*>(event);
|
||||
if( ev->key() == Qt::Key_Enter || ev->key() == Qt::Key_Return
|
||||
|| ev->key() == Qt::Key_Tab || ev->key() == Qt::Key_Backtab
|
||||
|| ev->key() == Qt::Key_Escape){
|
||||
if (ev->key() == Qt::Key_Enter || ev->key() == Qt::Key_Return ||
|
||||
ev->key() == Qt::Key_Tab || ev->key() == Qt::Key_Backtab ||
|
||||
ev->key() == Qt::Key_Escape) {
|
||||
// treat Qt as a silly little boy - pretending that the key_return nwas pressed on the combo,
|
||||
// instead of the list of choices. this can be extended later for
|
||||
// other imputs, like tab navigation and esc.
|
||||
|
|
|
@ -27,6 +27,7 @@ void DiveCartesianAxis::setTextColor(const QColor& color)
|
|||
|
||||
DiveCartesianAxis::DiveCartesianAxis() : orientation(Qt::Horizontal)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
DiveCartesianAxis::~DiveCartesianAxis()
|
||||
|
@ -71,8 +72,7 @@ void DiveCartesianAxis::updateTicks()
|
|||
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);
|
||||
}
|
||||
|
@ -97,8 +97,7 @@ void DiveCartesianAxis::updateTicks()
|
|||
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);
|
||||
|
|
|
@ -2,4 +2,5 @@
|
|||
|
||||
DivePixmapItem::DivePixmapItem(QObject* parent): QObject(parent), QGraphicsPixmapItem()
|
||||
{
|
||||
|
||||
}
|
|
@ -10,6 +10,7 @@
|
|||
DiveProfileItem::DiveProfileItem(): QObject(), QGraphicsPolygonItem(),
|
||||
hAxis(NULL), hDataColumn(-1), dataModel(NULL), vAxis(NULL), vDataColumn(-1)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DiveProfileItem::setHorizontalAxis(DiveCartesianAxis* horizontal)
|
||||
|
|
|
@ -2,4 +2,5 @@
|
|||
|
||||
DiveRectItem::DiveRectItem(QObject* parent, QGraphicsItem* parentItem): QObject(parent), QGraphicsRectItem(parentItem )
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -65,8 +65,8 @@ 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;
|
||||
QList<QGraphicsItem*> stateItems; stateItems << background << profileYAxis << gasYAxis <<
|
||||
timeAxis << depthController << timeController;
|
||||
Q_FOREACH(QGraphicsItem *item, stateItems) {
|
||||
scene()->addItem(item);
|
||||
}
|
||||
|
@ -196,9 +196,9 @@ 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;
|
||||
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);
|
||||
|
|
|
@ -52,7 +52,8 @@ extern int evn_used;
|
|||
QPoint(viewport()->geometry().width() - toolBarProxy->boundingRect().width(), \
|
||||
viewport()->geometry().height() - toolBarProxy->boundingRect().height() )
|
||||
|
||||
ProfileGraphicsView::ProfileGraphicsView(QWidget* parent) : QGraphicsView(parent), toolTip(0) , diveId(0), diveDC(0), rulerItem(0), toolBarProxy(0)
|
||||
ProfileGraphicsView::ProfileGraphicsView(QWidget* parent) : QGraphicsView(parent),
|
||||
toolTip(0) , diveId(0), diveDC(0), rulerItem(0), toolBarProxy(0)
|
||||
{
|
||||
printMode = false;
|
||||
isGrayscale = false;
|
||||
|
@ -269,9 +270,9 @@ void ProfileGraphicsView::mouseMoveEvent(QMouseEvent* event)
|
|||
QPoint toolTipPos = mapFromScene(toolTip->pos());
|
||||
scrollViewTo(event->pos());
|
||||
|
||||
if (zoomLevel == 0)
|
||||
if (zoomLevel == 0) {
|
||||
QGraphicsView::mouseMoveEvent(event);
|
||||
else{
|
||||
} else {
|
||||
toolTip->setPos(mapToScene(toolTipPos));
|
||||
toolBarProxy->setPos(mapToScene(TOOLBAR_POS));
|
||||
}
|
||||
|
@ -1683,11 +1684,9 @@ void RulerNodeItem::recalculate()
|
|||
uint16_t count = 0;
|
||||
if (x() < 0) {
|
||||
setPos(0, y());
|
||||
}
|
||||
else if (x() > SCALEXGC(data->sec)) {
|
||||
} else if (x() > SCALEXGC(data->sec)) {
|
||||
setPos(SCALEXGC(data->sec), y());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
data = pi->entry;
|
||||
count=0;
|
||||
while (SCALEXGC(data->sec) < x() && count < pi->nr) {
|
||||
|
|
|
@ -60,8 +60,9 @@ double MinMaxAvgWidget::minimum() const
|
|||
return d->minValue->text().toDouble();
|
||||
}
|
||||
|
||||
MinMaxAvgWidget::MinMaxAvgWidget(QWidget* parent)
|
||||
: d(new MinMaxAvgWidgetPrivate(this)){
|
||||
MinMaxAvgWidget::MinMaxAvgWidget(QWidget* parent) : d(new MinMaxAvgWidgetPrivate(this))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
MinMaxAvgWidget::~MinMaxAvgWidget()
|
||||
|
|
|
@ -45,7 +45,8 @@ void TableView::setTitle(const QString& title)
|
|||
ui.groupBox->setTitle(title);
|
||||
}
|
||||
|
||||
void TableView::setModel(QAbstractItemModel *model){
|
||||
void TableView::setModel(QAbstractItemModel *model)
|
||||
{
|
||||
ui.tableView->setModel(model);
|
||||
connect(ui.tableView, SIGNAL(clicked(QModelIndex)), model, SLOT(remove(QModelIndex)));
|
||||
|
||||
|
@ -80,10 +81,12 @@ void TableView::showEvent(QShowEvent* event)
|
|||
fixPlusPosition();
|
||||
}
|
||||
|
||||
void TableView::edit(const QModelIndex& index){
|
||||
void TableView::edit(const QModelIndex& index)
|
||||
{
|
||||
ui.tableView->edit(index);
|
||||
}
|
||||
|
||||
QTableView *TableView::view(){
|
||||
QTableView *TableView::view()
|
||||
{
|
||||
return ui.tableView;
|
||||
}
|
||||
|
|
|
@ -18,13 +18,11 @@ TagWidget::TagWidget(QWidget *parent) : GroupedLineEdit(parent), m_completer(NUL
|
|||
addColor( QColor(Qt::red).lighter(120) );
|
||||
addColor( QColor(Qt::green).lighter(120) );
|
||||
addColor( QColor(Qt::blue).lighter(120) );
|
||||
}
|
||||
else if ( l <= 0.6 ){ // moderated dark text. get a somewhat brigth background
|
||||
} else if ( l <= 0.6 ) { // moderated dark text. get a somewhat brigth background
|
||||
addColor( QColor(Qt::red).lighter(60) );
|
||||
addColor( QColor(Qt::green).lighter(60) );
|
||||
addColor( QColor(Qt::blue).lighter(60) );
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
addColor( QColor(Qt::red).darker(120) );
|
||||
addColor( QColor(Qt::green).darker(120) );
|
||||
addColor( QColor(Qt::blue).darker(120) );
|
||||
|
@ -125,10 +123,9 @@ void TagWidget::reparse()
|
|||
QAbstractItemView *popup = m_completer->popup();
|
||||
if (popup)
|
||||
popup->hide();
|
||||
}
|
||||
else
|
||||
} else {
|
||||
m_completer->complete();
|
||||
|
||||
}
|
||||
} else {
|
||||
m_completer->complete();
|
||||
}
|
||||
|
@ -141,8 +138,7 @@ void TagWidget::completionSelected(QString completion) {
|
|||
if (pos.first >= 0 && pos.second > 0) {
|
||||
setText(text().remove(pos.first, pos.second-pos.first).insert(pos.first, completion));
|
||||
setCursorPosition(pos.first+completion.length());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
setText(completion.append(", "));
|
||||
setCursorPosition(text().length());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue