From 29ef08bb7545e62f15325ad79abce4ece3e5792c Mon Sep 17 00:00:00 2001 From: cc9cii Date: Mon, 30 Mar 2015 11:53:33 +1100 Subject: [PATCH] Spelling and other consistencies nit pick. --- apps/opencs/CMakeLists.txt | 2 +- apps/opencs/model/world/collectionbase.hpp | 23 ------------ apps/opencs/model/world/idtable.cpp | 1 + ...{nestedadaptors.cpp => nestedadapters.cpp} | 2 +- ...{nestedadaptors.hpp => nestedadapters.hpp} | 4 +-- apps/opencs/model/world/nestedcollection.hpp | 35 +++++++++++++++++++ apps/opencs/model/world/refidadapter.hpp | 30 ++++++++-------- apps/opencs/model/world/refidadapterimp.hpp | 8 ++--- apps/opencs/model/world/refidcollection.cpp | 24 ++++++------- apps/opencs/model/world/refidcollection.hpp | 5 +-- 10 files changed, 74 insertions(+), 60 deletions(-) rename apps/opencs/model/world/{nestedadaptors.cpp => nestedadapters.cpp} (81%) rename apps/opencs/model/world/{nestedadaptors.hpp => nestedadapters.hpp} (99%) create mode 100644 apps/opencs/model/world/nestedcollection.hpp diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index 82d9f6977..c9ca60b33 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -26,7 +26,7 @@ opencs_units (model/world opencs_units_noqt (model/world universalid record commands columnbase scriptcontext cell refidcollection refidadapter refiddata refidadapterimp ref collectionbase refcollection columns infocollection tablemimedata cellcoordinates cellselection resources resourcesmanager scope - pathgrid landtexture land nestedtablewrapper nestedadaptors + pathgrid landtexture land nestedtablewrapper nestedadapters ) opencs_hdrs_noqt (model/world diff --git a/apps/opencs/model/world/collectionbase.hpp b/apps/opencs/model/world/collectionbase.hpp index 29ac33bc8..ef826e31c 100644 --- a/apps/opencs/model/world/collectionbase.hpp +++ b/apps/opencs/model/world/collectionbase.hpp @@ -13,7 +13,6 @@ namespace CSMWorld { struct ColumnBase; struct RecordBase; - class NestedTableWrapperBase; /// \brief Base class for record collections /// @@ -105,28 +104,6 @@ namespace CSMWorld ///< Return index of column with the given \a id. If no such column exists, an exception is /// thrown. }; - - class NestedCollection : public CollectionBase - { - public: - virtual void addNestedRow(int row, int col, int position) = 0; - - virtual QVariant getNestedData(int row, int column, int subRow, int subColumn) const = 0; - - virtual NestedTableWrapperBase* nestedTable(int row, int column) const = 0; - - virtual void setNestedTable(int row, int column, const NestedTableWrapperBase& nestedTable) = 0; - - virtual void setNestedData(int row, int column, const QVariant& data, int subRow, int subColumn) = 0; - - virtual int getNestedRowsCount(int row, int column) const = 0; - - virtual int getNestedColumnsCount(int row, int column) const = 0; - - virtual void removeNestedRows(int row, int column, int subRow) = 0; - - - }; } #endif diff --git a/apps/opencs/model/world/idtable.cpp b/apps/opencs/model/world/idtable.cpp index fc8ac66b7..964b68cd1 100644 --- a/apps/opencs/model/world/idtable.cpp +++ b/apps/opencs/model/world/idtable.cpp @@ -6,6 +6,7 @@ #include "nestedtablewrapper.hpp" #include "collectionbase.hpp" +#include "nestedcollection.hpp" #include "columnbase.hpp" CSMWorld::IdTable::IdTable (CollectionBase *idCollection, unsigned int features) diff --git a/apps/opencs/model/world/nestedadaptors.cpp b/apps/opencs/model/world/nestedadapters.cpp similarity index 81% rename from apps/opencs/model/world/nestedadaptors.cpp rename to apps/opencs/model/world/nestedadapters.cpp index 1e8425229..1c8b1eff1 100644 --- a/apps/opencs/model/world/nestedadaptors.cpp +++ b/apps/opencs/model/world/nestedadapters.cpp @@ -1,4 +1,4 @@ -#include "nestedadaptors.hpp" +#include "nestedadapters.hpp" CSMWorld::HelperBase::HelperBase(CSMWorld::UniversalId::Type type) : mType(type) diff --git a/apps/opencs/model/world/nestedadaptors.hpp b/apps/opencs/model/world/nestedadapters.hpp similarity index 99% rename from apps/opencs/model/world/nestedadaptors.hpp rename to apps/opencs/model/world/nestedadapters.hpp index cc062e827..ac2a650d4 100644 --- a/apps/opencs/model/world/nestedadaptors.hpp +++ b/apps/opencs/model/world/nestedadapters.hpp @@ -1,5 +1,5 @@ -#ifndef CSM_WORLD_NESTEDADAPTORS_H -#define CSM_WORLD_NESTEDADAPTORS_H +#ifndef CSM_WORLD_NESTEDADAPTERS_H +#define CSM_WORLD_NESTEDADAPTERS_H #include #include diff --git a/apps/opencs/model/world/nestedcollection.hpp b/apps/opencs/model/world/nestedcollection.hpp new file mode 100644 index 000000000..dffa29573 --- /dev/null +++ b/apps/opencs/model/world/nestedcollection.hpp @@ -0,0 +1,35 @@ +#ifndef CSM_WOLRD_NESTEDCOLLECTION_H +#define CSM_WOLRD_NESTEDCOLLECTION_H + +#include "collectionbase.hpp" + +class QVariant; + +namespace CSMWorld +{ + class NestedTableWrapperBase; + + class NestedCollection : public CollectionBase + { + public: + virtual void addNestedRow(int row, int col, int position) = 0; + + virtual QVariant getNestedData(int row, int column, int subRow, int subColumn) const = 0; + + virtual NestedTableWrapperBase* nestedTable(int row, int column) const = 0; + + virtual void setNestedTable(int row, int column, const NestedTableWrapperBase& nestedTable) = 0; + + virtual void setNestedData(int row, int column, const QVariant& data, int subRow, int subColumn) = 0; + + virtual int getNestedRowsCount(int row, int column) const = 0; + + virtual int getNestedColumnsCount(int row, int column) const = 0; + + virtual void removeNestedRows(int row, int column, int subRow) = 0; + + + }; +} + +#endif diff --git a/apps/opencs/model/world/refidadapter.hpp b/apps/opencs/model/world/refidadapter.hpp index 387ee8606..af7469637 100644 --- a/apps/opencs/model/world/refidadapter.hpp +++ b/apps/opencs/model/world/refidadapter.hpp @@ -4,10 +4,10 @@ #include #include -#include "nestedadaptors.hpp" +#include "nestedadapters.hpp" /*! \brief - * Adaptors acts as indirection layer, abstracting details of the record types (in the wrappers) from the higher levels of model. + * Adapters acts as indirection layer, abstracting details of the record types (in the wrappers) from the higher levels of model. * Please notice that nested adaptor uses helper classes for actually performing any actions. Different record types require different helpers (needs to be created in the subclass and then fetched via member function). * Important point: don't forget to make sure that getData on the nestedColumn returns true (otherwise code will not treat the index pointing to the column as having childs! */ @@ -79,25 +79,25 @@ namespace CSMWorld public: NestedRefIdAdapter(); - + virtual ~NestedRefIdAdapter(); - + virtual void setNestedData (const RefIdColumn *column, RefIdData& data, int row, const QVariant& value, int subRowIndex, int subColIndex) const; - + virtual QVariant getNestedData (const RefIdColumn *column, const RefIdData& data, int index, int subRowIndex, int subColIndex) const; - + virtual int getNestedColumnsCount(const RefIdColumn *column, const RefIdData& data) const; - + virtual int getNestedRowsCount(const RefIdColumn *column, const RefIdData& data, int index) const; - + virtual void removeNestedRow (const RefIdColumn *column, RefIdData& data, int index, int rowToRemove) const; - + virtual void addNestedRow (const RefIdColumn *column, RefIdData& data, int index, int position) const; - + virtual void setNestedTable (const RefIdColumn* column, RefIdData& data, int index, const NestedTableWrapperBase& nestedTable); - + virtual NestedTableWrapperBase* nestedTable (const RefIdColumn* column, const RefIdData& data, int index) const; protected: @@ -105,12 +105,12 @@ namespace CSMWorld ///The ownership of the Helper pointers is transfered. ///The ownership of the column pointers it not transfered (it is not surprising, since columns are created by collection). ///You MUST call this method to setup the nested adaptor! - - void addAssocColumn(const std::pair & assocColumn); + + void addAssocColumn(const std::pair & assocColumn); ///Like setAssocColumn, when it is impossible to set all columns at once - + private: - + HelperBase* getHelper(const RefIdColumn *column) const; }; } diff --git a/apps/opencs/model/world/refidadapterimp.hpp b/apps/opencs/model/world/refidadapterimp.hpp index 11befaeec..acc6c40c1 100644 --- a/apps/opencs/model/world/refidadapterimp.hpp +++ b/apps/opencs/model/world/refidadapterimp.hpp @@ -12,7 +12,7 @@ #include "refiddata.hpp" #include "universalid.hpp" #include "refidadapter.hpp" -#include "nestedadaptors.hpp" +#include "nestedadapters.hpp" namespace CSMWorld { @@ -509,7 +509,7 @@ namespace CSMWorld assoCol.push_back(std::make_pair(mActors.mInventory, new InventoryHelper(type))); assoCol.push_back(std::make_pair(mActors.mSpells, new SpellsHelper(type))); - + setAssocColumns(assoCol); } @@ -540,7 +540,7 @@ namespace CSMWorld if (column==mActors.mSpells) return true; - + std::map::const_iterator iter = mActors.mServices.find (column); @@ -666,7 +666,7 @@ namespace CSMWorld const RefIdColumn *mOrganic; const RefIdColumn *mRespawn; const RefIdColumn *mContent; - + public: ContainerRefIdAdapter (const NameColumns& columns, const RefIdColumn *weight, diff --git a/apps/opencs/model/world/refidcollection.cpp b/apps/opencs/model/world/refidcollection.cpp index ee09cafa1..c48896435 100644 --- a/apps/opencs/model/world/refidcollection.cpp +++ b/apps/opencs/model/world/refidcollection.cpp @@ -27,7 +27,7 @@ bool CSMWorld::RefIdColumn::isUserEditable() const } -CSMWorld::RefIdAdapter& CSMWorld::RefIdCollection::findAdaptor (UniversalId::Type type) const +CSMWorld::RefIdAdapter& CSMWorld::RefIdCollection::findAdapter (UniversalId::Type type) const { std::map::const_iterator iter = mAdapters.find (type); @@ -452,7 +452,7 @@ QVariant CSMWorld::RefIdCollection::getData (int index, int column) const { RefIdData::LocalIndex localIndex = mData.globalToLocalIndex (index); - const RefIdAdapter& adaptor = findAdaptor (localIndex.second); + const RefIdAdapter& adaptor = findAdapter (localIndex.second); return adaptor.getData (&mColumns.at (column), mData, localIndex.first); } @@ -461,7 +461,7 @@ QVariant CSMWorld::RefIdCollection::getNestedData (int row, int column, int subR { RefIdData::LocalIndex localIndex = mData.globalToLocalIndex(row); - const CSMWorld::NestedRefIdAdapter& adaptor = dynamic_cast(findAdaptor (localIndex.second)); + const CSMWorld::NestedRefIdAdapter& adaptor = dynamic_cast(findAdapter (localIndex.second)); return adaptor.getNestedData (&mColumns.at (column), mData, localIndex.first, subRow, subColumn); } @@ -470,7 +470,7 @@ void CSMWorld::RefIdCollection::setData (int index, int column, const QVariant& { RefIdData::LocalIndex localIndex = mData.globalToLocalIndex (index); - const RefIdAdapter& adaptor = findAdaptor (localIndex.second); + const RefIdAdapter& adaptor = findAdapter (localIndex.second); adaptor.setData (&mColumns.at (column), mData, localIndex.first, data); } @@ -479,7 +479,7 @@ void CSMWorld::RefIdCollection::setNestedData(int row, int column, const QVarian { RefIdData::LocalIndex localIndex = mData.globalToLocalIndex (row); - const RefIdAdapter& adaptor = findAdaptor (localIndex.second); + const RefIdAdapter& adaptor = findAdapter (localIndex.second); dynamic_cast(adaptor).setNestedData (&mColumns.at (column), mData, localIndex.first, data, subRow, subColumn); } @@ -493,7 +493,7 @@ void CSMWorld::RefIdCollection::removeNestedRows(int row, int column, int subRow { RefIdData::LocalIndex localIndex = mData.globalToLocalIndex (row); - const RefIdAdapter& adaptor = findAdaptor (localIndex.second); + const RefIdAdapter& adaptor = findAdapter (localIndex.second); dynamic_cast(adaptor).removeNestedRow(&mColumns.at (column), mData, localIndex.first, subRow); } @@ -530,7 +530,7 @@ void CSMWorld::RefIdCollection::cloneRecord(const std::string& origin, void CSMWorld::RefIdCollection::appendRecord (const RecordBase& record, UniversalId::Type type) { - std::string id = findAdaptor (type).getId (record); + std::string id = findAdapter (type).getId (record); int index = mData.getAppendIndex (type); @@ -637,7 +637,7 @@ int CSMWorld::RefIdCollection::getNestedRowsCount(int row, int column) const { RefIdData::LocalIndex localIndex = mData.globalToLocalIndex (row); - const CSMWorld::NestedRefIdAdapter& adaptor = dynamic_cast(findAdaptor (localIndex.second)); + const CSMWorld::NestedRefIdAdapter& adaptor = dynamic_cast(findAdapter (localIndex.second)); return adaptor.getNestedRowsCount(&mColumns.at(column), mData, localIndex.first); } @@ -646,7 +646,7 @@ int CSMWorld::RefIdCollection::getNestedColumnsCount(int row, int column) const { RefIdData::LocalIndex localIndex = mData.globalToLocalIndex (row); - const CSMWorld::NestedRefIdAdapter& adaptor = dynamic_cast(findAdaptor (localIndex.second)); + const CSMWorld::NestedRefIdAdapter& adaptor = dynamic_cast(findAdapter (localIndex.second)); return adaptor.getNestedColumnsCount(&mColumns.at(column), mData); } @@ -655,7 +655,7 @@ void CSMWorld::RefIdCollection::addNestedRow(int row, int col, int position) { RefIdData::LocalIndex localIndex = mData.globalToLocalIndex (row); - const CSMWorld::NestedRefIdAdapter& adaptor = dynamic_cast(findAdaptor (localIndex.second)); + const CSMWorld::NestedRefIdAdapter& adaptor = dynamic_cast(findAdapter (localIndex.second)); adaptor.addNestedRow(&mColumns.at(col), mData, localIndex.first, position); } @@ -664,7 +664,7 @@ void CSMWorld::RefIdCollection::setNestedTable(int row, int column, const CSMWor { RefIdData::LocalIndex localIndex = mData.globalToLocalIndex (row); - CSMWorld::NestedRefIdAdapter& adaptor = dynamic_cast(findAdaptor (localIndex.second)); + CSMWorld::NestedRefIdAdapter& adaptor = dynamic_cast(findAdapter (localIndex.second)); adaptor.setNestedTable(&mColumns.at(column), mData, localIndex.first, nestedTable); } @@ -673,7 +673,7 @@ CSMWorld::NestedTableWrapperBase* CSMWorld::RefIdCollection::nestedTable(int row { RefIdData::LocalIndex localIndex = mData.globalToLocalIndex (row); - const CSMWorld::NestedRefIdAdapter& adaptor = dynamic_cast(findAdaptor (localIndex.second)); + const CSMWorld::NestedRefIdAdapter& adaptor = dynamic_cast(findAdapter (localIndex.second)); return adaptor.nestedTable(&mColumns.at(column), mData, localIndex.first); } diff --git a/apps/opencs/model/world/refidcollection.hpp b/apps/opencs/model/world/refidcollection.hpp index 62616d369..ab25c93fa 100644 --- a/apps/opencs/model/world/refidcollection.hpp +++ b/apps/opencs/model/world/refidcollection.hpp @@ -7,6 +7,7 @@ #include "columnbase.hpp" #include "collectionbase.hpp" +#include "nestedcollection.hpp" #include "refiddata.hpp" namespace ESM @@ -45,7 +46,7 @@ namespace CSMWorld private: - RefIdAdapter& findAdaptor (UniversalId::Type) const; + RefIdAdapter& findAdapter (UniversalId::Type) const; ///< Throws an exception if no adaptor for \a Type can be found. public: @@ -71,7 +72,7 @@ namespace CSMWorld virtual QVariant getData (int index, int column) const; virtual QVariant getNestedData(int row, int column, int subRow, int subColumn) const; - + virtual NestedTableWrapperBase* nestedTable(int row, int column) const; virtual void setNestedTable(int row, int column, const NestedTableWrapperBase& nestedTable);