From 860754e460523abad2a865d99b0e8ab68ada65cb Mon Sep 17 00:00:00 2001 From: cc9cii Date: Thu, 9 Apr 2015 19:33:42 +1000 Subject: [PATCH] Minor formatting cleanup and comments. --- apps/opencs/model/world/nestedadapters.hpp | 123 ------------------ .../model/world/nestedtableproxymodel.cpp | 2 +- .../model/world/nestedtableproxymodel.hpp | 6 +- apps/opencs/model/world/refidadapter.hpp | 5 +- apps/opencs/model/world/refidadapterimp.cpp | 13 +- apps/opencs/model/world/refidadapterimp.hpp | 4 +- 6 files changed, 15 insertions(+), 138 deletions(-) diff --git a/apps/opencs/model/world/nestedadapters.hpp b/apps/opencs/model/world/nestedadapters.hpp index ac2a650d4..a2cbea1a6 100644 --- a/apps/opencs/model/world/nestedadapters.hpp +++ b/apps/opencs/model/world/nestedadapters.hpp @@ -177,129 +177,6 @@ namespace CSMWorld }; - /* - template - class MagicEffectsHelper : public CastableHelper - { - public: - - MagicEffectsHelper(CSMWorld::UniversalId::Type type) - : CastableHelper(type) {} - - virtual void setNestedTable(RefIdData& data, - int index, - const NestedTableWrapperBase& nestedTable) - { - CastableHelper::getRecord(data, index).get().mEffects = - (static_cast&>(nestedTable)).mNestedTable; - } - - virtual NestedTableWrapperBase* nestedTable(const RefIdData& data, - int index) const - { - return new NestedTableWrapper(CastableHelper::getRecord(data, index).get().mEffects); - } - - virtual QVariant getNestedData(const CSMWorld::RefIdData& data, - int index, - int subRowIndex, - int subColIndex) const - { - const ESM::EffectList& content = CastableHelper::getRecord(data, index).get().mEffects; - - switch (subColIndex) - { - case 0: - return content.at(subRowIndex).mEffectID; - - case 1: - return content.at(subRowIndex).mRange; - - case 2: - return content.at(subRowIndex).mDuration; - - case 3: - return content.at(subRowIndex).mArea; - - case 4: - return content.at(subRowIndex).mMagMin; - - case 5: - return content.at(subRowIndex).mMagMax; - - case 6: - return (int)content.at(rubRowIndex).mSkill; - - case 7: - return (int)content.at(subRowIndex).mAttribute; - - default: - throw std::logic_error("Trying to access non-existing column in the nested table!"); - } - } - - virtual void removeNestedRow (RefIdData& data, int index, int rowToRemove) const - { - ESM::EffectList& list = CastableHelper::getRecord(data, index).get().mEffects; - - list.erase (list.begin () + rowToRemove); - } - - void setNestedData (RefIdData& data, - int index, - const QVariant& value, - int subRowIndex, - int subColIndex) const - { - switch(subColIndex) - { - case 0: - CastableHelper::getRecord(data, index).get().mEffects.at(subRowIndex).mEffectID = value.toInt(); - break; - - default: - throw std::logic_error("Trying to access non-existing column in the nested table!"); - } - } - - virtual void addNestedRow (RefIdData& data, int index, int position) const - { - std::vector& list = CastableHelper::getRecord(data, index).get().mTransport.mList; - - ESM::Position newPos; - for (unsigned i = 0; i < 3; ++i) - { - newPos.pos[i] = 0; - newPos.rot[i] = 0; - } - - ESM::Transport::Dest newRow; - newRow.mPos = newPos; - newRow.mCellName = ""; - - if (position >= (int)list.size()) - { - list.push_back(newRow); - return; - } - - list.insert(list.begin()+position, newRow); - } - - virtual int getNestedColumnsCount(const RefIdData& data) const - { - return 7; - } - - - virtual int getNestedRowsCount(const RefIdData& data, - int index) const - { - return CastableHelper::getRecord(data, index).get().mTransport.mList.size(); - } - - }; - */ template class DestinationsHelper : public CastableHelper { diff --git a/apps/opencs/model/world/nestedtableproxymodel.cpp b/apps/opencs/model/world/nestedtableproxymodel.cpp index fede8383b..182ed11ab 100644 --- a/apps/opencs/model/world/nestedtableproxymodel.cpp +++ b/apps/opencs/model/world/nestedtableproxymodel.cpp @@ -99,7 +99,7 @@ QVariant CSMWorld::NestedTableProxyModel::headerData(int section, } -bool CSMWorld::NestedTableProxyModel::setData ( const QModelIndex & index, const QVariant & value, int role) +bool CSMWorld::NestedTableProxyModel::setData (const QModelIndex & index, const QVariant & value, int role) { return mMainModel->setData(mapToSource(index), value, role); } diff --git a/apps/opencs/model/world/nestedtableproxymodel.hpp b/apps/opencs/model/world/nestedtableproxymodel.hpp index 7dc66989c..177a25d28 100644 --- a/apps/opencs/model/world/nestedtableproxymodel.hpp +++ b/apps/opencs/model/world/nestedtableproxymodel.hpp @@ -27,7 +27,7 @@ namespace CSMWorld IdTree* mMainModel; std::string mId; - public: + public: NestedTableProxyModel(const QModelIndex& parent, ColumnBase::Display displayType, IdTree* parentModel); @@ -51,9 +51,9 @@ namespace CSMWorld virtual QModelIndex parent(const QModelIndex& index) const; - virtual QVariant headerData ( int section, Qt::Orientation orientation, int role ) const; + virtual QVariant headerData (int section, Qt::Orientation orientation, int role) const; - virtual bool setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole ); + virtual bool setData (const QModelIndex & index, const QVariant & value, int role = Qt::EditRole); virtual Qt::ItemFlags flags(const QModelIndex& index) const; diff --git a/apps/opencs/model/world/refidadapter.hpp b/apps/opencs/model/world/refidadapter.hpp index af7469637..7f7d00413 100644 --- a/apps/opencs/model/world/refidadapter.hpp +++ b/apps/opencs/model/world/refidadapter.hpp @@ -9,6 +9,7 @@ /*! \brief * 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! */ @@ -44,7 +45,7 @@ namespace CSMWorld virtual std::string getId (const RecordBase& record) const = 0; - virtual void setId(RecordBase& record, const std::string& id) = 0; + virtual void setId(RecordBase& record, const std::string& id) = 0; // FIXME: used by RefIdCollection::cloneRecord() }; class NestedRefIdAdapterBase @@ -75,7 +76,7 @@ namespace CSMWorld class NestedRefIdAdapter : public NestedRefIdAdapterBase { - std::vector > mAssociatedColumns; //basicly, i wanted map, but with pointer key + std::vector > mAssociatedColumns; //basically, i wanted a map, but with pointer key public: NestedRefIdAdapter(); diff --git a/apps/opencs/model/world/refidadapterimp.cpp b/apps/opencs/model/world/refidadapterimp.cpp index 99117cc7f..b2a08e71c 100644 --- a/apps/opencs/model/world/refidadapterimp.cpp +++ b/apps/opencs/model/world/refidadapterimp.cpp @@ -186,11 +186,11 @@ CSMWorld::ContainerRefIdAdapter::ContainerRefIdAdapter (const NameColumns& colum std::vector > assoCol; assoCol.push_back(std::make_pair(content, new InventoryHelper(UniversalId::Type_Container))); - + setAssocColumns(assoCol); } -QVariant CSMWorld::ContainerRefIdAdapter::getData (const RefIdColumn *column, +QVariant CSMWorld::ContainerRefIdAdapter::getData (const RefIdColumn *column, const RefIdData& data, int index) const { @@ -207,12 +207,11 @@ QVariant CSMWorld::ContainerRefIdAdapter::getData (const RefIdColumn *column, return (record.get().mFlags & ESM::Container::Respawn)!=0; if (column==mContent) - return true; + return true; // required by IdTree::hasChildren() return NameRefIdAdapter::getData (column, data, index); } - void CSMWorld::ContainerRefIdAdapter::setData (const RefIdColumn *column, RefIdData& data, int index, const QVariant& value) const { @@ -490,16 +489,16 @@ QVariant CSMWorld::NpcRefIdAdapter::getData (const RefIdColumn *column, const Re if (column==mColumns.mHead) return QString::fromUtf8 (record.get().mHead.c_str()); - + if (column==mColumns.mDestinations) - return true; + return true; // required by IdTree::hasChildren() std::map::const_iterator iter = mColumns.mFlags.find (column); if (iter!=mColumns.mFlags.end()) return (record.get().mFlags & iter->second)!=0; - + return ActorRefIdAdapter::getData (column, data, index); } diff --git a/apps/opencs/model/world/refidadapterimp.hpp b/apps/opencs/model/world/refidadapterimp.hpp index acc6c40c1..f72c0d196 100644 --- a/apps/opencs/model/world/refidadapterimp.hpp +++ b/apps/opencs/model/world/refidadapterimp.hpp @@ -536,10 +536,10 @@ namespace CSMWorld return record.get().mAiData.mAlarm; if (column==mActors.mInventory) - return true; + return true; // required by IdTree::hasChildren() if (column==mActors.mSpells) - return true; + return true; // required by IdTree::hasChildren() std::map::const_iterator iter = mActors.mServices.find (column);