mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-24 10:52:56 +00:00
properly indent QSqlRelationalDelegate
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
68c87b624a
commit
2872a3bd26
1 changed files with 52 additions and 52 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue