From ba5e2a0330d203bac77b8d0185c6cca12d9176ed Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 19 Sep 2013 13:42:19 +0200 Subject: [PATCH] changed ID listing to include deleted records by default --- apps/opencs/model/world/collection.hpp | 8 ++--- apps/opencs/model/world/collectionbase.hpp | 4 +-- apps/opencs/model/world/data.cpp | 36 ++++++++++----------- apps/opencs/model/world/data.hpp | 7 ++-- apps/opencs/model/world/refidcollection.cpp | 4 +-- apps/opencs/model/world/refidcollection.hpp | 4 +-- apps/opencs/model/world/refiddata.cpp | 4 +-- apps/opencs/model/world/refiddata.hpp | 4 +-- 8 files changed, 36 insertions(+), 35 deletions(-) diff --git a/apps/opencs/model/world/collection.hpp b/apps/opencs/model/world/collection.hpp index a5014e66c..84a00cef8 100644 --- a/apps/opencs/model/world/collection.hpp +++ b/apps/opencs/model/world/collection.hpp @@ -107,10 +107,10 @@ namespace CSMWorld virtual int getAppendIndex (UniversalId::Type type = UniversalId::Type_None) const; ///< \param type Will be ignored, unless the collection supports multiple record types - virtual std::vector getIds() const; + virtual std::vector getIds (bool listDeleted = true) const; ///< Return a sorted collection of all IDs /// - /// \note Deleted records are not listed. + /// \param listDeleted include deleted record in the list void addColumn (Column *column); @@ -299,14 +299,14 @@ namespace CSMWorld } template - std::vector Collection::getIds() const + std::vector Collection::getIds (bool listDeleted) const { std::vector ids; for (typename std::map::const_iterator iter = mIndex.begin(); iter!=mIndex.end(); ++iter) { - if (!mRecords[iter->second].isDeleted()) + if (listDeleted || !mRecords[iter->second].isDeleted()) ids.push_back (IdAccessorT().getId (mRecords[iter->second].get())); } diff --git a/apps/opencs/model/world/collectionbase.hpp b/apps/opencs/model/world/collectionbase.hpp index 16b88e5e1..ff6dab247 100644 --- a/apps/opencs/model/world/collectionbase.hpp +++ b/apps/opencs/model/world/collectionbase.hpp @@ -79,10 +79,10 @@ namespace CSMWorld virtual int getAppendIndex (UniversalId::Type type = UniversalId::Type_None) const = 0; ///< \param type Will be ignored, unless the collection supports multiple record types - virtual std::vector getIds() const = 0; + virtual std::vector getIds (bool listDeleted = true) const = 0; ///< Return a sorted collection of all IDs /// - /// \note Deleted records are not listed. + /// \param listDeleted include deleted record in the list }; } diff --git a/apps/opencs/model/world/data.cpp b/apps/opencs/model/world/data.cpp index 06fbf61bf..7eb96a5c3 100644 --- a/apps/opencs/model/world/data.cpp +++ b/apps/opencs/model/world/data.cpp @@ -35,9 +35,10 @@ void CSMWorld::Data::addModel (QAbstractItemModel *model, UniversalId::Type type } } -void CSMWorld::Data::appendIds (std::vector& ids, const CollectionBase& collection) +void CSMWorld::Data::appendIds (std::vector& ids, const CollectionBase& collection, + bool listDeleted) { - std::vector ids2 = collection.getIds(); + std::vector ids2 = collection.getIds (listDeleted); 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; } -std::vector CSMWorld::Data::getIds() const +std::vector CSMWorld::Data::getIds (bool listDeleted) const { std::vector ids; - appendIds (ids, mGlobals); - appendIds (ids, mGmsts); - appendIds (ids, mClasses); - appendIds (ids, mFactions); - appendIds (ids, mRaces); - appendIds (ids, mSounds); - appendIds (ids, mScripts); - appendIds (ids, mRegions); - appendIds (ids, mBirthsigns); - appendIds (ids, mSpells); - appendIds (ids, mCells); - appendIds (ids, mReferenceables); + appendIds (ids, mGlobals, listDeleted); + appendIds (ids, mGmsts, listDeleted); + appendIds (ids, mClasses, listDeleted); + appendIds (ids, mFactions, listDeleted); + appendIds (ids, mRaces, listDeleted); + appendIds (ids, mSounds, listDeleted); + appendIds (ids, mScripts, listDeleted); + appendIds (ids, mRegions, listDeleted); + appendIds (ids, mBirthsigns, listDeleted); + appendIds (ids, mSpells, listDeleted); + appendIds (ids, mCells, listDeleted); + appendIds (ids, mReferenceables, listDeleted); std::sort (ids.begin(), ids.end()); @@ -483,9 +484,8 @@ std::vector CSMWorld::Data::getIds() const 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 - // the state of the record is changed. - emit idListChanged(); + if (topLeft.column()<=0) + emit idListChanged(); } void CSMWorld::Data::rowsChanged (const QModelIndex& parent, int start, int end) diff --git a/apps/opencs/model/world/data.hpp b/apps/opencs/model/world/data.hpp index 1b024751d..e900bb10f 100644 --- a/apps/opencs/model/world/data.hpp +++ b/apps/opencs/model/world/data.hpp @@ -62,7 +62,8 @@ namespace CSMWorld void addModel (QAbstractItemModel *model, UniversalId::Type type1, UniversalId::Type type2 = UniversalId::Type_None, bool update = true); - static void appendIds (std::vector& ids, const CollectionBase& collection); + static void appendIds (std::vector& ids, const CollectionBase& collection, + bool listDeleted); ///< Append all IDs from collection to \a ids. public: @@ -145,10 +146,10 @@ namespace CSMWorld bool hasId (const std::string& id) const; - std::vector getIds() const; + std::vector getIds (bool listDeleted = true) const; ///< 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: diff --git a/apps/opencs/model/world/refidcollection.cpp b/apps/opencs/model/world/refidcollection.cpp index 5aadb1be3..cda2711cc 100644 --- a/apps/opencs/model/world/refidcollection.cpp +++ b/apps/opencs/model/world/refidcollection.cpp @@ -535,7 +535,7 @@ int CSMWorld::RefIdCollection::getAppendIndex (UniversalId::Type type) const return mData.getAppendIndex (type); } -std::vector CSMWorld::RefIdCollection::getIds() const +std::vector CSMWorld::RefIdCollection::getIds (bool listDeleted) const { - return mData.getIds(); + return mData.getIds (listDeleted); } diff --git a/apps/opencs/model/world/refidcollection.hpp b/apps/opencs/model/world/refidcollection.hpp index b6c8efdce..22f83150d 100644 --- a/apps/opencs/model/world/refidcollection.hpp +++ b/apps/opencs/model/world/refidcollection.hpp @@ -90,10 +90,10 @@ namespace CSMWorld virtual int getAppendIndex (UniversalId::Type type) const; ///< \param type Will be ignored, unless the collection supports multiple record types - virtual std::vector getIds() const; + virtual std::vector getIds (bool listDeleted) const; ///< Return a sorted collection of all IDs /// - /// \note Deleted records are not listed. + /// \param listDeleted include deleted record in the list }; } diff --git a/apps/opencs/model/world/refiddata.cpp b/apps/opencs/model/world/refiddata.cpp index fca0d8a71..9457937f1 100644 --- a/apps/opencs/model/world/refiddata.cpp +++ b/apps/opencs/model/world/refiddata.cpp @@ -197,14 +197,14 @@ int CSMWorld::RefIdData::getSize() const return mIndex.size(); } -std::vector CSMWorld::RefIdData::getIds() const +std::vector CSMWorld::RefIdData::getIds (bool listDeleted) const { std::vector ids; for (std::map::const_iterator iter (mIndex.begin()); iter!=mIndex.end(); ++iter) { - if (!getRecord (iter->second).isDeleted()) + if (listDeleted || !getRecord (iter->second).isDeleted()) { std::map::const_iterator container = mRecordContainers.find (iter->second.second); diff --git a/apps/opencs/model/world/refiddata.hpp b/apps/opencs/model/world/refiddata.hpp index bb8c83360..e221fbc7c 100644 --- a/apps/opencs/model/world/refiddata.hpp +++ b/apps/opencs/model/world/refiddata.hpp @@ -183,10 +183,10 @@ namespace CSMWorld int getSize() const; - std::vector getIds() const; + std::vector getIds (bool listDeleted = true) const; ///< Return a sorted collection of all IDs /// - /// \note Deleted records are not listed. + /// \param listDeleted include deleted record in the list }; }