forked from mirror/openmw-tes3mp
undo works now
This commit is contained in:
parent
4d79034dbf
commit
87eed066c2
7 changed files with 56 additions and 5 deletions
|
@ -19,12 +19,12 @@ opencs_hdrs_noqt (model/doc
|
|||
|
||||
opencs_units (model/world
|
||||
idtable idtableproxymodel regionmap data commanddispatcher
|
||||
idtablebase resourcetable nestedtablemodel nestedtablewrapper
|
||||
idtablebase resourcetable nestedtablemodel
|
||||
)
|
||||
|
||||
|
||||
opencs_units_noqt (model/world
|
||||
universalid record commands columnbase scriptcontext cell refidcollection
|
||||
nestedtablewrapper universalid record commands columnbase scriptcontext cell refidcollection
|
||||
refidadapter refiddata refidadapterimp ref collectionbase refcollection columns infocollection tablemimedata cellcoordinates cellselection resources resourcesmanager
|
||||
)
|
||||
|
||||
|
|
|
@ -366,10 +366,22 @@ void CSMWorld::IdTable::setNestedTable(const QModelIndex& index, const CSMWorld:
|
|||
throw std::logic_error("Tried to set nested table, but index has no children");
|
||||
}
|
||||
|
||||
bool removeRowsMode = false;
|
||||
if (nestedTable.size() != this->nestedTable(index)->size())
|
||||
{
|
||||
emit resetStart(this->index(index.row(), 0).data().toString());
|
||||
removeRowsMode = true;
|
||||
}
|
||||
|
||||
mIdCollection->setNestedTable(index.row(), index.column(), nestedTable);
|
||||
|
||||
emit dataChanged (CSMWorld::IdTable::index (index.row(), 0),
|
||||
CSMWorld::IdTable::index (index.row(), mIdCollection->getColumns()-1));
|
||||
|
||||
if (removeRowsMode)
|
||||
{
|
||||
emit resetEnd(this->index(index.row(), 0).data().toString());
|
||||
}
|
||||
}
|
||||
|
||||
CSMWorld::NestedTableWrapperBase* CSMWorld::IdTable::nestedTable(const QModelIndex& index) const
|
||||
|
|
|
@ -52,9 +52,9 @@ namespace CSMWorld
|
|||
virtual QVariant headerData (int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
||||
|
||||
QVariant nestedHeaderData(int section, int subSection, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
||||
|
||||
|
||||
NestedTableWrapperBase* nestedTable(const QModelIndex &index) const;
|
||||
|
||||
|
||||
void setNestedTable(const QModelIndex &index, const NestedTableWrapperBase& nestedTable);
|
||||
|
||||
virtual bool setData ( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
|
||||
|
@ -105,6 +105,11 @@ namespace CSMWorld
|
|||
virtual bool isDeleted (const std::string& id) const;
|
||||
|
||||
int getColumnId(int column) const;
|
||||
|
||||
signals:
|
||||
void resetStart(const QString& id);
|
||||
|
||||
void resetEnd(const QString& id);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,12 @@ CSMWorld::NestedTableModel::NestedTableModel(const QModelIndex& parent,
|
|||
|
||||
connect(mMainModel, SIGNAL(rowsRemoved(const QModelIndex &, int, int)),
|
||||
this, SLOT(forwardRowsRemoved(const QModelIndex &, int, int)));
|
||||
|
||||
connect(mMainModel, SIGNAL(resetStart(const QString&)),
|
||||
this, SLOT(forwardResetStart(const QString&)));
|
||||
|
||||
connect(mMainModel, SIGNAL(resetEnd(const QString&)),
|
||||
this, SLOT(forwardResetEnd(const QString&)));
|
||||
}
|
||||
|
||||
QModelIndex CSMWorld::NestedTableModel::mapFromSource(const QModelIndex& sourceIndex) const
|
||||
|
@ -157,3 +163,15 @@ void CSMWorld::NestedTableModel::forwardRowsRemoved(const QModelIndex& parent, i
|
|||
endRemoveRows();
|
||||
}
|
||||
}
|
||||
|
||||
void CSMWorld::NestedTableModel::forwardResetStart(const QString& id)
|
||||
{
|
||||
if (id.toUtf8() == mId.c_str())
|
||||
beginResetModel();
|
||||
}
|
||||
|
||||
void CSMWorld::NestedTableModel::forwardResetEnd(const QString& id)
|
||||
{
|
||||
if (id.toUtf8() == mId.c_str())
|
||||
endResetModel();
|
||||
}
|
||||
|
|
|
@ -70,6 +70,10 @@ namespace CSMWorld
|
|||
void forwardRowsAboutToRemoved(const QModelIndex & parent, int first, int last);
|
||||
|
||||
void forwardRowsRemoved(const QModelIndex & parent, int first, int last);
|
||||
|
||||
void forwardResetStart(const QString& id);
|
||||
|
||||
void forwardResetEnd(const QString& id);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -5,3 +5,8 @@ CSMWorld::NestedTableWrapperBase::NestedTableWrapperBase()
|
|||
|
||||
CSMWorld::NestedTableWrapperBase::~NestedTableWrapperBase()
|
||||
{}
|
||||
|
||||
int CSMWorld::NestedTableWrapperBase::size() const
|
||||
{
|
||||
return -5;
|
||||
}
|
||||
|
|
|
@ -7,9 +7,11 @@ namespace CSMWorld
|
|||
{
|
||||
virtual ~NestedTableWrapperBase();
|
||||
|
||||
virtual int size() const;
|
||||
|
||||
NestedTableWrapperBase();
|
||||
};
|
||||
|
||||
|
||||
template<typename NestedTable>
|
||||
struct NestedTableWrapper : public NestedTableWrapperBase
|
||||
{
|
||||
|
@ -19,6 +21,11 @@ namespace CSMWorld
|
|||
: mNestedTable(nestedTable) {}
|
||||
|
||||
virtual ~NestedTableWrapper() {}
|
||||
|
||||
virtual int size() const
|
||||
{
|
||||
return mNestedTable.size(); //i hope that this will be enough
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue