forked from teamnwah/openmw-tes3coop
Alternative way of finding UniversalId without bloating IdTree.
This commit is contained in:
parent
8aaa74a983
commit
932f1f9fbd
3 changed files with 6 additions and 25 deletions
|
@ -8,7 +8,6 @@
|
||||||
#include "../doc/document.hpp"
|
#include "../doc/document.hpp"
|
||||||
|
|
||||||
#include "idtable.hpp"
|
#include "idtable.hpp"
|
||||||
#include "idtree.hpp"
|
|
||||||
#include "record.hpp"
|
#include "record.hpp"
|
||||||
#include "commands.hpp"
|
#include "commands.hpp"
|
||||||
|
|
||||||
|
@ -156,10 +155,10 @@ void CSMWorld::CommandDispatcher::executeDelete()
|
||||||
|
|
||||||
if (mId.getType() == UniversalId::Type_Referenceables)
|
if (mId.getType() == UniversalId::Type_Referenceables)
|
||||||
{
|
{
|
||||||
IdTree& tree = dynamic_cast<IdTree&> (*mDocument.getData().getTableModel (mId));
|
mDocument.getUndoStack().push ( new CSMWorld::DeleteCommand (model, id,
|
||||||
std::pair<int, UniversalId::Type> localIndex = tree.searchId (id);
|
static_cast<CSMWorld::UniversalId::Type>(model.data (model.index (
|
||||||
|
model.getModelIndex (id, columnIndex).row(),
|
||||||
mDocument.getUndoStack().push (new CSMWorld::DeleteCommand (model, id, localIndex.second));
|
model.findColumnIndex (CSMWorld::Columns::ColumnId_RecordType))).toInt())));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
mDocument.getUndoStack().push (new CSMWorld::DeleteCommand (model, id));
|
mDocument.getUndoStack().push (new CSMWorld::DeleteCommand (model, id));
|
||||||
|
@ -228,17 +227,8 @@ void CSMWorld::CommandDispatcher::executeExtendedDelete()
|
||||||
Misc::StringUtils::lowerCase (record.get().mCell)))
|
Misc::StringUtils::lowerCase (record.get().mCell)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (mId.getType() == UniversalId::Type_Referenceables)
|
mDocument.getUndoStack().push (
|
||||||
{
|
new CSMWorld::DeleteCommand (model, record.get().mId));
|
||||||
IdTree& tree = dynamic_cast<IdTree&> (*mDocument.getData().getTableModel (mId));
|
|
||||||
std::pair<int, UniversalId::Type> localIndex = tree.searchId (record.get().mId);
|
|
||||||
|
|
||||||
mDocument.getUndoStack().push (
|
|
||||||
new CSMWorld::DeleteCommand (model, record.get().mId, localIndex.second));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
mDocument.getUndoStack().push (
|
|
||||||
new CSMWorld::DeleteCommand (model, record.get().mId));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
#include "collectionbase.hpp"
|
#include "collectionbase.hpp"
|
||||||
#include "nestedcollection.hpp"
|
#include "nestedcollection.hpp"
|
||||||
#include "refidcollection.hpp" // HACK: for searchId() only
|
|
||||||
#include "columnbase.hpp"
|
#include "columnbase.hpp"
|
||||||
|
|
||||||
// NOTE: parent class still needs idCollection
|
// NOTE: parent class still needs idCollection
|
||||||
|
@ -258,9 +257,3 @@ CSMWorld::NestedTableWrapperBase* CSMWorld::IdTree::nestedTable(const QModelInde
|
||||||
|
|
||||||
return mNestedCollection->nestedTable(index.row(), index.column());
|
return mNestedCollection->nestedTable(index.row(), index.column());
|
||||||
}
|
}
|
||||||
|
|
||||||
// HACK: to get the UniversalId::Type associated with a particular record
|
|
||||||
std::pair<int, CSMWorld::UniversalId::Type> CSMWorld::IdTree::searchId (const std::string& id) const
|
|
||||||
{
|
|
||||||
return dynamic_cast<CSMWorld::RefIdCollection*>(idCollection())->getDataSet().searchId(id);
|
|
||||||
}
|
|
||||||
|
|
|
@ -73,8 +73,6 @@ namespace CSMWorld
|
||||||
|
|
||||||
virtual bool hasChildren (const QModelIndex& index) const;
|
virtual bool hasChildren (const QModelIndex& index) const;
|
||||||
|
|
||||||
std::pair<int, UniversalId::Type> searchId (const std::string& id) const;
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
void resetStart(const QString& id);
|
void resetStart(const QString& id);
|
||||||
|
|
Loading…
Reference in a new issue