|
|
|
@ -1,6 +1,8 @@
|
|
|
|
|
|
|
|
|
|
#include "util.hpp"
|
|
|
|
|
|
|
|
|
|
#include <stdexcept>
|
|
|
|
|
|
|
|
|
|
#include <QUndoStack>
|
|
|
|
|
|
|
|
|
|
#include "../../model/world/commands.hpp"
|
|
|
|
@ -35,6 +37,57 @@ QVariant CSVWorld::NastyTableModelHack::getData() const
|
|
|
|
|
return mData;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CSVWorld::CommandDelegateFactory::~CommandDelegateFactory() {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CSVWorld::CommandDelegateFactoryCollection *CSVWorld::CommandDelegateFactoryCollection::sThis = 0;
|
|
|
|
|
|
|
|
|
|
CSVWorld::CommandDelegateFactoryCollection::CommandDelegateFactoryCollection()
|
|
|
|
|
{
|
|
|
|
|
if (sThis)
|
|
|
|
|
throw std::logic_error ("multiple instances of CSVWorld::CommandDelegateFactoryCollection");
|
|
|
|
|
|
|
|
|
|
sThis = this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CSVWorld::CommandDelegateFactoryCollection::~CommandDelegateFactoryCollection()
|
|
|
|
|
{
|
|
|
|
|
sThis = 0;
|
|
|
|
|
|
|
|
|
|
for (std::map<CSMWorld::ColumnBase::Display, CommandDelegateFactory *>::iterator iter (
|
|
|
|
|
mFactories.begin());
|
|
|
|
|
iter!=mFactories.end(); ++iter)
|
|
|
|
|
delete iter->second;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CSVWorld::CommandDelegateFactoryCollection::add (CSMWorld::ColumnBase::Display display,
|
|
|
|
|
CommandDelegateFactory *factory)
|
|
|
|
|
{
|
|
|
|
|
mFactories.insert (std::make_pair (display, factory));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CSVWorld::CommandDelegate *CSVWorld::CommandDelegateFactoryCollection::makeDelegate (
|
|
|
|
|
CSMWorld::ColumnBase::Display display, QUndoStack& undoStack, QObject *parent) const
|
|
|
|
|
{
|
|
|
|
|
std::map<CSMWorld::ColumnBase::Display, CommandDelegateFactory *>::const_iterator iter =
|
|
|
|
|
mFactories.find (display);
|
|
|
|
|
|
|
|
|
|
if (iter!=mFactories.end())
|
|
|
|
|
return iter->second->makeDelegate (undoStack, parent);
|
|
|
|
|
|
|
|
|
|
return new CommandDelegate (undoStack, parent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const CSVWorld::CommandDelegateFactoryCollection& CSVWorld::CommandDelegateFactoryCollection::get()
|
|
|
|
|
{
|
|
|
|
|
if (!sThis)
|
|
|
|
|
throw std::logic_error ("no instance of CSVWorld::CommandDelegateFactoryCollection");
|
|
|
|
|
|
|
|
|
|
return *sThis;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CSVWorld::CommandDelegate::CommandDelegate (QUndoStack& undoStack, QObject *parent)
|
|
|
|
|
: QStyledItemDelegate (parent), mUndoStack (undoStack), mEditLock (false)
|
|
|
|
|
{}
|
|
|
|
|