mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 06:53:53 +00:00
changed CreateCommand to work directly on the model instead of the proxy
This commit is contained in:
parent
f93af52486
commit
2d46a1db2f
4 changed files with 5 additions and 12 deletions
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include <QAbstractItemModel>
|
#include <QAbstractItemModel>
|
||||||
|
|
||||||
#include "idtableproxymodel.hpp"
|
#include "idtable.hpp"
|
||||||
#include "idtable.hpp"
|
#include "idtable.hpp"
|
||||||
|
|
||||||
CSMWorld::ModifyCommand::ModifyCommand (QAbstractItemModel& model, const QModelIndex& index,
|
CSMWorld::ModifyCommand::ModifyCommand (QAbstractItemModel& model, const QModelIndex& index,
|
||||||
|
@ -25,7 +25,7 @@ void CSMWorld::ModifyCommand::undo()
|
||||||
mModel.setData (mIndex, mOld);
|
mModel.setData (mIndex, mOld);
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMWorld::CreateCommand::CreateCommand (IdTableProxyModel& model, const std::string& id, QUndoCommand *parent)
|
CSMWorld::CreateCommand::CreateCommand (IdTable& model, const std::string& id, QUndoCommand *parent)
|
||||||
: QUndoCommand (parent), mModel (model), mId (id)
|
: QUndoCommand (parent), mModel (model), mId (id)
|
||||||
{
|
{
|
||||||
setText (("Create record " + id).c_str());
|
setText (("Create record " + id).c_str());
|
||||||
|
|
|
@ -14,7 +14,7 @@ class QAbstractItemModel;
|
||||||
|
|
||||||
namespace CSMWorld
|
namespace CSMWorld
|
||||||
{
|
{
|
||||||
class IdTableProxyModel;
|
class IdTable;
|
||||||
class IdTable;
|
class IdTable;
|
||||||
class RecordBase;
|
class RecordBase;
|
||||||
|
|
||||||
|
@ -37,12 +37,12 @@ namespace CSMWorld
|
||||||
|
|
||||||
class CreateCommand : public QUndoCommand
|
class CreateCommand : public QUndoCommand
|
||||||
{
|
{
|
||||||
IdTableProxyModel& mModel;
|
IdTable& mModel;
|
||||||
std::string mId;
|
std::string mId;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
CreateCommand (IdTableProxyModel& model, const std::string& id, QUndoCommand *parent = 0);
|
CreateCommand (IdTable& model, const std::string& id, QUndoCommand *parent = 0);
|
||||||
|
|
||||||
virtual void redo();
|
virtual void redo();
|
||||||
|
|
||||||
|
|
|
@ -7,11 +7,6 @@ CSMWorld::IdTableProxyModel::IdTableProxyModel (QObject *parent)
|
||||||
: QSortFilterProxyModel (parent)
|
: QSortFilterProxyModel (parent)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void CSMWorld::IdTableProxyModel::addRecord (const std::string& id)
|
|
||||||
{
|
|
||||||
dynamic_cast<IdTable&> (*sourceModel()).addRecord (id);
|
|
||||||
}
|
|
||||||
|
|
||||||
QModelIndex CSMWorld::IdTableProxyModel::getModelIndex (const std::string& id, int column) const
|
QModelIndex CSMWorld::IdTableProxyModel::getModelIndex (const std::string& id, int column) const
|
||||||
{
|
{
|
||||||
return mapFromSource (dynamic_cast<IdTable&> (*sourceModel()).getModelIndex (id, column));
|
return mapFromSource (dynamic_cast<IdTable&> (*sourceModel()).getModelIndex (id, column));
|
||||||
|
|
|
@ -15,8 +15,6 @@ namespace CSMWorld
|
||||||
|
|
||||||
IdTableProxyModel (QObject *parent = 0);
|
IdTableProxyModel (QObject *parent = 0);
|
||||||
|
|
||||||
virtual void addRecord (const std::string& id);
|
|
||||||
|
|
||||||
virtual QModelIndex getModelIndex (const std::string& id, int column) const;
|
virtual QModelIndex getModelIndex (const std::string& id, int column) const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue