Alternative way of finding UniversalId without bloating IdTree.

test
cc9cii 10 years ago
parent 8aaa74a983
commit 932f1f9fbd

@ -8,7 +8,6 @@
#include "../doc/document.hpp"
#include "idtable.hpp"
#include "idtree.hpp"
#include "record.hpp"
#include "commands.hpp"
@ -156,10 +155,10 @@ void CSMWorld::CommandDispatcher::executeDelete()
if (mId.getType() == UniversalId::Type_Referenceables)
{
IdTree& tree = dynamic_cast<IdTree&> (*mDocument.getData().getTableModel (mId));
std::pair<int, UniversalId::Type> localIndex = tree.searchId (id);
mDocument.getUndoStack().push (new CSMWorld::DeleteCommand (model, id, localIndex.second));
mDocument.getUndoStack().push ( new CSMWorld::DeleteCommand (model, id,
static_cast<CSMWorld::UniversalId::Type>(model.data (model.index (
model.getModelIndex (id, columnIndex).row(),
model.findColumnIndex (CSMWorld::Columns::ColumnId_RecordType))).toInt())));
}
else
mDocument.getUndoStack().push (new CSMWorld::DeleteCommand (model, id));
@ -228,17 +227,8 @@ void CSMWorld::CommandDispatcher::executeExtendedDelete()
Misc::StringUtils::lowerCase (record.get().mCell)))
continue;
if (mId.getType() == UniversalId::Type_Referenceables)
{
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));
mDocument.getUndoStack().push (
new CSMWorld::DeleteCommand (model, record.get().mId));
}
}
}

@ -4,7 +4,6 @@
#include "collectionbase.hpp"
#include "nestedcollection.hpp"
#include "refidcollection.hpp" // HACK: for searchId() only
#include "columnbase.hpp"
// NOTE: parent class still needs idCollection
@ -258,9 +257,3 @@ CSMWorld::NestedTableWrapperBase* CSMWorld::IdTree::nestedTable(const QModelInde
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;
std::pair<int, UniversalId::Type> searchId (const std::string& id) const;
signals:
void resetStart(const QString& id);

Loading…
Cancel
Save