diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index 8c50438291..97922c1b72 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -30,7 +30,7 @@ opencs_units (model/world ) opencs_hdrs (model/world - columnimp idcollection collection info subcellcollection + columnimp disabletag idcollection collection info subcellcollection ) diff --git a/apps/opencs/main.cpp b/apps/opencs/main.cpp index 18caa3181c..f2e2156865 100644 --- a/apps/opencs/main.cpp +++ b/apps/opencs/main.cpp @@ -13,6 +13,7 @@ #include #include "model/doc/messages.hpp" +#include "model/world/disabletag.hpp" #include "model/world/universalid.hpp" #ifdef Q_OS_MAC @@ -53,6 +54,7 @@ int runApplication(int argc, char* argv[]) qRegisterMetaType("std::string"); qRegisterMetaType("CSMWorld::UniversalId"); + qRegisterMetaType("CSMWorld::DisableTag"); qRegisterMetaType("CSMDoc::Message"); setQSurfaceFormat(); diff --git a/apps/opencs/model/world/columnimp.cpp b/apps/opencs/model/world/columnimp.cpp index bce8223993..c31f9c01d0 100644 --- a/apps/opencs/model/world/columnimp.cpp +++ b/apps/opencs/model/world/columnimp.cpp @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -283,7 +284,8 @@ namespace CSMWorld { return QString::fromUtf8(record.get().mRace.getRefIdString().c_str()); } - return QVariant(QVariant::UserType); + + return DisableTag::getVariant(); } void BodyPartRaceColumn::set(Record& record, const QVariant& data) diff --git a/apps/opencs/model/world/disabletag.hpp b/apps/opencs/model/world/disabletag.hpp new file mode 100644 index 0000000000..1aee1ce6fc --- /dev/null +++ b/apps/opencs/model/world/disabletag.hpp @@ -0,0 +1,22 @@ +#ifndef CSM_WOLRD_DISABLETAG_H +#define CSM_WOLRD_DISABLETAG_H + +#include + +namespace CSMWorld +{ + class DisableTag + { + public: + static QVariant getVariant() { return QVariant::fromValue(CSMWorld::DisableTag()); } + + static bool isDisableTag(const QVariant& variant) + { + return strcmp(variant.typeName(), "CSMWorld::DisableTag") == 0; + } + }; +} + +Q_DECLARE_METATYPE(CSMWorld::DisableTag) + +#endif diff --git a/apps/opencs/model/world/nestedcoladapterimp.cpp b/apps/opencs/model/world/nestedcoladapterimp.cpp index c844c5a18f..26c52ce50a 100644 --- a/apps/opencs/model/world/nestedcoladapterimp.cpp +++ b/apps/opencs/model/world/nestedcoladapterimp.cpp @@ -7,6 +7,7 @@ #include #include +#include #include #include @@ -892,24 +893,24 @@ namespace CSMWorld // While the ambient information is not necessarily valid if the subrecord wasn't loaded, // the user should still be allowed to edit it case 1: - return (isInterior && !behaveLikeExterior) ? cell.mAmbi.mAmbient : QVariant(QVariant::UserType); + return (isInterior && !behaveLikeExterior) ? cell.mAmbi.mAmbient : DisableTag::getVariant(); case 2: - return (isInterior && !behaveLikeExterior) ? cell.mAmbi.mSunlight : QVariant(QVariant::UserType); + return (isInterior && !behaveLikeExterior) ? cell.mAmbi.mSunlight : DisableTag::getVariant(); case 3: - return (isInterior && !behaveLikeExterior) ? cell.mAmbi.mFog : QVariant(QVariant::UserType); + return (isInterior && !behaveLikeExterior) ? cell.mAmbi.mFog : DisableTag::getVariant(); case 4: - return (isInterior && !behaveLikeExterior) ? cell.mAmbi.mFogDensity : QVariant(QVariant::UserType); + return (isInterior && !behaveLikeExterior) ? cell.mAmbi.mFogDensity : DisableTag::getVariant(); case 5: { if (isInterior && interiorWater) return cell.mWater; else - return QVariant(QVariant::UserType); + return DisableTag::getVariant(); } case 6: - return isInterior ? QVariant(QVariant::UserType) : cell.mMapColor; // TODO: how to select? + return isInterior ? DisableTag::getVariant() : cell.mMapColor; // TODO: how to select? // case 7: return isInterior ? - // behaveLikeExterior : QVariant(QVariant::UserType); + // behaveLikeExterior : DisableTag::getVariant(); default: throw std::runtime_error("Cell subcolumn index out of range"); } diff --git a/apps/opencs/model/world/refidadapterimp.cpp b/apps/opencs/model/world/refidadapterimp.cpp index c25ad6e511..e7d6eb0c1c 100644 --- a/apps/opencs/model/world/refidadapterimp.cpp +++ b/apps/opencs/model/world/refidadapterimp.cpp @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -1117,11 +1118,11 @@ QVariant CSMWorld::NpcMiscRefIdAdapter::getNestedData( case 0: return static_cast(record.get().mNpdt.mLevel); case 1: - return QVariant(QVariant::UserType); + return CSMWorld::DisableTag::getVariant(); case 2: - return QVariant(QVariant::UserType); + return CSMWorld::DisableTag::getVariant(); case 3: - return QVariant(QVariant::UserType); + return CSMWorld::DisableTag::getVariant(); case 4: return static_cast(record.get().mNpdt.mDisposition); case 5: diff --git a/apps/opencs/view/world/dialoguesubview.cpp b/apps/opencs/view/world/dialoguesubview.cpp index 24fe70af94..3a87e6cf31 100644 --- a/apps/opencs/view/world/dialoguesubview.cpp +++ b/apps/opencs/view/world/dialoguesubview.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -655,7 +656,7 @@ void CSVWorld::EditWidget::remake(int row) ++unlocked; } - if (mTable->index(row, i).data().type() == QVariant::UserType) + if (CSMWorld::DisableTag::isDisableTag(mTable->index(row, i).data())) { editor->setEnabled(false); label->setEnabled(false); @@ -705,7 +706,7 @@ void CSVWorld::EditWidget::remake(int row) unlockedLayout->addWidget(editor, unlocked, 1); ++unlocked; - if (tree->index(0, col, tree->index(row, i)).data().type() == QVariant::UserType) + if (CSMWorld::DisableTag::isDisableTag(tree->index(0, col, tree->index(row, i)).data())) { editor->setEnabled(false); label->setEnabled(false);