1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-19 21:53:51 +00:00

changed ID listing to include deleted records by default

This commit is contained in:
Marc Zinnschlag 2013-09-19 13:42:19 +02:00
parent 9c751ae370
commit ba5e2a0330
8 changed files with 36 additions and 35 deletions

View file

@ -107,10 +107,10 @@ namespace CSMWorld
virtual int getAppendIndex (UniversalId::Type type = UniversalId::Type_None) const; virtual int getAppendIndex (UniversalId::Type type = UniversalId::Type_None) const;
///< \param type Will be ignored, unless the collection supports multiple record types ///< \param type Will be ignored, unless the collection supports multiple record types
virtual std::vector<std::string> getIds() const; virtual std::vector<std::string> getIds (bool listDeleted = true) const;
///< Return a sorted collection of all IDs ///< Return a sorted collection of all IDs
/// ///
/// \note Deleted records are not listed. /// \param listDeleted include deleted record in the list
void addColumn (Column<ESXRecordT> *column); void addColumn (Column<ESXRecordT> *column);
@ -299,14 +299,14 @@ namespace CSMWorld
} }
template<typename ESXRecordT, typename IdAccessorT> template<typename ESXRecordT, typename IdAccessorT>
std::vector<std::string> Collection<ESXRecordT, IdAccessorT>::getIds() const std::vector<std::string> Collection<ESXRecordT, IdAccessorT>::getIds (bool listDeleted) const
{ {
std::vector<std::string> ids; std::vector<std::string> ids;
for (typename std::map<std::string, int>::const_iterator iter = mIndex.begin(); for (typename std::map<std::string, int>::const_iterator iter = mIndex.begin();
iter!=mIndex.end(); ++iter) iter!=mIndex.end(); ++iter)
{ {
if (!mRecords[iter->second].isDeleted()) if (listDeleted || !mRecords[iter->second].isDeleted())
ids.push_back (IdAccessorT().getId (mRecords[iter->second].get())); ids.push_back (IdAccessorT().getId (mRecords[iter->second].get()));
} }

View file

@ -79,10 +79,10 @@ namespace CSMWorld
virtual int getAppendIndex (UniversalId::Type type = UniversalId::Type_None) const = 0; virtual int getAppendIndex (UniversalId::Type type = UniversalId::Type_None) const = 0;
///< \param type Will be ignored, unless the collection supports multiple record types ///< \param type Will be ignored, unless the collection supports multiple record types
virtual std::vector<std::string> getIds() const = 0; virtual std::vector<std::string> getIds (bool listDeleted = true) const = 0;
///< Return a sorted collection of all IDs ///< Return a sorted collection of all IDs
/// ///
/// \note Deleted records are not listed. /// \param listDeleted include deleted record in the list
}; };
} }

View file

@ -35,9 +35,10 @@ void CSMWorld::Data::addModel (QAbstractItemModel *model, UniversalId::Type type
} }
} }
void CSMWorld::Data::appendIds (std::vector<std::string>& ids, const CollectionBase& collection) void CSMWorld::Data::appendIds (std::vector<std::string>& ids, const CollectionBase& collection,
bool listDeleted)
{ {
std::vector<std::string> ids2 = collection.getIds(); std::vector<std::string> ids2 = collection.getIds (listDeleted);
ids.insert (ids.end(), ids2.begin(), ids2.end()); ids.insert (ids.end(), ids2.begin(), ids2.end());
} }
@ -459,22 +460,22 @@ bool CSMWorld::Data::hasId (const std::string& id) const
getReferenceables().searchId (id)!=-1; getReferenceables().searchId (id)!=-1;
} }
std::vector<std::string> CSMWorld::Data::getIds() const std::vector<std::string> CSMWorld::Data::getIds (bool listDeleted) const
{ {
std::vector<std::string> ids; std::vector<std::string> ids;
appendIds (ids, mGlobals); appendIds (ids, mGlobals, listDeleted);
appendIds (ids, mGmsts); appendIds (ids, mGmsts, listDeleted);
appendIds (ids, mClasses); appendIds (ids, mClasses, listDeleted);
appendIds (ids, mFactions); appendIds (ids, mFactions, listDeleted);
appendIds (ids, mRaces); appendIds (ids, mRaces, listDeleted);
appendIds (ids, mSounds); appendIds (ids, mSounds, listDeleted);
appendIds (ids, mScripts); appendIds (ids, mScripts, listDeleted);
appendIds (ids, mRegions); appendIds (ids, mRegions, listDeleted);
appendIds (ids, mBirthsigns); appendIds (ids, mBirthsigns, listDeleted);
appendIds (ids, mSpells); appendIds (ids, mSpells, listDeleted);
appendIds (ids, mCells); appendIds (ids, mCells, listDeleted);
appendIds (ids, mReferenceables); appendIds (ids, mReferenceables, listDeleted);
std::sort (ids.begin(), ids.end()); std::sort (ids.begin(), ids.end());
@ -483,9 +484,8 @@ std::vector<std::string> CSMWorld::Data::getIds() const
void CSMWorld::Data::dataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight) void CSMWorld::Data::dataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight)
{ {
// Note: The performance of of ID list change updates could be improved only emit the signal, if if (topLeft.column()<=0)
// the state of the record is changed. emit idListChanged();
emit idListChanged();
} }
void CSMWorld::Data::rowsChanged (const QModelIndex& parent, int start, int end) void CSMWorld::Data::rowsChanged (const QModelIndex& parent, int start, int end)

