Automated whitespace / coding style correction

First attempt to use the tools on one of our source files.
So far so good. Not perfect, but a HUGE improvement.

Most importantly it effortlessly fixed the Allman style braces introduced
in commit 51220f26ef ("Add recent files to main menu.").

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2014-02-13 22:11:05 -08:00
parent ebac81b784
commit f26896da1b

View file

@ -70,8 +70,8 @@ MainWindow::MainWindow() : QMainWindow(),
ui.ListWidget->reloadHeaderActions(); ui.ListWidget->reloadHeaderActions();
ui.ListWidget->setFocus(); ui.ListWidget->setFocus();
ui.globe->reload(); ui.globe->reload();
ui.ListWidget->expand(ui.ListWidget->model()->index(0,0)); ui.ListWidget->expand(ui.ListWidget->model()->index(0, 0));
ui.ListWidget->scrollTo(ui.ListWidget->model()->index(0,0), QAbstractItemView::PositionAtCenter); ui.ListWidget->scrollTo(ui.ListWidget->model()->index(0, 0), QAbstractItemView::PositionAtCenter);
ui.divePlanner->settingsChanged(); ui.divePlanner->settingsChanged();
ui.divePlannerWidget->settingsChanged(); ui.divePlannerWidget->settingsChanged();
@ -116,7 +116,7 @@ void MainWindow::current_dive_changed(int divenr)
* a single profile plot on the canvas. I know that we are using only one right now, * a single profile plot on the canvas. I know that we are using only one right now,
* but let's keep like this so it's easy to change when we need? :) * but let's keep like this so it's easy to change when we need? :)
*/ */
ui.newProfile->plotDives( QList<dive*>() << (current_dive) ); ui.newProfile->plotDives(QList<dive *>() << (current_dive));
ui.InfoWidget->updateDiveInfo(divenr); ui.InfoWidget->updateDiveInfo(divenr);
} }
@ -142,7 +142,7 @@ void MainWindow::on_actionOpen_triggered()
return; return;
updateLastUsedDir(QFileInfo(filename).dir().path()); updateLastUsedDir(QFileInfo(filename).dir().path());
on_actionClose_triggered(); on_actionClose_triggered();
loadFiles( QStringList() << filename ); loadFiles(QStringList() << filename);
} }
QTabWidget *MainWindow::tabWidget() QTabWidget *MainWindow::tabWidget()
@ -213,7 +213,7 @@ QString MainWindow::lastUsedDir()
return lastDir; return lastDir;
} }
void MainWindow::updateLastUsedDir(const QString& dir) void MainWindow::updateLastUsedDir(const QString &dir)
{ {
QSettings s; QSettings s;
s.beginGroup("FileDialog"); s.beginGroup("FileDialog");
@ -478,14 +478,16 @@ void MainWindow::on_actionViewAll_triggered()
redrawProfile(); redrawProfile();
} }
void MainWindow::beginChangeState(CurrentState s) { void MainWindow::beginChangeState(CurrentState s)
{
if (state == VIEWALL && state != s) { if (state == VIEWALL && state != s) {
saveSplitterSizes(); saveSplitterSizes();
} }
state = s; state = s;
} }
void MainWindow::saveSplitterSizes() { void MainWindow::saveSplitterSizes()
{
QSettings settings; QSettings settings;
settings.beginGroup("MainWindow"); settings.beginGroup("MainWindow");
settings.setValue("mainSplitter", ui.mainSplitter->saveState()); settings.setValue("mainSplitter", ui.mainSplitter->saveState());
@ -497,7 +499,7 @@ void MainWindow::on_actionPreviousDC_triggered()
{ {
dc_number--; dc_number--;
ui.InfoWidget->updateDiveInfo(selected_dive); ui.InfoWidget->updateDiveInfo(selected_dive);
ui.newProfile->plotDives(QList<struct dive*>() << (current_dive)); ui.newProfile->plotDives(QList<struct dive *>() << (current_dive));
redrawProfile(); redrawProfile();
} }
@ -505,7 +507,7 @@ void MainWindow::on_actionNextDC_triggered()
{ {
dc_number++; dc_number++;
ui.InfoWidget->updateDiveInfo(selected_dive); ui.InfoWidget->updateDiveInfo(selected_dive);
ui.newProfile->plotDives(QList<struct dive*>() << (current_dive)); ui.newProfile->plotDives(QList<struct dive *>() << (current_dive));
redrawProfile(); redrawProfile();
} }
@ -602,13 +604,23 @@ void MainWindow::initialUiSetup()
else else
resize(sz); resize(sz);
state = (CurrentState) settings.value("lastState", 0).toInt(); state = (CurrentState)settings.value("lastState", 0).toInt();
switch (state) { switch (state) {
case VIEWALL: on_actionViewAll_triggered(); break; case VIEWALL:
case GLOBE_MAXIMIZED : on_actionViewGlobe_triggered(); break; on_actionViewAll_triggered();
case INFO_MAXIMIZED : on_actionViewInfo_triggered(); break; break;
case LIST_MAXIMIZED : on_actionViewList_triggered(); break; case GLOBE_MAXIMIZED:
case PROFILE_MAXIMIZED : on_actionViewProfile_triggered(); break; on_actionViewGlobe_triggered();
break;
case INFO_MAXIMIZED:
on_actionViewInfo_triggered();
break;
case LIST_MAXIMIZED:
on_actionViewList_triggered();
break;
case PROFILE_MAXIMIZED:
on_actionViewProfile_triggered();
break;
} }
settings.endGroup(); settings.endGroup();
} }
@ -635,7 +647,6 @@ void MainWindow::readSettings()
ui.profPO2->setChecked(s.value("po2graph").toBool()); ui.profPO2->setChecked(s.value("po2graph").toBool());
ui.profRuler->setChecked(s.value("rulergraph").toBool()); ui.profRuler->setChecked(s.value("rulergraph").toBool());
ui.profSAC->setChecked(s.value("show_sac").toBool()); ui.profSAC->setChecked(s.value("show_sac").toBool());
} }
void MainWindow::writeSettings() void MainWindow::writeSettings()
@ -643,7 +654,7 @@ void MainWindow::writeSettings()
QSettings settings; QSettings settings;
settings.beginGroup("MainWindow"); settings.beginGroup("MainWindow");
settings.setValue("lastState", (int) state); settings.setValue("lastState", (int)state);
settings.setValue("maximized", isMaximized()); settings.setValue("maximized", isMaximized());
if (!isMaximized()) if (!isMaximized())
settings.setValue("size", size()); settings.setValue("size", size());
@ -674,22 +685,22 @@ void MainWindow::closeEvent(QCloseEvent *event)
writeSettings(); writeSettings();
} }
DiveListView* MainWindow::dive_list() DiveListView *MainWindow::dive_list()
{ {
return ui.ListWidget; return ui.ListWidget;
} }
GlobeGPS* MainWindow::globe() GlobeGPS *MainWindow::globe()
{ {
return ui.globe; return ui.globe;
} }
ProfileGraphicsView* MainWindow::graphics() ProfileGraphicsView *MainWindow::graphics()
{ {
return ui.ProfileWidget; return ui.ProfileWidget;
} }
MainTab* MainWindow::information() MainTab *MainWindow::information()
{ {
return ui.InfoWidget; return ui.InfoWidget;
} }
@ -700,42 +711,29 @@ void MainWindow::loadRecentFiles(QSettings *s)
bool modified = false; bool modified = false;
s->beginGroup("Recent_Files"); s->beginGroup("Recent_Files");
for (int c = 1; c <= 4; c++) for (int c = 1; c <= 4; c++) {
{
QString key = QString("File_%1").arg(c); QString key = QString("File_%1").arg(c);
if (s->contains(key)) if (s->contains(key)) {
{
QString file = s->value(key).toString(); QString file = s->value(key).toString();
if (QFile::exists(file)) if (QFile::exists(file)) {
{
files.append(file); files.append(file);
} } else {
else
{
modified = true; modified = true;
} }
} } else {
else
{
break; break;
} }
} }
if (modified) if (modified) {
{ for (int c = 0; c < 4; c++) {
for (int c = 0; c < 4; c++)
{
QString key = QString("File_%1").arg(c + 1); QString key = QString("File_%1").arg(c + 1);
if (files.count() > c) if (files.count() > c) {
{
s->setValue(key, files.at(c)); s->setValue(key, files.at(c));
} } else {
else if (s->contains(key)) {
{
if (s->contains(key))
{
s->remove(key); s->remove(key);
} }
} }
@ -745,19 +743,15 @@ void MainWindow::loadRecentFiles(QSettings *s)
} }
s->endGroup(); s->endGroup();
for (int c = 0; c < 4; c++) for (int c = 0; c < 4; c++) {
{
QAction *action = this->findChild<QAction *>(QString("actionRecent%1").arg(c + 1)); QAction *action = this->findChild<QAction *>(QString("actionRecent%1").arg(c + 1));
if (files.count() > c) if (files.count() > c) {
{
QFileInfo fi(files.at(c)); QFileInfo fi(files.at(c));
action->setText(fi.fileName()); action->setText(fi.fileName());
action->setToolTip(fi.absoluteFilePath()); action->setToolTip(fi.absoluteFilePath());
action->setVisible(true); action->setVisible(true);
} } else {
else
{
action->setVisible(false); action->setVisible(false);
} }
} }
@ -768,63 +762,48 @@ void MainWindow::addRecentFile(const QStringList &newFiles)
QStringList files; QStringList files;
QSettings s; QSettings s;
if (newFiles.isEmpty()) if (newFiles.isEmpty()) {
{
return; return;
} }
s.beginGroup("Recent_Files"); s.beginGroup("Recent_Files");
for (int c = 1; c <= 4; c++) for (int c = 1; c <= 4; c++) {
{
QString key = QString("File_%1").arg(c); QString key = QString("File_%1").arg(c);
if (s.contains(key)) if (s.contains(key)) {
{
QString file = s.value(key).toString(); QString file = s.value(key).toString();
files.append(file); files.append(file);
} } else {
else
{
break; break;
} }
} }
foreach(const QString &file, newFiles) foreach(const QString & file, newFiles) {
{
int index = files.indexOf(file); int index = files.indexOf(file);
if (index >= 0) if (index >= 0) {
{
files.removeAt(index); files.removeAt(index);
} }
} }
foreach(const QString &file, newFiles) foreach(const QString & file, newFiles) {
{ if (QFile::exists(file)) {
if (QFile::exists(file))
{
files.prepend(file); files.prepend(file);
} }
} }
while(files.count() > 4) while (files.count() > 4) {
{
files.removeLast(); files.removeLast();
} }
for (int c = 0; c < 4; c++) for (int c = 0; c < 4; c++) {
{
QString key = QString("File_%1").arg(c + 1); QString key = QString("File_%1").arg(c + 1);
if (files.count() > c) if (files.count() > c) {
{
s.setValue(key, files.at(c)); s.setValue(key, files.at(c));
} } else {
else if (s.contains(key)) {
{
if (s.contains(key))
{
s.remove(key); s.remove(key);
} }
} }
@ -883,7 +862,7 @@ void MainWindow::file_save(void)
ui.InfoWidget->acceptChanges(); ui.InfoWidget->acceptChanges();
current_default = prefs.default_filename; current_default = prefs.default_filename;
if (strcmp(existing_filename, current_default) == 0) { if (strcmp(existing_filename, current_default) == 0) {
/* if we are using the default filename the directory /* if we are using the default filename the directory
* that we are creating the file in may not exist */ * that we are creating the file in may not exist */
QDir current_def_dir = QFileInfo(current_default).absoluteDir(); QDir current_def_dir = QFileInfo(current_default).absoluteDir();
@ -979,7 +958,7 @@ void MainWindow::on_actionImportDiveLog_triggered()
return; return;
updateLastUsedDir(QFileInfo(fileNames[0]).dir().path()); updateLastUsedDir(QFileInfo(fileNames[0]).dir().path());
QStringList logFiles = fileNames.filter( QRegExp("^.*\\.(?!csv)", Qt::CaseInsensitive) ) ; QStringList logFiles = fileNames.filter(QRegExp("^.*\\.(?!csv)", Qt::CaseInsensitive));
QStringList csvFiles = fileNames.filter(".csv", Qt::CaseInsensitive); QStringList csvFiles = fileNames.filter(".csv", Qt::CaseInsensitive);
if (logFiles.size()) { if (logFiles.size()) {
importFiles(logFiles); importFiles(logFiles);
@ -1020,9 +999,9 @@ void MainWindow::editCurrentDive()
} }
} }
#define TOOLBOX_PREF_PROFILE(PREFS)\ #define TOOLBOX_PREF_PROFILE(PREFS) \
QSettings s; \ QSettings s; \
s.beginGroup("TecDetails"); \ s.beginGroup("TecDetails"); \
s.setValue(#PREFS, triggered); \ s.setValue(#PREFS, triggered); \
PreferencesDialog::instance()->emitSettingsChanged(); PreferencesDialog::instance()->emitSettingsChanged();