#include <CQComboDelegate.h>
|
| CQComboDelegate (const QStringList *pComboItems, QObject *parent=NULL, bool commitOnSelect=true) |
|
virtual QWidget * | createEditor (QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const |
|
const QStringList * | getItems (int row) const |
|
bool | isCommitOnSelect () const |
|
void | setCommitOnSelect (bool commitOnSelect) |
|
virtual void | setEditorData (QWidget *editor, const QModelIndex &index) const |
|
void | setItems (int row, const QStringList *pComboItems) |
|
virtual void | setModelData (QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const |
|
virtual void | updateEditorGeometry (QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const |
|
virtual | ~CQComboDelegate () |
|
Definition at line 16 of file CQComboDelegate.h.
CQComboDelegate::CQComboDelegate |
( |
const QStringList * |
pComboItems, |
|
|
QObject * |
parent = NULL , |
|
|
bool |
commitOnSelect = true |
|
) |
| |
Definition at line 18 of file CQComboDelegate.cpp.
19 QItemDelegate(parent),
const QStringList * mpComboItems
QMap< QWidget *, QModelIndex > mEditorToIndex
QMap< int, const QStringList * > mRowToItems
CQComboDelegate::~CQComboDelegate |
( |
| ) |
|
|
virtual |
QWidget * CQComboDelegate::createEditor |
( |
QWidget * |
parent, |
|
|
const QStyleOptionViewItem & |
option, |
|
|
const QModelIndex & |
index |
|
) |
| const |
|
virtual |
Definition at line 29 of file CQComboDelegate.cpp.
References currentIndexChanged(), getItems(), mEditorToIndex, slotCurrentIndexChanged(), and slotEditorDeleted().
33 QModelIndex SourceIndex = index;
34 const QAbstractItemModel *pModel = index.model();
36 while (pModel->inherits(
"QSortFilterProxyModel"))
38 SourceIndex =
static_cast< const QSortFilterProxyModel *
>(pModel)->mapToSource(index);
39 pModel = SourceIndex.model();
42 QComboBox *pEditor =
new QComboBox(parent);
44 if (
getItems(SourceIndex.row()) != NULL)
46 pEditor->addItems(*
getItems(SourceIndex.row()));
52 connect(pEditor, SIGNAL(destroyed(QObject *)),
this, SLOT(
slotEditorDeleted(QObject *)));
QMap< QWidget *, QModelIndex > mEditorToIndex
void currentIndexChanged(int, int)
const QStringList * getItems(int row) const
void slotEditorDeleted(QObject *pObject)
void slotCurrentIndexChanged(int index)
void CQComboDelegate::currentIndexChanged |
( |
int |
, |
|
|
int |
|
|
) |
| |
|
signal |
const QStringList * CQComboDelegate::getItems |
( |
int |
row | ) |
const |
bool CQComboDelegate::isCommitOnSelect |
( |
| ) |
const |
void CQComboDelegate::setCommitOnSelect |
( |
bool |
commitOnSelect | ) |
|
void CQComboDelegate::setEditorData |
( |
QWidget * |
editor, |
|
|
const QModelIndex & |
index |
|
) |
| const |
|
virtual |
Definition at line 57 of file CQComboDelegate.cpp.
60 QString value = index.model()->data(index, Qt::DisplayRole).toString();
61 QComboBox *comboBox =
static_cast<QComboBox*
>(editor);
63 comboBox->blockSignals(
true);
64 comboBox->setCurrentIndex(comboBox->findText(value));
65 comboBox->blockSignals(
false);
void CQComboDelegate::setItems |
( |
int |
row, |
|
|
const QStringList * |
pComboItems |
|
) |
| |
void CQComboDelegate::setModelData |
( |
QWidget * |
editor, |
|
|
QAbstractItemModel * |
model, |
|
|
const QModelIndex & |
index |
|
) |
| const |
|
virtual |
Reimplemented in CQIndexComboDelegate.
Definition at line 68 of file CQComboDelegate.cpp.
71 QComboBox *comboBox =
static_cast<QComboBox*
>(editor);
72 QVariant value(comboBox->currentText());
73 model->setData(index, value, Qt::EditRole);
void CQComboDelegate::slotCurrentIndexChanged |
( |
int |
index | ) |
|
|
protectedslot |
void CQComboDelegate::slotEditorDeleted |
( |
QObject * |
pObject | ) |
|
|
protectedslot |
void CQComboDelegate::updateEditorGeometry |
( |
QWidget * |
editor, |
|
|
const QStyleOptionViewItem & |
option, |
|
|
const QModelIndex & |
index |
|
) |
| const |
|
virtual |
bool CQComboDelegate::mCommitOnSelect |
|
private |
QMap< QWidget * , QModelIndex > CQComboDelegate::mEditorToIndex |
|
mutableprivate |
const QStringList* CQComboDelegate::mpComboItems |
|
private |
QMap< int, const QStringList * > CQComboDelegate::mRowToItems |
|
mutableprivate |
The documentation for this class was generated from the following files: