mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
cleanup: whitespace fixes in modeldelegates.[cpp|h]
We put the pointer and reference modifier to the variable, not the type. Some people don't like this, but 1) This is consistent with the rest of the code base. 2) This is how C and C++ parse, love it or hate it. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
d30b773365
commit
d85f92c5df
2 changed files with 22 additions and 22 deletions
|
@ -29,7 +29,7 @@
|
||||||
#include <QAbstractItemView>
|
#include <QAbstractItemView>
|
||||||
#include <QSpinBox>
|
#include <QSpinBox>
|
||||||
|
|
||||||
QSize DiveListDelegate::sizeHint(const QStyleOptionViewItem&, const QModelIndex&) const
|
QSize DiveListDelegate::sizeHint(const QStyleOptionViewItem &, const QModelIndex &) const
|
||||||
{
|
{
|
||||||
const QFontMetrics metrics(qApp->font());
|
const QFontMetrics metrics(qApp->font());
|
||||||
return QSize(50, qMax(22, metrics.height()));
|
return QSize(50, qMax(22, metrics.height()));
|
||||||
|
@ -42,7 +42,7 @@ QSize DiveListDelegate::sizeHint(const QStyleOptionViewItem&, const QModelIndex&
|
||||||
StarWidgetsDelegate::StarWidgetsDelegate(QWidget *parent) : QStyledItemDelegate(parent),
|
StarWidgetsDelegate::StarWidgetsDelegate(QWidget *parent) : QStyledItemDelegate(parent),
|
||||||
parentWidget(parent)
|
parentWidget(parent)
|
||||||
{
|
{
|
||||||
const IconMetrics& metrics = defaultIconMetrics();
|
const IconMetrics &metrics = defaultIconMetrics();
|
||||||
minStarSize = QSize(metrics.sz_small * TOTALSTARS + metrics.spacing * (TOTALSTARS - 1), metrics.sz_small);
|
minStarSize = QSize(metrics.sz_small * TOTALSTARS + metrics.spacing * (TOTALSTARS - 1), metrics.sz_small);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ void StarWidgetsDelegate::paint(QPainter *painter, const QStyleOptionViewItem &o
|
||||||
painter->setRenderHint(QPainter::Antialiasing, true);
|
painter->setRenderHint(QPainter::Antialiasing, true);
|
||||||
const QPixmap active = QPixmap::fromImage(StarWidget::starActive());
|
const QPixmap active = QPixmap::fromImage(StarWidget::starActive());
|
||||||
const QPixmap inactive = QPixmap::fromImage(StarWidget::starInactive());
|
const QPixmap inactive = QPixmap::fromImage(StarWidget::starInactive());
|
||||||
const IconMetrics& metrics = defaultIconMetrics();
|
const IconMetrics &metrics = defaultIconMetrics();
|
||||||
|
|
||||||
for (int i = 0; i < rating; i++)
|
for (int i = 0; i < rating; i++)
|
||||||
painter->drawPixmap(option.rect.x() + i * metrics.sz_small + metrics.spacing, option.rect.y() + deltaY, active);
|
painter->drawPixmap(option.rect.x() + i * metrics.sz_small + metrics.spacing, option.rect.y() + deltaY, active);
|
||||||
|
@ -71,12 +71,12 @@ void StarWidgetsDelegate::paint(QPainter *painter, const QStyleOptionViewItem &o
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
QSize StarWidgetsDelegate::sizeHint(const QStyleOptionViewItem&, const QModelIndex&) const
|
QSize StarWidgetsDelegate::sizeHint(const QStyleOptionViewItem &, const QModelIndex &) const
|
||||||
{
|
{
|
||||||
return minStarSize;
|
return minStarSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QSize& StarWidgetsDelegate::starSize() const
|
const QSize &StarWidgetsDelegate::starSize() const
|
||||||
{
|
{
|
||||||
return minStarSize;
|
return minStarSize;
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ void ComboBoxDelegate::setEditorData(QWidget *editor, const QModelIndex &index)
|
||||||
c->lineEdit()->setSelection(0, c->lineEdit()->text().length());
|
c->lineEdit()->setSelection(0, c->lineEdit()->text().length());
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *ComboBoxDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem&, const QModelIndex &index) const
|
QWidget *ComboBoxDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
QComboBox *comboDelegate = new QComboBox(parent);
|
QComboBox *comboDelegate = new QComboBox(parent);
|
||||||
comboDelegate->setModel(model);
|
comboDelegate->setModel(model);
|
||||||
|
@ -122,7 +122,7 @@ QWidget *ComboBoxDelegate::createEditor(QWidget *parent, const QStyleOptionViewI
|
||||||
currCombo.activeText = currCombo.model->data(index).toString();
|
currCombo.activeText = currCombo.model->data(index).toString();
|
||||||
|
|
||||||
// Current display of things on Gnome3 looks like shit, so
|
// Current display of things on Gnome3 looks like shit, so
|
||||||
// let`s fix that.
|
// let's fix that.
|
||||||
if (isGnome3Session()) {
|
if (isGnome3Session()) {
|
||||||
QPalette p;
|
QPalette p;
|
||||||
p.setColor(QPalette::Window, QColor(Qt::white));
|
p.setColor(QPalette::Window, QColor(Qt::white));
|
||||||
|
@ -198,7 +198,7 @@ bool ComboBoxDelegate::eventFilter(QObject *object, QEvent *event)
|
||||||
return QStyledItemDelegate::eventFilter(object, event);
|
return QStyledItemDelegate::eventFilter(object, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComboBoxDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex&) const
|
void ComboBoxDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &) const
|
||||||
{
|
{
|
||||||
QRect defaultRect = option.rect;
|
QRect defaultRect = option.rect;
|
||||||
defaultRect.setX(defaultRect.x() - 1);
|
defaultRect.setX(defaultRect.x() - 1);
|
||||||
|
@ -208,7 +208,7 @@ void ComboBoxDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionV
|
||||||
editor->setGeometry(defaultRect);
|
editor->setGeometry(defaultRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TankInfoDelegate::setModelData(QWidget*, QAbstractItemModel*, const QModelIndex&) const
|
void TankInfoDelegate::setModelData(QWidget *, QAbstractItemModel *, const QModelIndex &) const
|
||||||
{
|
{
|
||||||
QAbstractItemModel *mymodel = currCombo.model;
|
QAbstractItemModel *mymodel = currCombo.model;
|
||||||
TankInfoModel *tanks = TankInfoModel::instance();
|
TankInfoModel *tanks = TankInfoModel::instance();
|
||||||
|
@ -235,7 +235,7 @@ TankInfoDelegate::TankInfoDelegate(QObject *parent) : ComboBoxDelegate(TankInfoM
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void TankInfoDelegate::editorClosed(QWidget*, QAbstractItemDelegate::EndEditHint hint)
|
void TankInfoDelegate::editorClosed(QWidget *, QAbstractItemDelegate::EndEditHint hint)
|
||||||
{
|
{
|
||||||
QAbstractItemModel *mymodel = currCombo.model;
|
QAbstractItemModel *mymodel = currCombo.model;
|
||||||
// Ugly hack: We misuse setData() with COMMIT_ROLE or REVERT_ROLE to commit or
|
// Ugly hack: We misuse setData() with COMMIT_ROLE or REVERT_ROLE to commit or
|
||||||
|
@ -251,7 +251,7 @@ TankUseDelegate::TankUseDelegate(QObject *parent) : QStyledItemDelegate(parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *TankUseDelegate::createEditor(QWidget * parent, const QStyleOptionViewItem&, const QModelIndex&) const
|
QWidget *TankUseDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &) const
|
||||||
{
|
{
|
||||||
QComboBox *comboBox = new QComboBox(parent);
|
QComboBox *comboBox = new QComboBox(parent);
|
||||||
for (int i = 0; i < NUM_GAS_USE; i++)
|
for (int i = 0; i < NUM_GAS_USE; i++)
|
||||||
|
@ -259,20 +259,20 @@ QWidget *TankUseDelegate::createEditor(QWidget * parent, const QStyleOptionViewI
|
||||||
return comboBox;
|
return comboBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TankUseDelegate::setEditorData(QWidget * editor, const QModelIndex & index) const
|
void TankUseDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
QComboBox *comboBox = qobject_cast<QComboBox*>(editor);
|
QComboBox *comboBox = qobject_cast<QComboBox *>(editor);
|
||||||
QString indexString = index.data().toString();
|
QString indexString = index.data().toString();
|
||||||
comboBox->setCurrentIndex(cylinderuse_from_text(qPrintable(indexString)));
|
comboBox->setCurrentIndex(cylinderuse_from_text(qPrintable(indexString)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TankUseDelegate::setModelData(QWidget * editor, QAbstractItemModel * model, const QModelIndex & index) const
|
void TankUseDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
QComboBox *comboBox = qobject_cast<QComboBox*>(editor);
|
QComboBox *comboBox = qobject_cast<QComboBox *>(editor);
|
||||||
model->setData(index, comboBox->currentIndex());
|
model->setData(index, comboBox->currentIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
void WSInfoDelegate::editorClosed(QWidget*, QAbstractItemDelegate::EndEditHint hint)
|
void WSInfoDelegate::editorClosed(QWidget *, QAbstractItemDelegate::EndEditHint hint)
|
||||||
{
|
{
|
||||||
WeightModel *mymodel = qobject_cast<WeightModel *>(currCombo.model);
|
WeightModel *mymodel = qobject_cast<WeightModel *>(currCombo.model);
|
||||||
if (hint == QAbstractItemDelegate::RevertModelCache)
|
if (hint == QAbstractItemDelegate::RevertModelCache)
|
||||||
|
@ -281,7 +281,7 @@ void WSInfoDelegate::editorClosed(QWidget*, QAbstractItemDelegate::EndEditHint h
|
||||||
mymodel->commitTempWS();
|
mymodel->commitTempWS();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WSInfoDelegate::setModelData(QWidget*, QAbstractItemModel*, const QModelIndex&) const
|
void WSInfoDelegate::setModelData(QWidget *, QAbstractItemModel *, const QModelIndex &) const
|
||||||
{
|
{
|
||||||
WeightModel *mymodel = qobject_cast<WeightModel *>(currCombo.model);
|
WeightModel *mymodel = qobject_cast<WeightModel *>(currCombo.model);
|
||||||
WSInfoModel *wsim = WSInfoModel::instance();
|
WSInfoModel *wsim = WSInfoModel::instance();
|
||||||
|
@ -301,7 +301,7 @@ WSInfoDelegate::WSInfoDelegate(QObject *parent) : ComboBoxDelegate(WSInfoModel::
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void AirTypesDelegate::editorClosed(QWidget*, QAbstractItemDelegate::EndEditHint)
|
void AirTypesDelegate::editorClosed(QWidget *, QAbstractItemDelegate::EndEditHint)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -317,7 +317,7 @@ AirTypesDelegate::AirTypesDelegate(QObject *parent) : ComboBoxDelegate(GasSelect
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiveTypesDelegate::editorClosed(QWidget*, QAbstractItemDelegate::EndEditHint)
|
void DiveTypesDelegate::editorClosed(QWidget *, QAbstractItemDelegate::EndEditHint)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -380,7 +380,7 @@ void LocationFilterDelegate::paint(QPainter *painter, const QStyleOptionViewItem
|
||||||
QFont fontSmaller = qApp->font();
|
QFont fontSmaller = qApp->font();
|
||||||
QFontMetrics fmBigger(fontBigger);
|
QFontMetrics fmBigger(fontBigger);
|
||||||
QStyleOptionViewItem opt = option;
|
QStyleOptionViewItem opt = option;
|
||||||
const QAbstractProxyModel *proxyModel = dynamic_cast<const QAbstractProxyModel*>(origIdx.model());
|
const QAbstractProxyModel *proxyModel = dynamic_cast<const QAbstractProxyModel *>(origIdx.model());
|
||||||
if (!proxyModel)
|
if (!proxyModel)
|
||||||
return;
|
return;
|
||||||
QModelIndex index = proxyModel->mapToSource(origIdx);
|
QModelIndex index = proxyModel->mapToSource(origIdx);
|
||||||
|
|
|
@ -23,7 +23,7 @@ public:
|
||||||
explicit StarWidgetsDelegate(QWidget *parent = 0);
|
explicit StarWidgetsDelegate(QWidget *parent = 0);
|
||||||
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
||||||
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
||||||
const QSize& starSize() const;
|
const QSize &starSize() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QWidget *parentWidget;
|
QWidget *parentWidget;
|
||||||
|
@ -74,7 +74,7 @@ public:
|
||||||
explicit TankUseDelegate(QObject *parent = 0);
|
explicit TankUseDelegate(QObject *parent = 0);
|
||||||
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override;
|
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override;
|
||||||
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
||||||
void setEditorData(QWidget * editor, const QModelIndex & index) const override;
|
void setEditorData(QWidget *editor, const QModelIndex &index) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class WSInfoDelegate : public ComboBoxDelegate {
|
class WSInfoDelegate : public ComboBoxDelegate {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue