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-12-20 04:02:18 +00:00
|
|
|
// The savegame format limits the player faction string to 32 characters.
|
|
|
|
// The region sound name is limited to 32 characters. (ESM::Region::SoundRef::mSound)
|
|
|
|
// The script name is limited to 32 characters. (ESM::Script::SCHD::mName)
|
|
|
|
// The cell name is limited to 64 characters. (ESM::Header::GMDT::mCurrentCell)
|
|
|
|
if (display == CSMWorld::ColumnBase::Display_Faction ||
|
|
|
|
display == CSMWorld::ColumnBase::Display_Sound ||
|
|
|
|
display == CSMWorld::ColumnBase::Display_Script ||
|
|
|
|
display == CSMWorld::ColumnBase::Display_Referenceable)
|
|
|
|
{
|
|
|
|
editor->setMaxLength (32);
|
|
|
|
}
|
|
|
|
else if (display == CSMWorld::ColumnBase::Display_Cell)
|
|
|
|
{
|
|
|
|
editor->setMaxLength (64);
|
|
|
|
}
|
|
|
|
|
2015-05-30 12:51:33 +00:00
|
|
|
return editor;
|
|
|
|
}
|
|
|
|
|
|
|
|
CSVWorld::CommandDelegate *CSVWorld::IdCompletionDelegateFactory::makeDelegate(CSMWorld::CommandDispatcher *dispatcher,
|
2015-12-20 04:02:18 +00:00
|
|
|
CSMDoc::Document& document,
|
2015-05-30 12:51:33 +00:00
|
|
|
QObject *parent) const
|
|
|
|
{
|
|
|
|
return new IdCompletionDelegate(dispatcher, document, parent);
|
2015-05-31 15:18:49 +00:00
|
|
|
}
|