View file

@ -62,7 +62,8 @@ namespace CSMWorld
void addModel (QAbstractItemModel *model, UniversalId::Type type1, void addModel (QAbstractItemModel *model, UniversalId::Type type1,
UniversalId::Type type2 = UniversalId::Type_None, bool update = true); UniversalId::Type type2 = UniversalId::Type_None, bool update = true);
static void appendIds (std::vector<std::string>& ids, const CollectionBase& collection); static void appendIds (std::vector<std::string>& ids, const CollectionBase& collection,
bool listDeleted);
///< Append all IDs from collection to \a ids. ///< Append all IDs from collection to \a ids.
public: public:
@ -145,10 +146,10 @@ namespace CSMWorld
bool hasId (const std::string& id) const; bool hasId (const std::string& id) const;
std::vector<std::string> getIds() const; std::vector<std::string> getIds (bool listDeleted = true) const;
///< Return a sorted collection of all IDs that are not internal to the editor. ///< Return a sorted collection of all IDs that are not internal to the editor.
/// ///
/// \note Deleted records are not listed. /// \param listDeleted include deleted record in the list
signals: signals:

View file

@ -535,7 +535,7 @@ int CSMWorld::RefIdCollection::getAppendIndex (UniversalId::Type type) const
return mData.getAppendIndex (type); return mData.getAppendIndex (type);
} }
std::vector<std::string> CSMWorld::RefIdCollection::getIds() const std::vector<std::string> CSMWorld::RefIdCollection::getIds (bool listDeleted) const
{ {
return mData.getIds(); return mData.getIds (listDeleted);
} }

View file

@ -90,10 +90,10 @@ namespace CSMWorld
virtual int getAppendIndex (UniversalId::Type type) const; virtual int getAppendIndex (UniversalId::Type type) const;
///< \param type Will be ignored, unless the collection supports multiple record types ///< \param type Will be ignored, unless the collection supports multiple record types
virtual std::vector<std::string> getIds() const; virtual std::vector<std::string> getIds (bool listDeleted) const;
///< Return a sorted collection of all IDs ///< Return a sorted collection of all IDs
/// ///
/// \note Deleted records are not listed. /// \param listDeleted include deleted record in the list
}; };
} }

View file

@ -197,14 +197,14 @@ int CSMWorld::RefIdData::getSize() const
return mIndex.size(); return mIndex.size();
} }
std::vector<std::string> CSMWorld::RefIdData::getIds() const std::vector<std::string> CSMWorld::RefIdData::getIds (bool listDeleted) const
{ {
std::vector<std::string> ids; std::vector<std::string> ids;
for (std::map<std::string, LocalIndex>::const_iterator iter (mIndex.begin()); iter!=mIndex.end(); for (std::map<std::string, LocalIndex>::const_iterator iter (mIndex.begin()); iter!=mIndex.end();
++iter) ++iter)
{ {
if (!getRecord (iter->second).isDeleted()) if (listDeleted || !getRecord (iter->second).isDeleted())
{ {
std::map<UniversalId::Type, RefIdDataContainerBase *>::const_iterator container = std::map<UniversalId::Type, RefIdDataContainerBase *>::const_iterator container =
mRecordContainers.find (iter->second.second); mRecordContainers.find (iter->second.second);

View file

@ -183,10 +183,10 @@ namespace CSMWorld
int getSize() const; int getSize() const;
std::vector<std::string> getIds() const; std::vector<std::string> getIds (bool listDeleted = true) const;
///< Return a sorted collection of all IDs ///< Return a sorted collection of all IDs
/// ///
/// \note Deleted records are not listed. /// \param listDeleted include deleted record in the list
}; };
} }