2015-05-30 12:51:33 +00:00
|
|
|
#include "idcompletiondelegate.hpp"
|
|
|
|
|
|
|
|
#include "../../model/world/idcompletionmanager.hpp"
|
|
|
|
|
2015-06-20 14:33:36 +00:00
|
|
|
#include "../widget/droplineedit.hpp"
|
|
|
|
|
2015-05-30 12:51:33 +00:00
|
|
|
CSVWorld::IdCompletionDelegate::IdCompletionDelegate(CSMWorld::CommandDispatcher *dispatcher,
|
|
|
|
CSMDoc::Document& document,
|
|
|
|
QObject *parent)
|
|
|
|
: CommandDelegate(dispatcher, document, parent)
|
|
|
|
{}
|
|
|
|
|
|
|
|
QWidget *CSVWorld::IdCompletionDelegate::createEditor(QWidget *parent,
|
|
|
|
const QStyleOptionViewItem &option,
|
|
|
|
const QModelIndex &index) const
|
|
|
|
{
|
2015-06-03 09:01:13 +00:00
|
|
|
return createEditor(parent, option, index, getDisplayTypeFromIndex(index));
|
2015-05-30 12:51:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QWidget *CSVWorld::IdCompletionDelegate::createEditor(QWidget *parent,
|
|
|
|
const QStyleOptionViewItem &option,
|
|
|
|
const QModelIndex &index,
|
|
|
|
CSMWorld::ColumnBase::Display display) const
|
|
|
|
{
|
2015-06-03 09:01:13 +00:00
|
|
|
if (!index.data(Qt::EditRole).isValid() && !index.data(Qt::DisplayRole).isValid())
|
2015-05-30 12:51:33 +00:00
|
|
|
{
|
2015-06-03 09:01:13 +00:00
|
|
|
return NULL;
|
2015-05-30 12:51:33 +00:00
|
|
|
}
|
2015-06-03 09:01:13 +00:00
|
|
|
|
|
|
|
CSMWorld::IdCompletionManager &completionManager = getDocument().getIdCompletionManager();
|
2015-06-20 15:29:31 +00:00
|
|
|
CSVWidget::DropLineEdit *editor = new CSVWidget::DropLineEdit(display, parent);
|
2015-06-03 09:01:13 +00:00
|
|
|
editor->setCompleter(completionManager.getCompleter(display).get());
|
2015-05-30 12:51:33 +00:00
|
|
|
return editor;
|
|
|
|
}
|
|
|
|
|
|
|
|
CSVWorld::CommandDelegate *CSVWorld::IdCompletionDelegateFactory::makeDelegate(CSMWorld::CommandDispatcher *dispatcher,
|
|
|
|
CSMDoc::Document& document,
|
|
|
|
QObject *parent) const
|
|
|
|
{
|
|
|
|
return new IdCompletionDelegate(dispatcher, document, parent);
|
2015-05-31 15:18:49 +00:00
|
|
|
}
|