Small whitespace updates

We aren't really consistent. And I don't do this often enough. But based
on a few things that I saw in a recent commit, I wanted to at least fix
those. And then of course fixed everything in those two files.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2017-12-24 08:39:21 -08:00
parent 734bd6d459
commit eec69de7ab
2 changed files with 37 additions and 40 deletions

View file

@ -162,14 +162,14 @@ void RenumberDialog::buttonClicked(QAbstractButton *button)
if (ui.buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole) {
MainWindow::instance()->dive_list()->rememberSelection();
// we remember a map from dive uuid to a pair of old number / new number
QMap<int,QPair<int, int> > renumberedDives;
QMap<int, QPair<int, int>> renumberedDives;
int i;
int newNr = ui.spinBox->value();
struct dive *dive = NULL;
for_each_dive (i, dive) {
if (!selectedOnly || dive->selected) {
invalidate_dive_cache(dive);
renumberedDives.insert(dive->id, QPair<int,int>(dive->number, newNr++));
renumberedDives.insert(dive->id, QPair<int, int>(dive->number, newNr++));
}
}
UndoRenumberDives *undoCommand = new UndoRenumberDives(renumberedDives);
@ -214,8 +214,7 @@ void SetpointDialog::buttonClicked(QAbstractButton *button)
MainWindow::instance()->graphics()->replot();
}
SetpointDialog::SetpointDialog(QWidget *parent) :
QDialog(parent),
SetpointDialog::SetpointDialog(QWidget *parent) : QDialog(parent),
dc(0)
{
ui.setupUi(this);
@ -281,8 +280,7 @@ void ShiftTimesDialog::changeTime()
ui.shiftedTime->setText(get_dive_date_string(amount + when));
}
ShiftTimesDialog::ShiftTimesDialog(QWidget *parent) :
QDialog(parent),
ShiftTimesDialog::ShiftTimesDialog(QWidget *parent) : QDialog(parent),
when(0)
{
ui.setupUi(this);
@ -346,8 +344,7 @@ bool ShiftImageTimesDialog::matchAll()
return matchAllImages;
}
ShiftImageTimesDialog::ShiftImageTimesDialog(QWidget *parent, QStringList fileNames) :
QDialog(parent),
ShiftImageTimesDialog::ShiftImageTimesDialog(QWidget *parent, QStringList fileNames) : QDialog(parent),
fileNames(fileNames),
m_amount(0),
matchAllImages(false)
@ -359,7 +356,7 @@ ShiftImageTimesDialog::ShiftImageTimesDialog(QWidget *parent, QStringList fileNa
connect(ui.backwards, SIGNAL(toggled(bool)), this, SLOT(timeEditChanged()));
connect(ui.matchAllImages, SIGNAL(toggled(bool)), this, SLOT(matchAllImagesToggled(bool)));
dcImageEpoch = (time_t)0;
updateInvalid();
}
@ -409,7 +406,7 @@ void ShiftImageTimesDialog::updateInvalid()
allValid = false;
}
if (!allValid){
if (!allValid) {
ui.warningLabel->show();
ui.invalidFilesText->show();
}
@ -419,15 +416,16 @@ void ShiftImageTimesDialog::timeEditChanged(const QTime &time)
{
m_amount = time.hour() * 3600 + time.minute() * 60;
if (ui.backwards->isChecked())
m_amount *= -1;
m_amount *= -1;
updateInvalid();
}
void ShiftImageTimesDialog::timeEditChanged()
{
if ((m_amount > 0) == ui.backwards->isChecked())
m_amount *= -1;
if (m_amount) updateInvalid();
m_amount *= -1;
if (m_amount)
updateInvalid();
}
URLDialog::URLDialog(QWidget *parent) : QDialog(parent)
@ -500,9 +498,8 @@ void DiveComponentSelection::buttonClicked(QAbstractButton *button)
}
}
FilterBase::FilterBase(FilterModelBase *model_, QWidget *parent)
: QWidget(parent)
, model(model_)
FilterBase::FilterBase(FilterModelBase *model_, QWidget *parent) : QWidget(parent),
model(model_)
{
ui.setupUi(this);
#if QT_VERSION >= 0x050200
@ -563,7 +560,7 @@ MultiFilter::MultiFilter(QWidget *parent) : QWidget(parent)
TagFilter *tagFilter = new TagFilter(this);
int minimumHeight = tagFilter->ui.filterInternalList->height() +
tagFilter->ui.verticalLayout->spacing() * tagFilter->ui.verticalLayout->count();
tagFilter->ui.verticalLayout->spacing() * tagFilter->ui.verticalLayout->count();
QListView *dummyList = new QListView();
QStringListModel *dummy = new QStringListModel(QStringList() << "Dummy Text");
@ -582,7 +579,7 @@ MultiFilter::MultiFilter(QWidget *parent) : QWidget(parent)
expandedWidget->setLayout(l);
ui.scrollArea->setWidget(expandedWidget);
expandedWidget->resize(expandedWidget->width(), minimumHeight + dummyList->sizeHintForRow(0) * 5 );
expandedWidget->resize(expandedWidget->width(), minimumHeight + dummyList->sizeHintForRow(0) * 5);
ui.scrollArea->setMinimumHeight(expandedWidget->height() + 5);
connect(MultiFilterSortModel::instance(), SIGNAL(filterFinished()), this, SLOT(filterFinished()));
@ -738,7 +735,8 @@ QString TextHyperlinkEventFilter::fromCursorTilWhitespace(QTextCursor *cursor, c
}
grownText = cursor->selectedText();
if (grownText.size() == oldSize) movedOk = false;
if (grownText.size() == oldSize)
movedOk = false;
oldSize = grownText.size();
noSpaces = grownText.simplified().replace(" ", "");
} while (grownText == noSpaces && movedOk);

View file

@ -12,12 +12,12 @@
#include <QDebug>
#include <algorithm>
#define CREATE_INSTANCE_METHOD( CLASS ) \
CLASS *CLASS::instance() \
{ \
static CLASS *self = new CLASS(); \
return self; \
}
#define CREATE_INSTANCE_METHOD(CLASS) \
CLASS *CLASS::instance() \
{ \
static CLASS *self = new CLASS(); \
return self; \
}
CREATE_INSTANCE_METHOD(TagFilterModel)
CREATE_INSTANCE_METHOD(BuddyFilterModel)
@ -25,8 +25,8 @@ CREATE_INSTANCE_METHOD(LocationFilterModel)
CREATE_INSTANCE_METHOD(SuitsFilterModel)
CREATE_INSTANCE_METHOD(MultiFilterSortModel)
FilterModelBase::FilterModelBase(QObject *parent) : QStringListModel(parent)
, anyChecked(false)
FilterModelBase::FilterModelBase(QObject *parent) : QStringListModel(parent),
anyChecked(false)
{
}
@ -97,22 +97,22 @@ void FilterModelBase::clearFilter()
{
std::fill(checkState.begin(), checkState.end(), false);
anyChecked = false;
emit dataChanged(createIndex(0,0), createIndex(rowCount()-1, 0));
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, 0));
}
void FilterModelBase::selectAll()
{
std::fill(checkState.begin(), checkState.end(), true);
anyChecked = true;
emit dataChanged(createIndex(0,0), createIndex(rowCount()-1, 0));
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, 0));
}
void FilterModelBase::invertSelection()
{
for (char &b: checkState)
for (char &b : checkState)
b = !b;
anyChecked = std::any_of(checkState.begin(), checkState.end(), [](char b){return !!b;});
emit dataChanged(createIndex(0,0), createIndex(rowCount()-1, 0));
anyChecked = std::any_of(checkState.begin(), checkState.end(), [](char b) { return !!b; });
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, 0));
}
SuitsFilterModel::SuitsFilterModel(QObject *parent) : FilterModelBase(parent)
@ -249,7 +249,7 @@ bool BuddyFilterModel::doFilter(dive *d, QModelIndex &index0, QAbstractItemModel
// Checked means 'Show', Unchecked means 'Hide'.
QString persons = QString(d->buddy) + "," + QString(d->divemaster);
QStringList personsList = persons.split(',', QString::SkipEmptyParts);
for (QString &s: personsList)
for (QString &s : personsList)
s = s.trimmed();
// only show empty buddie dives if the user checked that.
if (personsList.isEmpty()) {
@ -373,8 +373,7 @@ void LocationFilterModel::addName(const QString &newName)
checkState.insert(checkState.begin(), true);
}
MultiFilterSortModel::MultiFilterSortModel(QObject *parent) :
QSortFilterProxyModel(parent),
MultiFilterSortModel::MultiFilterSortModel(QObject *parent) : QSortFilterProxyModel(parent),
divesDisplayed(0),
justCleared(false),
curr_dive_site(NULL)
@ -394,14 +393,14 @@ bool MultiFilterSortModel::filterAcceptsRow(int source_row, const QModelIndex &s
bool showTrip = false;
for (int i = 0; i < sourceModel()->rowCount(index0); i++) {
QModelIndex child = sourceModel()->index(i, 0, index0);
d = (struct dive *) sourceModel()->data(child, DiveTripModel::DIVE_ROLE).value<void*>();
d = (struct dive *)sourceModel()->data(child, DiveTripModel::DIVE_ROLE).value<void *>();
ds = get_dive_site_by_uuid(d->dive_site_uuid);
if (!ds)
continue;
if ( same_string(ds->name, curr_dive_site->name) || ds->uuid == curr_dive_site->uuid) {
if (same_string(ds->name, curr_dive_site->name) || ds->uuid == curr_dive_site->uuid) {
if (ds->uuid != curr_dive_site->uuid) {
qWarning() << "Warning, two different dive sites with same name have a different id"
<< ds->uuid << "and" << curr_dive_site->uuid;
<< ds->uuid << "and" << curr_dive_site->uuid;
}
showTrip = true; // do not shortcircuit the loop or the counts will be wrong
}
@ -411,7 +410,7 @@ bool MultiFilterSortModel::filterAcceptsRow(int source_row, const QModelIndex &s
ds = get_dive_site_by_uuid(d->dive_site_uuid);
if (!ds)
return false;
return ( same_string(ds->name, curr_dive_site->name) || ds->uuid == curr_dive_site->uuid);
return (same_string(ds->name, curr_dive_site->name) || ds->uuid == curr_dive_site->uuid);
}
if (justCleared || models.isEmpty())
@ -467,7 +466,7 @@ void MultiFilterSortModel::myInvalidate()
dlv->selectDives(curSelectedDives);
}
for_each_dive (i,d) {
for_each_dive (i, d) {
if (!d->hidden_by_filter)
divesDisplayed++;
}