mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-21 11:23:51 +00:00
make delegates use the whole document instead of the undo stack
This commit is contained in:
parent
f468c53281
commit
30830d0693
16 changed files with 67 additions and 62 deletions
|
@ -21,7 +21,7 @@ CSVTools::ReportSubView::ReportSubView (const CSMWorld::UniversalId& id, CSMDoc:
|
||||||
mTable->setSelectionMode (QAbstractItemView::ExtendedSelection);
|
mTable->setSelectionMode (QAbstractItemView::ExtendedSelection);
|
||||||
|
|
||||||
mIdTypeDelegate = CSVWorld::IdTypeDelegateFactory().makeDelegate (
|
mIdTypeDelegate = CSVWorld::IdTypeDelegateFactory().makeDelegate (
|
||||||
document.getUndoStack(), this);
|
document, this);
|
||||||
|
|
||||||
mTable->setItemDelegateForColumn (0, mIdTypeDelegate);
|
mTable->setItemDelegateForColumn (0, mIdTypeDelegate);
|
||||||
|
|
||||||
|
|
|
@ -6,11 +6,11 @@
|
||||||
|
|
||||||
CSVWorld::DataDisplayDelegate::DataDisplayDelegate(const ValueList &values,
|
CSVWorld::DataDisplayDelegate::DataDisplayDelegate(const ValueList &values,
|
||||||
const IconList &icons,
|
const IconList &icons,
|
||||||
QUndoStack &undoStack,
|
CSMDoc::Document& document,
|
||||||
const QString &pageName,
|
const QString &pageName,
|
||||||
const QString &settingName,
|
const QString &settingName,
|
||||||
QObject *parent)
|
QObject *parent)
|
||||||
: EnumDelegate (values, undoStack, parent), mDisplayMode (Mode_TextOnly),
|
: EnumDelegate (values, document, parent), mDisplayMode (Mode_TextOnly),
|
||||||
mIcons (icons), mIconSize (QSize(16, 16)), mIconLeftOffset(3),
|
mIcons (icons), mIconSize (QSize(16, 16)), mIconLeftOffset(3),
|
||||||
mTextLeftOffset(8), mSettingKey (pageName + '/' + settingName)
|
mTextLeftOffset(8), mSettingKey (pageName + '/' + settingName)
|
||||||
{
|
{
|
||||||
|
@ -126,8 +126,6 @@ void CSVWorld::DataDisplayDelegate::updateDisplayMode (const QString &mode)
|
||||||
|
|
||||||
CSVWorld::DataDisplayDelegate::~DataDisplayDelegate()
|
CSVWorld::DataDisplayDelegate::~DataDisplayDelegate()
|
||||||
{
|
{
|
||||||
mIcons.clear();
|
|
||||||
mPixmaps.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::DataDisplayDelegateFactory::add (int enumValue, QString enumName, QString iconFilename)
|
void CSVWorld::DataDisplayDelegateFactory::add (int enumValue, QString enumName, QString iconFilename)
|
||||||
|
@ -137,11 +135,10 @@ void CSVWorld::DataDisplayDelegateFactory::add (int enumValue, QString enumName,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CSVWorld::CommandDelegate *CSVWorld::DataDisplayDelegateFactory::makeDelegate (QUndoStack& undoStack,
|
CSVWorld::CommandDelegate *CSVWorld::DataDisplayDelegateFactory::makeDelegate (
|
||||||
QObject *parent) const
|
CSMDoc::Document& document, QObject *parent) const
|
||||||
{
|
{
|
||||||
|
return new DataDisplayDelegate (mValues, mIcons, document, "", "", parent);
|
||||||
return new DataDisplayDelegate (mValues, mIcons, undoStack, "", "", parent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ namespace CSVWorld
|
||||||
public:
|
public:
|
||||||
explicit DataDisplayDelegate (const ValueList & values,
|
explicit DataDisplayDelegate (const ValueList & values,
|
||||||
const IconList & icons,
|
const IconList & icons,
|
||||||
QUndoStack& undoStack,
|
CSMDoc::Document& document,
|
||||||
const QString &pageName,
|
const QString &pageName,
|
||||||
const QString &settingName,
|
const QString &settingName,
|
||||||
QObject *parent);
|
QObject *parent);
|
||||||
|
@ -82,7 +82,7 @@ namespace CSVWorld
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual CommandDelegate *makeDelegate (QUndoStack& undoStack, QObject *parent) const;
|
virtual CommandDelegate *makeDelegate (CSMDoc::Document& document, QObject *parent) const;
|
||||||
///< The ownership of the returned CommandDelegate is transferred to the caller.
|
///< The ownership of the returned CommandDelegate is transferred to the caller.
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -167,10 +167,10 @@ void CSVWorld::DialogueDelegateDispatcherProxy::tableMimeDataDropped(const std::
|
||||||
==============================DialogueDelegateDispatcher==========================================
|
==============================DialogueDelegateDispatcher==========================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
CSVWorld::DialogueDelegateDispatcher::DialogueDelegateDispatcher(QObject* parent, CSMWorld::IdTable* table, QUndoStack& undoStack) :
|
CSVWorld::DialogueDelegateDispatcher::DialogueDelegateDispatcher(QObject* parent, CSMWorld::IdTable* table, CSMDoc::Document& document) :
|
||||||
mParent(parent),
|
mParent(parent),
|
||||||
mTable(table),
|
mTable(table),
|
||||||
mUndoStack(undoStack),
|
mDocument (document),
|
||||||
mNotEditableDelegate(table, parent)
|
mNotEditableDelegate(table, parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -182,7 +182,7 @@ CSVWorld::CommandDelegate* CSVWorld::DialogueDelegateDispatcher::makeDelegate(CS
|
||||||
if (delegateIt == mDelegates.end())
|
if (delegateIt == mDelegates.end())
|
||||||
{
|
{
|
||||||
delegate = CommandDelegateFactoryCollection::get().makeDelegate (
|
delegate = CommandDelegateFactoryCollection::get().makeDelegate (
|
||||||
display, mUndoStack, mParent);
|
display, mDocument, mParent);
|
||||||
mDelegates.insert(std::make_pair(display, delegate));
|
mDelegates.insert(std::make_pair(display, delegate));
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
|
@ -315,12 +315,12 @@ CSVWorld::DialogueDelegateDispatcher::~DialogueDelegateDispatcher()
|
||||||
=============================================================EditWidget=====================================================
|
=============================================================EditWidget=====================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
CSVWorld::EditWidget::EditWidget(QWidget *parent, int row, CSMWorld::IdTable* table, QUndoStack& undoStack, bool createAndDelete) :
|
CSVWorld::EditWidget::EditWidget(QWidget *parent, int row, CSMWorld::IdTable* table, CSMDoc::Document& document, bool createAndDelete) :
|
||||||
mDispatcher(this, table, undoStack),
|
mDispatcher(this, table, document),
|
||||||
QScrollArea(parent),
|
QScrollArea(parent),
|
||||||
mWidgetMapper(NULL),
|
mWidgetMapper(NULL),
|
||||||
mMainWidget(NULL),
|
mMainWidget(NULL),
|
||||||
mUndoStack(undoStack),
|
mDocument (document),
|
||||||
mTable(table)
|
mTable(table)
|
||||||
{
|
{
|
||||||
remake (row);
|
remake (row);
|
||||||
|
@ -478,7 +478,7 @@ CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id, CSM
|
||||||
|
|
||||||
mMainLayout = new QVBoxLayout(mainWidget);
|
mMainLayout = new QVBoxLayout(mainWidget);
|
||||||
|
|
||||||
mEditWidget = new EditWidget(mainWidget, mRow, mTable, mUndoStack, false);
|
mEditWidget = new EditWidget(mainWidget, mRow, mTable, document, false);
|
||||||
connect(mEditWidget, SIGNAL(tableMimeDataDropped(QWidget*, const QModelIndex&, const CSMWorld::UniversalId&, const CSMDoc::Document*)),
|
connect(mEditWidget, SIGNAL(tableMimeDataDropped(QWidget*, const QModelIndex&, const CSMWorld::UniversalId&, const CSMDoc::Document*)),
|
||||||
this, SLOT(tableMimeDataDropped(QWidget*, const QModelIndex&, const CSMWorld::UniversalId&, const CSMDoc::Document*)));
|
this, SLOT(tableMimeDataDropped(QWidget*, const QModelIndex&, const CSMWorld::UniversalId&, const CSMDoc::Document*)));
|
||||||
|
|
||||||
|
|
|
@ -101,14 +101,14 @@ namespace CSVWorld
|
||||||
|
|
||||||
CSMWorld::IdTable* mTable;
|
CSMWorld::IdTable* mTable;
|
||||||
|
|
||||||
QUndoStack& mUndoStack;
|
CSMDoc::Document& mDocument;
|
||||||
|
|
||||||
NotEditableSubDelegate mNotEditableDelegate;
|
NotEditableSubDelegate mNotEditableDelegate;
|
||||||
|
|
||||||
std::vector<DialogueDelegateDispatcherProxy*> mProxys; //once we move to the C++11 we should use unique_ptr
|
std::vector<DialogueDelegateDispatcherProxy*> mProxys; //once we move to the C++11 we should use unique_ptr
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DialogueDelegateDispatcher(QObject* parent, CSMWorld::IdTable* table, QUndoStack& undoStack);
|
DialogueDelegateDispatcher(QObject* parent, CSMWorld::IdTable* table, CSMDoc::Document& document);
|
||||||
|
|
||||||
~DialogueDelegateDispatcher();
|
~DialogueDelegateDispatcher();
|
||||||
|
|
||||||
|
@ -145,11 +145,11 @@ namespace CSVWorld
|
||||||
DialogueDelegateDispatcher mDispatcher;
|
DialogueDelegateDispatcher mDispatcher;
|
||||||
QWidget* mMainWidget;
|
QWidget* mMainWidget;
|
||||||
CSMWorld::IdTable* mTable;
|
CSMWorld::IdTable* mTable;
|
||||||
QUndoStack& mUndoStack;
|
CSMDoc::Document& mDocument;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
EditWidget (QWidget *parent, int row, CSMWorld::IdTable* table, QUndoStack& undoStack, bool createAndDelete = false);
|
EditWidget (QWidget *parent, int row, CSMWorld::IdTable* table, CSMDoc::Document& document, bool createAndDelete = false);
|
||||||
|
|
||||||
void remake(int row);
|
void remake(int row);
|
||||||
|
|
||||||
|
|
|
@ -35,8 +35,8 @@ void CSVWorld::EnumDelegate::addCommands (QAbstractItemModel *model,
|
||||||
|
|
||||||
|
|
||||||
CSVWorld::EnumDelegate::EnumDelegate (const std::vector<std::pair<int, QString> >& values,
|
CSVWorld::EnumDelegate::EnumDelegate (const std::vector<std::pair<int, QString> >& values,
|
||||||
QUndoStack& undoStack, QObject *parent)
|
CSMDoc::Document& document, QObject *parent)
|
||||||
: CommandDelegate (undoStack, parent), mValues (values)
|
: CommandDelegate (document, parent), mValues (values)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -140,10 +140,10 @@ CSVWorld::EnumDelegateFactory::EnumDelegateFactory (const std::vector<std::strin
|
||||||
add (i, names[i].c_str());
|
add (i, names[i].c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
CSVWorld::CommandDelegate *CSVWorld::EnumDelegateFactory::makeDelegate (QUndoStack& undoStack,
|
CSVWorld::CommandDelegate *CSVWorld::EnumDelegateFactory::makeDelegate (
|
||||||
QObject *parent) const
|
CSMDoc::Document& document, QObject *parent) const
|
||||||
{
|
{
|
||||||
return new EnumDelegate (mValues, undoStack, parent);
|
return new EnumDelegate (mValues, document, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::EnumDelegateFactory::add (int value, const QString& name)
|
void CSVWorld::EnumDelegateFactory::add (int value, const QString& name)
|
||||||
|
|
|
@ -30,7 +30,7 @@ namespace CSVWorld
|
||||||
public:
|
public:
|
||||||
|
|
||||||
EnumDelegate (const std::vector<std::pair<int, QString> >& values,
|
EnumDelegate (const std::vector<std::pair<int, QString> >& values,
|
||||||
QUndoStack& undoStack, QObject *parent);
|
CSMDoc::Document& document, QObject *parent);
|
||||||
|
|
||||||
virtual QWidget *createEditor(QWidget *parent,
|
virtual QWidget *createEditor(QWidget *parent,
|
||||||
const QStyleOptionViewItem& option,
|
const QStyleOptionViewItem& option,
|
||||||
|
@ -64,7 +64,7 @@ namespace CSVWorld
|
||||||
EnumDelegateFactory (const std::vector<std::string>& names, bool allowNone = false);
|
EnumDelegateFactory (const std::vector<std::string>& names, bool allowNone = false);
|
||||||
/// \param allowNone Use value of -1 for "none selected" (empty string)
|
/// \param allowNone Use value of -1 for "none selected" (empty string)
|
||||||
|
|
||||||
virtual CommandDelegate *makeDelegate (QUndoStack& undoStack, QObject *parent) const;
|
virtual CommandDelegate *makeDelegate (CSMDoc::Document& document, QObject *parent) const;
|
||||||
///< The ownership of the returned CommandDelegate is transferred to the caller.
|
///< The ownership of the returned CommandDelegate is transferred to the caller.
|
||||||
|
|
||||||
void add (int value, const QString& name);
|
void add (int value, const QString& name);
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
#include "../../model/world/universalid.hpp"
|
#include "../../model/world/universalid.hpp"
|
||||||
|
|
||||||
CSVWorld::IdTypeDelegate::IdTypeDelegate
|
CSVWorld::IdTypeDelegate::IdTypeDelegate
|
||||||
(const ValueList &values, const IconList &icons, QUndoStack& undoStack, QObject *parent)
|
(const ValueList &values, const IconList &icons, CSMDoc::Document& document, QObject *parent)
|
||||||
: DataDisplayDelegate (values, icons, undoStack,
|
: DataDisplayDelegate (values, icons, document,
|
||||||
"Display Format", "Referenceable ID Type Display",
|
"Display Format", "Referenceable ID Type Display",
|
||||||
parent)
|
parent)
|
||||||
{}
|
{}
|
||||||
|
@ -20,8 +20,8 @@ CSVWorld::IdTypeDelegateFactory::IdTypeDelegateFactory()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CSVWorld::CommandDelegate *CSVWorld::IdTypeDelegateFactory::makeDelegate (QUndoStack& undoStack,
|
CSVWorld::CommandDelegate *CSVWorld::IdTypeDelegateFactory::makeDelegate (
|
||||||
QObject *parent) const
|
CSMDoc::Document& document, QObject *parent) const
|
||||||
{
|
{
|
||||||
return new IdTypeDelegate (mValues, mIcons, undoStack, parent);
|
return new IdTypeDelegate (mValues, mIcons, document, parent);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace CSVWorld
|
||||||
class IdTypeDelegate : public DataDisplayDelegate
|
class IdTypeDelegate : public DataDisplayDelegate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
IdTypeDelegate (const ValueList &mValues, const IconList &icons, QUndoStack& undoStack, QObject *parent);
|
IdTypeDelegate (const ValueList &mValues, const IconList &icons, CSMDoc::Document& document, QObject *parent);
|
||||||
};
|
};
|
||||||
|
|
||||||
class IdTypeDelegateFactory : public DataDisplayDelegateFactory
|
class IdTypeDelegateFactory : public DataDisplayDelegateFactory
|
||||||
|
@ -20,7 +20,7 @@ namespace CSVWorld
|
||||||
|
|
||||||
IdTypeDelegateFactory();
|
IdTypeDelegateFactory();
|
||||||
|
|
||||||
virtual CommandDelegate *makeDelegate (QUndoStack& undoStack, QObject *parent) const;
|
virtual CommandDelegate *makeDelegate (CSMDoc::Document& document, QObject *parent) const;
|
||||||
///< The ownership of the returned CommandDelegate is transferred to the caller.
|
///< The ownership of the returned CommandDelegate is transferred to the caller.
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,16 +9,16 @@
|
||||||
|
|
||||||
CSVWorld::RecordStatusDelegate::RecordStatusDelegate(const ValueList& values,
|
CSVWorld::RecordStatusDelegate::RecordStatusDelegate(const ValueList& values,
|
||||||
const IconList & icons,
|
const IconList & icons,
|
||||||
QUndoStack &undoStack, QObject *parent)
|
CSMDoc::Document& document, QObject *parent)
|
||||||
: DataDisplayDelegate (values, icons, undoStack,
|
: DataDisplayDelegate (values, icons, document,
|
||||||
"Display Format", "Record Status Display",
|
"Display Format", "Record Status Display",
|
||||||
parent)
|
parent)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
CSVWorld::CommandDelegate *CSVWorld::RecordStatusDelegateFactory::makeDelegate (QUndoStack& undoStack,
|
CSVWorld::CommandDelegate *CSVWorld::RecordStatusDelegateFactory::makeDelegate (
|
||||||
QObject *parent) const
|
CSMDoc::Document& document, QObject *parent) const
|
||||||
{
|
{
|
||||||
return new RecordStatusDelegate (mValues, mIcons, undoStack, parent);
|
return new RecordStatusDelegate (mValues, mIcons, document, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
CSVWorld::RecordStatusDelegateFactory::RecordStatusDelegateFactory()
|
CSVWorld::RecordStatusDelegateFactory::RecordStatusDelegateFactory()
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace CSVWorld
|
||||||
|
|
||||||
explicit RecordStatusDelegate(const ValueList& values,
|
explicit RecordStatusDelegate(const ValueList& values,
|
||||||
const IconList& icons,
|
const IconList& icons,
|
||||||
QUndoStack& undoStack, QObject *parent = 0);
|
CSMDoc::Document& document, QObject *parent = 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
class RecordStatusDelegateFactory : public DataDisplayDelegateFactory
|
class RecordStatusDelegateFactory : public DataDisplayDelegateFactory
|
||||||
|
@ -28,7 +28,7 @@ namespace CSVWorld
|
||||||
|
|
||||||
RecordStatusDelegateFactory();
|
RecordStatusDelegateFactory();
|
||||||
|
|
||||||
virtual CommandDelegate *makeDelegate (QUndoStack& undoStack, QObject *parent) const;
|
virtual CommandDelegate *makeDelegate (CSMDoc::Document& document, QObject *parent) const;
|
||||||
///< The ownership of the returned CommandDelegate is transferred to the caller.
|
///< The ownership of the returned CommandDelegate is transferred to the caller.
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -179,7 +179,7 @@ CSVWorld::Table::Table (const CSMWorld::UniversalId& id,
|
||||||
mModel->headerData (i, Qt::Horizontal, CSMWorld::ColumnBase::Role_Display).toInt());
|
mModel->headerData (i, Qt::Horizontal, CSMWorld::ColumnBase::Role_Display).toInt());
|
||||||
|
|
||||||
CommandDelegate *delegate = CommandDelegateFactoryCollection::get().makeDelegate (display,
|
CommandDelegate *delegate = CommandDelegateFactoryCollection::get().makeDelegate (display,
|
||||||
mDocument.getUndoStack(), this);
|
mDocument, this);
|
||||||
|
|
||||||
mDelegates.push_back (delegate);
|
mDelegates.push_back (delegate);
|
||||||
setItemDelegateForColumn (i, delegate);
|
setItemDelegateForColumn (i, delegate);
|
||||||
|
|
|
@ -78,15 +78,15 @@ void CSVWorld::CommandDelegateFactoryCollection::add (CSMWorld::ColumnBase::Disp
|
||||||
}
|
}
|
||||||
|
|
||||||
CSVWorld::CommandDelegate *CSVWorld::CommandDelegateFactoryCollection::makeDelegate (
|
CSVWorld::CommandDelegate *CSVWorld::CommandDelegateFactoryCollection::makeDelegate (
|
||||||
CSMWorld::ColumnBase::Display display, QUndoStack& undoStack, QObject *parent) const
|
CSMWorld::ColumnBase::Display display, CSMDoc::Document& document, QObject *parent) const
|
||||||
{
|
{
|
||||||
std::map<CSMWorld::ColumnBase::Display, CommandDelegateFactory *>::const_iterator iter =
|
std::map<CSMWorld::ColumnBase::Display, CommandDelegateFactory *>::const_iterator iter =
|
||||||
mFactories.find (display);
|
mFactories.find (display);
|
||||||
|
|
||||||
if (iter!=mFactories.end())
|
if (iter!=mFactories.end())
|
||||||
return iter->second->makeDelegate (undoStack, parent);
|
return iter->second->makeDelegate (document, parent);
|
||||||
|
|
||||||
return new CommandDelegate (undoStack, parent);
|
return new CommandDelegate (document, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
const CSVWorld::CommandDelegateFactoryCollection& CSVWorld::CommandDelegateFactoryCollection::get()
|
const CSVWorld::CommandDelegateFactoryCollection& CSVWorld::CommandDelegateFactoryCollection::get()
|
||||||
|
@ -100,7 +100,12 @@ const CSVWorld::CommandDelegateFactoryCollection& CSVWorld::CommandDelegateFacto
|
||||||
|
|
||||||
QUndoStack& CSVWorld::CommandDelegate::getUndoStack() const
|
QUndoStack& CSVWorld::CommandDelegate::getUndoStack() const
|
||||||
{
|
{
|
||||||
return mUndoStack;
|
return mDocument.getUndoStack();
|
||||||
|
}
|
||||||
|
|
||||||
|
CSMDoc::Document& CSVWorld::CommandDelegate::getDocument() const
|
||||||
|
{
|
||||||
|
return mDocument;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::CommandDelegate::setModelDataImp (QWidget *editor, QAbstractItemModel *model,
|
void CSVWorld::CommandDelegate::setModelDataImp (QWidget *editor, QAbstractItemModel *model,
|
||||||
|
@ -112,11 +117,11 @@ void CSVWorld::CommandDelegate::setModelDataImp (QWidget *editor, QAbstractItemM
|
||||||
QVariant new_ = hack.getData();
|
QVariant new_ = hack.getData();
|
||||||
|
|
||||||
if (model->data (index)!=new_)
|
if (model->data (index)!=new_)
|
||||||
mUndoStack.push (new CSMWorld::ModifyCommand (*model, index, new_));
|
getUndoStack().push (new CSMWorld::ModifyCommand (*model, index, new_));
|
||||||
}
|
}
|
||||||
|
|
||||||
CSVWorld::CommandDelegate::CommandDelegate (QUndoStack& undoStack, QObject *parent)
|
CSVWorld::CommandDelegate::CommandDelegate (CSMDoc::Document& document, QObject *parent)
|
||||||
: QStyledItemDelegate (parent), mUndoStack (undoStack), mEditLock (false)
|
: QStyledItemDelegate (parent), mDocument (document), mEditLock (false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void CSVWorld::CommandDelegate::setModelData (QWidget *editor, QAbstractItemModel *model,
|
void CSVWorld::CommandDelegate::setModelData (QWidget *editor, QAbstractItemModel *model,
|
||||||
|
|
|
@ -51,7 +51,8 @@ namespace CSVWorld
|
||||||
|
|
||||||
virtual ~CommandDelegateFactory();
|
virtual ~CommandDelegateFactory();
|
||||||
|
|
||||||
virtual CommandDelegate *makeDelegate (QUndoStack& undoStack, QObject *parent) const = 0;
|
virtual CommandDelegate *makeDelegate (CSMDoc::Document& document, QObject *parent)
|
||||||
|
const = 0;
|
||||||
///< The ownership of the returned CommandDelegate is transferred to the caller.
|
///< The ownership of the returned CommandDelegate is transferred to the caller.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -77,7 +78,7 @@ namespace CSVWorld
|
||||||
///
|
///
|
||||||
/// This function must not be called more than once per value of \a display.
|
/// This function must not be called more than once per value of \a display.
|
||||||
|
|
||||||
CommandDelegate *makeDelegate (CSMWorld::ColumnBase::Display display, QUndoStack& undoStack,
|
CommandDelegate *makeDelegate (CSMWorld::ColumnBase::Display display, CSMDoc::Document& document,
|
||||||
QObject *parent) const;
|
QObject *parent) const;
|
||||||
///< The ownership of the returned CommandDelegate is transferred to the caller.
|
///< The ownership of the returned CommandDelegate is transferred to the caller.
|
||||||
///
|
///
|
||||||
|
@ -110,19 +111,21 @@ namespace CSVWorld
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
QUndoStack& mUndoStack;
|
CSMDoc::Document& mDocument;
|
||||||
bool mEditLock;
|
bool mEditLock;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
QUndoStack& getUndoStack() const;
|
QUndoStack& getUndoStack() const;
|
||||||
|
|
||||||
|
CSMDoc::Document& getDocument() const;
|
||||||
|
|
||||||
virtual void setModelDataImp (QWidget *editor, QAbstractItemModel *model,
|
virtual void setModelDataImp (QWidget *editor, QAbstractItemModel *model,
|
||||||
const QModelIndex& index) const;
|
const QModelIndex& index) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
CommandDelegate (QUndoStack& undoStack, QObject *parent);
|
CommandDelegate (CSMDoc::Document& document, QObject *parent);
|
||||||
|
|
||||||
virtual void setModelData (QWidget *editor, QAbstractItemModel *model,
|
virtual void setModelData (QWidget *editor, QAbstractItemModel *model,
|
||||||
const QModelIndex& index) const;
|
const QModelIndex& index) const;
|
||||||
|
|
|
@ -47,8 +47,8 @@ void CSVWorld::VarTypeDelegate::addCommands (QAbstractItemModel *model, const QM
|
||||||
}
|
}
|
||||||
|
|
||||||
CSVWorld::VarTypeDelegate::VarTypeDelegate (const std::vector<std::pair<int, QString> >& values,
|
CSVWorld::VarTypeDelegate::VarTypeDelegate (const std::vector<std::pair<int, QString> >& values,
|
||||||
QUndoStack& undoStack, QObject *parent)
|
CSMDoc::Document& document, QObject *parent)
|
||||||
: EnumDelegate (values, undoStack, parent)
|
: EnumDelegate (values, document, parent)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
@ -68,10 +68,10 @@ CSVWorld::VarTypeDelegateFactory::VarTypeDelegateFactory (ESM::VarType type0,
|
||||||
add (type3);
|
add (type3);
|
||||||
}
|
}
|
||||||
|
|
||||||
CSVWorld::CommandDelegate *CSVWorld::VarTypeDelegateFactory::makeDelegate (QUndoStack& undoStack,
|
CSVWorld::CommandDelegate *CSVWorld::VarTypeDelegateFactory::makeDelegate (
|
||||||
QObject *parent) const
|
CSMDoc::Document& document, QObject *parent) const
|
||||||
{
|
{
|
||||||
return new VarTypeDelegate (mValues, undoStack, parent);
|
return new VarTypeDelegate (mValues, document, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::VarTypeDelegateFactory::add (ESM::VarType type)
|
void CSVWorld::VarTypeDelegateFactory::add (ESM::VarType type)
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace CSVWorld
|
||||||
public:
|
public:
|
||||||
|
|
||||||
VarTypeDelegate (const std::vector<std::pair<int, QString> >& values,
|
VarTypeDelegate (const std::vector<std::pair<int, QString> >& values,
|
||||||
QUndoStack& undoStack, QObject *parent);
|
CSMDoc::Document& document, QObject *parent);
|
||||||
};
|
};
|
||||||
|
|
||||||
class VarTypeDelegateFactory : public CommandDelegateFactory
|
class VarTypeDelegateFactory : public CommandDelegateFactory
|
||||||
|
@ -30,7 +30,7 @@ namespace CSVWorld
|
||||||
ESM::VarType type1 = ESM::VT_Unknown, ESM::VarType type2 = ESM::VT_Unknown,
|
ESM::VarType type1 = ESM::VT_Unknown, ESM::VarType type2 = ESM::VT_Unknown,
|
||||||
ESM::VarType type3 = ESM::VT_Unknown);
|
ESM::VarType type3 = ESM::VT_Unknown);
|
||||||
|
|
||||||
virtual CommandDelegate *makeDelegate (QUndoStack& undoStack, QObject *parent) const;
|
virtual CommandDelegate *makeDelegate (CSMDoc::Document& document, QObject *parent) const;
|
||||||
///< The ownership of the returned CommandDelegate is transferred to the caller.
|
///< The ownership of the returned CommandDelegate is transferred to the caller.
|
||||||
|
|
||||||
void add (ESM::VarType type);
|
void add (ESM::VarType type);
|
||||||
|
|
Loading…
Reference in a new issue