|
|
|
@ -13,6 +13,10 @@
|
|
|
|
|
#include <QLineEdit>
|
|
|
|
|
#include <QEvent>
|
|
|
|
|
#include <QDataWidgetMapper>
|
|
|
|
|
#include <QCheckBox>
|
|
|
|
|
#include <QLineEdit>
|
|
|
|
|
#include <QPlainTextEdit>
|
|
|
|
|
#include <QComboBox>
|
|
|
|
|
|
|
|
|
|
#include "../../model/world/columnbase.hpp"
|
|
|
|
|
#include "../../model/world/idtable.hpp"
|
|
|
|
@ -126,30 +130,46 @@ QSize CSVWorld::DialogueDelegateDispatcher::sizeHint (const QStyleOptionViewItem
|
|
|
|
|
|
|
|
|
|
QWidget* CSVWorld::DialogueDelegateDispatcher::makeEditor(CSMWorld::ColumnBase::Display display, const QModelIndex& index)
|
|
|
|
|
{
|
|
|
|
|
bool hasEnums = CSMWorld::Columns::hasEnums(static_cast<CSMWorld::Columns::ColumnId>(mTable->getColumnId(index.column() ) ) );
|
|
|
|
|
QVariant variant = index.data();
|
|
|
|
|
if (!variant.isValid())
|
|
|
|
|
{
|
|
|
|
|
variant = index.data(Qt::DisplayRole);
|
|
|
|
|
if (!variant.isValid())
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QWidget* editor = NULL;
|
|
|
|
|
std::map<int, CommandDelegate*>::iterator delegateIt(mDelegates.find(display));
|
|
|
|
|
if (delegateIt != mDelegates.end())
|
|
|
|
|
{
|
|
|
|
|
editor = delegateIt->second->createEditor(dynamic_cast<QWidget*>(mParent), QStyleOptionViewItem(), index, display);
|
|
|
|
|
DialogueDelegateDispatcherProxy* proxy = new DialogueDelegateDispatcherProxy(editor, display);
|
|
|
|
|
if (hasEnums) //combox is used for all enums
|
|
|
|
|
{
|
|
|
|
|
connect(editor, SIGNAL(currentIndexChanged (int)), proxy, SLOT(editorDataCommited()));
|
|
|
|
|
} else
|
|
|
|
|
{
|
|
|
|
|
connect(editor, SIGNAL(editingFinished()), proxy, SLOT(editorDataCommited()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool skip = false;
|
|
|
|
|
if (qobject_cast<QLineEdit*>(editor))
|
|
|
|
|
{
|
|
|
|
|
connect(editor, SIGNAL(editingFinished()), proxy, SLOT(editorDataCommited()));
|
|
|
|
|
skip = true;
|
|
|
|
|
}
|
|
|
|
|
if(!skip && qobject_cast<QCheckBox*>(editor))
|
|
|
|
|
{
|
|
|
|
|
connect(editor, SIGNAL(stateChanged(int)), proxy, SLOT(editorDataCommited()));
|
|
|
|
|
skip = true;
|
|
|
|
|
}
|
|
|
|
|
if(!skip && qobject_cast<QPlainTextEdit*>(editor))
|
|
|
|
|
{
|
|
|
|
|
connect(editor, SIGNAL(textChanged()), proxy, SLOT(editorDataCommited()));
|
|
|
|
|
skip = true;
|
|
|
|
|
}
|
|
|
|
|
if(!skip && qobject_cast<QComboBox*>(editor))
|
|
|
|
|
{
|
|
|
|
|
connect(editor, SIGNAL(currentIndexChanged (int)), proxy, SLOT(editorDataCommited()));
|
|
|
|
|
skip = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
connect(proxy, SIGNAL(editorDataCommited(QWidget*, const QModelIndex&, CSMWorld::ColumnBase::Display)), this, SLOT(editorDataCommited(QWidget*, const QModelIndex&, CSMWorld::ColumnBase::Display)));
|
|
|
|
|
mProxys.push_back(proxy); //deleted in the destructor
|
|
|
|
|
}
|
|
|
|
|