Random whitespace update

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2014-09-17 15:39:49 -07:00
parent d6d82a5af8
commit 0d1da0563b
7 changed files with 62 additions and 56 deletions

View file

@ -209,7 +209,7 @@ void DiveListView::unselectDives()
// would only cause pointless churn // would only cause pointless churn
int i; int i;
struct dive *dive; struct dive *dive;
for_each_dive(i, dive) { for_each_dive (i, dive) {
dive->selected = false; dive->selected = false;
} }
} }
@ -486,7 +486,7 @@ void DiveListView::selectionChanged(const QItemSelection &selected, const QItemS
QTreeView::selectionChanged(selectionModel()->selection(), newDeselected); QTreeView::selectionChanged(selectionModel()->selection(), newDeselected);
connect(selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, SLOT(selectionChanged(QItemSelection, QItemSelection))); connect(selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, SLOT(selectionChanged(QItemSelection, QItemSelection)));
connect(selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)), this, SLOT(currentChanged(QModelIndex, QModelIndex))); connect(selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)), this, SLOT(currentChanged(QModelIndex, QModelIndex)));
if(!dontEmitDiveChangedSignal) if (!dontEmitDiveChangedSignal)
Q_EMIT currentDiveChanged(selected_dive); Q_EMIT currentDiveChanged(selected_dive);
} }
@ -784,7 +784,7 @@ void DiveListView::loadImages()
shiftDialog.exec(); shiftDialog.exec();
updateLastImageTimeOffset(shiftDialog.amount()); updateLastImageTimeOffset(shiftDialog.amount());
Q_FOREACH(const QString& fileName, fileNames) { Q_FOREACH (const QString &fileName, fileNames) {
int j = 0; int j = 0;
struct dive *dive; struct dive *dive;
for_each_dive (j, dive) { for_each_dive (j, dive) {

View file

@ -124,7 +124,7 @@ MainWindow::MainWindow() : QMainWindow(),
memset(&what, 0, sizeof(what)); memset(&what, 0, sizeof(what));
QToolBar *toolBar = new QToolBar(); QToolBar *toolBar = new QToolBar();
Q_FOREACH(QAction *a, profileToolbarActions) Q_FOREACH (QAction *a, profileToolbarActions)
toolBar->addAction(a); toolBar->addAction(a);
toolBar->setOrientation(Qt::Vertical); toolBar->setOrientation(Qt::Vertical);
@ -133,7 +133,7 @@ MainWindow::MainWindow() : QMainWindow(),
// I need to take the current item that's in the toolbar Position // I need to take the current item that's in the toolbar Position
// and reposition it alongside the grid layout. // and reposition it alongside the grid layout.
QLayoutItem *p = ui.gridLayout->takeAt(0); QLayoutItem *p = ui.gridLayout->takeAt(0);
ui.gridLayout->addWidget(toolBar,0,0); ui.gridLayout->addWidget(toolBar, 0, 0);
ui.gridLayout->addItem(p, 0, 1); ui.gridLayout->addItem(p, 0, 1);
} }
@ -499,10 +499,10 @@ void MainWindow::on_actionDivePlanner_triggered()
void MainWindow::on_actionAddDive_triggered() void MainWindow::on_actionAddDive_triggered()
{ {
if(!plannerStateClean()) if (!plannerStateClean())
return; return;
if (dive_list()->selectedTrips().count() >= 1){ if (dive_list()->selectedTrips().count() >= 1) {
dive_list()->rememberSelection(); dive_list()->rememberSelection();
dive_list()->clearSelection(); dive_list()->clearSelection();
} }
@ -1257,18 +1257,18 @@ void MainWindow::editCurrentDive()
} }
} }
#define PREF_PROFILE(QT_PREFS) \ #define PREF_PROFILE(QT_PREFS) \
QSettings s; \ QSettings s; \
s.beginGroup("TecDetails"); \ s.beginGroup("TecDetails"); \
s.setValue(#QT_PREFS, triggered); \ s.setValue(#QT_PREFS, triggered); \
PreferencesDialog::instance()->emitSettingsChanged(); PreferencesDialog::instance()->emitSettingsChanged();
#define TOOLBOX_PREF_PROFILE(METHOD, INTERNAL_PREFS, QT_PREFS) \ #define TOOLBOX_PREF_PROFILE(METHOD, INTERNAL_PREFS, QT_PREFS) \
void MainWindow::on_ ## METHOD ##_triggered(bool triggered) \ void MainWindow::on_##METHOD##_triggered(bool triggered) \
{ \ { \
prefs. INTERNAL_PREFS = triggered;\ prefs.INTERNAL_PREFS = triggered; \
PREF_PROFILE(QT_PREFS); \ PREF_PROFILE(QT_PREFS); \
} }
TOOLBOX_PREF_PROFILE(profCalcAllTissues, calcalltissues, calcalltissues); TOOLBOX_PREF_PROFILE(profCalcAllTissues, calcalltissues, calcalltissues);
TOOLBOX_PREF_PROFILE(profCalcCeiling, calcceiling, calcceiling); TOOLBOX_PREF_PROFILE(profCalcCeiling, calcceiling, calcceiling);
@ -1311,7 +1311,7 @@ void MainWindow::on_actionConfigure_Dive_Computer_triggered()
void MainWindow::setEnabledToolbar(bool arg1) void MainWindow::setEnabledToolbar(bool arg1)
{ {
Q_FOREACH(QAction *b, profileToolbarActions) Q_FOREACH (QAction *b, profileToolbarActions)
b->setEnabled(arg1); b->setEnabled(arg1);
} }

View file

@ -190,7 +190,7 @@ private:
QDialog *survey; QDialog *survey;
struct dive copyPasteDive; struct dive copyPasteDive;
struct dive_components what; struct dive_components what;
QList<QAction*> profileToolbarActions; QList<QAction *> profileToolbarActions;
}; };
#endif // MAINWINDOW_H #endif // MAINWINDOW_H

View file

@ -267,7 +267,7 @@ bool CylindersModel::setData(const QModelIndex &index, const QVariant &value, in
cyl->gasmix.o2 = string_to_fraction(vString.toUtf8().data()); cyl->gasmix.o2 = string_to_fraction(vString.toUtf8().data());
pressure_t modpO2; pressure_t modpO2;
modpO2.mbar = prefs.decopo2; modpO2.mbar = prefs.decopo2;
cyl->depth = gas_mod(&cyl->gasmix, modpO2, M_OR_FT(3,10)); cyl->depth = gas_mod(&cyl->gasmix, modpO2, M_OR_FT(3, 10));
changed = true; changed = true;
} }
break; break;
@ -378,8 +378,8 @@ void CylindersModel::remove(const QModelIndex &index)
(DivePlannerPointsModel::instance()->currentMode() == DivePlannerPointsModel::NOTHING && (DivePlannerPointsModel::instance()->currentMode() == DivePlannerPointsModel::NOTHING &&
(cyl->manually_added || is_cylinder_used(&displayed_dive, index.row()))))) { (cyl->manually_added || is_cylinder_used(&displayed_dive, index.row()))))) {
QMessageBox::warning(MainWindow::instance(), TITLE_OR_TEXT( QMessageBox::warning(MainWindow::instance(), TITLE_OR_TEXT(
tr("Cylinder cannot be removed"), tr("Cylinder cannot be removed"),
tr("This gas is in use. Only cylinders that are not used in the dive can be removed.")), tr("This gas is in use. Only cylinders that are not used in the dive can be removed.")),
QMessageBox::Ok); QMessageBox::Ok);
return; return;
} }
@ -2101,7 +2101,7 @@ int LanguageModel::rowCount(const QModelIndex &parent) const
} }
TagFilterModel::TagFilterModel(QObject *parent): QStringListModel(parent), checkState(NULL) TagFilterModel::TagFilterModel(QObject *parent) : QStringListModel(parent), checkState(NULL)
{ {
} }
@ -2113,7 +2113,7 @@ TagFilterModel *TagFilterModel::instance()
QVariant TagFilterModel::data(const QModelIndex &index, int role) const QVariant TagFilterModel::data(const QModelIndex &index, int role) const
{ {
if(role == Qt::CheckStateRole){ if (role == Qt::CheckStateRole) {
return checkState[index.row()] ? Qt::Checked : Qt::Unchecked; return checkState[index.row()] ? Qt::Checked : Qt::Unchecked;
} else if (role == Qt::DisplayRole) { } else if (role == Qt::DisplayRole) {
return stringList()[index.row()]; return stringList()[index.row()];
@ -2141,32 +2141,32 @@ void TagFilterModel::repopulate()
delete[] checkState; delete[] checkState;
checkState = new bool[list.count()]; checkState = new bool[list.count()];
memset(checkState, true, list.count()); memset(checkState, true, list.count());
checkState[list.count()-1] = true; checkState[list.count() - 1] = true;
} }
bool TagFilterModel::setData(const QModelIndex &index, const QVariant &value, int role) bool TagFilterModel::setData(const QModelIndex &index, const QVariant &value, int role)
{ {
if(role == Qt::CheckStateRole){ if (role == Qt::CheckStateRole) {
checkState[index.row()] = value.toBool(); checkState[index.row()] = value.toBool();
dataChanged(index,index); dataChanged(index, index);
return true; return true;
} }
return false; return false;
} }
TagFilterSortModel::TagFilterSortModel(QObject *parent): QSortFilterProxyModel(parent) TagFilterSortModel::TagFilterSortModel(QObject *parent) : QSortFilterProxyModel(parent)
{ {
connect(TagFilterModel::instance(), SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(invalidate())); connect(TagFilterModel::instance(), SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(invalidate()));
} }
bool TagFilterSortModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const bool TagFilterSortModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
{ {
QModelIndex index0 = sourceModel()->index(source_row, 0, source_parent); QModelIndex index0 = sourceModel()->index(source_row, 0, source_parent);
QVariant diveVariant = sourceModel()->data(index0, DiveTripModel::DIVE_ROLE); QVariant diveVariant = sourceModel()->data(index0, DiveTripModel::DIVE_ROLE);
struct dive* d = (struct dive* ) diveVariant.value<void*>(); struct dive *d = (struct dive *)diveVariant.value<void *>();
if (!d) { // It's a trip, only show the ones that have dives to be shown. if (!d) { // It's a trip, only show the ones that have dives to be shown.
for(int i = 0; i < sourceModel()->rowCount(index0); i++){ for (int i = 0; i < sourceModel()->rowCount(index0); i++) {
if (filterAcceptsRow(i, index0)) if (filterAcceptsRow(i, index0))
return true; return true;
} }
@ -2175,14 +2175,14 @@ bool TagFilterSortModel::filterAcceptsRow(int source_row, const QModelIndex &sou
// Checked means 'Show', Unchecked means 'Hide'. // Checked means 'Show', Unchecked means 'Hide'.
struct tag_entry *head = d->tag_list; struct tag_entry *head = d->tag_list;
if (!head){ // last tag means "Show empty tags"; if (!head) { // last tag means "Show empty tags";
return TagFilterModel::instance()->checkState[TagFilterModel::instance()->rowCount()-1]; return TagFilterModel::instance()->checkState[TagFilterModel::instance()->rowCount() - 1];
} }
// have at least one tag. // have at least one tag.
QStringList tagList = TagFilterModel::instance()->stringList(); QStringList tagList = TagFilterModel::instance()->stringList();
tagList.removeLast(); // remove the "Show Empty Tags"; tagList.removeLast(); // remove the "Show Empty Tags";
while(head) { while (head) {
QString tagName(head->tag->name); QString tagName(head->tag->name);
int index = tagList.indexOf(tagName); int index = tagList.indexOf(tagName);
if (TagFilterModel::instance()->checkState[index]) if (TagFilterModel::instance()->checkState[index])

View file

@ -425,8 +425,10 @@ public:
virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
virtual Qt::ItemFlags flags(const QModelIndex &index) const; virtual Qt::ItemFlags flags(const QModelIndex &index) const;
bool *checkState; bool *checkState;
public slots: public
slots:
void repopulate(); void repopulate();
private: private:
explicit TagFilterModel(QObject *parent = 0); explicit TagFilterModel(QObject *parent = 0);
}; };

View file

@ -296,7 +296,7 @@ DateWidget::DateWidget(QWidget *parent) : QWidget(parent),
calendarWidget(new QCalendarWidget()) calendarWidget(new QCalendarWidget())
{ {
setDate(QDate::currentDate()); setDate(QDate::currentDate());
setMinimumSize(QSize(80,64)); setMinimumSize(QSize(80, 64));
setFocusPolicy(Qt::StrongFocus); setFocusPolicy(Qt::StrongFocus);
calendarWidget->setWindowFlags(Qt::FramelessWindowHint); calendarWidget->setWindowFlags(Qt::FramelessWindowHint);
calendarWidget->setFirstDayOfWeek(getLocale().firstDayOfWeek()); calendarWidget->setFirstDayOfWeek(getLocale().firstDayOfWeek());
@ -311,13 +311,13 @@ DateWidget::DateWidget(QWidget *parent) : QWidget(parent),
bool DateWidget::eventFilter(QObject *object, QEvent *event) bool DateWidget::eventFilter(QObject *object, QEvent *event)
{ {
if(event->type() == QEvent::FocusOut){ if (event->type() == QEvent::FocusOut) {
calendarWidget->hide(); calendarWidget->hide();
return true; return true;
} }
if(event->type() == QEvent::KeyPress){ if (event->type() == QEvent::KeyPress) {
QKeyEvent *ev = static_cast<QKeyEvent*>(event); QKeyEvent *ev = static_cast<QKeyEvent *>(event);
if(ev->key() == Qt::Key_Escape){ if (ev->key() == Qt::Key_Escape) {
calendarWidget->hide(); calendarWidget->hide();
} }
} }
@ -325,7 +325,7 @@ bool DateWidget::eventFilter(QObject *object, QEvent *event)
} }
void DateWidget::setDate(const QDate& date) void DateWidget::setDate(const QDate &date)
{ {
mDate = date; mDate = date;
update(); update();
@ -339,7 +339,7 @@ QDate DateWidget::date() const
void DateWidget::changeEvent(QEvent *event) void DateWidget::changeEvent(QEvent *event)
{ {
if(event->type() == QEvent::EnabledChange){ if (event->type() == QEvent::EnabledChange) {
update(); update();
} }
} }
@ -347,11 +347,11 @@ void DateWidget::changeEvent(QEvent *event)
#define DATEWIDGETWIDTH 80 #define DATEWIDGETWIDTH 80
void DateWidget::paintEvent(QPaintEvent *event) void DateWidget::paintEvent(QPaintEvent *event)
{ {
static QPixmap pix = QPixmap(":/calendar").scaled(DATEWIDGETWIDTH,64); static QPixmap pix = QPixmap(":/calendar").scaled(DATEWIDGETWIDTH, 64);
QPainter painter(this); QPainter painter(this);
painter.drawPixmap(QPoint(0,0), isEnabled() ? pix : QPixmap::fromImage(grayImage(pix.toImage()))); painter.drawPixmap(QPoint(0, 0), isEnabled() ? pix : QPixmap::fromImage(grayImage(pix.toImage())));
QString month = mDate.toString("MMM"); QString month = mDate.toString("MMM");
QString year = mDate.toString("yyyy"); QString year = mDate.toString("yyyy");
@ -367,7 +367,7 @@ void DateWidget::paintEvent(QPaintEvent *event)
font.setPointSize(14); font.setPointSize(14);
metrics = QFontMetrics(font); metrics = QFontMetrics(font);
painter.setPen(QPen(QBrush(Qt::black),0)); painter.setPen(QPen(QBrush(Qt::black), 0));
painter.setBrush(Qt::black); painter.setBrush(Qt::black);
painter.setFont(font); painter.setFont(font);
painter.drawText(QPoint(DATEWIDGETWIDTH / 2 - metrics.width(day) / 2, 45), day); painter.drawText(QPoint(DATEWIDGETWIDTH / 2 - metrics.width(day) / 2, 45), day);
@ -402,13 +402,13 @@ void DateWidget::focusOutEvent(QFocusEvent *event)
void DateWidget::keyPressEvent(QKeyEvent *event) void DateWidget::keyPressEvent(QKeyEvent *event)
{ {
if ( event->key() == Qt::Key_Return || if (event->key() == Qt::Key_Return ||
event->key() == Qt::Key_Enter || event->key() == Qt::Key_Enter ||
event->key() == Qt::Key_Space){ event->key() == Qt::Key_Space) {
calendarWidget->move(mapToGlobal(QPoint(0,64))); calendarWidget->move(mapToGlobal(QPoint(0, 64)));
calendarWidget->show(); calendarWidget->show();
event->setAccepted(true); event->setAccepted(true);
}else{ } else {
QWidget::keyPressEvent(event); QWidget::keyPressEvent(event);
} }
} }
@ -416,8 +416,7 @@ void DateWidget::keyPressEvent(QKeyEvent *event)
#define COMPONENT_FROM_UI(_component) what->_component = ui._component->isChecked() #define COMPONENT_FROM_UI(_component) what->_component = ui._component->isChecked()
#define UI_FROM_COMPONENT(_component) ui._component->setChecked(what->_component) #define UI_FROM_COMPONENT(_component) ui._component->setChecked(what->_component)
DiveComponentSelection::DiveComponentSelection(QWidget *parent, struct dive *target, struct dive_components *_what): DiveComponentSelection::DiveComponentSelection(QWidget *parent, struct dive *target, struct dive_components *_what) : targetDive(target)
targetDive(target)
{ {
ui.setupUi(this); ui.setupUi(this);
what = _what; what = _what;
@ -457,7 +456,7 @@ void DiveComponentSelection::buttonClicked(QAbstractButton *button)
} }
} }
TagFilter::TagFilter(QWidget *parent): QWidget(parent) TagFilter::TagFilter(QWidget *parent) : QWidget(parent)
{ {
ui.setupUi(this); ui.setupUi(this);
QSortFilterProxyModel *filter = new QSortFilterProxyModel(); QSortFilterProxyModel *filter = new QSortFilterProxyModel();

View file

@ -96,8 +96,10 @@ class DateWidget : public QWidget {
public: public:
DateWidget(QWidget *parent = 0); DateWidget(QWidget *parent = 0);
QDate date() const; QDate date() const;
public slots: public
void setDate(const QDate& date); slots:
void setDate(const QDate &date);
protected: protected:
void paintEvent(QPaintEvent *event); void paintEvent(QPaintEvent *event);
void mousePressEvent(QMouseEvent *event); void mousePressEvent(QMouseEvent *event);
@ -107,7 +109,8 @@ protected:
void changeEvent(QEvent *); void changeEvent(QEvent *);
bool eventFilter(QObject *, QEvent *); bool eventFilter(QObject *, QEvent *);
signals: signals:
void dateChanged(const QDate& date); void dateChanged(const QDate &date);
private: private:
QDate mDate; QDate mDate;
QCalendarWidget *calendarWidget; QCalendarWidget *calendarWidget;
@ -120,6 +123,7 @@ public:
private private
slots: slots:
void buttonClicked(QAbstractButton *button); void buttonClicked(QAbstractButton *button);
private: private:
Ui::DiveComponentSelectionDialog ui; Ui::DiveComponentSelectionDialog ui;
struct dive *targetDive; struct dive *targetDive;
@ -130,11 +134,12 @@ class TagFilter : public QWidget {
Q_OBJECT Q_OBJECT
public: public:
TagFilter(QWidget *parent = 0); TagFilter(QWidget *parent = 0);
private: private:
Ui::TagFilter ui; Ui::TagFilter ui;
}; };
bool isGnome3Session(); bool isGnome3Session();
QImage grayImage(const QImage& coloredImg); QImage grayImage(const QImage &coloredImg);
#endif // SIMPLEWIDGETS_H #endif // SIMPLEWIDGETS_H