mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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:
parent
734bd6d459
commit
eec69de7ab
2 changed files with 37 additions and 40 deletions
|
@ -162,14 +162,14 @@ void RenumberDialog::buttonClicked(QAbstractButton *button)
|
||||||
if (ui.buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole) {
|
if (ui.buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole) {
|
||||||
MainWindow::instance()->dive_list()->rememberSelection();
|
MainWindow::instance()->dive_list()->rememberSelection();
|
||||||
// we remember a map from dive uuid to a pair of old number / new number
|
// 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 i;
|
||||||
int newNr = ui.spinBox->value();
|
int newNr = ui.spinBox->value();
|
||||||
struct dive *dive = NULL;
|
struct dive *dive = NULL;
|
||||||
for_each_dive (i, dive) {
|
for_each_dive (i, dive) {
|
||||||
if (!selectedOnly || dive->selected) {
|
if (!selectedOnly || dive->selected) {
|
||||||
invalidate_dive_cache(dive);
|
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);
|
UndoRenumberDives *undoCommand = new UndoRenumberDives(renumberedDives);
|
||||||
|
@ -214,8 +214,7 @@ void SetpointDialog::buttonClicked(QAbstractButton *button)
|
||||||
MainWindow::instance()->graphics()->replot();
|
MainWindow::instance()->graphics()->replot();
|
||||||
}
|
}
|
||||||
|
|
||||||
SetpointDialog::SetpointDialog(QWidget *parent) :
|
SetpointDialog::SetpointDialog(QWidget *parent) : QDialog(parent),
|
||||||
QDialog(parent),
|
|
||||||
dc(0)
|
dc(0)
|
||||||
{
|
{
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
|
@ -281,8 +280,7 @@ void ShiftTimesDialog::changeTime()
|
||||||
ui.shiftedTime->setText(get_dive_date_string(amount + when));
|
ui.shiftedTime->setText(get_dive_date_string(amount + when));
|
||||||
}
|
}
|
||||||
|
|
||||||
ShiftTimesDialog::ShiftTimesDialog(QWidget *parent) :
|
ShiftTimesDialog::ShiftTimesDialog(QWidget *parent) : QDialog(parent),
|
||||||
QDialog(parent),
|
|
||||||
when(0)
|
when(0)
|
||||||
{
|
{
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
|
@ -346,8 +344,7 @@ bool ShiftImageTimesDialog::matchAll()
|
||||||
return matchAllImages;
|
return matchAllImages;
|
||||||
}
|
}
|
||||||
|
|
||||||
ShiftImageTimesDialog::ShiftImageTimesDialog(QWidget *parent, QStringList fileNames) :
|
ShiftImageTimesDialog::ShiftImageTimesDialog(QWidget *parent, QStringList fileNames) : QDialog(parent),
|
||||||
QDialog(parent),
|
|
||||||
fileNames(fileNames),
|
fileNames(fileNames),
|
||||||
m_amount(0),
|
m_amount(0),
|
||||||
matchAllImages(false)
|
matchAllImages(false)
|
||||||
|
@ -409,7 +406,7 @@ void ShiftImageTimesDialog::updateInvalid()
|
||||||
allValid = false;
|
allValid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!allValid){
|
if (!allValid) {
|
||||||
ui.warningLabel->show();
|
ui.warningLabel->show();
|
||||||
ui.invalidFilesText->show();
|
ui.invalidFilesText->show();
|
||||||
}
|
}
|
||||||
|
@ -419,15 +416,16 @@ void ShiftImageTimesDialog::timeEditChanged(const QTime &time)
|
||||||
{
|
{
|
||||||
m_amount = time.hour() * 3600 + time.minute() * 60;
|
m_amount = time.hour() * 3600 + time.minute() * 60;
|
||||||
if (ui.backwards->isChecked())
|
if (ui.backwards->isChecked())
|
||||||
m_amount *= -1;
|
m_amount *= -1;
|
||||||
updateInvalid();
|
updateInvalid();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShiftImageTimesDialog::timeEditChanged()
|
void ShiftImageTimesDialog::timeEditChanged()
|
||||||
{
|
{
|
||||||
if ((m_amount > 0) == ui.backwards->isChecked())
|
if ((m_amount > 0) == ui.backwards->isChecked())
|
||||||
m_amount *= -1;
|
m_amount *= -1;
|
||||||
if (m_amount) updateInvalid();
|
if (m_amount)
|
||||||
|
updateInvalid();
|
||||||
}
|
}
|
||||||
|
|
||||||
URLDialog::URLDialog(QWidget *parent) : QDialog(parent)
|
URLDialog::URLDialog(QWidget *parent) : QDialog(parent)
|
||||||
|
@ -500,9 +498,8 @@ void DiveComponentSelection::buttonClicked(QAbstractButton *button)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FilterBase::FilterBase(FilterModelBase *model_, QWidget *parent)
|
FilterBase::FilterBase(FilterModelBase *model_, QWidget *parent) : QWidget(parent),
|
||||||
: QWidget(parent)
|
model(model_)
|
||||||
, model(model_)
|
|
||||||
{
|
{
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
#if QT_VERSION >= 0x050200
|
#if QT_VERSION >= 0x050200
|
||||||
|
@ -563,7 +560,7 @@ MultiFilter::MultiFilter(QWidget *parent) : QWidget(parent)
|
||||||
|
|
||||||
TagFilter *tagFilter = new TagFilter(this);
|
TagFilter *tagFilter = new TagFilter(this);
|
||||||
int minimumHeight = tagFilter->ui.filterInternalList->height() +
|
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();
|
QListView *dummyList = new QListView();
|
||||||
QStringListModel *dummy = new QStringListModel(QStringList() << "Dummy Text");
|
QStringListModel *dummy = new QStringListModel(QStringList() << "Dummy Text");
|
||||||
|
@ -582,7 +579,7 @@ MultiFilter::MultiFilter(QWidget *parent) : QWidget(parent)
|
||||||
expandedWidget->setLayout(l);
|
expandedWidget->setLayout(l);
|
||||||
|
|
||||||
ui.scrollArea->setWidget(expandedWidget);
|
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);
|
ui.scrollArea->setMinimumHeight(expandedWidget->height() + 5);
|
||||||
|
|
||||||
connect(MultiFilterSortModel::instance(), SIGNAL(filterFinished()), this, SLOT(filterFinished()));
|
connect(MultiFilterSortModel::instance(), SIGNAL(filterFinished()), this, SLOT(filterFinished()));
|
||||||
|
@ -738,7 +735,8 @@ QString TextHyperlinkEventFilter::fromCursorTilWhitespace(QTextCursor *cursor, c
|
||||||
}
|
}
|
||||||
|
|
||||||
grownText = cursor->selectedText();
|
grownText = cursor->selectedText();
|
||||||
if (grownText.size() == oldSize) movedOk = false;
|
if (grownText.size() == oldSize)
|
||||||
|
movedOk = false;
|
||||||
oldSize = grownText.size();
|
oldSize = grownText.size();
|
||||||
noSpaces = grownText.simplified().replace(" ", "");
|
noSpaces = grownText.simplified().replace(" ", "");
|
||||||
} while (grownText == noSpaces && movedOk);
|
} while (grownText == noSpaces && movedOk);
|
||||||
|
|
|
@ -12,12 +12,12 @@
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#define CREATE_INSTANCE_METHOD( CLASS ) \
|
#define CREATE_INSTANCE_METHOD(CLASS) \
|
||||||
CLASS *CLASS::instance() \
|
CLASS *CLASS::instance() \
|
||||||
{ \
|
{ \
|
||||||
static CLASS *self = new CLASS(); \
|
static CLASS *self = new CLASS(); \
|
||||||
return self; \
|
return self; \
|
||||||
}
|
}
|
||||||
|
|
||||||
CREATE_INSTANCE_METHOD(TagFilterModel)
|
CREATE_INSTANCE_METHOD(TagFilterModel)
|
||||||
CREATE_INSTANCE_METHOD(BuddyFilterModel)
|
CREATE_INSTANCE_METHOD(BuddyFilterModel)
|
||||||
|
@ -25,8 +25,8 @@ CREATE_INSTANCE_METHOD(LocationFilterModel)
|
||||||
CREATE_INSTANCE_METHOD(SuitsFilterModel)
|
CREATE_INSTANCE_METHOD(SuitsFilterModel)
|
||||||
CREATE_INSTANCE_METHOD(MultiFilterSortModel)
|
CREATE_INSTANCE_METHOD(MultiFilterSortModel)
|
||||||
|
|
||||||
FilterModelBase::FilterModelBase(QObject *parent) : QStringListModel(parent)
|
FilterModelBase::FilterModelBase(QObject *parent) : QStringListModel(parent),
|
||||||
, anyChecked(false)
|
anyChecked(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,22 +97,22 @@ void FilterModelBase::clearFilter()
|
||||||
{
|
{
|
||||||
std::fill(checkState.begin(), checkState.end(), false);
|
std::fill(checkState.begin(), checkState.end(), false);
|
||||||
anyChecked = false;
|
anyChecked = false;
|
||||||
emit dataChanged(createIndex(0,0), createIndex(rowCount()-1, 0));
|
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FilterModelBase::selectAll()
|
void FilterModelBase::selectAll()
|
||||||
{
|
{
|
||||||
std::fill(checkState.begin(), checkState.end(), true);
|
std::fill(checkState.begin(), checkState.end(), true);
|
||||||
anyChecked = true;
|
anyChecked = true;
|
||||||
emit dataChanged(createIndex(0,0), createIndex(rowCount()-1, 0));
|
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FilterModelBase::invertSelection()
|
void FilterModelBase::invertSelection()
|
||||||
{
|
{
|
||||||
for (char &b: checkState)
|
for (char &b : checkState)
|
||||||
b = !b;
|
b = !b;
|
||||||
anyChecked = std::any_of(checkState.begin(), checkState.end(), [](char b){return !!b;});
|
anyChecked = std::any_of(checkState.begin(), checkState.end(), [](char b) { return !!b; });
|
||||||
emit dataChanged(createIndex(0,0), createIndex(rowCount()-1, 0));
|
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
SuitsFilterModel::SuitsFilterModel(QObject *parent) : FilterModelBase(parent)
|
SuitsFilterModel::SuitsFilterModel(QObject *parent) : FilterModelBase(parent)
|
||||||
|
@ -249,7 +249,7 @@ bool BuddyFilterModel::doFilter(dive *d, QModelIndex &index0, QAbstractItemModel
|
||||||
// Checked means 'Show', Unchecked means 'Hide'.
|
// Checked means 'Show', Unchecked means 'Hide'.
|
||||||
QString persons = QString(d->buddy) + "," + QString(d->divemaster);
|
QString persons = QString(d->buddy) + "," + QString(d->divemaster);
|
||||||
QStringList personsList = persons.split(',', QString::SkipEmptyParts);
|
QStringList personsList = persons.split(',', QString::SkipEmptyParts);
|
||||||
for (QString &s: personsList)
|
for (QString &s : personsList)
|
||||||
s = s.trimmed();
|
s = s.trimmed();
|
||||||
// only show empty buddie dives if the user checked that.
|
// only show empty buddie dives if the user checked that.
|
||||||
if (personsList.isEmpty()) {
|
if (personsList.isEmpty()) {
|
||||||
|
@ -373,8 +373,7 @@ void LocationFilterModel::addName(const QString &newName)
|
||||||
checkState.insert(checkState.begin(), true);
|
checkState.insert(checkState.begin(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiFilterSortModel::MultiFilterSortModel(QObject *parent) :
|
MultiFilterSortModel::MultiFilterSortModel(QObject *parent) : QSortFilterProxyModel(parent),
|
||||||
QSortFilterProxyModel(parent),
|
|
||||||
divesDisplayed(0),
|
divesDisplayed(0),
|
||||||
justCleared(false),
|
justCleared(false),
|
||||||
curr_dive_site(NULL)
|
curr_dive_site(NULL)
|
||||||
|
@ -394,14 +393,14 @@ bool MultiFilterSortModel::filterAcceptsRow(int source_row, const QModelIndex &s
|
||||||
bool showTrip = false;
|
bool showTrip = false;
|
||||||
for (int i = 0; i < sourceModel()->rowCount(index0); i++) {
|
for (int i = 0; i < sourceModel()->rowCount(index0); i++) {
|
||||||
QModelIndex child = sourceModel()->index(i, 0, index0);
|
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);
|
ds = get_dive_site_by_uuid(d->dive_site_uuid);
|
||||||
if (!ds)
|
if (!ds)
|
||||||
continue;
|
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) {
|
if (ds->uuid != curr_dive_site->uuid) {
|
||||||
qWarning() << "Warning, two different dive sites with same name have a different id"
|
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
|
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);
|
ds = get_dive_site_by_uuid(d->dive_site_uuid);
|
||||||
if (!ds)
|
if (!ds)
|
||||||
return false;
|
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())
|
if (justCleared || models.isEmpty())
|
||||||
|
@ -467,7 +466,7 @@ void MultiFilterSortModel::myInvalidate()
|
||||||
dlv->selectDives(curSelectedDives);
|
dlv->selectDives(curSelectedDives);
|
||||||
}
|
}
|
||||||
|
|
||||||
for_each_dive (i,d) {
|
for_each_dive (i, d) {
|
||||||
if (!d->hidden_by_filter)
|
if (!d->hidden_by_filter)
|
||||||
divesDisplayed++;
|
divesDisplayed++;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue