diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2014-02-27 20:09:57 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-02-27 20:09:57 -0800 |
commit | 76e6420f6b3503b76bd3eec00ab0e53d6ea17a20 (patch) | |
tree | 8b50298f41bd29d55bbd6f4301f36ad31dc0b008 /qt-ui/modeldelegates.cpp | |
parent | 006265d7a088cff4fea665159dbb454956c2cd76 (diff) | |
download | subsurface-76e6420f6b3503b76bd3eec00ab0e53d6ea17a20.tar.gz |
Massive automated whitespace cleanup
I know everyone will hate it.
Go ahead. Complain. Call me names.
At least now things are consistent and reproducible.
If you want changes, have your complaint come with a patch to
scripts/whitespace.pl so that we can automate it.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/modeldelegates.cpp')
-rw-r--r-- | qt-ui/modeldelegates.cpp | 106 |
1 files changed, 52 insertions, 54 deletions
diff --git a/qt-ui/modeldelegates.cpp b/qt-ui/modeldelegates.cpp index 5e5bc9353..85542f0f9 100644 --- a/qt-ui/modeldelegates.cpp +++ b/qt-ui/modeldelegates.cpp @@ -18,9 +18,9 @@ #include <QAbstractItemView> #include <QApplication> -QSize DiveListDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const +QSize DiveListDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const { - return QSize(50,22); + return QSize(50, 22); } // Gets the index of the model in the currentRow and column. @@ -28,14 +28,12 @@ QSize DiveListDelegate::sizeHint(const QStyleOptionViewItem& option, const QMode #define IDX(_XX) mymodel->index(currCombo.currRow, (_XX)) static bool keyboardFinished = false; -StarWidgetsDelegate::StarWidgetsDelegate(QWidget* parent): - QStyledItemDelegate(parent), +StarWidgetsDelegate::StarWidgetsDelegate(QWidget *parent) : QStyledItemDelegate(parent), parentWidget(parent) { - } -void StarWidgetsDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const +void StarWidgetsDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { QStyledItemDelegate::paint(painter, option, index); if (!index.isValid()) @@ -46,7 +44,7 @@ void StarWidgetsDelegate::paint(QPainter* painter, const QStyleOptionViewItem& o return; int rating = value.toInt(); - int deltaY = option.rect.height() / 2 - StarWidget::starActive().height() / 2 ; + int deltaY = option.rect.height() / 2 - StarWidget::starActive().height() / 2; painter->save(); painter->setRenderHint(QPainter::Antialiasing, true); for (int i = 0; i < rating; i++) @@ -56,20 +54,20 @@ void StarWidgetsDelegate::paint(QPainter* painter, const QStyleOptionViewItem& o painter->restore(); } -QSize StarWidgetsDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const +QSize StarWidgetsDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const { - return QSize(IMG_SIZE * TOTALSTARS + SPACING * (TOTALSTARS-1), IMG_SIZE); + return QSize(IMG_SIZE * TOTALSTARS + SPACING * (TOTALSTARS - 1), IMG_SIZE); } -ComboBoxDelegate::ComboBoxDelegate(QAbstractItemModel *model, QObject* parent): QStyledItemDelegate(parent), model(model) +ComboBoxDelegate::ComboBoxDelegate(QAbstractItemModel *model, QObject *parent) : QStyledItemDelegate(parent), model(model) { - connect(this, SIGNAL(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)), - this, SLOT(revertModelData(QWidget*, QAbstractItemDelegate::EndEditHint))); + connect(this, SIGNAL(closeEditor(QWidget *, QAbstractItemDelegate::EndEditHint)), + this, SLOT(revertModelData(QWidget *, QAbstractItemDelegate::EndEditHint))); } -void ComboBoxDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const +void ComboBoxDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { - QComboBox *c = qobject_cast<QComboBox*>(editor); + QComboBox *c = qobject_cast<QComboBox *>(editor); QString data = index.model()->data(index, Qt::DisplayRole).toString(); int i = c->findText(data); if (i != -1) @@ -86,7 +84,7 @@ struct CurrSelected { bool ignoreSelection; } currCombo; -QWidget* ComboBoxDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const +QWidget *ComboBoxDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const { QComboBox *comboDelegate = new QComboBox(parent); comboDelegate->setModel(model); @@ -95,14 +93,14 @@ QWidget* ComboBoxDelegate::createEditor(QWidget* parent, const QStyleOptionViewI comboDelegate->setAutoCompletionCaseSensitivity(Qt::CaseInsensitive); comboDelegate->completer()->setCompletionMode(QCompleter::PopupCompletion); comboDelegate->view()->setEditTriggers(QAbstractItemView::AllEditTriggers); - comboDelegate->lineEdit()->installEventFilter( const_cast<QObject*>(qobject_cast<const QObject*>(this))); - comboDelegate->view()->installEventFilter( const_cast<QObject*>(qobject_cast<const QObject*>(this))); + comboDelegate->lineEdit()->installEventFilter(const_cast<QObject *>(qobject_cast<const QObject *>(this))); + comboDelegate->view()->installEventFilter(const_cast<QObject *>(qobject_cast<const QObject *>(this))); connect(comboDelegate, SIGNAL(highlighted(QString)), this, SLOT(testActivation(QString))); connect(comboDelegate, SIGNAL(activated(QString)), this, SLOT(fakeActivation())); - connect(this, SIGNAL(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)), this, SLOT(fixTabBehavior())); + connect(this, SIGNAL(closeEditor(QWidget *, QAbstractItemDelegate::EndEditHint)), this, SLOT(fixTabBehavior())); currCombo.comboEditor = comboDelegate; currCombo.currRow = index.row(); - currCombo.model = const_cast<QAbstractItemModel*>(index.model()); + currCombo.model = const_cast<QAbstractItemModel *>(index.model()); keyboardFinished = false; // Current display of things on Gnome3 looks like shit, so @@ -122,14 +120,15 @@ QWidget* ComboBoxDelegate::createEditor(QWidget* parent, const QStyleOptionViewI * One thing is important, if the user writes a *new* cylinder or weight type, it will * be ADDED to the list, and the user will need to fill the other data. */ -void ComboBoxDelegate::testActivation(const QString& currText) +void ComboBoxDelegate::testActivation(const QString &currText) { currCombo.activeText = currText.isEmpty() ? currCombo.comboEditor->currentText() : currText; setModelData(currCombo.comboEditor, currCombo.model, QModelIndex()); } // HACK, send a fake event so Qt thinks we hit 'enter' on the line edit. -void ComboBoxDelegate::fakeActivation() { +void ComboBoxDelegate::fakeActivation() +{ /* this test is needed because as soon as I show the selector, * the first item gots selected, this sending an activated signal, * calling this fakeActivation code and setting as the current, @@ -151,28 +150,28 @@ void ComboBoxDelegate::fakeActivation() { void ComboBoxDelegate::fixTabBehavior() { if (keyboardFinished) { - setModelData(0,0,QModelIndex()); + setModelData(0, 0, QModelIndex()); } } -bool ComboBoxDelegate::eventFilter(QObject* object, QEvent* event) +bool ComboBoxDelegate::eventFilter(QObject *object, QEvent *event) { // Reacts on Key_UP and Key_DOWN to show the QComboBox - list of choices. if (event->type() == QEvent::KeyPress || event->type() == QEvent::ShortcutOverride) { if (object == currCombo.comboEditor) { // the 'LineEdit' part - QKeyEvent *ev = static_cast<QKeyEvent*>(event); + QKeyEvent *ev = static_cast<QKeyEvent *>(event); if (ev->key() == Qt::Key_Up || ev->key() == Qt::Key_Down) { currCombo.ignoreSelection = true; currCombo.comboEditor->showPopup(); } if (ev->key() == Qt::Key_Tab || ev->key() == Qt::Key_Enter || ev->key() == Qt::Key_Return) { - currCombo.activeText = currCombo.comboEditor->currentText(); + currCombo.activeText = currCombo.comboEditor->currentText(); keyboardFinished = true; } - } else { // the 'Drop Down Menu' part. - QKeyEvent *ev = static_cast<QKeyEvent*>(event); + } 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_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 @@ -185,13 +184,13 @@ bool ComboBoxDelegate::eventFilter(QObject* object, QEvent* event) return QStyledItemDelegate::eventFilter(object, event); } -void ComboBoxDelegate::updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const +void ComboBoxDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const { QRect defaultRect = option.rect; - defaultRect.setX( defaultRect.x() -1); - defaultRect.setY( defaultRect.y() -1); - defaultRect.setWidth( defaultRect.width() + 2); - defaultRect.setHeight( defaultRect.height() + 2); + defaultRect.setX(defaultRect.x() - 1); + defaultRect.setY(defaultRect.y() - 1); + defaultRect.setWidth(defaultRect.width() + 2); + defaultRect.setHeight(defaultRect.height() + 2); editor->setGeometry(defaultRect); } @@ -201,16 +200,16 @@ struct RevertCylinderData { int size; } currCylinderData; -void TankInfoDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& thisindex) const +void TankInfoDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &thisindex) const { CylindersModel *mymodel = qobject_cast<CylindersModel *>(currCombo.model); TankInfoModel *tanks = TankInfoModel::instance(); - QModelIndexList matches = tanks->match(tanks->index(0,0), Qt::DisplayRole, currCombo.activeText); + QModelIndexList matches = tanks->match(tanks->index(0, 0), Qt::DisplayRole, currCombo.activeText); int row; if (matches.isEmpty()) { // we need to add this tanks->insertRows(tanks->rowCount(), 1); - tanks->setData(tanks->index(tanks->rowCount() -1, 0), currCombo.activeText); + tanks->setData(tanks->index(tanks->rowCount() - 1, 0), currCombo.activeText); row = tanks->rowCount() - 1; } else { row = matches.first().row(); @@ -223,17 +222,17 @@ void TankInfoDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, mymodel->passInData(IDX(CylindersModel::SIZE), tankSize); } -TankInfoDelegate::TankInfoDelegate(QObject* parent): ComboBoxDelegate(TankInfoModel::instance(), parent) +TankInfoDelegate::TankInfoDelegate(QObject *parent) : ComboBoxDelegate(TankInfoModel::instance(), parent) { } -void TankInfoDelegate::revertModelData(QWidget* widget, QAbstractItemDelegate::EndEditHint hint) +void TankInfoDelegate::revertModelData(QWidget *widget, QAbstractItemDelegate::EndEditHint hint) { if ( #if !defined __APPLE__ - hint == QAbstractItemDelegate::NoHint || + hint == QAbstractItemDelegate::NoHint || #endif - hint == QAbstractItemDelegate::RevertModelCache) { + hint == QAbstractItemDelegate::RevertModelCache) { CylindersModel *mymodel = qobject_cast<CylindersModel *>(currCombo.model); mymodel->setData(IDX(CylindersModel::TYPE), currCylinderData.type, Qt::EditRole); mymodel->passInData(IDX(CylindersModel::WORKINGPRESS), currCylinderData.pressure); @@ -241,7 +240,7 @@ void TankInfoDelegate::revertModelData(QWidget* widget, QAbstractItemDelegate::E } } -QWidget* TankInfoDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const +QWidget *TankInfoDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const { // ncreate editor needs to be called before because it will populate a few // things in the currCombo global var. @@ -259,24 +258,24 @@ struct RevertWeightData { int weight; } currWeight; -void WSInfoDelegate::revertModelData(QWidget* widget, QAbstractItemDelegate::EndEditHint hint) +void WSInfoDelegate::revertModelData(QWidget *widget, QAbstractItemDelegate::EndEditHint hint) { if ( #if !defined __APPLE__ - hint == QAbstractItemDelegate::NoHint || + hint == QAbstractItemDelegate::NoHint || #endif - hint == QAbstractItemDelegate::RevertModelCache) { + hint == QAbstractItemDelegate::RevertModelCache) { WeightModel *mymodel = qobject_cast<WeightModel *>(currCombo.model); mymodel->setData(IDX(WeightModel::TYPE), currWeight.type, Qt::EditRole); mymodel->passInData(IDX(WeightModel::WEIGHT), currWeight.weight); } } -void WSInfoDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& thisindex) const +void WSInfoDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &thisindex) const { WeightModel *mymodel = qobject_cast<WeightModel *>(currCombo.model); WSInfoModel *wsim = WSInfoModel::instance(); - QModelIndexList matches = wsim->match(wsim->index(0,0), Qt::DisplayRole, currCombo.activeText); + QModelIndexList matches = wsim->match(wsim->index(0, 0), Qt::DisplayRole, currCombo.activeText); int row; if (matches.isEmpty()) { // we need to add this puppy @@ -293,11 +292,11 @@ void WSInfoDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, co mymodel->passInData(IDX(WeightModel::WEIGHT), grams); } -WSInfoDelegate::WSInfoDelegate(QObject* parent): ComboBoxDelegate(WSInfoModel::instance(), parent) +WSInfoDelegate::WSInfoDelegate(QObject *parent) : ComboBoxDelegate(WSInfoModel::instance(), parent) { } -QWidget* WSInfoDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const +QWidget *WSInfoDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const { /* First, call the combobox-create editor, it will setup our globals. */ QWidget *editor = ComboBoxDelegate::createEditor(parent, option, index); @@ -308,24 +307,23 @@ QWidget* WSInfoDelegate::createEditor(QWidget* parent, const QStyleOptionViewIte return editor; } -void AirTypesDelegate::revertModelData(QWidget* widget, QAbstractItemDelegate::EndEditHint hint) +void AirTypesDelegate::revertModelData(QWidget *widget, QAbstractItemDelegate::EndEditHint hint) { } -void AirTypesDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const +void AirTypesDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const { if (!index.isValid()) return; - QComboBox *combo = qobject_cast<QComboBox*>(editor); + QComboBox *combo = qobject_cast<QComboBox *>(editor); model->setData(index, QVariant(combo->currentText())); } -AirTypesDelegate::AirTypesDelegate(QObject* parent) : ComboBoxDelegate(GasSelectionModel::instance(), parent) +AirTypesDelegate::AirTypesDelegate(QObject *parent) : ComboBoxDelegate(GasSelectionModel::instance(), parent) { } -ProfilePrintDelegate::ProfilePrintDelegate(QObject *parent) - : QStyledItemDelegate(parent) +ProfilePrintDelegate::ProfilePrintDelegate(QObject *parent) : QStyledItemDelegate(parent) { } |