|
|
|
@ -14,7 +14,7 @@
|
|
|
|
|
void CSVWorld::EnumDelegate::setModelDataImp (QWidget *editor, QAbstractItemModel *model,
|
|
|
|
|
const QModelIndex& index) const
|
|
|
|
|
{
|
|
|
|
|
if (QComboBox *comboBox = qobject_cast<QComboBox *> (editor))
|
|
|
|
|
if (QComboBox *comboBox = dynamic_cast<QComboBox *> (editor))
|
|
|
|
|
{
|
|
|
|
|
QString value = comboBox->currentText();
|
|
|
|
|
|
|
|
|
@ -42,25 +42,18 @@ CSVWorld::EnumDelegate::EnumDelegate (const std::vector<std::pair<int, QString>
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QWidget *CSVWorld::EnumDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem& option,
|
|
|
|
|
const QModelIndex& index, CSMWorld::ColumnBase::Display display) const
|
|
|
|
|
QWidget *CSVWorld::EnumDelegate::createEditor(QWidget *parent,
|
|
|
|
|
const QStyleOptionViewItem& option,
|
|
|
|
|
const QModelIndex& index) const
|
|
|
|
|
{
|
|
|
|
|
if (!index.data(Qt::EditRole).isValid() && !index.data(Qt::DisplayRole).isValid())
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
QComboBox *comboBox = new QComboBox (parent);
|
|
|
|
|
|
|
|
|
|
for (std::vector<std::pair<int, QString> >::const_iterator iter (mValues.begin());
|
|
|
|
|
iter!=mValues.end(); ++iter)
|
|
|
|
|
comboBox->addItem (iter->second);
|
|
|
|
|
|
|
|
|
|
return comboBox;
|
|
|
|
|
return createEditor(parent, option, index, CSMWorld::ColumnBase::Display_None);
|
|
|
|
|
//overloading virtual functions is HARD
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QWidget *CSVWorld::EnumDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem& option,
|
|
|
|
|
const QModelIndex& index) const
|
|
|
|
|
const QModelIndex& index, CSMWorld::ColumnBase::Display display) const
|
|
|
|
|
{
|
|
|
|
|
if (!index.data(Qt::EditRole).isValid())
|
|
|
|
|
if (!index.data(Qt::EditRole).isValid() && !index.data(Qt::DisplayRole).isValid())
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
QComboBox *comboBox = new QComboBox (parent);
|
|
|
|
@ -74,7 +67,7 @@ QWidget *CSVWorld::EnumDelegate::createEditor(QWidget *parent, const QStyleOptio
|
|
|
|
|
|
|
|
|
|
void CSVWorld::EnumDelegate::setEditorData (QWidget *editor, const QModelIndex& index, bool tryDisplay) const
|
|
|
|
|
{
|
|
|
|
|
if (QComboBox *comboBox = qobject_cast<QComboBox *> (editor)) //qobject_cast is faster than dynamic_cast
|
|
|
|
|
if (QComboBox *comboBox = dynamic_cast<QComboBox *> (editor))
|
|
|
|
|
{
|
|
|
|
|
QVariant data = index.data (Qt::EditRole);
|
|
|
|
|
|
|
|
|
|