|
|
@ -40,8 +40,12 @@ QAbstractItemDelegate(parent),
|
|
|
|
mTable(table)
|
|
|
|
mTable(table)
|
|
|
|
{}
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
void CSVWorld::NotEditableSubDelegate::setEditorData (QLabel* editor, const QModelIndex& index) const
|
|
|
|
void CSVWorld::NotEditableSubDelegate::setEditorData (QWidget* editor, const QModelIndex& index) const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
QLabel* label = qobject_cast<QLabel*>(editor);
|
|
|
|
|
|
|
|
if(!label)
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
QVariant v = index.data(Qt::EditRole);
|
|
|
|
QVariant v = index.data(Qt::EditRole);
|
|
|
|
if (!v.isValid())
|
|
|
|
if (!v.isValid())
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -54,16 +58,17 @@ void CSVWorld::NotEditableSubDelegate::setEditorData (QLabel* editor, const QMod
|
|
|
|
|
|
|
|
|
|
|
|
if (QVariant::String == v.type())
|
|
|
|
if (QVariant::String == v.type())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
editor->setText(v.toString());
|
|
|
|
label->setText(v.toString());
|
|
|
|
} else //else we are facing enums
|
|
|
|
}
|
|
|
|
|
|
|
|
else //else we are facing enums
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int data = v.toInt();
|
|
|
|
int data = v.toInt();
|
|
|
|
std::vector<std::string> enumNames (CSMWorld::Columns::getEnums (static_cast<CSMWorld::Columns::ColumnId> (mTable->getColumnId (index.column()))));
|
|
|
|
std::vector<std::string> enumNames (CSMWorld::Columns::getEnums (static_cast<CSMWorld::Columns::ColumnId> (mTable->getColumnId (index.column()))));
|
|
|
|
editor->setText(QString::fromUtf8(enumNames.at(data).c_str()));
|
|
|
|
label->setText(QString::fromUtf8(enumNames.at(data).c_str()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CSVWorld::NotEditableSubDelegate::setModelData (QWidget* editor, QAbstractItemModel* model, const QModelIndex& index, CSMWorld::ColumnBase::Display display) const
|
|
|
|
void CSVWorld::NotEditableSubDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//not editable widgets will not save model data
|
|
|
|
//not editable widgets will not save model data
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -80,8 +85,7 @@ QSize CSVWorld::NotEditableSubDelegate::sizeHint (const QStyleOptionViewItem& op
|
|
|
|
|
|
|
|
|
|
|
|
QWidget* CSVWorld::NotEditableSubDelegate::createEditor (QWidget *parent,
|
|
|
|
QWidget* CSVWorld::NotEditableSubDelegate::createEditor (QWidget *parent,
|
|
|
|
const QStyleOptionViewItem& option,
|
|
|
|
const QStyleOptionViewItem& option,
|
|
|
|
const QModelIndex& index,
|
|
|
|
const QModelIndex& index) const
|
|
|
|
CSMWorld::ColumnBase::Display display) const
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return new QLabel(parent);
|
|
|
|
return new QLabel(parent);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -224,6 +228,11 @@ void CSVWorld::DialogueDelegateDispatcher::setEditorData (QWidget* editor, const
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CSVWorld::DialogueDelegateDispatcher::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
setModelData(editor, model, index, CSMWorld::ColumnBase::Display_None);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CSVWorld::DialogueDelegateDispatcher::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index, CSMWorld::ColumnBase::Display display) const
|
|
|
|
void CSVWorld::DialogueDelegateDispatcher::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index, CSMWorld::ColumnBase::Display display) const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::map<int, CommandDelegate*>::const_iterator delegateIt(mDelegates.find(display));
|
|
|
|
std::map<int, CommandDelegate*>::const_iterator delegateIt(mDelegates.find(display));
|
|
|
@ -258,7 +267,7 @@ QWidget* CSVWorld::DialogueDelegateDispatcher::makeEditor(CSMWorld::ColumnBase::
|
|
|
|
QWidget* editor = NULL;
|
|
|
|
QWidget* editor = NULL;
|
|
|
|
if (! (mTable->flags (index) & Qt::ItemIsEditable))
|
|
|
|
if (! (mTable->flags (index) & Qt::ItemIsEditable))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return mNotEditableDelegate.createEditor(qobject_cast<QWidget*>(mParent), QStyleOptionViewItem(), index, display);
|
|
|
|
return mNotEditableDelegate.createEditor(qobject_cast<QWidget*>(mParent), QStyleOptionViewItem(), index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::map<int, CommandDelegate*>::iterator delegateIt(mDelegates.find(display));
|
|
|
|
std::map<int, CommandDelegate*>::iterator delegateIt(mDelegates.find(display));
|
|
|
|