properly indent QSqlRelationalDelegate

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2020-12-03 16:33:39 +00:00
parent 68c87b624a
commit 2872a3bd26

View file

@ -50,17 +50,17 @@ class QSqlRelationalDelegate: public QItemDelegate
{
public:
explicit QSqlRelationalDelegate(QObject *aParent = Q_NULLPTR)
explicit QSqlRelationalDelegate(QObject *aParent = Q_NULLPTR)
: QItemDelegate(aParent)
{}
{}
~QSqlRelationalDelegate()
{}
~QSqlRelationalDelegate()
{}
QWidget *createEditor(QWidget *aParent,
QWidget *createEditor(QWidget *aParent,
const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
{
const QSqlRelationalTableModel *sqlModel = qobject_cast<const QSqlRelationalTableModel *>(index.model());
QSqlTableModel *childModel = sqlModel ? sqlModel->relationModel(index.column()) : 0;
if (!childModel)
@ -72,10 +72,10 @@ QWidget *createEditor(QWidget *aParent,
combo->installEventFilter(const_cast<QSqlRelationalDelegate *>(this));
return combo;
}
}
void setEditorData(QWidget *editor, const QModelIndex &index) const
{
void setEditorData(QWidget *editor, const QModelIndex &index) const
{
const QSqlRelationalTableModel *sqlModel = qobject_cast<const QSqlRelationalTableModel *>(index.model());
QComboBox *combo = qobject_cast<QComboBox *>(editor);
if (!sqlModel || !combo) {
@ -83,10 +83,10 @@ void setEditorData(QWidget *editor, const QModelIndex &index) const
return;
}
combo->setCurrentIndex(combo->findText(sqlModel->data(index).toString()));
}
}
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
{
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
{
if (!index.isValid())
return;
@ -107,7 +107,7 @@ void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex
sqlModel->setData(index,
childModel->data(childModel->index(currentItem, childEditIndex), Qt::EditRole),
Qt::EditRole);
}
}
};