Added capability to create editors from an editor factory to PgLabItemDelegate
This commit is contained in:
parent
62c6ad5bfb
commit
f8d61b61f4
3 changed files with 66 additions and 0 deletions
|
|
@ -4,6 +4,7 @@
|
|||
#include "Pgsql_oids.h"
|
||||
#include "ResultTableModelUtil.h"
|
||||
#include "CustomDataRole.h"
|
||||
#include "AbstractEditorFactory.h"
|
||||
|
||||
PgLabItemDelegate::PgLabItemDelegate(QObject *parent)
|
||||
: QStyledItemDelegate(parent)
|
||||
|
|
@ -128,3 +129,32 @@ void PgLabItemDelegate::paint(QPainter *painter,
|
|||
QStyle *style = widget ? widget->style() : QApplication::style();
|
||||
style->drawControl(QStyle::CE_ItemViewItem, &opt, painter, widget);
|
||||
}
|
||||
|
||||
QWidget *PgLabItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
if (m_editorFactory)
|
||||
return m_editorFactory->createEditor(parent, option, index);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void PgLabItemDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
|
||||
{
|
||||
if (m_editorFactory)
|
||||
m_editorFactory->setEditorData(editor, index);
|
||||
}
|
||||
|
||||
void PgLabItemDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
|
||||
{
|
||||
if (m_editorFactory)
|
||||
m_editorFactory->setModelData(editor, model, index);
|
||||
}
|
||||
|
||||
AbstractEditorFactory* PgLabItemDelegate::editorFactory()
|
||||
{
|
||||
return m_editorFactory;
|
||||
}
|
||||
|
||||
void PgLabItemDelegate::setEditorFactory(AbstractEditorFactory *editor_factory)
|
||||
{
|
||||
m_editorFactory = editor_factory;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue