diff options
author | Määttä Antti <antti.maatta@qt.io> | 2018-11-14 10:15:34 +0200 |
---|---|---|
committer | Antti Määttä <antti.maatta@qt.io> | 2018-11-23 08:20:24 +0000 |
commit | e4287d43e0209105e7218a24f5778059d9a6015c (patch) | |
tree | 2bb3390f0d69cad9b73c042568d9c19aaa9a029e | |
parent | 5e9528d3b53a48eba0b9235c8a9c111902096c59 (diff) |
Replace paths and strings with QString and QFileInfo
Task-number: QT3DS-1899
Task-number: QT3DS-2066
Change-Id: Ice88413479a1a767acd5385cc574c97564a3eea2
Reviewed-by: Antti Määttä <antti.maatta@qt.io>
165 files changed, 5565 insertions, 5516 deletions
diff --git a/src/Authoring/Client/Code/Core/Commands/CmdDataModelActionSetValue.h b/src/Authoring/Client/Code/Core/Commands/CmdDataModelActionSetValue.h index cfffe450..202b8a2f 100644 --- a/src/Authoring/Client/Code/Core/Commands/CmdDataModelActionSetValue.h +++ b/src/Authoring/Client/Code/Core/Commands/CmdDataModelActionSetValue.h @@ -103,12 +103,12 @@ protected: // Members SObjectRefType m_Object; bool m_ResetEvent; - wstring m_Event; + QString m_Event; public: // Construction CCmdDataModelActionSetTriggerObject(CDoc *inDoc, Qt3DSDMActionHandle inAction, const SObjectRefType &inObject) - : CCmdDataModelActionSetValue(inDoc, inAction, "Set Trigger Object") + : CCmdDataModelActionSetValue(inDoc, inAction, QObject::tr("Set Trigger Object")) , m_Object(inObject) , m_ResetEvent(false) { @@ -122,7 +122,7 @@ public: // Construction } } - virtual void ResetEvent(wstring inEvent) + virtual void ResetEvent(const QString &inEvent) { m_ResetEvent = true; m_Event = inEvent; @@ -132,11 +132,11 @@ public: // Construction class CCmdDataModelActionSetEvent : public CCmdDataModelActionSetValue { protected: // Members - wstring m_Event; + QString m_Event; public: // Construction - CCmdDataModelActionSetEvent(CDoc *inDoc, Qt3DSDMActionHandle inAction, const wstring &inEvent) - : CCmdDataModelActionSetValue(inDoc, inAction, "Set Event") + CCmdDataModelActionSetEvent(CDoc *inDoc, Qt3DSDMActionHandle inAction, const QString &inEvent) + : CCmdDataModelActionSetValue(inDoc, inAction, QObject::tr("Set Event")) , m_Event(inEvent) { } @@ -151,7 +151,7 @@ class CCmdDataModelActionResetHandler : public CCmdDataModelActionSetValue { protected: // Members bool m_ResetHandler; - wstring m_Handler; + QString m_Handler; protected: // helper functions virtual void ResetHandlerHandle() @@ -159,7 +159,7 @@ protected: // helper functions m_Doc->GetStudioSystem()->GetActionCore()->SetHandler(m_Action, m_Handler); } - virtual void ResetHandlerArguments(const wstring &inHandler) + virtual void ResetHandlerArguments(const QString &inHandler) { m_Handler = inHandler; m_Doc->GetStudioSystem()->GetClientDataModelBridge()->ResetHandlerArguments(m_Action, @@ -177,7 +177,7 @@ public: // Construction // Changing Trigger Object may make the current Action Name to be unapplicable. // Changing Action Name may make the current Action Args to be unapplicable. // If that's the case, Reset the Action Name and/or Action Args. - virtual void ResetHandler(const wstring &inHandler) + virtual void ResetHandler(const QString &inHandler) { m_ResetHandler = true; m_Handler = inHandler; @@ -192,7 +192,7 @@ protected: // Members public: // Construction CCmdDataModelActionSetTargetObject(CDoc *inDoc, Qt3DSDMActionHandle inAction, const SObjectRefType &inObject) - : CCmdDataModelActionResetHandler(inDoc, inAction, "Set Target Object") + : CCmdDataModelActionResetHandler(inDoc, inAction, QObject::tr("Set Target Object")) , m_Object(inObject) { } @@ -210,12 +210,12 @@ public: // Construction class CCmdDataModelActionSetHandler : public CCmdDataModelActionResetHandler { protected: // Members - qt3dsdm::wstring m_Handler; + QString m_Handler; public: // Construction CCmdDataModelActionSetHandler(CDoc *inDoc, Qt3DSDMActionHandle inAction, - qt3dsdm::wstring inHandler) - : CCmdDataModelActionResetHandler(inDoc, inAction, "Set Handler") + const QString &inHandler) + : CCmdDataModelActionResetHandler(inDoc, inAction, QObject::tr("Set Handler")) , m_Handler(inHandler) { } @@ -289,7 +289,7 @@ protected: // Members public: // Construction CCmdDataModelActionSetEyeball(CDoc *inDoc, Qt3DSDMSlideHandle inActiveSlide, Qt3DSDMActionHandle inAction, bool inValue) - : CCmdDataModelActionSetValue(inDoc, inAction, "Set Action Eyeball") + : CCmdDataModelActionSetValue(inDoc, inAction, QObject::tr("Set Action Eyeball")) , m_Value(inValue) , m_ActiveSlide(inActiveSlide) { diff --git a/src/Authoring/Client/Code/Core/Core/Core.cpp b/src/Authoring/Client/Code/Core/Core/Core.cpp index 7e4726b7..93817360 100644 --- a/src/Authoring/Client/Code/Core/Core/Core.cpp +++ b/src/Authoring/Client/Code/Core/Core/Core.cpp @@ -190,16 +190,15 @@ void CCore::RegisterGlobalKeyboardShortcuts(CHotKeys *inShortcutHandler, QWidget } void CCore::GetCreateDirectoryFileName(const QString &inDocument, - Q3DStudio::CFilePath &outFinalDir, - Q3DStudio::CFilePath &outFinalDoc) + QString &outFinalDir, + QString &outFinalDoc) { - using namespace Q3DStudio; - CFilePath theOriginal(inDocument); - CFilePath theName(theOriginal.GetFileName()); - CString theStem(theOriginal.GetFileStem()); - CFilePath theDir = theOriginal.GetDirectory(); - outFinalDir = CFilePath::CombineBaseAndRelative(theDir, theStem); - outFinalDoc = CFilePath::CombineBaseAndRelative(outFinalDir, theName); + QFileInfo theOriginal(inDocument); + QString theName(theOriginal.fileName()); + QString theStem(theOriginal.baseName()); + QString theDir = theOriginal.canonicalPath(); + outFinalDir = Q3DStudio::CFilePath::CombineBaseAndRelative(theDir, theStem); + outFinalDoc = Q3DStudio::CFilePath::CombineBaseAndRelative(outFinalDir, theName); } ProjectFile &CCore::getProjectFile() diff --git a/src/Authoring/Client/Code/Core/Core/Core.h b/src/Authoring/Client/Code/Core/Core/Core.h index 7a820a54..b2b9d3d0 100644 --- a/src/Authoring/Client/Code/Core/Core/Core.h +++ b/src/Authoring/Client/Code/Core/Core/Core.h @@ -72,8 +72,8 @@ public: void SetCommandModifiedFlag(bool inModified) override; void CommandUpdate(unsigned long inUpdateFlags) override; - void GetCreateDirectoryFileName(const QString &inDocument, Q3DStudio::CFilePath &outFinalDir, - Q3DStudio::CFilePath &outFinalDoc); + void GetCreateDirectoryFileName(const QString &inDocument, QString &outFinalDir, + QString &outFinalDoc); // CPresentationListener void OnNewPresentation() override; diff --git a/src/Authoring/Client/Code/Core/Doc/ClientDataModelBridge/ClientDataModelBridge.cpp b/src/Authoring/Client/Code/Core/Doc/ClientDataModelBridge/ClientDataModelBridge.cpp index 29d64442..13a43c75 100644 --- a/src/Authoring/Client/Code/Core/Doc/ClientDataModelBridge/ClientDataModelBridge.cpp +++ b/src/Authoring/Client/Code/Core/Doc/ClientDataModelBridge/ClientDataModelBridge.cpp @@ -104,7 +104,7 @@ CClientDataModelBridge::~CClientDataModelBridge() Qt3DSDMSlideHandle CClientDataModelBridge::CreateNonMasterSlide(Qt3DSDMSlideHandle inMasterSlide, Q3DStudio::CId inGuid, - const Q3DStudio::CString &inName) + const QString &inName) { Qt3DSDMInstanceHandle theInstance = m_DataCore->CreateInstance(); m_DataCore->DeriveInstance(theInstance, m_SlideItem.m_Instance); @@ -163,11 +163,11 @@ CClientDataModelBridge::GetOrCreateGraph(qt3dsdm::Qt3DSDMInstanceHandle inInstan m_DataCore->DeriveInstance(rootInstance, m_SlideItem.m_Instance); m_DataCore->SetInstancePropertyValue(rootInstance, m_SlideItem.m_ComponentId, GuidToLong4(theGuid)); - SetName(rootInstance, Q3DStudio::CString::fromQString(QObject::tr("Master Slide"))); + SetName(rootInstance, QObject::tr("Master Slide")); Qt3DSDMSlideHandle masterSlide = m_SlideCore->CreateSlide(rootInstance); Qt3DSDMSlideGraphHandle retval(m_SlideGraphCore->CreateSlideGraph(masterSlide)); Qt3DSDMSlideHandle theSlide1Handle = - CreateNonMasterSlide(masterSlide, theGuid, Q3DStudio::CString::fromQString(QObject::tr("Slide1"))); + CreateNonMasterSlide(masterSlide, theGuid, QObject::tr("Slide1")); // always activate slide 1 on create m_SlideGraphCore->SetGraphActiveSlide(retval, theSlide1Handle); @@ -460,7 +460,7 @@ CClientDataModelBridge::GetComponentSlide(qt3dsdm::Qt3DSDMInstanceHandle inCompo // void CClientDataModelBridge::SetName(qt3dsdm::Qt3DSDMInstanceHandle inInstanceHandle, - const Q3DStudio::CString &inName) + const QString &inName) { TDataStrPtr theName(new CDataStr(inName)); Qt3DSDMSlideHandle theAssociatedSlide = @@ -476,7 +476,7 @@ void CClientDataModelBridge::SetName(qt3dsdm::Qt3DSDMInstanceHandle inInstanceHa } } -Q3DStudio::CString CClientDataModelBridge::GetName(qt3dsdm::Qt3DSDMInstanceHandle inInstanceHandle) +QString CClientDataModelBridge::GetName(qt3dsdm::Qt3DSDMInstanceHandle inInstanceHandle) { IPropertySystem *thePropertySystem = m_Doc->GetStudioSystem()->GetPropertySystem(); TDataStrPtr theString; @@ -487,7 +487,9 @@ Q3DStudio::CString CClientDataModelBridge::GetName(qt3dsdm::Qt3DSDMInstanceHandl && GetValueType(theValue) == DataModelDataType::String) theString = qt3dsdm::get<TDataStrPtr>(theValue); } - return (theString) ? Q3DStudio::CString(theString->GetData()) : ""; + if (theString) + return theString->toQString(); + return {}; } bool CClientDataModelBridge::IsActiveComponent(qt3dsdm::Qt3DSDMInstanceHandle inInstance) @@ -504,20 +506,19 @@ bool CClientDataModelBridge::IsActiveComponent(qt3dsdm::Qt3DSDMInstanceHandle in return theActiveComponentId == theInstanceId; } -// Helper for getting the type as a wstring... returns "" if it can't figure things out -std::wstring GetInstanceType(IPropertySystem *inPropertySystem, Qt3DSDMInstanceHandle inInstance) +// Helper for getting the type as a QString... returns "" if it can't figure things out +QString GetInstanceType(IPropertySystem *inPropertySystem, Qt3DSDMInstanceHandle inInstance) { - std::wstring theReturn(L""); + QString theReturn; try { Qt3DSDMPropertyHandle theProperty = - inPropertySystem->GetAggregateInstancePropertyByName(inInstance, L"type"); + inPropertySystem->GetAggregateInstancePropertyByName(inInstance, QStringLiteral("type")); SValue theTypeValue; if (theProperty && inPropertySystem->GetInstancePropertyValue(inInstance, theProperty, theTypeValue)) { - theReturn.assign(qt3dsdm::get<TDataStrPtr>(theTypeValue)->GetData()); + theReturn = qt3dsdm::get<TDataStrPtr>(theTypeValue)->toQString(); } } catch (...) { - theReturn.assign(L""); } return theReturn; @@ -530,7 +531,7 @@ bool CClientDataModelBridge::GetMaterialFromImageInstance( { IPropertySystem *thePropertySystem = m_Doc->GetStudioSystem()->GetPropertySystem(); SLong4 theDeletedImageLong4 = - GetNamedInstancePropertyValue<SLong4>(thePropertySystem, inInstance, L"id"); + GetNamedInstancePropertyValue<SLong4>(thePropertySystem, inInstance, QStringLiteral("id")); TInstanceHandleList theInstances; m_DataCore->GetInstancesDerivedFrom( @@ -538,8 +539,8 @@ bool CClientDataModelBridge::GetMaterialFromImageInstance( size_t theInstanceCount = theInstances.size(); for (size_t theInstanceIndex = 0; theInstanceIndex < theInstanceCount; ++theInstanceIndex) { Qt3DSDMInstanceHandle theInstance = theInstances[theInstanceIndex]; - std::wstring theWideTypeString(GetInstanceType(thePropertySystem, theInstance)); - if (theWideTypeString == L"Material") { + QString type(GetInstanceType(thePropertySystem, theInstance)); + if (type == QLatin1String("Material")) { TPropertyHandleList theProperties; thePropertySystem->GetAggregateInstanceProperties(theInstance, theProperties); size_t thePropertyCount = theProperties.size(); @@ -567,8 +568,8 @@ bool CClientDataModelBridge::GetMaterialFromImageInstance( theInstanceCount = theInstances.size(); for (size_t theInstanceIndex = 0; theInstanceIndex < theInstanceCount; ++theInstanceIndex) { Qt3DSDMInstanceHandle theInstance = theInstances[theInstanceIndex]; - std::wstring theWideTypeString(GetInstanceType(thePropertySystem, theInstance)); - if (theWideTypeString == L"CustomMaterial") { + QString type(GetInstanceType(thePropertySystem, theInstance)); + if (type == QLatin1String("CustomMaterial")) { TPropertyHandleList theProperties; thePropertySystem->GetAggregateInstanceProperties(theInstance, theProperties); size_t thePropertyCount = theProperties.size(); @@ -599,7 +600,7 @@ bool CClientDataModelBridge::GetLayerFromImageProbeInstance( { IPropertySystem *thePropertySystem = m_Doc->GetStudioSystem()->GetPropertySystem(); SLong4 theDeletedImageLong4 = - GetNamedInstancePropertyValue<SLong4>(thePropertySystem, inInstance, L"id"); + GetNamedInstancePropertyValue<SLong4>(thePropertySystem, inInstance, QStringLiteral("id")); TInstanceHandleList theInstances; m_DataCore->GetInstancesDerivedFrom( @@ -608,8 +609,8 @@ bool CClientDataModelBridge::GetLayerFromImageProbeInstance( for (size_t theInstanceIndex = 0; theInstanceIndex < theInstanceCount; ++theInstanceIndex) { Qt3DSDMInstanceHandle theInstance = theInstances[theInstanceIndex]; - std::wstring theWideTypeString(GetInstanceType(thePropertySystem, theInstance)); - if (theWideTypeString == L"Layer") { + QString type(GetInstanceType(thePropertySystem, theInstance)); + if (type == QLatin1String("Layer")) { // Layer should have only one image property, which is the light probe, but this is a // little more // generic should anyone ever add more in the future. @@ -855,7 +856,7 @@ CClientDataModelBridge::GetInstance(qt3dsdm::Qt3DSDMInstanceHandle inRoot, case ObjectReferenceType::Absolute: return GetInstanceByGUID(get<SLong4>(inValue.m_Value)); case ObjectReferenceType::Relative: { - Q3DStudio::CString thePath(qt3dsdm::get<qt3dsdm::TDataStrPtr>(inValue.m_Value)->GetData()); + QString thePath(qt3dsdm::get<qt3dsdm::TDataStrPtr>(inValue.m_Value)->toQString()); IObjectReferenceHelper *theObjRefHelper = m_Doc->GetDataModelObjectReferenceHelper(); if (theObjRefHelper) { bool theFullResolvedFlag; @@ -1000,55 +1001,48 @@ CClientDataModelBridge::GetParentComponent(qt3dsdm::Qt3DSDMInstanceHandle inInst * @param inDesiredName the desired base name for the object. * @return a unique name that no other child has. */ -Q3DStudio::CString +QString CClientDataModelBridge::GetUniqueChildName(qt3dsdm::Qt3DSDMInstanceHandle inParent, qt3dsdm::Qt3DSDMInstanceHandle inInstance, - Q3DStudio::CString inDesiredName) + const QString &inDesiredName) { // fyi, if we get abc123, theBaseName gets abc and theBaseIndex gets 123 - Q3DStudio::CString theBaseName = inDesiredName; - Q3DStudio::CString theBaseIndex; + QString theBaseName = inDesiredName; + QString theBaseIndex; // Strip off all trailing numbers to get the base name - if (theBaseName.Length() > 0) { - wchar_t theLastChar = static_cast<const wchar_t *>(theBaseName)[theBaseName.Length() - 1]; - while (theBaseName.Length() > 0 && theLastChar >= '0' && theLastChar <= '9') { - // get a wchar_t* so we can index - const wchar_t *theBasePtr = theBaseName; - // find where the desired character is - long theDesiredOffset = theBaseName.Length() - 1; - // make a CString of the desired character and concatenate with the existing base index - theBaseIndex = Q3DStudio::CString(theBasePtr + theDesiredOffset, 1) + theBaseIndex; - - // take out that last character - theBaseName = theBaseName.Extract(0, theBaseName.Length() - 1); + if (theBaseName.length() > 0) { + QChar theLastChar = theBaseName.at(theBaseName.length() - 1); + while (theBaseName.length() > 0 && theLastChar.isNumber()) { + theBaseIndex.insert(0, theLastChar); + theBaseName = theBaseName.left(theBaseName.length() - 1); // get the new last char - if (theBaseName.Length() > 0) - theLastChar = static_cast<const wchar_t *>(theBaseName)[theBaseName.Length() - 1]; + if (theBaseName.length() > 0) + theLastChar = theBaseName.at(theBaseName.length() - 1); } } qt3dsdm::Qt3DSDMInstanceHandle theExistingChild = 0; // If there is a base name then use it - if (theBaseName.Length() > 0) + if (theBaseName.length() > 0) theExistingChild = GetChildByName(inParent, inDesiredName, inInstance); else // there is no base name, just set it to a random setting so it'll fall into the while loop theExistingChild = inParent; - Q3DStudio::CString theUniqueName = inDesiredName; + QString theUniqueName = inDesiredName; if (theExistingChild != 0 && theExistingChild != inInstance) { long theIndex; - if (theBaseIndex.Length() != 0) - theIndex = atoi(theBaseIndex.GetCharStar()); + if (theBaseIndex.length() != 0) + theIndex = theBaseIndex.toLong(); else theIndex = 2; // If the name is in use then increment the index until one is found. while (theExistingChild != 0 && theExistingChild != inInstance) { - theUniqueName.Format(_LSTR("%ls%d"), static_cast<const wchar_t *>(theBaseName), theIndex); + theUniqueName = theBaseName + QString::number(theIndex); ++theIndex; theExistingChild = GetChildByName(inParent, theUniqueName, inInstance); } @@ -1059,10 +1053,10 @@ CClientDataModelBridge::GetUniqueChildName(qt3dsdm::Qt3DSDMInstanceHandle inPare bool CClientDataModelBridge::CheckNameUnique(qt3dsdm::Qt3DSDMInstanceHandle inParentInstance, qt3dsdm::Qt3DSDMInstanceHandle inInstance, - Q3DStudio::CString inDesiredName) + const QString &inDesiredName) { qt3dsdm::Qt3DSDMInstanceHandle theExistingChild = 0; - if (inDesiredName.Length() > 0) { + if (inDesiredName.length() > 0) { theExistingChild = GetChildByName(inParentInstance, inDesiredName, qt3dsdm::Qt3DSDMInstanceHandle()); } @@ -1074,7 +1068,7 @@ bool CClientDataModelBridge::CheckNameUnique(qt3dsdm::Qt3DSDMInstanceHandle inPa /** * Get SourcePath value for this instance */ -Q3DStudio::CString +QString CClientDataModelBridge::GetSourcePath(qt3dsdm::Qt3DSDMInstanceHandle inInstance) const { if (inInstance.Valid()) { @@ -1082,9 +1076,9 @@ CClientDataModelBridge::GetSourcePath(qt3dsdm::Qt3DSDMInstanceHandle inInstance) IPropertySystem *thePropertySystem = m_Doc->GetStudioSystem()->GetPropertySystem(); thePropertySystem->GetInstancePropertyValue(inInstance, m_SceneAsset.m_SourcePath, theValue); - return qt3dsdm::get<TDataStrPtr>(theValue)->GetData(); - } else - return L""; + return qt3dsdm::get<TDataStrPtr>(theValue)->toQString(); + } + return {}; } /** @@ -1095,18 +1089,16 @@ CClientDataModelBridge::GetSourcePath(qt3dsdm::Qt3DSDMInstanceHandle inInstance) * * @return the sub-presentation property value */ -Q3DStudio::CString -CClientDataModelBridge::getSubpresentation(qt3dsdm::Qt3DSDMInstanceHandle inInstance) const +QString CClientDataModelBridge::getSubpresentation(qt3dsdm::Qt3DSDMInstanceHandle inInstance) const { if (inInstance.Valid() && GetObjectType(inInstance) == OBJTYPE_IMAGE) { qt3dsdm::SValue theValue; IPropertySystem *thePropertySystem = m_Doc->GetStudioSystem()->GetPropertySystem(); thePropertySystem->GetInstancePropertyValue(inInstance, m_SceneImage.m_SubPresentation, theValue); - return qt3dsdm::get<TDataStrPtr>(theValue)->GetData(); + return qt3dsdm::get<TDataStrPtr>(theValue)->toQString(); } - - return L""; + return {}; } //============================================================================= @@ -1120,12 +1112,12 @@ TInstanceHandleList CClientDataModelBridge::GetItemBaseInstances() const return theInstances; } -inline void AddSourcePathToList(std::set<Q3DStudio::CString> &ioSourcePathList, +inline void AddSourcePathToList(std::set<QString> &ioSourcePathList, const SValue &inValue) { - Q3DStudio::CFilePath theSourcePath = qt3dsdm::get<TDataStrPtr>(inValue)->GetData(); - if (!theSourcePath.filePath().isEmpty()) - ioSourcePathList.insert(theSourcePath.toCString()); + QString theSourcePath = qt3dsdm::get<TDataStrPtr>(inValue)->toQString(); + if (!theSourcePath.isEmpty()) + ioSourcePathList.insert(theSourcePath); } //============================================================================= @@ -1216,15 +1208,15 @@ struct SValueListFilter : public IValueFilter /** * Get SourcePath list from all instances */ -std::set<Q3DStudio::CString> CClientDataModelBridge::GetSourcePathList() const +std::set<QString> CClientDataModelBridge::GetSourcePathList() const { // Get the source path property list SValueListFilter theFilter(*this); std::vector<SValue> theValueList = GetValueList(m_SceneAsset.m_Instance, m_SceneAsset.m_SourcePath, &theFilter); - // Translate from SValue to Q3DStudio::CString and also remove the identifier - std::set<Q3DStudio::CString> theSourcePathList; + // Translate from SValue to QString and also remove the identifier + std::set<QString> theSourcePathList; for (std::vector<SValue>::iterator theIter = theValueList.begin(); theIter != theValueList.end(); ++theIter) AddSourcePathToList(theSourcePathList, *theIter); @@ -1232,10 +1224,10 @@ std::set<Q3DStudio::CString> CClientDataModelBridge::GetSourcePathList() const return theSourcePathList; } -inline void AddStringToList(std::set<Q3DStudio::CString> &ioStringList, const SValue &inValue) +inline void AddStringToList(std::set<QString> &ioStringList, const SValue &inValue) { - Q3DStudio::CString theString = qt3dsdm::get<TDataStrPtr>(inValue)->GetData(); - if (theString != L"") + QString theString = qt3dsdm::get<TDataStrPtr>(inValue)->toQString(); + if (!theString.isEmpty()) ioStringList.insert(theString); } @@ -1243,11 +1235,11 @@ inline void AddStringToList(std::set<Q3DStudio::CString> &ioStringList, const SV /** * Get Font file list from all Text instances */ -std::set<Q3DStudio::CString> CClientDataModelBridge::GetFontFileList() const +std::set<QString> CClientDataModelBridge::GetFontFileList() const { // Get the font name property list std::vector<SValue> theValueList = GetValueList(m_Text.m_Instance, m_Text.m_Font); - std::set<Q3DStudio::CString> theFontNameList; + std::set<QString> theFontNameList; for (std::vector<SValue>::iterator theIter = theValueList.begin(); theIter != theValueList.end(); ++theIter) AddStringToList(theFontNameList, *theIter); @@ -1257,30 +1249,28 @@ std::set<Q3DStudio::CString> CClientDataModelBridge::GetFontFileList() const return theFontNameList; // Translate the font name to font file - std::set<Q3DStudio::CString> theFontFileList; - std::vector<std::pair<Q3DStudio::CString, Q3DStudio::CString>> theFontNameFileList; + std::set<QString> theFontFileList; + std::vector<std::pair<QString, QString>> theFontNameFileList; m_Doc->GetProjectFonts(theFontNameFileList); - for (std::set<Q3DStudio::CString>::iterator theFontNameIter = theFontNameList.begin(); - theFontNameIter != theFontNameList.end(); ++theFontNameIter) { + for (auto &fontName : theFontNameList) { // Given the font name, try to get the font file from the list of fonts registered in // Studio. // If the font is not found, it means that we are using missing font file. // Create some non-existing path to inform user that this font is missing. bool theFontFound = false; - Q3DStudio::CString theFontFile; - for (size_t idx = 0, end = theFontNameFileList.size(); idx < end; ++idx) { - if (theFontNameFileList[idx].first == *theFontNameIter) { + QString theFontFile; + for (auto &fontNamePair : theFontNameFileList) { + if (fontNamePair.first == fontName) { theFontFound = true; - theFontFile = theFontNameFileList[idx].second; + theFontFile = fontNamePair.second; break; } } if (!theFontFound) { - theFontFile = L"fonts\\File with font name ["; - theFontFile.append(*theFontNameIter); - theFontFile.append(" ]"); + theFontFile = QLatin1String("fonts\\File with font name [") + fontName + + QLatin1String(" ]"); } - theFontFileList.insert(Q3DStudio::CFilePath(theFontFile).toCString()); + theFontFileList.insert(theFontFile); } return theFontFileList; } @@ -1335,7 +1325,7 @@ static void GetDynamicObjecTextures(IDataCore &inDataCore, IPropertySystem &inPr /** * Get texture list from all effect instances */ -std::set<Q3DStudio::CString> CClientDataModelBridge::GetDynamicObjectTextureList() const +std::set<QString> CClientDataModelBridge::GetDynamicObjectTextureList() const { std::vector<SValue> theValueList; @@ -1349,7 +1339,7 @@ std::set<Q3DStudio::CString> CClientDataModelBridge::GetDynamicObjectTextureList theValueList, *this); // Translate from SValue to Q3DStudio::CString and also remove the identifier - std::set<Q3DStudio::CString> theSourcePathList; + std::set<QString> theSourcePathList; for (std::vector<SValue>::iterator theIter = theValueList.begin(); theIter != theValueList.end(); ++theIter) AddSourcePathToList(theSourcePathList, *theIter); @@ -1525,7 +1515,7 @@ CClientDataModelBridge::GetResidingLayer(qt3dsdm::Qt3DSDMInstanceHandle inInstan */ qt3dsdm::Qt3DSDMInstanceHandle CClientDataModelBridge::GetChildByName(qt3dsdm::Qt3DSDMInstanceHandle inParent, - Q3DStudio::CString inName, + const QString &inName, qt3dsdm::Qt3DSDMInstanceHandle skipInstance) { Q3DStudio::CGraphIterator theChildren; @@ -1568,49 +1558,49 @@ CClientDataModelBridge::GetObjectType(qt3dsdm::Qt3DSDMInstanceHandle inInstance) SValue theTypeValue; IPropertySystem *thePropertySystem = m_Doc->GetStudioSystem()->GetPropertySystem(); thePropertySystem->GetInstancePropertyValue(inInstance, GetTypeProperty(), theTypeValue); - std::wstring theType(qt3dsdm::get<TDataStrPtr>(theTypeValue)->GetData()); + QString theType(qt3dsdm::get<TDataStrPtr>(theTypeValue)->toQString()); - if (theType == L"Behavior") + if (theType == QLatin1String("Behavior")) return OBJTYPE_BEHAVIOR; - else if (theType == L"Camera") + else if (theType == QLatin1String("Camera")) return OBJTYPE_CAMERA; - else if (theType == L"Group") + else if (theType == QLatin1String("Group")) return OBJTYPE_GROUP; - else if (theType == L"Component") + else if (theType == QLatin1String("Component")) return OBJTYPE_COMPONENT; - else if (theType == L"Image" || theType == L"LibraryImage") + else if (theType == QLatin1String("Image") || theType == QLatin1String("LibraryImage")) return OBJTYPE_IMAGE; - else if (theType == L"Layer") + else if (theType == QLatin1String("Layer")) return OBJTYPE_LAYER; - else if (theType == L"Light") + else if (theType == QLatin1String("Light")) return OBJTYPE_LIGHT; - else if (theType == L"Material") + else if (theType == QLatin1String("Material")) return OBJTYPE_MATERIAL; - else if (theType == L"Model") + else if (theType == QLatin1String("Model")) return OBJTYPE_MODEL; - else if (theType == L"Alias") + else if (theType == QLatin1String("Alias")) return OBJTYPE_ALIAS; - else if (theType == L"Scene") + else if (theType == QLatin1String("Scene")) return OBJTYPE_SCENE; - else if (theType == L"Slide") + else if (theType == QLatin1String("Slide")) return OBJTYPE_SLIDE; - else if (theType == L"Text") + else if (theType == QLatin1String("Text")) return OBJTYPE_TEXT; - else if (theType == L"Effect") + else if (theType == QLatin1String("Effect")) return OBJTYPE_EFFECT; - else if (theType == L"RenderPlugin") + else if (theType == QLatin1String("RenderPlugin")) return OBJTYPE_RENDERPLUGIN; - else if (theType == L"CustomMaterial") + else if (theType == QLatin1String("CustomMaterial")) return OBJTYPE_CUSTOMMATERIAL; - else if (theType == L"ReferencedMaterial") + else if (theType == QLatin1String("ReferencedMaterial")) return OBJTYPE_REFERENCEDMATERIAL; - else if (theType == L"Path") + else if (theType == QLatin1String("Path")) return OBJTYPE_PATH; - else if (theType == L"PathAnchorPoint") + else if (theType == QLatin1String("PathAnchorPoint")) return OBJTYPE_PATHANCHORPOINT; - else if (theType == L"SubPath") + else if (theType == QLatin1String("SubPath")) return OBJTYPE_SUBPATH; - else if (theType == L"Lightmaps") + else if (theType == QLatin1String("Lightmaps")) return OBJTYPE_LIGHTMAPS; else { ASSERT(0); @@ -1787,25 +1777,25 @@ void CClientDataModelBridge::UpdateHandlerArgumentValue(qt3dsdm::HandlerArgument } } -std::wstring CClientDataModelBridge::GetDefaultHandler(Qt3DSDMInstanceHandle inInstance, - std::wstring inOldHandler) +QString CClientDataModelBridge::GetDefaultHandler(Qt3DSDMInstanceHandle inInstance, + const QString &inOldHandler) { IMetaData *theMetaData = m_Doc->GetStudioSystem()->GetActionMetaData(); // We try to maintain old handler whenever possible. // This is to fix bug 6569: Maintain handler option under action palette when changing target // object - if (inOldHandler != L"" - && theMetaData->FindHandlerByName(inInstance, inOldHandler.c_str()).Valid()) + if (!inOldHandler.isEmpty() + && theMetaData->FindHandlerByName(inInstance, inOldHandler).Valid()) return inOldHandler; // This is to fix bug 5106: Default action for components should be Go To Slide - std::wstring theHandlerName; + QString theHandlerName; if (m_DataCore->IsInstanceOrDerivedFrom(inInstance, m_ObjectDefinitions->m_SlideOwner.m_Instance)) { - theHandlerName = L"Go to Slide"; + theHandlerName = "Go to Slide"; // Verify that Go to Slide is valid, just in case MetaData.xml is changed - if (theMetaData->FindHandlerByName(inInstance, theHandlerName.c_str()).Valid()) + if (theMetaData->FindHandlerByName(inInstance, theHandlerName).Valid()) return theHandlerName; } @@ -1813,29 +1803,27 @@ std::wstring CClientDataModelBridge::GetDefaultHandler(Qt3DSDMInstanceHandle inI THandlerHandleList theHandlerList; GetHandlers(inInstance, theHandlerList); if (theHandlerList.size() > 0) - theHandlerName = theMetaData->GetHandlerInfo(theHandlerList[0])->m_Name.wide_str(); + theHandlerName = theMetaData->GetHandlerInfo(theHandlerList[0])->m_Name; else - theHandlerName = L""; // set to unknown handler + theHandlerName.clear(); // set to unknown handler return theHandlerName; } -std::wstring CClientDataModelBridge::GetDefaultEvent(Qt3DSDMInstanceHandle inInstance, - std::wstring inOldEvent) +QString CClientDataModelBridge::GetDefaultEvent(Qt3DSDMInstanceHandle inInstance, + const QString &inOldEvent) { IMetaData *theMetaData = m_Doc->GetStudioSystem()->GetActionMetaData(); // We try to maintain old event whenever possible. - if (inOldEvent != L"" && theMetaData->FindEvent(inInstance, inOldEvent.c_str()).Valid()) + if (!inOldEvent.isEmpty() && theMetaData->FindEvent(inInstance, inOldEvent).Valid()) return inOldEvent; // Default to the first event found - std::wstring theEventName; + QString theEventName; TEventHandleList theEventList; GetEvents(inInstance, theEventList); if (theEventList.size() > 0) - theEventName = theMetaData->GetEventInfo(theEventList[0])->m_Name.wide_str(); - else - theEventName = L""; // set to unknown event + theEventName = theMetaData->GetEventInfo(theEventList[0])->m_Name; return theEventName; } @@ -1887,12 +1875,12 @@ void CClientDataModelBridge::ResetHandlerArguments(Qt3DSDMActionHandle inAction, SActionInvalidProperty(*thePropertySystem, theTargetObject)); if (theProperties.size() > 0) { theValue = qt3dsdm::TDataStrPtr(new qt3dsdm::CDataStr( - thePropertySystem->GetName(theProperties[0]).wide_str())); + thePropertySystem->GetName(theProperties[0]))); } } break; case HandlerArgumentType::Slide: { - std::list<Q3DStudio::CString> theSlideNames; + std::list<QString> theSlideNames; GetSlideNamesOfAction(inAction, theSlideNames); if (theSlideNames.size() > 0) theValue = TDataStrPtr(new CDataStr(*theSlideNames.begin())); @@ -1923,8 +1911,8 @@ void CClientDataModelBridge::ResetHandlerArguments(Qt3DSDMActionHandle inAction, SActionInfo theActionInfo = theActionCore->GetActionInfo(inAction); theDependentInstance = GetInstance(theActionInfo.m_Owner, theActionInfo.m_TargetObject); - TCharStr thePropertyName = - qt3dsdm::get<qt3dsdm::TDataStrPtr>(theArgument.m_Value)->GetData(); + QString thePropertyName = + qt3dsdm::get<qt3dsdm::TDataStrPtr>(theArgument.m_Value)->toQString(); theDependentProperty = GetAggregateInstancePropertyByName(theDependentInstance, thePropertyName); theDataType = thePropertySystem->GetDataType(theDependentProperty); @@ -1942,7 +1930,7 @@ void CClientDataModelBridge::ResetHandlerArguments(Qt3DSDMActionHandle inAction, } // Resolve the path void CClientDataModelBridge::ResetHandlerArguments(qt3dsdm::Qt3DSDMActionHandle inAction, - const std::wstring &inHandler) + const QString &inHandler) { IActionCore &theActionCore = *m_Doc->GetStudioSystem()->GetActionCore(); const SActionInfo &theInfo(theActionCore.GetActionInfo(inAction)); @@ -1953,25 +1941,25 @@ void CClientDataModelBridge::ResetHandlerArguments(qt3dsdm::Qt3DSDMActionHandle qt3dsdm::Qt3DSDMEventHandle CClientDataModelBridge::ResolveEvent(qt3dsdm::Qt3DSDMInstanceHandle inResolveRoot, const qt3dsdm::SObjectRefType &inResolution, - const std::wstring &inEventName) + const QString &inEventName) { Qt3DSDMInstanceHandle theInstance = GetInstance(inResolveRoot, inResolution); if (theInstance.Valid() == false) return 0; IMetaData &theMetaData(*m_Doc->GetStudioSystem()->GetActionMetaData()); - return theMetaData.FindEvent(theInstance, inEventName.c_str()); + return theMetaData.FindEvent(theInstance, inEventName); } qt3dsdm::Qt3DSDMHandlerHandle CClientDataModelBridge::ResolveHandler(qt3dsdm::Qt3DSDMInstanceHandle inResolveRoot, const qt3dsdm::SObjectRefType &inResolution, - const std::wstring &inHandlerName) + const QString &inHandlerName) { Qt3DSDMInstanceHandle theInstance = GetInstance(inResolveRoot, inResolution); if (theInstance.Valid() == false) return 0; IMetaData &theMetaData(*m_Doc->GetStudioSystem()->GetActionMetaData()); - return theMetaData.FindHandlerByName(theInstance, inHandlerName.c_str()); + return theMetaData.FindHandlerByName(theInstance, inHandlerName); } qt3dsdm::Qt3DSDMEventHandle CClientDataModelBridge::ResolveEvent(const qt3dsdm::SActionInfo &inInfo) @@ -2000,8 +1988,8 @@ void CClientDataModelBridge::SetHandlerArgumentValue(Qt3DSDMHandlerArgHandle inH theActionCore->GetActionInfo(theHandlerArgument.m_Action); Qt3DSDMInstanceHandle theInstance = GetInstance(theActionInfo.m_Owner, theActionInfo.m_TargetObject); - TCharStr thePropertyName = - qt3dsdm::get<qt3dsdm::TDataStrPtr>(theHandlerArgument.m_Value)->GetData(); + QString thePropertyName = + qt3dsdm::get<qt3dsdm::TDataStrPtr>(theHandlerArgument.m_Value)->toQString(); Qt3DSDMPropertyHandle thePropertyHandle = GetAggregateInstancePropertyByName(theInstance, thePropertyName); DataModelDataType::Value theDataType = thePropertySystem->GetDataType(thePropertyHandle); @@ -2033,8 +2021,8 @@ void CClientDataModelBridge::GetActionDependentProperty(Qt3DSDMActionHandle inAc const SHandlerArgumentInfo &theArgument = theActionCore->GetHandlerArgumentInfo(*theIterator); if (theArgument.m_ArgType == HandlerArgumentType::Property) { - TCharStr thePropertyName = - qt3dsdm::get<qt3dsdm::TDataStrPtr>(theArgument.m_Value)->GetData(); + QString thePropertyName = + qt3dsdm::get<qt3dsdm::TDataStrPtr>(theArgument.m_Value)->toQString(); outProperty = GetAggregateInstancePropertyByName(outInstance, thePropertyName); break; } @@ -2042,7 +2030,7 @@ void CClientDataModelBridge::GetActionDependentProperty(Qt3DSDMActionHandle inAc } void CClientDataModelBridge::GetSlideNamesOfAction(qt3dsdm::Qt3DSDMActionHandle inAction, - std::list<Q3DStudio::CString> &outSlideNames) + std::list<QString> &outSlideNames) { SActionInfo theActionInfo = m_Doc->GetStudioSystem()->GetActionCore()->GetActionInfo(inAction); Qt3DSDMInstanceHandle theTargetInstance = @@ -2115,7 +2103,7 @@ qt3dsdm::SHandlerInfo CClientDataModelBridge::GetHandlerInfo(qt3dsdm::Qt3DSDMHan Qt3DSDMPropertyHandle CClientDataModelBridge::GetAggregateInstancePropertyByName(Qt3DSDMInstanceHandle inInstance, - const TCharStr &inPropertyName) + const QString &inPropertyName) { return m_DataCore->GetAggregateInstancePropertyByName(inInstance, inPropertyName); } diff --git a/src/Authoring/Client/Code/Core/Doc/ClientDataModelBridge/ClientDataModelBridge.h b/src/Authoring/Client/Code/Core/Doc/ClientDataModelBridge/ClientDataModelBridge.h index 4d802494..6e77bb2b 100644 --- a/src/Authoring/Client/Code/Core/Doc/ClientDataModelBridge/ClientDataModelBridge.h +++ b/src/Authoring/Client/Code/Core/Doc/ClientDataModelBridge/ClientDataModelBridge.h @@ -254,20 +254,20 @@ public: // Bridging to Actions. These needs to be here as DataModel has no hiera void UpdateHandlerArgumentValue(qt3dsdm::HandlerArgumentType::Value inArgType, qt3dsdm::Qt3DSDMInstanceHandle inTargetObject, qt3dsdm::SValue inOrigValue, qt3dsdm::SValue inNewValue); - std::wstring GetDefaultHandler(qt3dsdm::Qt3DSDMInstanceHandle inInstance, - std::wstring inOldHandler = L""); - std::wstring GetDefaultEvent(qt3dsdm::Qt3DSDMInstanceHandle inInstance, - std::wstring inOldEvent = L""); + QString GetDefaultHandler(qt3dsdm::Qt3DSDMInstanceHandle inInstance, + const QString &inOldHandler = {}); + QString GetDefaultEvent(qt3dsdm::Qt3DSDMInstanceHandle inInstance, + const QString &inOldEvent = {}); void ResetHandlerArguments(qt3dsdm::Qt3DSDMActionHandle inAction, qt3dsdm::Qt3DSDMHandlerHandle inHandler); // Resolve the path - void ResetHandlerArguments(qt3dsdm::Qt3DSDMActionHandle inAction, const std::wstring &inHandler); + void ResetHandlerArguments(qt3dsdm::Qt3DSDMActionHandle inAction, const QString &inHandler); qt3dsdm::Qt3DSDMEventHandle ResolveEvent(qt3dsdm::Qt3DSDMInstanceHandle inResolveRoot, - const qt3dsdm::SObjectRefType &inResolution, - const std::wstring &inEventName); + const qt3dsdm::SObjectRefType &inResolution, + const QString &inEventName); qt3dsdm::Qt3DSDMHandlerHandle ResolveHandler(qt3dsdm::Qt3DSDMInstanceHandle inResolveRoot, - const qt3dsdm::SObjectRefType &inResolution, - const std::wstring &inHandlerName); + const qt3dsdm::SObjectRefType &inResolution, + const QString &inHandlerName); qt3dsdm::Qt3DSDMEventHandle ResolveEvent(const qt3dsdm::SActionInfo &inInfo); qt3dsdm::Qt3DSDMHandlerHandle ResolveHandler(const qt3dsdm::SActionInfo &inInfo); void SetHandlerArgumentValue(qt3dsdm::Qt3DSDMHandlerArgHandle inHandlerArgument, @@ -276,7 +276,7 @@ public: // Bridging to Actions. These needs to be here as DataModel has no hiera qt3dsdm::Qt3DSDMInstanceHandle &outInstance, qt3dsdm::Qt3DSDMPropertyHandle &outProperty); void GetSlideNamesOfAction(qt3dsdm::Qt3DSDMActionHandle inAction, - std::list<Q3DStudio::CString> &outSlideNames); + std::list<QString> &outSlideNames); protected: void SetArgTypeDependentDefaultValue(qt3dsdm::Qt3DSDMHandlerArgHandle inHandlerArgument, @@ -294,7 +294,7 @@ public: // TODO: We should really consider having CStudioCoreSystem or CStudioFu qt3dsdm::Qt3DSDMPropertyHandle GetAggregateInstancePropertyByName(qt3dsdm::Qt3DSDMInstanceHandle inInstance, - const qt3dsdm::TCharStr &inStr); + const QString &inStr); private: qt3dsdm::Qt3DSDMInstanceHandle @@ -313,7 +313,7 @@ private: qt3dsdm::Qt3DSDMInstanceHandle GetSceneOrComponentInstance(qt3dsdm::Qt3DSDMInstanceHandle inInstance); qt3dsdm::Qt3DSDMSlideHandle CreateNonMasterSlide(qt3dsdm::Qt3DSDMSlideHandle inMasterSlide, Q3DStudio::CId inGuid, - const Q3DStudio::CString &inName); + const QString &inName); public: // helpers void BeginRender(); // enable cache to increase performance @@ -343,8 +343,8 @@ public: // helpers CreateImageInstance(qt3dsdm::Qt3DSDMInstanceHandle inSourceInstance, qt3dsdm::Qt3DSDMPropertyHandle inSlot, qt3dsdm::Qt3DSDMSlideHandle inSlide); - void SetName(qt3dsdm::Qt3DSDMInstanceHandle inInstanceHandle, const Q3DStudio::CString &inName); - Q3DStudio::CString GetName(qt3dsdm::Qt3DSDMInstanceHandle inInstanceHandle); + void SetName(qt3dsdm::Qt3DSDMInstanceHandle inInstanceHandle, const QString &inName); + QString GetName(qt3dsdm::Qt3DSDMInstanceHandle inInstanceHandle); // Convenience functions to get GUID property value from instance handle private: @@ -357,18 +357,18 @@ public: bool IsInComponent(qt3dsdm::Qt3DSDMInstanceHandle inInstance, qt3dsdm::Qt3DSDMInstanceHandle inComponentInstance); qt3dsdm::Qt3DSDMInstanceHandle GetParentComponent(qt3dsdm::Qt3DSDMInstanceHandle inInstance, - bool inIsFirstCall = true); - Q3DStudio::CString GetUniqueChildName(qt3dsdm::Qt3DSDMInstanceHandle inParent, - qt3dsdm::Qt3DSDMInstanceHandle inInstance, - Q3DStudio::CString inDesiredName); + bool inIsFirstCall = true); + QString GetUniqueChildName(qt3dsdm::Qt3DSDMInstanceHandle inParent, + qt3dsdm::Qt3DSDMInstanceHandle inInstance, + const QString &inDesiredName); bool CheckNameUnique(qt3dsdm::Qt3DSDMInstanceHandle inParentInstance, qt3dsdm::Qt3DSDMInstanceHandle inInstance, - Q3DStudio::CString inDesiredName); - Q3DStudio::CString GetSourcePath(qt3dsdm::Qt3DSDMInstanceHandle inInstance) const; - Q3DStudio::CString getSubpresentation(qt3dsdm::Qt3DSDMInstanceHandle inInstance) const; - std::set<Q3DStudio::CString> GetSourcePathList() const; - std::set<Q3DStudio::CString> GetFontFileList() const; - std::set<Q3DStudio::CString> GetDynamicObjectTextureList() const; + const QString &inDesiredName); + QString GetSourcePath(qt3dsdm::Qt3DSDMInstanceHandle inInstance) const; + QString getSubpresentation(qt3dsdm::Qt3DSDMInstanceHandle inInstance) const; + std::set<QString> GetSourcePathList() const; + std::set<QString> GetFontFileList() const; + std::set<QString> GetDynamicObjectTextureList() const; std::set<QString> getRenderableList() const; bool IsLockedAtAll(qt3dsdm::Qt3DSDMInstanceHandle inInstance); bool IsDuplicateable(qt3dsdm::Qt3DSDMInstanceHandle inInstance); @@ -383,7 +383,7 @@ public: protected: qt3dsdm::Qt3DSDMInstanceHandle GetChildByName(qt3dsdm::Qt3DSDMInstanceHandle inParent, - Q3DStudio::CString inChildName, + const QString &inChildName, qt3dsdm::Qt3DSDMInstanceHandle skipInstance); std::vector<qt3dsdm::SValue> GetValueList(qt3dsdm::Qt3DSDMInstanceHandle inParentInstance, diff --git a/src/Authoring/Client/Code/Core/Doc/ComposerEditorInterface.cpp b/src/Authoring/Client/Code/Core/Doc/ComposerEditorInterface.cpp index fc33acde..f11bb047 100644 --- a/src/Authoring/Client/Code/Core/Doc/ComposerEditorInterface.cpp +++ b/src/Authoring/Client/Code/Core/Doc/ComposerEditorInterface.cpp @@ -38,75 +38,47 @@ using namespace Q3DStudio::ComposerImport; using namespace qt3ds::foundation; namespace { + // base class between performing refresh and performing // imports - -struct STCharPtrHash -{ - size_t operator()(TCharPtr nm) const - { -#ifdef KDAB_TEMPORARILY_REMOVED - StaticAssert<sizeof(wchar_t) == sizeof(char16_t)>::valid_expression(); -#endif - return eastl::hash<const char16_t *>()(reinterpret_cast<const char16_t *>(nm)); - } -}; -struct STCharPtrEqualTo -{ - bool operator()(TCharPtr lhs, TCharPtr rhs) const { return AreEqual(lhs, rhs); } -}; - struct SComposerImportBase { IDocumentEditor &m_Editor; - CFilePath m_DocumentPath; - CFilePath m_DestImportDir; - CFilePath m_DestImportFile; - Q3DStudio::CFilePath m_Relativeimportfile; + QString m_DocumentPath; // Root directory where the studio file sits. + QString m_DestImportDir; // Directory where we are saving the import file + QString m_DestImportFile; + QString m_Relativeimportfile; qt3ds::QT3DSI32 m_StartTime; - qt3dsdm::IStringTable &m_StringTable; - SComposerImportBase( - IDocumentEditor &inEditor, - const Q3DStudio::CFilePath &docPath /// Root directory where the studio file sits. - , - const Q3DStudio::CFilePath &inFullPathToImportFile, long inStartTime, - qt3dsdm::IStringTable &inStringTable) + SComposerImportBase(IDocumentEditor &inEditor, const QString &docPath, + const QString &inFullPathToImportFile, long inStartTime) : m_Editor(inEditor) , m_DocumentPath(docPath) - , m_DestImportDir(inFullPathToImportFile - .GetDirectory()) // Directory where we are saving the import file + , m_DestImportDir(QFileInfo(inFullPathToImportFile).absolutePath()) , m_DestImportFile(inFullPathToImportFile) - , m_Relativeimportfile( - Q3DStudio::CFilePath::GetRelativePathFromBase(m_DocumentPath, inFullPathToImportFile)) + , m_Relativeimportfile(Q3DStudio::CFilePath::GetRelativePathFromBase( + m_DocumentPath, inFullPathToImportFile)) , m_StartTime(inStartTime) - , m_StringTable(inStringTable) { } }; struct SComposerImportInterface : public SComposerImportBase, public IComposerEditorInterface { - typedef eastl::hash_map<TImportId, Qt3DSDMInstanceHandle, STCharPtrHash, STCharPtrEqualTo> - TImportInstanceMap; + typedef QHash<TImportId, Qt3DSDMInstanceHandle> TImportInstanceMap; Qt3DSDMInstanceHandle m_Parent; Qt3DSDMInstanceHandle m_Root; Qt3DSDMSlideHandle m_Slide; - Q3DStudio::CString m_TypeBuffer; qt3ds::QT3DSI32 m_StartTime; Import *m_ImportObj; TImportInstanceMap m_ImportToInstanceMap; TImportInstanceMap m_MaterialToInstanceMap; // When we are refreshing, the root assets is the group we are refreshing. - SComposerImportInterface( - Q3DStudio::IDocumentEditor &editor, qt3dsdm::CDataModelHandle parent // Parent object - , - qt3dsdm::CDataModelHandle root, qt3dsdm::Qt3DSDMSlideHandle slide, - const Q3DStudio::CFilePath &docPath /// Root directory where the studio file sits. - , - const Q3DStudio::CFilePath &inFullPathToImportFile, long inStartTime, - qt3dsdm::IStringTable &inStringTable) - : SComposerImportBase(editor, docPath, inFullPathToImportFile, inStartTime, inStringTable) + SComposerImportInterface(Q3DStudio::IDocumentEditor &editor, qt3dsdm::CDataModelHandle parent, + qt3dsdm::CDataModelHandle root, qt3dsdm::Qt3DSDMSlideHandle slide, + const QString &docPath, const QString &inFullPathToImportFile, + long inStartTime) + : SComposerImportBase(editor, docPath, inFullPathToImportFile, inStartTime) , m_Parent(parent) , m_Root(root) , m_Slide(slide) @@ -123,23 +95,23 @@ struct SComposerImportInterface : public SComposerImportBase, public IComposerEd bool HasError() override { return m_Root.Valid() == false; } - const wchar_t *GetRelativeimportfile() const {return nullptr;} + QString GetRelativeimportfile() const { return {}; } - void Finalize(const Q3DStudio::CFilePath &inFilePath) override + void Finalize(const QString &inFilePath) override { m_Editor.SetSpecificInstancePropertyValue( - m_Slide, m_Root, L"sourcepath", - std::make_shared<CDataStr>(m_Relativeimportfile.toCString())); + m_Slide, m_Root, QStringLiteral("sourcepath"), + std::make_shared<CDataStr>(m_Relativeimportfile)); m_Editor.SetSpecificInstancePropertyValue( - m_Slide, m_Root, L"importfile", - std::make_shared<CDataStr>(m_Relativeimportfile.toCString())); + m_Slide, m_Root, QStringLiteral("importfile"), + std::make_shared<CDataStr>(m_Relativeimportfile)); } Qt3DSDMInstanceHandle FindInstance(TImportId inImportHdl) override { TImportInstanceMap::const_iterator entry(m_ImportToInstanceMap.find(inImportHdl)); if (entry != m_ImportToInstanceMap.end()) - return entry->second; + return *entry; return 0; } @@ -147,40 +119,28 @@ struct SComposerImportInterface : public SComposerImportBase, public IComposerEd { TImportInstanceMap::const_iterator entry(m_MaterialToInstanceMap.find(inImportHdl)); if (entry != m_MaterialToInstanceMap.end()) - return entry->second; + return *entry; return 0; } void AddInstanceMap(Qt3DSDMInstanceHandle instanceHandle, TImportId inImportId) override { - if (inImportId == NULL || *inImportId == 0) { - assert(0); - return; - } - bool success = - m_ImportToInstanceMap - .insert(eastl::make_pair(m_StringTable.RegisterStr(inImportId), instanceHandle)) - .second; - (void)success; - assert(success); + Q_ASSERT(!inImportId.isEmpty()); + bool success = m_ImportToInstanceMap.insert(inImportId, instanceHandle).key() == inImportId; + Q_ASSERT(success); } void addMaterialMap(Qt3DSDMInstanceHandle instanceHandle, TImportId inImportId) { - if (inImportId == nullptr || *inImportId == 0) { - assert(0); - return; - } - bool success = - m_MaterialToInstanceMap - .insert(eastl::make_pair(m_StringTable.RegisterStr(inImportId), instanceHandle)) - .second; - assert(success); + Q_ASSERT(!inImportId.isEmpty()); + bool success = m_MaterialToInstanceMap.insert(inImportId, instanceHandle).key() + == inImportId; + Q_ASSERT(success); } - Qt3DSDMInstanceHandle GetRoot() override { return m_Root; } + Qt3DSDMInstanceHandle GetRoot() const override { return m_Root; } - const Q3DStudio::CFilePath &GetDestImportFile() override { return m_DestImportFile; } + const QString GetDestImportFile() const override { return m_DestImportFile; } // IComposerEditor // Object is stack created for now @@ -222,11 +182,11 @@ struct SComposerImportInterface : public SComposerImportBase, public IComposerEd if (useParentSlide) slide = m_Editor.GetAssociatedSlide(parent); Qt3DSDMInstanceHandle retval = m_Editor.CreateSceneGraphInstance(type, parent, slide); - m_Editor.SetSpecificInstancePropertyValue(0, retval, L"importid", + m_Editor.SetSpecificInstancePropertyValue(0, retval, "importid", std::make_shared<CDataStr>(inImportId)); m_Editor.SetSpecificInstancePropertyValue( - slide, retval, L"importfile", - std::make_shared<CDataStr>(m_Relativeimportfile.toCString())); + slide, retval, QStringLiteral("importfile"), + std::make_shared<CDataStr>(m_Relativeimportfile)); AddInstanceMap(retval, inImportId); return retval; } @@ -267,25 +227,25 @@ struct SComposerImportInterface : public SComposerImportBase, public IComposerEd void createMaterial(const InstanceDesc &desc, TImportId inParent) override { - Q3DStudio::CString materialName = desc.m_Id; + QString materialName = desc.m_Id; Option<SValue> name = m_ImportObj->GetInstancePropertyValue(desc.m_Handle, ComposerPropertyNames::name); if (name.hasValue()) - materialName = qt3dsdm::get<TDataStrPtr>(*name)->GetData(); + materialName = qt3dsdm::get<TDataStrPtr>(*name)->toQString(); auto material = m_Editor.getMaterial(materialName); if (!material.Valid()) { material = m_Editor.getOrCreateMaterial(materialName); - m_Editor.SetSpecificInstancePropertyValue(0, material, L"importid", + m_Editor.SetSpecificInstancePropertyValue(0, material, QStringLiteral("importid"), std::make_shared<CDataStr>(desc.m_Id)); m_Editor.SetSpecificInstancePropertyValue( - m_Slide, material, L"importfile", - std::make_shared<CDataStr>(m_Relativeimportfile.toCString())); + m_Slide, material, QStringLiteral("importfile"), + std::make_shared<CDataStr>(m_Relativeimportfile)); addMaterialMap(material, desc.m_Id); } const auto sourcePath = m_Editor.writeMaterialFile(material, - materialName.toQString(), + materialName, true); Qt3DSDMInstanceHandle parent(FindInstance(inParent)); @@ -297,7 +257,7 @@ struct SComposerImportInterface : public SComposerImportBase, public IComposerEd } void UpdateInstanceProperties(TImportId inInstance, const PropertyValue *propertBuffer, - QT3DSU32 propertyBufferSize) override + QT3DSU32 propertyBufferSize) override { Qt3DSDMInstanceHandle hdl(FindInstance(inInstance)); if (hdl.Valid() == false) { @@ -319,17 +279,17 @@ struct SComposerImportInterface : public SComposerImportBase, public IComposerEd // is saved instead of where the import result is saved TDataStrPtr value = qt3dsdm::get<TDataStrPtr>(theValue); if (value->GetLength()) { - Q3DStudio::CString valueStr(value->GetData()); - Q3DStudio::CFilePath fullPath = + QString valueStr(value->toQString()); + QString fullPath = Q3DStudio::CFilePath::CombineBaseAndRelative(m_DestImportDir, valueStr); - Q3DStudio::CString relativePath = + QString relativePath = Q3DStudio::CFilePath::GetRelativePathFromBase(m_DocumentPath, fullPath); - theValue = std::make_shared<CDataStr>(relativePath.c_str()); + theValue = std::make_shared<CDataStr>(relativePath); } } else if (theType == DataModelDataType::StringRef) { SStringRef theRef = get<SStringRef>(theValue); SLong4 theGuid; - Qt3DSDMInstanceHandle target = FindInstance(theRef.m_Id); + Qt3DSDMInstanceHandle target = FindInstance(QString::fromWCharArray(theRef.m_Id)); if (target.Valid()) theGuid = m_Editor.GetGuidForInstance(target); theValue = theGuid; @@ -355,14 +315,14 @@ struct SComposerImportInterface : public SComposerImportBase, public IComposerEd m_Editor.AddChild(theParent, theChild, theSibling); } - void RemoveAnimation(TImportId inInstance, const wchar_t *propName, long propSubIndex) override + void RemoveAnimation(TImportId inInstance, const QString &propName, long propSubIndex) override { Qt3DSDMInstanceHandle hdl(FindInstance(inInstance)); if (hdl.Valid()) m_Editor.RemoveAnimation(m_Slide, hdl, propName, propSubIndex); } - void UpdateAnimation(TImportId inInstance, const wchar_t *propName, long propSubIndex, - EAnimationType animType, const float *animData, QT3DSU32 numFloats) override + void UpdateAnimation(TImportId inInstance, const QString &propName, long propSubIndex, + EAnimationType animType, const float *animData, QT3DSU32 numFloats) override { Qt3DSDMInstanceHandle hdl(FindInstance(inInstance)); if (hdl.Valid()) { @@ -373,8 +333,8 @@ struct SComposerImportInterface : public SComposerImportBase, public IComposerEd } } } - void AddAnimation(TImportId inInstance, const wchar_t *propName, long propSubIndex, - EAnimationType animType, const float *animData, QT3DSU32 numFloats) override + void AddAnimation(TImportId inInstance, const QString &propName, long propSubIndex, + EAnimationType animType, const float *animData, QT3DSU32 numFloats) override { UpdateAnimation(inInstance, propName, propSubIndex, animType, animData, numFloats); } @@ -390,17 +350,16 @@ struct SComposerRefreshInterface : public SComposerImportBase, public IComposerE struct SSlideInstanceIdMapIterator { - const vector<pair<Qt3DSDMSlideHandle, Qt3DSDMInstanceHandle>> *m_CurrentItems; + const QVector<QPair<Qt3DSDMSlideHandle, Qt3DSDMInstanceHandle>> *m_CurrentItems; size_t m_CurrentTreeIdx; size_t m_CurrentTreeEnd; - TCharPtr m_Id; + QString m_Id; - SSlideInstanceIdMapIterator(TImportId inImportId, TIdMultiMap &inItems, - qt3dsdm::IStringTable &inStringTable) - : m_CurrentItems(NULL) + SSlideInstanceIdMapIterator(TImportId inImportId, TIdMultiMap &inItems) + : m_CurrentItems(nullptr) , m_CurrentTreeIdx(0) , m_CurrentTreeEnd(0) - , m_Id(inStringTable.RegisterStr(inImportId)) + , m_Id(inImportId) { FindNextValidList(inItems); } @@ -408,12 +367,12 @@ struct SComposerRefreshInterface : public SComposerImportBase, public IComposerE { m_CurrentTreeIdx = 0; m_CurrentTreeEnd = 0; - m_CurrentItems = NULL; + m_CurrentItems = nullptr; TIdMultiMap::const_iterator theFind = inItems.find(m_Id); if (theFind != inItems.end()) { - m_CurrentItems = &theFind->second; + m_CurrentItems = &(*theFind); m_CurrentTreeIdx = 0; - m_CurrentTreeEnd = theFind->second.size(); + m_CurrentTreeEnd = theFind->size(); } } bool IsDone() const @@ -437,10 +396,9 @@ struct SComposerRefreshInterface : public SComposerImportBase, public IComposerE }; SComposerRefreshInterface(Q3DStudio::IDocumentEditor &editor, TIdMultiMap &inIdToInstanceMap, - const Q3DStudio::CFilePath &docPath, - const Q3DStudio::CFilePath &inDestimportfile, long inStartTime, - qt3dsdm::IStringTable &inStringTable, CGraph &inAssetGraph) - : SComposerImportBase(editor, docPath, inDestimportfile, inStartTime, inStringTable) + const QString &docPath, const QString &inDestimportfile, + long inStartTime, CGraph &inAssetGraph) + : SComposerImportBase(editor, docPath, inDestimportfile, inStartTime) , m_IdToSlideInstances(inIdToInstanceMap) , m_HasError(false) , m_AssetGraph(inAssetGraph) @@ -452,13 +410,12 @@ struct SComposerRefreshInterface : public SComposerImportBase, public IComposerE void RemoveChild(TImportId inParentId, TImportId inChildId) override { - for (SSlideInstanceIdMapIterator theIterator(inParentId, m_IdToSlideInstances, - m_StringTable); + for (SSlideInstanceIdMapIterator theIterator(inParentId, m_IdToSlideInstances); theIterator.IsDone() == false; theIterator.Next()) { Qt3DSDMInstanceHandle theParent = theIterator.GetCurrentInstance(); for (long idx = 0; idx < m_AssetGraph.GetChildCount(theParent); ++idx) { Qt3DSDMInstanceHandle theChild = m_AssetGraph.GetChild(theParent, idx); - CString theImportId = m_Editor.GetImportId(theChild); + QString theImportId = m_Editor.GetImportId(theChild); if (m_Editor.GetAssociatedSlide(theChild) == theIterator.GetCurrentSlide() && theImportId == inChildId) { m_Editor.RemoveChild(theParent, theChild); @@ -470,14 +427,14 @@ struct SComposerRefreshInterface : public SComposerImportBase, public IComposerE void RemoveInstance(TImportId inParentId) override { - SSlideInstanceIdMapIterator theIterator(inParentId, m_IdToSlideInstances, m_StringTable); + SSlideInstanceIdMapIterator theIterator(inParentId, m_IdToSlideInstances); if (!theIterator.IsDone()) { for (size_t parentIdx = 0, parentEnd = theIterator.m_CurrentTreeEnd; parentIdx < parentEnd; ++parentIdx) { if (m_Editor.IsInstance(theIterator.GetCurrentInstance())) m_Editor.DeleteInstance(theIterator.GetCurrentInstance()); } - m_IdToSlideInstances.erase(theIterator.m_Id); + m_IdToSlideInstances.erase(m_IdToSlideInstances.find(theIterator.m_Id)); } } /** @@ -491,25 +448,25 @@ struct SComposerRefreshInterface : public SComposerImportBase, public IComposerE void CreateInstance(TImportId inImportId, ComposerObjectTypes::Enum type, TImportId inParent) override { - const wchar_t *theInsertId(m_StringTable.GetWideStr(inImportId)); - pair<TIdMultiMap::iterator, bool> theInserter(m_IdToSlideInstances.insert( - make_pair(theInsertId, vector<pair<Qt3DSDMSlideHandle, Qt3DSDMInstanceHandle>>()))); + const QString &theInsertId(inImportId); + TIdMultiMap::iterator theInserter(m_IdToSlideInstances.insert( + theInsertId, QVector<QPair<Qt3DSDMSlideHandle, Qt3DSDMInstanceHandle>>())); - for (SSlideInstanceIdMapIterator theIterator(inParent, m_IdToSlideInstances, m_StringTable); + for (SSlideInstanceIdMapIterator theIterator(inParent, m_IdToSlideInstances); theIterator.IsDone() == false; theIterator.Next()) { Qt3DSDMInstanceHandle theParent = theIterator.GetCurrentInstance(); Qt3DSDMInstanceHandle newInstance = m_Editor.CreateSceneGraphInstance(type, theParent, theIterator.GetCurrentSlide()); if (m_StartTime >= 0) - m_Editor.SetSpecificInstancePropertyValue(0, newInstance, L"starttime", - m_StartTime); - m_Editor.SetSpecificInstancePropertyValue(0, newInstance, L"importid", + m_Editor.SetSpecificInstancePropertyValue(0, newInstance, + QStringLiteral("starttime"), m_StartTime); + m_Editor.SetSpecificInstancePropertyValue(0, newInstance, QStringLiteral("importid"), std::make_shared<CDataStr>(inImportId)); m_Editor.SetSpecificInstancePropertyValue( - 0, newInstance, L"importfile", - std::make_shared<CDataStr>(m_Relativeimportfile.toCString())); - insert_unique(theInserter.first->second, - make_pair(theIterator.GetCurrentSlide(), newInstance)); + 0, newInstance, QStringLiteral("importfile"), + std::make_shared<CDataStr>(m_Relativeimportfile)); + insert_unique_qt(*theInserter, + QPair<Qt3DSDMSlideHandle, Qt3DSDMInstanceHandle>(theIterator.GetCurrentSlide(), newInstance)); } } @@ -520,10 +477,9 @@ struct SComposerRefreshInterface : public SComposerImportBase, public IComposerE // We guarantee that all instances will be created before their properties are updated thus you // can resolve references during this updateInstanceProperties call if necessary. void UpdateInstanceProperties(TImportId inInstance, const PropertyValue *propertBuffer, - QT3DSU32 propertyBufferSize) override + QT3DSU32 propertyBufferSize) override { - for (SSlideInstanceIdMapIterator theIterator(inInstance, m_IdToSlideInstances, - m_StringTable); + for (SSlideInstanceIdMapIterator theIterator(inInstance, m_IdToSlideInstances); theIterator.IsDone() == false; theIterator.Next()) { Qt3DSDMInstanceHandle hdl = theIterator.GetCurrentInstance(); for (QT3DSU32 idx = 0; idx < propertyBufferSize; ++idx) { @@ -536,12 +492,12 @@ struct SComposerRefreshInterface : public SComposerImportBase, public IComposerE // is saved instead of where the import result is saved TDataStrPtr value = qt3dsdm::get<TDataStrPtr>(theValue); if (value->GetLength()) { - Q3DStudio::CString valueStr(value->GetData()); - Q3DStudio::CFilePath fullPath = + QString valueStr(value->toQString()); + QString fullPath = Q3DStudio::CFilePath::CombineBaseAndRelative(m_DestImportDir, valueStr); - Q3DStudio::CString relativePath = + QString relativePath = Q3DStudio::CFilePath::GetRelativePathFromBase(m_DocumentPath, fullPath); - theValue = std::make_shared<CDataStr>(relativePath.c_str()); + theValue = std::make_shared<CDataStr>(relativePath); } } else if (theType == DataModelDataType::StringRef) { SStringRef theRef = get<SStringRef>(theValue); @@ -552,7 +508,7 @@ struct SComposerRefreshInterface : public SComposerImportBase, public IComposerE childIdx < childCount; ++childIdx) { Qt3DSDMInstanceHandle target = m_AssetGraph.GetChild(hdl, childIdx); if (m_Editor.GetAssociatedSlide(hdl) == theIterator.GetCurrentSlide() - && m_Editor.GetImportId(target).Compare(theRef.m_Id)) { + && m_Editor.GetImportId(target) == QString::fromWCharArray(theRef.m_Id)) { theGuid = m_Editor.GetGuidForInstance(target); theValue = theGuid; } @@ -571,24 +527,24 @@ struct SComposerRefreshInterface : public SComposerImportBase, public IComposerE void AddChild(TImportId parent, TImportId child, TImportId nextSiblingId) override { TIdMultiMap::iterator theParentList = - m_IdToSlideInstances.find(m_StringTable.RegisterStr(parent)); + m_IdToSlideInstances.find(parent); TIdMultiMap::iterator theChildList = - m_IdToSlideInstances.find(m_StringTable.RegisterStr(child)); + m_IdToSlideInstances.find(child); if (theParentList == m_IdToSlideInstances.end() || theChildList == m_IdToSlideInstances.end()) return; - size_t numItems = qMin(theParentList->second.size(), theChildList->second.size()); + size_t numItems = qMin(theParentList->size(), theChildList->size()); for (size_t idx = 0; idx < numItems; ++idx) { - Qt3DSDMSlideHandle theParentSlide = theParentList->second[idx].first; - Qt3DSDMInstanceHandle theParent(theParentList->second[idx].second); - Qt3DSDMInstanceHandle theChild(theChildList->second[idx].second); + Qt3DSDMSlideHandle theParentSlide = (*theParentList)[idx].first; + Qt3DSDMInstanceHandle theParent((*theParentList)[idx].second); + Qt3DSDMInstanceHandle theChild((*theChildList)[idx].second); Qt3DSDMInstanceHandle nextSibling; - if (!IsTrivial(nextSiblingId)) { + if (!nextSiblingId.isEmpty()) { for (long childIdx = 0, childCount = m_AssetGraph.GetChildCount(theParent); childIdx < childCount; ++childIdx) { Qt3DSDMInstanceHandle theSibling = m_AssetGraph.GetChild(theParent, childIdx); if (m_Editor.GetAssociatedSlide(theSibling) == theParentSlide - && m_Editor.GetImportId(theSibling).Compare(nextSiblingId)) { + && m_Editor.GetImportId(theSibling) == nextSiblingId) { nextSibling = theSibling; break; } @@ -601,19 +557,17 @@ struct SComposerRefreshInterface : public SComposerImportBase, public IComposerE } } - void RemoveAnimation(TImportId inInstance, const wchar_t *propName, long propSubIndex) override + void RemoveAnimation(TImportId inInstance, const QString &propName, long propSubIndex) override { - for (SSlideInstanceIdMapIterator theIterator(inInstance, m_IdToSlideInstances, - m_StringTable); + for (SSlideInstanceIdMapIterator theIterator(inInstance, m_IdToSlideInstances); theIterator.IsDone() == false; theIterator.Next()) m_Editor.RemoveAnimation(theIterator.GetCurrentSlide(), theIterator.GetCurrentInstance(), propName, propSubIndex); } - void UpdateAnimation(TImportId inInstance, const wchar_t *propName, long propSubIndex, - EAnimationType animType, const float *animData, QT3DSU32 numFloats) override + void UpdateAnimation(TImportId inInstance, const QString &propName, long propSubIndex, + EAnimationType animType, const float *animData, QT3DSU32 numFloats) override { - for (SSlideInstanceIdMapIterator theIterator(inInstance, m_IdToSlideInstances, - m_StringTable); + for (SSlideInstanceIdMapIterator theIterator(inInstance, m_IdToSlideInstances); theIterator.IsDone() == false; theIterator.Next()) { if (m_Editor.AnimationExists(theIterator.GetCurrentSlide(), theIterator.GetCurrentInstance(), propName, propSubIndex) @@ -629,11 +583,10 @@ struct SComposerRefreshInterface : public SComposerImportBase, public IComposerE } } - void AddAnimation(TImportId inInstance, const wchar_t *propName, long propSubIndex, - EAnimationType animType, const float *animData, QT3DSU32 numFloats) override + void AddAnimation(TImportId inInstance, const QString &propName, long propSubIndex, + EAnimationType animType, const float *animData, QT3DSU32 numFloats) override { - for (SSlideInstanceIdMapIterator theIterator(inInstance, m_IdToSlideInstances, - m_StringTable); + for (SSlideInstanceIdMapIterator theIterator(inInstance, m_IdToSlideInstances); theIterator.IsDone() == false; theIterator.Next()) { if (!m_Editor.AnimationExists(theIterator.GetCurrentSlide(), theIterator.GetCurrentInstance(), propName, @@ -651,24 +604,21 @@ struct SComposerRefreshInterface : public SComposerImportBase, public IComposerE } std::shared_ptr<IComposerEditorInterface> IComposerEditorInterface::CreateEditorInterface( - Q3DStudio::IDocumentEditor &editor, qt3dsdm::CDataModelHandle parent // Parent object - , + Q3DStudio::IDocumentEditor &editor, qt3dsdm::CDataModelHandle parent, qt3dsdm::CDataModelHandle root, qt3dsdm::Qt3DSDMSlideHandle slide, - const Q3DStudio::CFilePath &docPath, const Q3DStudio::CFilePath &destimportfile, - long inStartTime, qt3dsdm::IStringTable &inStringTable) + const QString &docPath, const QString &destimportfile, + long inStartTime) { return std::make_shared<SComposerImportInterface>(std::ref(editor), parent, root, slide, - docPath, destimportfile, inStartTime, - std::ref(inStringTable)); + docPath, destimportfile, inStartTime); } // The refresh interface is setup to refresh multiple trees automatically std::shared_ptr<IComposerEditor> IComposerEditorInterface::CreateEditorInterface( - Q3DStudio::IDocumentEditor &editor, TIdMultiMap &inRoots, const Q3DStudio::CFilePath &docPath, - const Q3DStudio::CFilePath &destimportfile, long inStartTime, - qt3dsdm::IStringTable &inStringTable, CGraph &inAssetGraph) + Q3DStudio::IDocumentEditor &editor, TIdMultiMap &inRoots, const QString &docPath, + const QString &destimportfile, long inStartTime, CGraph &inAssetGraph) { return std::make_shared<SComposerRefreshInterface>( std::ref(editor), std::ref(inRoots), docPath, destimportfile, inStartTime, - std::ref(inStringTable), std::ref(inAssetGraph)); + std::ref(inAssetGraph)); } diff --git a/src/Authoring/Client/Code/Core/Doc/Doc.cpp b/src/Authoring/Client/Code/Core/Doc/Doc.cpp index 7ef034d2..b7c8572f 100644 --- a/src/Authoring/Client/Code/Core/Doc/Doc.cpp +++ b/src/Authoring/Client/Code/Core/Doc/Doc.cpp @@ -76,6 +76,7 @@ #include "Dialogs.h" #include "Q3DSStringTable.h" #include "Q3DSImageTextureData.h" +#include "Q3DSRenderBufferManager.h" #include <QtCore/qfileinfo.h> #include <QtWidgets/qaction.h> @@ -225,12 +226,12 @@ qt3dsdm::IPropertySystem *CDoc::GetPropertySystem() } void CDoc::SetInstancePropertyValue(qt3dsdm::Qt3DSDMInstanceHandle inInstance, - const std::wstring &inPropertyName, + const QString &inPropertyName, const qt3dsdm::SValue &inValue) { qt3dsdm::IPropertySystem *thePropertySystem = GetStudioSystem()->GetPropertySystem(); qt3dsdm::Qt3DSDMPropertyHandle theProperty = - thePropertySystem->GetAggregateInstancePropertyByName(inInstance, inPropertyName.c_str()); + thePropertySystem->GetAggregateInstancePropertyByName(inInstance, inPropertyName); if (theProperty.Valid()) thePropertySystem->SetInstancePropertyValue(inInstance, theProperty, inValue); } @@ -238,43 +239,40 @@ void CDoc::SetInstancePropertyValue(qt3dsdm::Qt3DSDMInstanceHandle inInstance, // Utility that either adds or removes control string for the specified // property. Does not check if the property already has a controller // in the controlledPropStr. Returns true on success. -bool ModifyControlStrForProperty(Q3DStudio::CString &controlledPropStr, - const Q3DStudio::CString &propName, +bool ModifyControlStrForProperty(QString &controlledPropStr, + const QString &propName, bool controlled = false, - const Q3DStudio::CString diName = Q3DStudio::CString()) + const QString &diName = {}) { - Q3DStudio::CString cpStr = controlledPropStr; + QString cpStr = controlledPropStr; if (!controlled) { // get the length of to-be-deleted controller - property string and // delete it from the overall controlledproperty - long posProp = cpStr.find(" " + propName); + long posProp = cpStr.indexOf(QLatin1Char(' ') + propName); - if (posProp == Q3DStudio::CString::ENDOFSTRING) + if (posProp == -1) return false; - long posCtrlr = cpStr.substr(0, posProp - 1).ReverseFind(" "); + long posCtrlr = cpStr.left(posProp - 1).lastIndexOf(QLatin1Char(' ')); // this is the first controller - property pair in controlledproperty if (posCtrlr < 0) posCtrlr = 0; - long deletableStrLen = (posProp + propName.Length()) - posCtrlr + 1; + long deletableStrLen = (posProp + propName.length()) - posCtrlr + 1; - cpStr.Delete(posCtrlr, deletableStrLen); + cpStr = cpStr.remove(posCtrlr, deletableStrLen); // clean up the string as we might have extra whitespaces - cpStr.Replace(" ", " "); + cpStr.replace(QLatin1String(" "), QLatin1String(" ")); - cpStr.TrimLeft(); - cpStr.TrimRight(); + cpStr = cpStr.trimmed(); } else { // Insert delimiter if we already have an existing string. if (cpStr.size()) - cpStr.append(" "); - cpStr.append("$" + diName); - cpStr.append(" "); - cpStr.append(propName); + cpStr += QLatin1Char(' '); + cpStr += QLatin1Char('$') + diName + QLatin1Char(' ') + propName; } controlledPropStr = cpStr; return true; @@ -289,9 +287,9 @@ void CDoc::RemoveDatainputBindings( const auto uniqueKeys = map->uniqueKeys(); for (const auto &name : uniqueKeys) { const auto values = map->values(name); - for (const auto pair : values) { - SetInstancePropertyControlled(pair.first, Q3DStudio::CString(), - pair.second, Q3DStudio::CString::fromQString(name), + for (const auto &pair : values) { + SetInstancePropertyControlled(pair.first, QString(), + pair.second, name, false, true); } } @@ -307,31 +305,30 @@ void CDoc::RemoveDatainputBindings( // If 'batch' is set to true, we group subsequent transactions together. // Caller is responsible for calling CloseTransaction() after all transactions // are finished -void CDoc::SetInstancePropertyControlled( - qt3dsdm::Qt3DSDMInstanceHandle instance, Q3DStudio::CString instancepath, - qt3dsdm::Qt3DSDMPropertyHandle propName, Q3DStudio::CString newCtrl, - bool controlled, bool batch) +void CDoc::SetInstancePropertyControlled(qt3dsdm::Qt3DSDMInstanceHandle instance, + const QString &instancepath, qt3dsdm::Qt3DSDMPropertyHandle propName, + const QString &newCtrl, bool controlled, bool batch) { qt3dsdm::IPropertySystem *thePropertySystem = GetStudioSystem()->GetPropertySystem(); // We might have invalid controller (not found from the global list of datainputs) bool newCtrlrValid = false; qt3dsdm::SValue controlledProperty; - Q3DStudio::CString currCtrldPropsStr = Q3DStudio::CString(); + QString currCtrldPropsStr; qt3dsdm::SValue currentCtrldProps; qt3dsdm::Qt3DSDMMetaDataPropertyHandle metadataHandle; qt3dsdm::Option<qt3dsdm::SMetaDataPropertyInfo> metadata; // Get current controller - property string for this element qt3dsdm::Qt3DSDMPropertyHandle ctrldElemPropHandle - = thePropertySystem->GetAggregateInstancePropertyByName(instance, - L"controlledproperty"); + = thePropertySystem->GetAggregateInstancePropertyByName( + instance, QStringLiteral("controlledproperty")); // Get the controlledproperty tag for the target element if (ctrldElemPropHandle.Valid()) { - thePropertySystem->GetInstancePropertyValue( - instance, ctrldElemPropHandle, currentCtrldProps); + thePropertySystem->GetInstancePropertyValue(instance, ctrldElemPropHandle, + currentCtrldProps); if (!currentCtrldProps.empty()) - currCtrldPropsStr = qt3dsdm::get<qt3dsdm::TDataStrPtr>(currentCtrldProps)->GetData(); + currCtrldPropsStr = qt3dsdm::get<qt3dsdm::TDataStrPtr>(currentCtrldProps)->toQString(); } // Get the name of controlled property if valid @@ -342,7 +339,7 @@ void CDoc::SetInstancePropertyControlled( } // Check for new controller validity - if (g_StudioApp.m_dataInputDialogItems.contains(newCtrl.toQString())) + if (g_StudioApp.m_dataInputDialogItems.contains(newCtrl)) newCtrlrValid = true; else if (controlled) return; // trying to set control on but new controller is not valid, abort @@ -358,12 +355,12 @@ void CDoc::SetInstancePropertyControlled( // removal here just for the purposes of enabling recursive removal of control throughout // the graph if (!propName.Valid() && !controlled) { - if (currCtrldPropsStr.find(newCtrl + " @slide") != Q3DStudio::CString::ENDOFSTRING) { - ModifyControlStrForProperty(currCtrldPropsStr, Q3DStudio::CString("@slide"), + if (currCtrldPropsStr.contains(newCtrl + QStringLiteral(" @slide"))) { + ModifyControlStrForProperty(currCtrldPropsStr, QStringLiteral("@slide"), false, newCtrl); } - if (currCtrldPropsStr.find(newCtrl + " @timeline") != Q3DStudio::CString::ENDOFSTRING) { - ModifyControlStrForProperty(currCtrldPropsStr, Q3DStudio::CString("@timeline"), + if (currCtrldPropsStr.contains(newCtrl + QStringLiteral(" @timeline"))) { + ModifyControlStrForProperty(currCtrldPropsStr, QStringLiteral("@timeline"), false, newCtrl); } // in any case, write out the controlledproperty string even if unmodified @@ -371,12 +368,12 @@ void CDoc::SetInstancePropertyControlled( } else { // We are going to set or change the controller for this property. Remove the // old controller - property pair from the controlledproperty string first if it exists. - if (currCtrldPropsStr.find(metadata->m_Name.c_str()) != Q3DStudio::CString::ENDOFSTRING) - ModifyControlStrForProperty(currCtrldPropsStr, metadata->m_Name.c_str(), false); + if (currCtrldPropsStr.contains(metadata->m_Name)) + ModifyControlStrForProperty(currCtrldPropsStr, metadata->m_Name, false); // Modify the controlledproperty tag for the target element if (controlled) { - ModifyControlStrForProperty(currCtrldPropsStr, metadata->m_Name.c_str(), true, newCtrl); + ModifyControlStrForProperty(currCtrldPropsStr, metadata->m_Name, true, newCtrl); controlledProperty = std::make_shared<qt3dsdm::CDataStr>(currCtrldPropsStr); } else if (!controlled) { if (currCtrldPropsStr.size()) { @@ -402,7 +399,8 @@ void CDoc::SetInstancePropertyControlled( } else { if (!IsTransactionOpened()) OpenTransaction(QObject::tr("Set multiple controlled"), __FILE__, __LINE__); - SetInstancePropertyValue(instance, L"controlledproperty", controlledProperty); + SetInstancePropertyValue(instance, QStringLiteral("controlledproperty"), + controlledProperty); } } @@ -840,12 +838,12 @@ void CDoc::CutObject(qt3dsdm::TInstanceHandleList inInstances) return; // Build the list of targets - Q3DStudio::CString theListOfTargets; - GetActionDependencies(inInstance, theListOfTargets); + QString theListOfTargets; + theListOfTargets = GetActionDependencies(inInstance, theListOfTargets); - if (!theListOfTargets.IsEmpty()) { + if (!theListOfTargets.isEmpty()) { if (m_DeletingReferencedObjectHandler) - m_DeletingReferencedObjectHandler->DisplayMessageBox(theListOfTargets.toQString()); + m_DeletingReferencedObjectHandler->DisplayMessageBox(theListOfTargets); // theContinueCutFlag = false; } } @@ -883,7 +881,8 @@ void CDoc::PasteObject(qt3dsdm::Qt3DSDMInstanceHandle inInstance) qint64 dummy = 0; Qt3DSFile theTempAPFile = CStudioClipboard::GetObjectFromClipboard(false, dummy); SCOPED_DOCUMENT_EDITOR(*this, QObject::tr("Paste Object")) - ->PasteSceneGraphObject(theTempAPFile.GetAbsolutePath(), theInstance, true, + ->PasteSceneGraphObject(theTempAPFile.GetAbsolutePath().toQString(), + theInstance, true, DocumentEditorInsertType::LastChild, CPt()); } } @@ -896,7 +895,8 @@ void CDoc::PasteObjectMaster(qt3dsdm::Qt3DSDMInstanceHandle inInstance) qint64 dummy = 0; Qt3DSFile theTempAPFile = CStudioClipboard::GetObjectFromClipboard(false, dummy); SCOPED_DOCUMENT_EDITOR(*this, QObject::tr("Paste Object")) - ->PasteSceneGraphObjectMaster(theTempAPFile.GetAbsolutePath(), theInstance, true, + ->PasteSceneGraphObjectMaster(theTempAPFile.GetAbsolutePath().toQString(), + theInstance, true, DocumentEditorInsertType::LastChild, CPt()); } } @@ -938,15 +938,11 @@ void CDoc::DeleteObject(const qt3dsdm::TInstanceHandleList &inInstances) // find all the custom items created for it and remove it all if (theClientBridge->CanDelete(inInstances[idx])) { - Q3DStudio::CString theListOfTargets; - GetActionDependencies(inInstances[idx], theListOfTargets); + QString theListOfTargets; + theListOfTargets = GetActionDependencies(inInstances[idx], theListOfTargets); - if (!theListOfTargets.IsEmpty()) { - if (m_DeletingReferencedObjectHandler) { - m_DeletingReferencedObjectHandler->DisplayMessageBox(theListOfTargets - .toQString()); - } - } + if (!theListOfTargets.isEmpty() && m_DeletingReferencedObjectHandler) + m_DeletingReferencedObjectHandler->DisplayMessageBox(theListOfTargets); deletableInstances.push_back(inInstances[idx]); } @@ -954,7 +950,8 @@ void CDoc::DeleteObject(const qt3dsdm::TInstanceHandleList &inInstances) if (deletableInstances.empty() == false) { NotifySelectionChanged(); - Q3DStudio::SCOPED_DOCUMENT_EDITOR(*this, QObject::tr("Delete"))->DeleteInstances(deletableInstances); + Q3DStudio::SCOPED_DOCUMENT_EDITOR(*this, QObject::tr("Delete")) + ->DeleteInstances(deletableInstances); } } @@ -964,16 +961,16 @@ void CDoc::DeleteObject(const qt3dsdm::TInstanceHandleList &inInstances) * @inAsset The asset to check for dependencies. * @ioActionDependencies String representation of objects that have actions referencing it. */ -void CDoc::GetActionDependencies(qt3dsdm::Qt3DSDMInstanceHandle inInstance, - Q3DStudio::CString &ioActionDependencies) +QString CDoc::GetActionDependencies(qt3dsdm::Qt3DSDMInstanceHandle inInstance, + const QString &inActionDependencies) { // Step 1 : Get all actions affecting myself and all my descendents + QString actionDependencies = inActionDependencies; qt3dsdm::TActionHandleList theAffectedActions; GetActionDependencies(inInstance, theAffectedActions); // Set of unique owner names - typedef std::set<Q3DStudio::CString> TActionOwners; - TActionOwners theActionOwners; + std::set<QString> theActionOwners; qt3dsdm::IActionCore *theActionCore = m_StudioSystem->GetActionCore(); qt3dsdm::TActionHandleList::iterator thePos = theAffectedActions.begin(); @@ -992,14 +989,13 @@ void CDoc::GetActionDependencies(qt3dsdm::Qt3DSDMInstanceHandle inInstance, } // Iterate the set and form the output string - TActionOwners::iterator theActionOwnersPos = theActionOwners.begin(); - TActionOwners::iterator theActionOwnersEnd = theActionOwners.end(); - for (; theActionOwnersPos != theActionOwnersEnd; ++theActionOwnersPos) { - if (ioActionDependencies.IsEmpty()) - ioActionDependencies += *theActionOwnersPos; + for (auto &actionOwner : theActionOwners) { + if (actionDependencies.isEmpty()) + actionDependencies += actionOwner; else - ioActionDependencies += ", " + *theActionOwnersPos; + actionDependencies += QStringLiteral(", ") + actionOwner; } + return actionDependencies; } //============================================================================= @@ -1156,7 +1152,7 @@ inline Q3DStudio::CString ConvertToWide(const char8_t *inStr) } void CDoc::GetProjectFonts( - std::vector<std::pair<Q3DStudio::CString, Q3DStudio::CString>> &outFontNameFileList) + std::vector<std::pair<QString, QString>> &outFontNameFileList) { outFontNameFileList.clear(); #ifdef RUNTIME_SPLIT_TEMPORARILY_REMOVED @@ -1172,7 +1168,7 @@ void CDoc::GetProjectFonts( #endif } -void CDoc::GetProjectFonts(std::vector<Q3DStudio::CString> &outFonts) +void CDoc::GetProjectFonts(std::vector<QString> &outFonts) { outFonts.clear(); #ifdef RUNTIME_SPLIT_TEMPORARILY_REMOVED @@ -1186,9 +1182,9 @@ void CDoc::GetProjectFonts(std::vector<Q3DStudio::CString> &outFonts) #endif } -Q3DStudio::CString CDoc::GetProjectFontName(const Q3DStudio::CFilePath &inFullPathToFontFile) +QString CDoc::GetProjectFontName(const QFileInfo &inFullPathToFontFile) { - Q3DStudio::CString theFont; + QString theFont; #ifdef RUNTIME_SPLIT_TEMPORARILY_REMOVED qt3ds::render::ITextRenderer *theRenderer = m_SceneGraph->GetTextRenderer(); if (theRenderer) { @@ -1281,8 +1277,8 @@ void CDoc::onPropertyChanged(qt3dsdm::Qt3DSDMInstanceHandle inInstance, using namespace qt3dsdm; // check if we changed datainput bindings - if (inProperty == m_StudioSystem->GetPropertySystem() - ->GetAggregateInstancePropertyByName(inInstance, L"controlledproperty")) { + if (inProperty == m_StudioSystem->GetPropertySystem()->GetAggregateInstancePropertyByName( + inInstance, QStringLiteral("controlledproperty"))) { // we need to rebuild the datainput map as we do not know what exactly // happened with controlledproperty property // TODO: implement a pre-change signal that can be used to extract @@ -1622,10 +1618,9 @@ QString CDoc::getPresentationId() const return m_presentationId; } -Q3DStudio::CString CDoc::GetDocumentDirectory() const +QString CDoc::GetDocumentDirectory() const { - Q3DStudio::CFilePath thePath(m_DocumentPath); - return thePath.GetDirectory(); + return QFileInfo(m_DocumentPath).canonicalPath(); } //============================================================================= @@ -1635,19 +1630,9 @@ Q3DStudio::CString CDoc::GetDocumentDirectory() const * This is used when we drag image / behavior / other files to scene. * In future we may want to return path to handle importing files from $CommonAssets. */ -Q3DStudio::CString CDoc::GetRelativePathToDoc(const Q3DStudio::CFilePath &inPath) -{ - Q3DStudio::CFilePath thePath(inPath); - Q3DStudio::CFilePath theDocumentPath(GetDocumentDirectory()); - if (thePath.IsInSubDirectory(theDocumentPath)) - thePath.ConvertToRelative(theDocumentPath); - - return thePath; -} - QString CDoc::GetRelativePathToDoc(const QFileInfo &inPath) { - QString documentDirectory = GetDocumentDirectory().toQString(); + QString documentDirectory = GetDocumentDirectory(); QDir basePathDir = inPath.canonicalFilePath(); if (basePathDir.exists() && basePathDir.exists(documentDirectory)) { basePathDir = QDir(documentDirectory); @@ -1657,7 +1642,6 @@ QString CDoc::GetRelativePathToDoc(const QFileInfo &inPath) return inPath.filePath(); } - //============================================================================= /** * Given a path (may be relative or absolute), return the path with respect to doc. @@ -1665,24 +1649,12 @@ QString CDoc::GetRelativePathToDoc(const QFileInfo &inPath) * Else, return normalized path so that we can easily do string comparison to compare path. * In future we may want to resolve path based on $CommonAssets. */ -Q3DStudio::CString CDoc::GetResolvedPathToDoc(const Q3DStudio::CFilePath &inPath) -{ - // If it is a relative path, resolve it. - if (!inPath.IsAbsolute()) { - // Sanity check that document path has been set properly. - ASSERT(QFileInfo(m_DocumentPath).exists()); - - return Q3DStudio::CFilePath::CombineBaseAndRelative(GetDocumentDirectory(), inPath); - } - return inPath.toCString(); -} - QString CDoc::GetResolvedPathToDoc(const QFileInfo &inPath) { if (inPath.isAbsolute() == false) { // Sanity check that document path has been set properly. - ASSERT(QFileInfo(m_DocumentPath).exists()); - return GetDocumentDirectory().toQString() + "/" + inPath.filePath(); + Q_ASSERT(QFileInfo(m_DocumentPath).exists()); + return GetDocumentDirectory() + QLatin1Char('/') + inPath.filePath(); } return inPath.absolutePath(); } @@ -2153,16 +2125,15 @@ void CDoc::HandleDuplicateCommand(bool slide) bool CDoc::VerifyCanRename(qt3dsdm::Qt3DSDMInstanceHandle inAsset) { bool theResult = true; - std::set<Q3DStudio::CString> theAffectedList; + std::set<QString> theAffectedList; GetActionsAffectedByRename(inAsset, theAffectedList); if (!theAffectedList.empty()) { - Q3DStudio::CString theFormulatedString; - std::set<Q3DStudio::CString>::iterator thePos = theAffectedList.begin(); - for (; thePos != theAffectedList.end(); ++thePos) { - if (theFormulatedString.IsEmpty()) - theFormulatedString += (*thePos); + QString theFormulatedString; + for (auto &affected : theAffectedList) { + if (theFormulatedString.isEmpty()) + theFormulatedString += affected; else - theFormulatedString += ", " + (*thePos); + theFormulatedString += QStringLiteral(", ") + affected; } ASSERT(0); // Dialogs by dispatch @@ -2248,17 +2219,29 @@ int CDoc::LoadStudioData(QIODevice *inInputStream) IDOMReader &theReader(*theReaderPtr); - theReader.Att("version", theVersion); + theReader.Att(QStringLiteral("version"), theVersion); CProjectSettingsSerializer theProjectSettingsSerializer( m_Core->GetStudioProjectSettings()); - theReader.Serialize(L"ProjectSettings", theProjectSettingsSerializer); + theReader.Serialize(QStringLiteral("ProjectSettings"), theProjectSettingsSerializer); if (m_AssetGraph) m_AssetGraph->Clear(); else m_AssetGraph = TAssetGraph::CreateGraph(); + if (theReader.MoveToFirstChild(QStringLiteral("BufferData")) + && theReader.MoveToFirstChild(QStringLiteral("ImageBuffer"))) { + do { + bool transparency; + QString sourcepath; + theReader.Att(QStringLiteral("sourcepath"), sourcepath); + theReader.Att(QStringLiteral("hasTransparency"), transparency); + m_SceneGraph->GetBufferManager() + ->SetImageHasTransparency(sourcepath, transparency); + } while (theReader.MoveToNextSibling(QStringLiteral("ImageBuffer"))); + } + // We definitely don't want a million events firing off during this deserialization. std::shared_ptr<IComposerSerializer> theSerializer(CreateTransactionlessSerializer()); theSerializer->SerializeScene(theReader, GetDocumentDirectory(), (int)theVersion); @@ -2439,7 +2422,7 @@ DoCreateDOMReader(QIODevice &inStream, return std::shared_ptr<qt3dsdm::IDOMReader>(); } -std::shared_ptr<qt3dsdm::IDOMReader> CDoc::CreateDOMReader(const Q3DStudio::CString &inFilePath, +std::shared_ptr<qt3dsdm::IDOMReader> CDoc::CreateDOMReader(const QString &inFilePath, qt3ds::QT3DSI32 &outVersion) { using namespace qt3dsdm; @@ -2594,7 +2577,7 @@ void CDoc::DeselectAllKeyframes() *reference, and hence all its descendants' action must be checked as well. */ void CDoc::GetActionsAffectedByRename(qt3dsdm::Qt3DSDMInstanceHandle inAsset, - std::set<Q3DStudio::CString> &ioActionsAffected) + std::set<QString> &ioActionsAffected) { if (!inAsset) return; @@ -2921,12 +2904,12 @@ void CDoc::getSceneMaterials(qt3dsdm::Qt3DSDMInstanceHandle inParent, void CDoc::CheckActionDependencies(qt3dsdm::Qt3DSDMInstanceHandle inInstance) { - Q3DStudio::CString theListOfTargets; + QString theListOfTargets; GetActionDependencies(inInstance, theListOfTargets); - if (!theListOfTargets.IsEmpty()) { + if (!theListOfTargets.isEmpty()) { if (m_DeletingReferencedObjectHandler) - m_DeletingReferencedObjectHandler->DisplayMessageBox(theListOfTargets.toQString()); + m_DeletingReferencedObjectHandler->DisplayMessageBox(theListOfTargets); } } @@ -2940,20 +2923,21 @@ void CDoc::UpdateDatainputMap( auto propSystem = GetPropertySystem(); qt3dsdm::Qt3DSDMPropertyHandle ctrldPropHandle - = propSystem->GetAggregateInstancePropertyByName(inInstance, L"controlledproperty"); + = propSystem->GetAggregateInstancePropertyByName(inInstance, + QStringLiteral("controlledproperty")); if (propSystem->HasAggregateInstanceProperty(inInstance, ctrldPropHandle)) { qt3dsdm::SValue ctrldPropVal; propSystem->GetInstancePropertyValue(inInstance, ctrldPropHandle, ctrldPropVal); - Q3DStudio::CString currCtrldPropsStr - = qt3dsdm::get<qt3dsdm::TDataStrPtr>(ctrldPropVal)->GetData(); - QStringList splitStr = currCtrldPropsStr.toQString().split(' '); + QString currCtrldPropsStr + = qt3dsdm::get<qt3dsdm::TDataStrPtr>(ctrldPropVal)->toQString(); + QStringList splitStr = currCtrldPropsStr.split(' '); for (int i = 0; i < splitStr.size() - 1; i += 2) { QString diName = splitStr[i].startsWith('$') ? splitStr[i].remove(0, 1) : splitStr[i]; QString propName = splitStr[i+1]; auto propHandle = propSystem->GetAggregateInstancePropertyByName( - inInstance, propName.toStdWString().c_str()); + inInstance, propName); auto propType = propSystem->GetDataType(propHandle); // Update the controlled elements and property types for // verified, existing datainputs. Note that for @timeline and @@ -2983,7 +2967,7 @@ void CDoc::UpdateDatainputMap( // be found in several elements. qt3dsdm::Qt3DSDMPropertyHandle prop = propSystem->GetAggregateInstancePropertyByName( - inInstance, splitStr[i+1].toStdWString().c_str()); + inInstance, splitStr[i+1]); QPair<qt3dsdm::Qt3DSDMInstanceHandle, qt3dsdm::Qt3DSDMPropertyHandle> valuepair(inInstance, prop); outMap->insertMulti(diName, valuepair); @@ -3004,16 +2988,17 @@ bool CDoc::VerifyControlledProperties(const qt3dsdm::Qt3DSDMInstanceHandle inIns bool ret = true; qt3dsdm::Qt3DSDMPropertyHandle ctrldPropHandle - = propSystem->GetAggregateInstancePropertyByName(inInstance, L"controlledproperty"); + = propSystem->GetAggregateInstancePropertyByName(inInstance, + QStringLiteral("controlledproperty")); // Split controlledproperty string to parts and check each for validity. if (ctrldPropHandle) { qt3dsdm::SValue ctrldPropVal; propSystem->GetInstancePropertyValue(inInstance, ctrldPropHandle, ctrldPropVal); - Q3DStudio::CString currCtrldPropsStr - = qt3dsdm::get<qt3dsdm::TDataStrPtr>(ctrldPropVal)->GetData(); - QStringList splitStr = currCtrldPropsStr.toQString().split(' '); + QString currCtrldPropsStr + = qt3dsdm::get<qt3dsdm::TDataStrPtr>(ctrldPropVal)->toQString(); + QStringList splitStr = currCtrldPropsStr.split(QLatin1Char(' ')); - Q3DStudio::CString validatedStr; + QString validatedStr; QRegExpValidator rxp(QRegExp("[A-Za-z0-9_$]+")); @@ -3029,7 +3014,7 @@ bool CDoc::VerifyControlledProperties(const qt3dsdm::Qt3DSDMInstanceHandle inIns // check that target property exists or the target is @slide or @timeline qt3dsdm::Qt3DSDMPropertyHandle targetPropHandle = propSystem->GetAggregateInstancePropertyByName( - inInstance, splitStr[i+1].toStdWString().c_str()); + inInstance, splitStr[i+1]); if (targetPropHandle || splitStr[i+1] == QLatin1String("@timeline") || splitStr[i+1] == QLatin1String("@slide")) { @@ -3042,9 +3027,8 @@ bool CDoc::VerifyControlledProperties(const qt3dsdm::Qt3DSDMInstanceHandle inIns && splitStr[i].size() && splitStr[i] != QLatin1String("$")) { // only add spacer if not at the first entry if (validatedStr.size()) - validatedStr.append(" "); - validatedStr.append(Q3DStudio::CString::fromQString(splitStr[i]) + " " - + Q3DStudio::CString::fromQString(splitStr[i+1])); + validatedStr += QLatin1Char(' '); + validatedStr += splitStr[i] + QLatin1Char(' ') + splitStr[i+1]; } else { ret = false; } @@ -3057,7 +3041,8 @@ bool CDoc::VerifyControlledProperties(const qt3dsdm::Qt3DSDMInstanceHandle inIns = std::make_shared<qt3dsdm::CDataStr>(validatedStr); // Set changed controlledproperty properties directly without creating // transaction and undo points - SetInstancePropertyValue(inInstance, L"controlledproperty", controlledProperty); + SetInstancePropertyValue(inInstance, QStringLiteral("controlledproperty"), + controlledProperty); } } diff --git a/src/Authoring/Client/Code/Core/Doc/Doc.h b/src/Authoring/Client/Code/Core/Doc/Doc.h index 2c51c487..412c971c 100644 --- a/src/Authoring/Client/Code/Core/Doc/Doc.h +++ b/src/Authoring/Client/Code/Core/Doc/Doc.h @@ -205,9 +205,7 @@ public: QString GetDocumentPath() const; void setPresentationId(const QString &id); QString getPresentationId() const; - Q3DStudio::CString GetDocumentDirectory() const; - Q3DStudio::CString GetRelativePathToDoc(const Q3DStudio::CFilePath &inPath); - Q3DStudio::CString GetResolvedPathToDoc(const Q3DStudio::CFilePath &inPath); + QString GetDocumentDirectory() const; QString getRelativePath() const; QString GetResolvedPathToDoc(const QFileInfo &inPath); QString GetRelativePathToDoc(const QFileInfo &inPath); @@ -333,12 +331,12 @@ public: qt3dsdm::IPropertySystem *GetPropertySystem() override; qt3dsdm::IAnimationCore *GetAnimationCore() override; void SetInstancePropertyValue(qt3dsdm::Qt3DSDMInstanceHandle inInstance, - const std::wstring &inPropertyName, + const QString &inPropertyName, const qt3dsdm::SValue &inValue) override; void SetInstancePropertyControlled(qt3dsdm::Qt3DSDMInstanceHandle instance, - Q3DStudio::CString instancepath, + const QString &instancepath, qt3dsdm::Qt3DSDMPropertyHandle propName, - Q3DStudio::CString controller, + const QString &controller, bool controlled, bool batch = false) override; void RemoveDatainputBindings( @@ -363,7 +361,7 @@ public: // Create a DOM reader and check that the top element's version is correct. Opens the reader // to the project element. virtual std::shared_ptr<qt3dsdm::IDOMReader> - CreateDOMReader(const Q3DStudio::CString &inFilePath, qt3ds::QT3DSI32 &outVersion) override; + CreateDOMReader(const QString &inFilePath, qt3ds::QT3DSI32 &outVersion) override; virtual std::shared_ptr<qt3dsdm::IDOMReader> CreateDOMReader(QIODevice &inStream, qt3ds::QT3DSI32 &outVersion); @@ -427,12 +425,10 @@ public: void SetSceneGraph(std::shared_ptr<Q3DStudio::IDocSceneGraph> inGraph); Q3DStudio::IDocSceneGraph *GetSceneGraph() { return m_SceneGraph.get(); } - void GetProjectFonts( - std::vector<std::pair<Q3DStudio::CString, Q3DStudio::CString>> &outFontNameFileList); - void GetProjectFonts(std::vector<Q3DStudio::CString> &outFonts); - Q3DStudio::CString - GetProjectFontName(const Q3DStudio::CFilePath - &inFullPathToFontFile); // Given a font file, return the font name + void GetProjectFonts(std::vector<std::pair<QString, QString>> &outFontNameFileList); + void GetProjectFonts(std::vector<QString> &outFonts); + // Given a font file, return the font name + QString GetProjectFontName(const QFileInfo &inFullPathToFontFile); void setPlayBackPreviewState(bool state); bool isPlayBackPreviewOn() const; int getSelectedInstancesCount() const; @@ -462,8 +458,8 @@ protected: void CreatePresentation(); void ClosePresentation(); - void GetActionDependencies(qt3dsdm::Qt3DSDMInstanceHandle inInstance, - Q3DStudio::CString &ioActionDependencies); + QString GetActionDependencies(qt3dsdm::Qt3DSDMInstanceHandle inInstance, + const QString &inActionDependencies); void GetActionDependencies(qt3dsdm::Qt3DSDMInstanceHandle inInstance, qt3dsdm::TActionHandleList &ioActionList); @@ -471,7 +467,7 @@ protected: qt3dsdm::Qt3DSDMInstanceHandle GetTopmostGroup(qt3dsdm::Qt3DSDMInstanceHandle inInstance); void GetActionsAffectedByRename(qt3dsdm::Qt3DSDMInstanceHandle inAsset, - std::set<Q3DStudio::CString> &ioActionsAffected); + std::set<QString> &ioActionsAffected); bool isFocusOnTextEditControl(); diff --git a/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp b/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp index 028c0d66..dd1c58fc 100644 --- a/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp +++ b/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp @@ -126,9 +126,9 @@ struct SImportXmlErrorHandler : public CXmlErrorHandler std::shared_ptr<IImportFailedHandler> m_handler; QString m_fullPathToDocument; SImportXmlErrorHandler(std::shared_ptr<IImportFailedHandler> hdl, - const Q3DStudio::CString &inFullPathToDocument) + const QString &inFullPathToDocument) : m_handler(hdl) - , m_fullPathToDocument(inFullPathToDocument.toQString()) + , m_fullPathToDocument(inFullPathToDocument) { } void OnXmlError(const QString &errorName, int line, int) override @@ -162,7 +162,7 @@ class CDocEditor : public Q3DStudio::IInternalDocumentEditor std::shared_ptr<ISignalConnection> m_ProjectDirWatcher; bool m_IgnoreDirChange; TCharPtrToSlideInstanceMap m_SourcePathInstanceMap; - unordered_map<TCharPtr, TCharPtr> m_ImportFileToDAEMap; + QHash<QString, QString> m_ImportFileToDAEMap; qt3dsdm::IStringTable &m_StringTable; Q3DStudio::Foundation::SStudioFoundation m_Foundation; TStreamFactoryPtr m_InputStreamFactory; @@ -244,7 +244,7 @@ public: } TPropertyHandle FindProperty(Qt3DSDMInstanceHandle instance, - const wchar_t *inPropName) const override + const QString &inPropName) const override { return m_DataCore.GetAggregateInstancePropertyByName(instance, inPropName); } @@ -302,14 +302,14 @@ public: return Empty(); } - Q3DStudio::CString GetObjectTypeName(TInstanceHandle instance) const override + QString GetObjectTypeName(TInstanceHandle instance) const override { if (IsInstance(instance)) { - Option<TCharStr> theTypeName = m_MetaData.GetTypeForInstance(instance); + Option<QString> theTypeName = m_MetaData.GetTypeForInstance(instance); if (theTypeName.hasValue()) - return CString(theTypeName->wide_str()); + return theTypeName; } - return Q3DStudio::CString(); + return {}; } // Get every property value associated with this instance, from the data core up. The @@ -392,7 +392,7 @@ public: if (m_DataCore.GetInstancePropertyValue(inInstance, inProperty, theValue)) { TDataStrPtr theStr(get<TDataStrPtr>(theValue)); if (theStr && theStr->GetLength()) - outPaths.push_back(make_pair(Qt3DSDMSlideHandle(0), CString(theStr->GetData()))); + outPaths.push_back(make_pair(Qt3DSDMSlideHandle(0), theStr->toQString())); } TSlideHandleList theSlides; @@ -405,12 +405,13 @@ public: theSlideValue)) { TDataStrPtr theStr(get<TDataStrPtr>(theSlideValue)); if (theStr && theStr->GetLength()) - outPaths.push_back(make_pair(theSlide, CString(theStr->GetData()))); + outPaths.push_back(make_pair(theSlide, theStr->toQString())); } } } - void GetAllSourcePaths(Qt3DSDMInstanceHandle inInstance, TSlideStringList &outPaths) const override + void GetAllSourcePaths(Qt3DSDMInstanceHandle inInstance, + TSlideStringList &outPaths) const override { SComposerObjectDefinitions &theDefinitions(m_Bridge.GetObjectDefinitions()); GetAllPaths(inInstance, theDefinitions.m_Asset.m_SourcePath, outPaths); @@ -431,15 +432,14 @@ public: GetAllPaths(theAsset, inProperty, thePaths); for (size_t pathIdx = 0, pathEnd = thePaths.size(); pathIdx < pathEnd; ++pathIdx) { - const pair<qt3dsdm::Qt3DSDMSlideHandle, Q3DStudio::CString> &theSlideStr( + const pair<qt3dsdm::Qt3DSDMSlideHandle, QString> &theSlideStr( thePaths[pathIdx]); - CFilePath thePath(theSlideStr.second); + QString thePath(theSlideStr.second); if (inIncludeIdentifiers == false) - thePath = thePath.filePath(); - const QString path = thePath.toQString(); - if (!outInstanceMap.contains(path)) - outInstanceMap.insert(path, TSlideInstanceList()); - insert_unique(outInstanceMap[path], + thePath = CFilePath::stripIdentifier(thePath); + if (!outInstanceMap.contains(thePath)) + outInstanceMap.insert(thePath, TSlideInstanceList()); + insert_unique(outInstanceMap[thePath], make_pair(theSlideStr.first, theAsset)); } } @@ -517,28 +517,28 @@ public: return false; } - CString GetImportId(TInstanceHandle inInstance) const override + QString GetImportId(TInstanceHandle inInstance) const override { SValue theValue; if (m_DataCore.GetInstancePropertyValue( inInstance, m_Bridge.GetObjectDefinitions().m_Asset.m_ImportId, theValue)) { TDataStrPtr theStr(get<TDataStrPtr>(theValue)); if (theStr) - return m_StringTable.RegisterStr(theStr->GetData()); + return theStr->toQString(); } - return m_StringTable.RegisterStr(L""); + return {}; } - CString GetFileId(TInstanceHandle inInstance) const override + QString GetFileId(TInstanceHandle inInstance) const override { SValue theValue; if (m_DataCore.GetInstancePropertyValue( inInstance, m_Bridge.GetObjectDefinitions().m_Asset.m_FileId, theValue)) { TDataStrPtr theStr(get<TDataStrPtr>(theValue)); if (theStr) - return m_StringTable.RegisterStr(theStr->GetData()); + return theStr->toQString(); } - return m_StringTable.RegisterStr(L""); + return {}; } std::pair<long, long> GetTimeRange(TInstanceHandle instance) const override @@ -587,7 +587,7 @@ public: return m_Bridge.GetInstanceByGUID(inGuid); } TInstanceHandle GetInstanceForObjectRef(TInstanceHandle inRoot, - const qt3dsdm::SObjectRefType &inReference) const override + const qt3dsdm::SObjectRefType &inReference) const override { return m_Bridge.GetInstance(inRoot, inReference); } @@ -599,7 +599,7 @@ public: // Get all the children if this instance in this slide. If the slide is invalid, // the get all the children of this parent in all slides. void GetChildren(TSlideHandle inSlide, TInstanceHandle inParent, - TInstanceList &outChildren) const override + TInstanceList &outChildren) const override { for (long theChildIdx = 0, theChildCount = m_AssetGraph.GetChildCount(inParent); theChildIdx < theChildCount; ++theChildIdx) { @@ -607,8 +607,9 @@ public: if (inSlide.Valid()) { if (m_SlideSystem.GetAssociatedSlide(theChild) == inSlide) outChildren.push_back(theChild); - } else + } else { outChildren.push_back(theChild); + } } } @@ -619,7 +620,7 @@ public: { for (QT3DSI32 idx = 0, end = m_AssetGraph.GetChildCount(path); idx < end; ++idx) { TInstanceHandle theChild = m_AssetGraph.GetChild(path, idx); - if (GetObjectTypeName(theChild) == L"SubPath") + if (GetObjectTypeName(theChild) == QLatin1String("SubPath")) return true; } return false; @@ -636,7 +637,7 @@ public: } bool AnimationExists(TSlideHandle inSlide, TInstanceHandle instance, - const wchar_t *propName, long subIndex) override + const QString &propName, long subIndex) override { Qt3DSDMPropertyHandle propHdl = m_DataCore.GetAggregateInstancePropertyByName(instance, propName); @@ -658,7 +659,7 @@ public: } bool IsAnimationArtistEdited(TSlideHandle inSlide, Qt3DSDMInstanceHandle instance, - const wchar_t *propName, long subIndex) override + const QString &propName, long subIndex) override { Qt3DSDMPropertyHandle propHdl = m_DataCore.GetAggregateInstancePropertyByName(instance, propName); @@ -820,8 +821,8 @@ public: return file; } - void ParseSourcePathsOutOfEffectFile(Q3DStudio::CString inFile, - std::vector<Q3DStudio::CString> &outFilePaths) override + void ParseSourcePathsOutOfEffectFile(const QString &inFile, + std::vector<QString> &outFilePaths) override { QSharedPointer<QFile> theStream( openQFileStream(inFile, qt3ds::foundation::FileReadFlags())); @@ -832,21 +833,23 @@ public: qt3dsdm::SDOMElement *theElem = CDOMSerializer::Read(*theFactory, *theStream, &theImportHandler); - CFilePath theFilePath(inFile); - CFilePath theFileDir(theFilePath.GetDirectory()); + QFileInfo theFilePath(inFile); + QString theFileDir(theFilePath.canonicalPath()); if (theElem) { std::shared_ptr<IDOMReader> theReader = IDOMReader::CreateDOMReader( *theElem, m_DataCore.GetStringTablePtr(), theFactory); - if (theReader->MoveToFirstChild("MetaData")) { - for (bool success = theReader->MoveToFirstChild("Property"); success; - success = theReader->MoveToNextSibling("Property")) { - const char8_t *type = "", *defValue = ""; - theReader->Att("type", type); - theReader->Att("default", defValue); - if (qt3dsdm::AreEqual(type, "Texture")) { - CFilePath theDefPath = - CFilePath::CombineBaseAndRelative(theFileDir, defValue); - if (theDefPath.IsFile()) + if (theReader->MoveToFirstChild(QStringLiteral("MetaData"))) { + for (bool success = theReader->MoveToFirstChild(QStringLiteral("Property")); + success; + success = theReader->MoveToNextSibling(QStringLiteral("Property"))) { + QString type; + QString defValue; + theReader->Att(QStringLiteral("type"), type); + theReader->Att(QStringLiteral("default"), defValue); + if (type == QLatin1String("Texture")) { + QFileInfo theDefPath(CFilePath::CombineBaseAndRelative( + theFileDir, defValue)); + if (theDefPath.isFile()) outFilePaths.push_back(defValue); } } @@ -855,9 +858,9 @@ public: } } - Q3DStudio::CString GetCustomMaterialName(const Q3DStudio::CString &inFullPathToFile) const override + QString GetCustomMaterialName(const QString &inFullPathToFile) const override { - Q3DStudio::CString retval; + QString retval; QSharedPointer<QFile> theStream( openQFileStream(inFullPathToFile, qt3ds::foundation::FileReadFlags())); if (!theStream.isNull()) { @@ -869,13 +872,14 @@ public: CDOMSerializer::Read(*theFactory, *theStream, &theImportHandler); if (theElem) { // OK, then this just may be a valid material file. Get the file stem of the path. - Q3DStudio::CFilePath thePath(inFullPathToFile); - retval = thePath.GetFileStem(); + QFileInfo thePath(inFullPathToFile); + retval = thePath.baseName(); std::shared_ptr<IDOMReader> theReader = IDOMReader::CreateDOMReader( *theElem, m_DataCore.GetStringTablePtr(), theFactory); - const char8_t *attValue; - if (theReader->UnregisteredAtt("formalName", attValue) && !isTrivial(attValue)) { - retval.assign(attValue); + QString formalName; + if (theReader->Att(QStringLiteral("formalName"), formalName) + && !formalName.isEmpty()) { + retval = formalName; } } } @@ -893,8 +897,7 @@ public: std::shared_ptr<IDOMFactory> theFactory = IDOMFactory::CreateDOMFactory(m_DataCore.GetStringTablePtr()); SImportXmlErrorHandler theImportHandler(m_Doc.GetImportFailedHandler(), - Q3DStudio::CString::fromQString( - inFullPathToFile)); + inFullPathToFile); qt3dsdm::SDOMElement *theElem = CDOMSerializer::Read(*theFactory, *theStream, &theImportHandler); if (theElem) { @@ -902,34 +905,37 @@ public: std::shared_ptr<IDOMReader> theReader = IDOMReader::CreateDOMReader( *theElem, m_DataCore.GetStringTablePtr(), theFactory); - for (bool success = theReader->MoveToFirstChild("Property"); success; - success = theReader->MoveToNextSibling("Property")) { - const char8_t *name = ""; - const char8_t *value = ""; - theReader->Att("name", name); + for (bool success = theReader->MoveToFirstChild(QStringLiteral("Property")); + success; + success = theReader->MoveToNextSibling(QStringLiteral("Property"))) { + QString name; + QString value; + theReader->Att(QStringLiteral("name"), name); theReader->Value(value); outValues[name] = value; } - if (AreEqual(theReader->GetElementName(), L"Property")) + if (theReader->GetElementName() == QLatin1String("Property")) theReader->Leave(); - for (bool texSuccess = theReader->MoveToFirstChild("TextureData"); texSuccess; - texSuccess = theReader->MoveToNextSibling("TextureData")) { + for (bool texSuccess = theReader->MoveToFirstChild(QStringLiteral("TextureData")); + texSuccess; + texSuccess = theReader->MoveToNextSibling(QStringLiteral("TextureData"))) { QMap<QString, QString> texValues; - const char8_t *texName = ""; - theReader->Att("name", texName); - for (bool success = theReader->MoveToFirstChild("Property"); success; - success = theReader->MoveToNextSibling("Property")) { - const char8_t *name = ""; - const char8_t *value = ""; - theReader->Att("name", name); + QString texName; + theReader->Att(QStringLiteral("name"), texName); + for (bool success = theReader->MoveToFirstChild(QStringLiteral("Property")); + success; + success = theReader->MoveToNextSibling(QStringLiteral("Property"))) { + QString name; + QString value; + theReader->Att(QStringLiteral("name"), name); theReader->Value(value); texValues[name] = value; } outTextureValues[texName] = texValues; - if (AreEqual(theReader->GetElementName(), L"Property")) + if (theReader->GetElementName() == QLatin1String("Property")) theReader->Leave(); } @@ -1040,20 +1046,15 @@ public: TInstanceHandle retval(CreateSceneGraphInstance(inType, inParent, inSlide, TInstanceHandle(), setTimeRange)); - Q3DStudio::CString theName; + QString theName; if (inType == ComposerObjectTypes::Model) { QString theSourcePath = m_Doc.GetBufferCache().GetPrimitiveName(inPrimitiveType); if (!theSourcePath.isEmpty()) { - wchar_t *ws = new wchar_t [theSourcePath.length() + 1]; - memset(ws, 0, sizeof(wchar_t) * (theSourcePath.length() + 1)); - theSourcePath.toWCharArray(ws); - // Trigger material generation. SetInstancePropertyValue(retval, m_Bridge.GetObjectDefinitions().m_Asset.m_SourcePath, - std::make_shared<CDataStr>(ws)); - theName = Q3DStudio::CString(ws + 1); - delete [] ws; + std::make_shared<CDataStr>(theSourcePath)); + theName = theSourcePath.right(theSourcePath.length() - 1); } else { theName = GetName(retval); } @@ -1085,16 +1086,16 @@ public: return handle; } - TCharPtr GetSourcePath(Qt3DSDMInstanceHandle inInstance) + QString GetSourcePath(Qt3DSDMInstanceHandle inInstance) { Option<SValue> theValue = GetInstancePropertyValue( inInstance, m_Bridge.GetObjectDefinitions().m_Asset.m_SourcePath); if (theValue.hasValue()) { TDataStrPtr theStr(get<TDataStrPtr>(*theValue)); if (theStr) - return theStr->GetData(); + return theStr->toQString(); } - return L""; + return {}; } void DoDeleteInstance(Qt3DSDMInstanceHandle instance) @@ -1194,7 +1195,7 @@ public: QT3DS_ASSERT(false); // First, we need to get the parent instance that has the same sourcepath property - CFilePath theSourcePath(GetSourcePath(instance)); + QString theSourcePath(GetSourcePath(instance)); TInstanceHandleList theParents; Qt3DSDMInstanceHandle theInstanceParent; m_DataCore.GetInstanceParents(instance, theParents); @@ -1202,7 +1203,7 @@ public: Qt3DSDMInstanceHandle theParent(theParents[idx]); if (m_DataCore.IsInstanceOrDerivedFrom(theParent, theObjectDefInstance) && theParent != theObjectDefInstance - && theSourcePath.toCString() == GetSourcePath(theParent)) { + && theSourcePath == GetSourcePath(theParent)) { theInstanceParent = theParent; break; } @@ -1302,7 +1303,7 @@ public: for (size_t propIdx = 0, propEnd = theValues.size(); propIdx < propEnd; ++propIdx) { TDataStrPtr newValue(get<TDataStrPtr>(theValues[propIdx].second)); Q3DSRenderMesh *theBuffer = m_Doc.GetBufferCache().GetOrCreateModelBuffer( - QString::fromWCharArray(newValue->GetData())); + newValue->toQString()); if (theBuffer) numSubsets = qMax(numSubsets, theBuffer->m_subsets.size()); } @@ -1340,16 +1341,12 @@ public: for (size_t propIdx = 0, propEnd = theValues.size(); propIdx < propEnd; ++propIdx) { TDataStrPtr newValue(get<TDataStrPtr>(theValues[propIdx].second)); Q3DSRenderMesh *theBuffer = m_Doc.GetBufferCache().GetOrCreateModelBuffer( - QString::fromWCharArray(newValue->GetData())); + newValue->toQString()); if (theBuffer == NULL) continue; for (long subsetIdx = 0, subsetEnd = theBuffer->m_subsets.size(); subsetIdx < subsetEnd; ++subsetIdx) { -#ifdef KDAB_TEMPORARILY_REMOVED - StaticAssert<sizeof(wchar_t) == sizeof(char16_t)>::valid_expression(); -#endif - const wstring &theSubsetName = - Q3DStudio::CString::fromQString(theBuffer->m_subsetNames[subsetIdx]).c_str(); + const QString &theSubsetName = theBuffer->m_subsetNames[subsetIdx]; if (theSubsetName.size()) { Qt3DSDMInstanceHandle theMaterial(theMaterials[subsetIdx]); SValue theValue; @@ -1361,21 +1358,17 @@ public: if (m_SlideCore.GetSpecificInstancePropertyValue(theSlide, theMaterial, theNameProp, theValue) == true - && AreEqual(get<TDataStrPtr>(theValue)->GetData(), - theSubsetName.c_str()) - == false) + && get<TDataStrPtr>(theValue)->toQString() != theSubsetName) m_SlideCore.ForceSetInstancePropertyValue( theSlide, theMaterial, theNameProp, - std::make_shared<CDataStr>(theSubsetName.c_str())); + std::make_shared<CDataStr>(theSubsetName)); } else if (m_DataCore.GetInstancePropertyValue(theMaterial, theNameProp, theDMValue) == false - || AreEqual(get<TDataStrPtr>(theDMValue)->GetData(), - theSubsetName.c_str()) - == false) { + || get<TDataStrPtr>(theDMValue)->toQString() != theSubsetName) { m_DataCore.SetInstancePropertyValue( theMaterial, theNameProp, - std::make_shared<CDataStr>(theSubsetName.c_str())); + std::make_shared<CDataStr>(theSubsetName)); } } } @@ -1414,7 +1407,7 @@ public: void CreatePathMaterial(TInstanceHandle instance, bool isStroke, bool hasStroke) { - const wchar_t *materialName = isStroke ? L"Stroke" : L"Fill"; + QString materialName = isStroke ? QStringLiteral("Stroke") : QStringLiteral("Fill"); TInstanceHandle firstChild; if (m_AssetGraph.GetChildCount(instance)) firstChild = m_AssetGraph.GetChild(instance, 0); @@ -1492,12 +1485,11 @@ public: for (QT3DSI32 idx = 0, end = m_AssetGraph.GetChildCount(instance); idx < end; ++idx) { TInstanceHandle child = m_AssetGraph.GetChild(instance, idx); - if (GetObjectTypeName(child) == L"SubPath") + if (GetObjectTypeName(child) == QLatin1String("SubPath")) subPathChildren.push_back(child); } - for (QT3DSU32 idx = 0, end = subPathChildren.size(); idx < end; ++idx) { + for (QT3DSU32 idx = 0, end = subPathChildren.size(); idx < end; ++idx) DeleteInstance(subPathChildren[idx]); - } } } thePropertySystem.SetInstancePropertyValue(instance, propName, value); @@ -1512,14 +1504,15 @@ public: TDataStrPtr newValue(get<TDataStrPtr>(value)); - CFilePath docPath(m_Doc.GetDocumentPath()); - CFilePath docDir(docPath.GetDirectory()); + QString docPath(m_Doc.GetDocumentPath()); + QString docDir(QFileInfo(docPath).absolutePath()); STranslationLog log; - CFilePath theFullPathToDocument( - m_Doc.GetResolvedPathToDoc(CFilePath(newValue->GetData()))); - if (newValue && *newValue->GetData() && theFullPathToDocument.Exists()) { + QString theFullPathToDocument( + m_Doc.GetResolvedPathToDoc(QFileInfo(newValue->toQString()))); + QFileInfo info(theFullPathToDocument); + if (newValue && *newValue->GetData() && info.exists()) { std::pair<long, long> times = GetTimeRange(instance); - DoImport(theFullPathToDocument, theFullPathToDocument, + DoImport(info, theFullPathToDocument, m_AssetGraph.GetParent(instance), instance, theNewSlide, docDir, log, std::bind(CPerformImport::ImportToComposerFromImportFile, std::placeholders::_1, std::placeholders::_2), @@ -1642,18 +1635,19 @@ public: } TInstanceHandle SetInstancePropertyValueAsImage(TInstanceHandle instance, - TPropertyHandle propName, - const Q3DStudio::CString &inSourcePath) override + TPropertyHandle propName, + const QString &inSourcePath) override { - CFilePath thePath = m_Doc.GetResolvedPathToDoc(inSourcePath); - assert(thePath.IsFile()); - if (!thePath.IsFile()) + QString thePath = m_Doc.GetResolvedPathToDoc(inSourcePath); + QFileInfo info(thePath); + assert(info.isFile()); + if (!info.isFile()) return 0; Qt3DSDMSlideHandle theSlide(GetAssociatedSlide(instance)); TInstanceHandle theImageInstance = CreateImageInstanceForMaterialOrLayer(instance, propName); - TDataStrPtr thePtrPath(new CDataStr(inSourcePath, inSourcePath.size())); + TDataStrPtr thePtrPath(new CDataStr(inSourcePath)); SetInstancePropertyValue(instance, propName, thePtrPath); return theImageInstance; @@ -1661,9 +1655,10 @@ public: virtual TInstanceHandle SetInstancePropertyValueAsRenderable(TInstanceHandle instance, TPropertyHandle propName, - const Q3DStudio::CString &inSourcePath) override + const QString &inSourcePath) override { - CFilePath thePath = m_Doc.GetResolvedPathToDoc(inSourcePath); + QString thePath = m_Doc.GetResolvedPathToDoc(inSourcePath); + QFileInfo info(thePath); // Delete any existing renderable object children. vector<TInstanceHandle> childrenToDelete; for (long idx = 0, end = m_AssetGraph.GetChildCount(instance); idx < end; ++idx) { @@ -1685,24 +1680,24 @@ public: bool parentEmptied = false; if (parent.Valid()) { SetInstancePropertyValue(parent, imageProperty, - std::make_shared<qt3dsdm::CDataStr>(inSourcePath.c_str()), + std::make_shared<qt3dsdm::CDataStr>(inSourcePath), true); // Setting the parent image property to empty will delete the image child, // so we should skip setting the property there - if (inSourcePath.IsEmpty()) + if (inSourcePath.isEmpty()) parentEmptied = true; } if (!parentEmptied) { SetInstancePropertyValue(instance, propName, - std::make_shared<qt3dsdm::CDataStr>(inSourcePath.c_str()), + std::make_shared<qt3dsdm::CDataStr>(inSourcePath), true); } } else if (m_Bridge.IsLayerInstance(instance) && m_Bridge.GetSourcePathProperty() == propName - && !inSourcePath.IsEmpty()) { + && !inSourcePath.isEmpty()) { // Resize the layer to be the size of the presentation - QSize presSize(g_StudioApp.getRenderableSize(inSourcePath.toQString())); + QSize presSize(g_StudioApp.getRenderableSize(inSourcePath)); auto &layer = m_Bridge.GetLayer(); // Determine if width and height properties are visible @@ -1765,18 +1760,18 @@ public: SetInstancePropertyValue(instance, layer.m_Bottom, bottom, true); } SetInstancePropertyValue(instance, propName, - std::make_shared<qt3dsdm::CDataStr>(inSourcePath.c_str()), + std::make_shared<qt3dsdm::CDataStr>(inSourcePath), true); } else { SetInstancePropertyValue(instance, propName, - std::make_shared<qt3dsdm::CDataStr>(inSourcePath.c_str()), + std::make_shared<qt3dsdm::CDataStr>(inSourcePath), true); } // If this is a render plugin - if (thePath.Exists() && thePath.GetExtension().CompareNoCase("plugin")) { + if (info.exists() && info.suffix() == QLatin1String("plugin")) { Qt3DSDMSlideHandle theSlide(GetAssociatedSlide(instance)); - return LoadRenderPlugin(thePath, instance, theSlide, + return LoadRenderPlugin(info.canonicalFilePath(), instance, theSlide, DocumentEditorInsertType::LastChild, -1); } return TInstanceHandle(); @@ -1791,7 +1786,7 @@ public: * @param pId the presentation Id to set for the texture */ void setInstanceImagePropertyValueAsRenderable(TInstanceHandle instance, TPropertyHandle prop, - const CString &pId) override + const QString &pId) override { Qt3DSDMPropertyHandle img = GetImageInstanceForProperty(instance, prop); @@ -1809,7 +1804,7 @@ public: * @param pos add position in the scene * @param startTime add at this start time */ - void addRectForSubpresentation(const CString &pId, TSlideHandle slide, const CPt &pos = CPt(), + void addRectForSubpresentation(const QString &pId, TSlideHandle slide, const CPt &pos = CPt(), long startTime = -1) override { qt3dsdm::Qt3DSDMPropertyHandle activeLayer = m_Doc.GetActiveLayer(); @@ -1835,7 +1830,7 @@ public: } void SetMaterialType(TInstanceHandle instance, - const Q3DStudio::CString &inRelativePathToMaterialFile) override + const QString &inRelativePathToMaterialFile) override { if (m_Bridge.GetSourcePath(instance) == inRelativePathToMaterialFile) return; @@ -1846,7 +1841,7 @@ public: // Keep material names the same so that if you change the material type // any relative path links will still work. // Next bug is harder (keep id's the same). - Q3DStudio::CString theName = GetName(instance); + QString theName = GetName(instance); SLong4 theGuid = m_Bridge.GetInstanceGUID(instance); TInstanceHandle nextChild = m_AssetGraph.GetSibling(instance, true); // Now get all the actions on the material and re-add them. @@ -1883,7 +1878,7 @@ public: newMaterial = CreateSceneGraphInstance(ComposerObjectTypes::ReferencedMaterial, model, theSlide, instance); else { - CFilePath thePath = m_Doc.GetResolvedPathToDoc(inRelativePathToMaterialFile); + QString thePath = m_Doc.GetResolvedPathToDoc(QFileInfo(inRelativePathToMaterialFile)); newMaterial = LoadCustomMaterial(thePath, model, theSlide, DocumentEditorInsertType::LastChild, 0, instance); } @@ -1934,10 +1929,10 @@ public: + materialName + QStringLiteral(".matdata"); } - Q3DStudio::CString writeMaterialFile(Qt3DSDMInstanceHandle instance, - const QString &materialName, - bool createNewFile, - const QString &sourcePath = {}) override + QString writeMaterialFile(Qt3DSDMInstanceHandle instance, + const QString &materialName, + bool createNewFile, + const QString &sourcePath = {}) override { EStudioObjectType type = m_Bridge.GetObjectType(instance); @@ -1954,11 +1949,10 @@ public: QFile file(actualSourcePath); if ((createNewFile && !file.exists()) || (!createNewFile && file.exists())) saveMaterial(instance, file); - return CString::fromQString( - m_Doc.GetRelativePathToDoc(QFileInfo(actualSourcePath))); + return m_Doc.GetRelativePathToDoc(QFileInfo(actualSourcePath)); } - return ""; + return {}; } void writeProperty(QFile &file, const QString &name, const QString &value, int indent = 1) @@ -2007,7 +2001,7 @@ public: qt3dsdm::TPropertyHandleList propList; m_PropertySystem.GetAggregateInstanceProperties(instance, propList); for (auto &prop : propList) { - const auto name = QString::fromWCharArray(m_PropertySystem.GetName(prop).wide_str()); + const auto name = m_PropertySystem.GetName(prop); if (!isSaveableMaterialProperty(name)) continue; @@ -2025,7 +2019,7 @@ public: if (guid.Valid()) { auto ref = m_Bridge.GetInstanceByGUID(guid); textureHandles[name] = ref; - path = m_Bridge.GetSourcePath(ref).toQString(); + path = m_Bridge.GetSourcePath(ref); } else { valid = false; } @@ -2054,8 +2048,7 @@ public: propList.clear(); m_PropertySystem.GetAggregateInstanceProperties(handle, propList); for (auto &prop : propList) { - const auto name = QString::fromWCharArray( - m_PropertySystem.GetName(prop).wide_str()); + const auto name = m_PropertySystem.GetName(prop); if (!isSaveableMaterialProperty(name)) continue; @@ -2091,7 +2084,7 @@ public: QString getMaterialContainerParentPath() const { - return GetName(m_Doc.GetSceneInstance()).toQString(); + return GetName(m_Doc.GetSceneInstance()); } QString getMaterialContainerPath() const @@ -2105,7 +2098,7 @@ public: Qt3DSDMInstanceHandle instance; CRelativePathTools::EPathType type; objRefHelper->ResolvePath(m_Doc.GetSceneInstance(), - CString::fromQString(getMaterialContainerPath()), + getMaterialContainerPath(), type, instance, true); return instance; } @@ -2118,7 +2111,7 @@ public: Qt3DSDMInstanceHandle parent; CRelativePathTools::EPathType type; objRefHelper->ResolvePath(m_Doc.GetSceneInstance(), - CString::fromQString(getMaterialContainerParentPath()), + getMaterialContainerParentPath(), type, parent, true); if (!parent.Valid()) parent = m_Doc.GetSceneInstance(); @@ -2126,17 +2119,17 @@ public: instance = CreateSceneGraphInstance(ComposerObjectTypes::Material, parent, slide, DocumentEditorInsertType::LastChild, CPt(), PRIMITIVETYPE_UNKNOWN, -1); - SetName(instance, CString::fromQString(getMaterialContainerName())); + SetName(instance, getMaterialContainerName()); SetTimeRange(instance, 0, 0); } return instance; } - Qt3DSDMInstanceHandle getMaterial(const Q3DStudio::CString &materialName) override + Qt3DSDMInstanceHandle getMaterial(const QString &materialName) override { IObjectReferenceHelper *objRefHelper = m_Doc.GetDataModelObjectReferenceHelper(); QString name = getMaterialContainerPath() + QStringLiteral(".") - + materialName.toQString().replace(QLatin1String("."), QLatin1String("\\.")); + + QString(materialName).replace(QLatin1String("."), QLatin1String("\\.")); Qt3DSDMInstanceHandle material; CRelativePathTools::EPathType type; objRefHelper->ResolvePath(m_Doc.GetSceneInstance(), @@ -2145,7 +2138,7 @@ public: return material; } - Qt3DSDMInstanceHandle getOrCreateMaterial(const Q3DStudio::CString &materialName) override + Qt3DSDMInstanceHandle getOrCreateMaterial(const QString &materialName) override { auto material = getMaterial(materialName); if (!material.Valid()) { @@ -2171,11 +2164,11 @@ public: } void setMaterialProperties(TInstanceHandle instance, const QString &materialName, - const Q3DStudio::CString &materialSourcePath, + const QString &materialSourcePath, const QMap<QString, QString> &values, const QMap<QString, QMap<QString, QString>> &textureValues) override { - setMaterialReferenceByName(instance, Q3DStudio::CString::fromQString(materialName)); + setMaterialReferenceByName(instance, materialName); setMaterialSourcePath(instance, materialSourcePath); setMaterialValues(materialName, values, textureValues); } @@ -2193,7 +2186,7 @@ public: } void setMaterialReferenceByName(TInstanceHandle instance, - const Q3DStudio::CString &materialName) override + const QString &materialName) override { Qt3DSDMInstanceHandle material = getOrCreateMaterial(materialName); IObjectReferenceHelper *objRefHelper = m_Doc.GetDataModelObjectReferenceHelper(); @@ -2206,7 +2199,7 @@ public: } void setMaterialSourcePath(TInstanceHandle instance, - const Q3DStudio::CString &materialSourcePath) override + const QString &materialSourcePath) override { SetInstancePropertyValue(instance, m_Bridge.GetSceneAsset().m_SourcePath, std::make_shared<CDataStr>(materialSourcePath)); @@ -2216,7 +2209,7 @@ public: const QMap<QString, QString> &values, const QMap<QString, QMap<QString, QString>> &textureValues) override { - auto instance = getOrCreateMaterial(Q3DStudio::CString::fromQString(materialName)); + auto instance = getOrCreateMaterial(materialName); if (instance.Valid()) setMaterialValues(instance, values, textureValues); } @@ -2238,8 +2231,8 @@ public: if (!isSaveableMaterialProperty(i.key())) continue; - TCharStr propName(i.key().toStdWString().c_str()); - Q3DStudio::CString propString = Q3DStudio::CString::fromQString(i.value()); + QString propName(i.key()); + QString propString = i.value(); Qt3DSDMPropertyHandle prop = m_PropertySystem.GetAggregateInstancePropertyByName( instance, propName); @@ -2314,12 +2307,9 @@ public: if (values.contains(QStringLiteral("type"))) { if (values[QStringLiteral("type")] == QLatin1String("CustomMaterial") && values.contains(QStringLiteral("sourcepath"))) { - SetMaterialType(instance, Q3DStudio::CString::fromQString( - values[QStringLiteral("sourcepath")])); - if (values.contains(QStringLiteral("name"))) { - SetName(instance, Q3DStudio::CString::fromQString( - values[QStringLiteral("name")])); - } + SetMaterialType(instance, values[QStringLiteral("sourcepath")]); + if (values.contains(QStringLiteral("name"))) + SetName(instance, values[QStringLiteral("name")]); } } @@ -2402,7 +2392,7 @@ public: m_PropertySystem.GetAggregateInstanceProperties(src, propList); for (auto &prop : propList) { - const auto name = QString::fromWCharArray(m_PropertySystem.GetName(prop).wide_str()); + const auto name = m_PropertySystem.GetName(prop); if (!isSaveableMaterialProperty(name)) continue; @@ -2670,12 +2660,12 @@ public: } } - void SetTimebarColor(TInstanceHandle inInstance, ::CColor inColor) override + void SetTimebarColor(TInstanceHandle inInstance, const QColor &inColor) override { m_PropertySystem.SetInstancePropertyValue( inInstance, m_Bridge.GetSceneAsset().m_TimebarColor, - qt3dsdm::SFloat3(inColor.GetRed() / 255.0f, inColor.GetGreen() / 255.0f, - inColor.GetBlue() / 255.0f)); + qt3dsdm::SFloat3(inColor.redF(), inColor.greenF(), + inColor.blueF())); } void SetTimebarText(TInstanceHandle inInstance, const Q3DStudio::CString &inComment) override @@ -2748,7 +2738,7 @@ public: virtual Qt3DSDMAnimationHandle CreateOrSetAnimation(Qt3DSDMSlideHandle inSlide, Qt3DSDMInstanceHandle instance, - const wchar_t *propName, long subIndex, EAnimationType animType, + const QString &propName, long subIndex, EAnimationType animType, const float *keyframeValues, long numValues, bool /*inUserEdited*/) override { Qt3DSDMPropertyHandle propHdl = @@ -2802,7 +2792,7 @@ public: return animHandle; } bool RemoveAnimation(Qt3DSDMSlideHandle inSlide, Qt3DSDMInstanceHandle instance, - const wchar_t *propName, long subIndex) override + const QString &propName, long subIndex) override { Qt3DSDMPropertyHandle propHdl = m_DataCore.GetAggregateInstancePropertyByName(instance, propName); @@ -2848,28 +2838,28 @@ public: return inInstance; } - CString GetName(Qt3DSDMInstanceHandle inInstance) const override + QString GetName(Qt3DSDMInstanceHandle inInstance) const override { Option<SValue> theValue = GetInstancePropertyValue( inInstance, m_Bridge.GetObjectDefinitions().m_Named.m_NameProp); if (theValue.hasValue()) { TDataStrPtr theNamePtr(get<TDataStrPtr>(*theValue)); if (theNamePtr) - return theNamePtr->GetData(); + return theNamePtr->toQString(); } - return L""; + return {}; } - CString GetSourcePath(Qt3DSDMInstanceHandle inInstance) const override + QString GetSourcePath(Qt3DSDMInstanceHandle inInstance) const override { Option<SValue> theValue = GetInstancePropertyValue( inInstance, m_Bridge.GetObjectDefinitions().m_Asset.m_SourcePath); if (theValue.hasValue()) { TDataStrPtr theNamePtr(get<TDataStrPtr>(*theValue)); if (theNamePtr) - return theNamePtr->GetData(); + return theNamePtr->toQString(); } - return L""; + return {}; } TInstanceHandle GetFirstBaseClass(Qt3DSDMInstanceHandle inInstance) const override @@ -2881,15 +2871,16 @@ public: return 0; } - void SetName(Qt3DSDMInstanceHandle inInstance, const CString &inName, + void SetName(Qt3DSDMInstanceHandle inInstance, const QString &inName, bool inMakeUnique = false) override { - CString theUniqueName = inName; + QString theUniqueName = inName; if (inMakeUnique) - theUniqueName = m_Bridge.GetUniqueChildName(GetParent(inInstance), inInstance, inName); + theUniqueName = m_Bridge.GetUniqueChildName(GetParent(inInstance), inInstance, + inName); SetInstancePropertyValue(inInstance, m_Bridge.GetNameProperty(), - std::make_shared<CDataStr>(theUniqueName.c_str()), false); + std::make_shared<CDataStr>(theUniqueName), false); } TInstanceHandleList DoPasteSceneGraphObject(std::shared_ptr<IDOMReader> inReader, @@ -2916,7 +2907,7 @@ public: return retval; } - TInstanceHandleList PasteSceneGraphObject(const CFilePath &inFilePath, + TInstanceHandleList PasteSceneGraphObject(const QString &inFilePath, TInstanceHandle inNewRoot, bool inGenerateUniqueName, DocumentEditorInsertType::Enum inInsertType, @@ -2924,7 +2915,7 @@ public: { qt3ds::QT3DSI32 theVersion = 0; std::shared_ptr<IDOMReader> theReader = m_Doc.CreateDOMReader( - inFilePath.toCString(), theVersion); + inFilePath, theVersion); if (!theReader) return TInstanceHandleList(); return DoPasteSceneGraphObject(theReader, inNewRoot, inGenerateUniqueName, inInsertType, @@ -2932,13 +2923,13 @@ public: } virtual TInstanceHandleList - PasteSceneGraphObjectMaster(const CFilePath &inFilePath, TInstanceHandle inNewRoot, + PasteSceneGraphObjectMaster(const QString &inFilePath, TInstanceHandle inNewRoot, bool inGenerateUniqueName, DocumentEditorInsertType::Enum inInsertType, const CPt &inPosition) override { qt3ds::QT3DSI32 theVersion = 0; std::shared_ptr<IDOMReader> theReader = m_Doc.CreateDOMReader( - inFilePath.toCString(), theVersion); + inFilePath, theVersion); if (!theReader) return TInstanceHandleList(); @@ -3037,15 +3028,12 @@ public: if (inInsertType == DocumentEditorInsertType::NextSibling) theInstance = sortableList[end - idx - 1]; // Rename if the new parent already has object with a same name - CString currName = m_Bridge.GetName(theInstance); + QString currName = m_Bridge.GetName(theInstance); if (checkUniqueName) { if (!m_Bridge.CheckNameUnique(theParent, theInstance, currName)) { - CString newName = m_Bridge.GetUniqueChildName(theParent, theInstance, - currName); - if (notifyRename) { - m_Doc.getMoveRenameHandler()->displayMessageBox(currName.toQString(), - newName.toQString()); - } + QString newName = m_Bridge.GetUniqueChildName(theParent, theInstance, currName); + if (notifyRename) + m_Doc.getMoveRenameHandler()->displayMessageBox(currName, newName); SetName(theInstance, newName); } } @@ -3114,8 +3102,7 @@ public: // Rename the selected and to-be deleted instance so that it is less likely to cause // name clash when its children are moved to the same level - CString name = GetName(selected); - name.append("@@to_be_deleted@@"); + QString name = GetName(selected) + QLatin1String("@@to_be_deleted@@"); SetName(selected, name); // Move group's children directly below the group item @@ -3175,7 +3162,7 @@ public: // Update pivot and position updatePivotAndPosition(component, inInstances); - CString theName = GetName(theInstances[0]); + QString theName = GetName(theInstances[0]); // now cut the group std::shared_ptr<IDOMReader> theReader(CopySceneGraphObjectsToMemory(theInstances)); @@ -3261,14 +3248,12 @@ public: // Check for name uniqueness if (checkUniqueName) { for (auto instance : insertedHandles) { - CString currName = m_Bridge.GetName(instance); + QString currName = m_Bridge.GetName(instance); if (!m_Bridge.CheckNameUnique(targetComponent, instance, currName)) { - CString newName = m_Bridge.GetUniqueChildName( - targetComponent, instance, currName); - if (notifyRename) { - m_Doc.getMoveRenameHandler()->displayMessageBox(currName.toQString(), - newName.toQString()); - } + QString newName = m_Bridge.GetUniqueChildName(targetComponent, instance, + currName); + if (notifyRename) + m_Doc.getMoveRenameHandler()->displayMessageBox(currName, newName); SetName(instance, newName); } } @@ -3297,7 +3282,7 @@ public: } Qt3DSDMActionHandle AddAction(Qt3DSDMSlideHandle inSlide, Qt3DSDMInstanceHandle inOwner, - const wstring &inEvent, const wstring &inHandler) override + const QString &inEvent, const QString &inHandler) override { Q3DStudio::CId theGuid = m_Bridge.GetGUID(inOwner); Q3DStudio::TGUIDPacked thePacked(theGuid); @@ -3316,11 +3301,10 @@ public: m_ActionSystem.DeleteAction(inAction); } - Qt3DSDMActionHandle PasteAction(const CFilePath &inFilePath, - Qt3DSDMInstanceHandle inNewRoot) override + Qt3DSDMActionHandle PasteAction(const QString &inFilePath, + Qt3DSDMInstanceHandle inNewRoot) override { - QSharedPointer<QFile> theStream(openQFileStream(inFilePath.toCString(), - FileReadFlags())); + QSharedPointer<QFile> theStream(openQFileStream(inFilePath, FileReadFlags())); if (!theStream.isNull()) { QT3DS_ASSERT(false); return 0; @@ -3338,7 +3322,7 @@ public: return theSerializer->SerializeAction(*theReader, inNewRoot, GetActiveSlide(inNewRoot)); } - bool ContainsSlideByName(const CString &inName, Qt3DSDMSlideHandle inMasterSlide) + bool ContainsSlideByName(const QString &inName, Qt3DSDMSlideHandle inMasterSlide) { size_t existingCount = m_SlideSystem.GetSlideCount(inMasterSlide); for (size_t idx = 0; idx < existingCount; ++idx) { @@ -3350,24 +3334,21 @@ public: return false; } - CString GenerateUniqueSlideName(const CString &inStem, Qt3DSDMSlideHandle inMasterSlide, + QString GenerateUniqueSlideName(const QString &inStem, Qt3DSDMSlideHandle inMasterSlide, int inStartIndex) { size_t theStartIndex = inStartIndex; if (theStartIndex < 0) theStartIndex = m_SlideSystem.GetSlideCount(inMasterSlide); - CString baseName = inStem; + QString baseName = inStem; int nameIdx = (int)theStartIndex; - wchar_t nameBuf[16]; - WStrOps<int>().ToStr(nameIdx, toDataRef(nameBuf, 16)); - CString theNameStr = baseName; - theNameStr.append(nameBuf); + QString theNameStr = baseName; + theNameStr.append(QString::number(nameIdx)); while (ContainsSlideByName(theNameStr, inMasterSlide)) { ++nameIdx; - WStrOps<int>().ToStr(nameIdx, toDataRef(nameBuf, 16)); theNameStr = baseName; - theNameStr.append(nameBuf); + theNameStr.append(QString::number(nameIdx)); } return theNameStr; } @@ -3418,12 +3399,13 @@ public: Qt3DSDMSlideHandle AddSlide(Qt3DSDMSlideHandle inMasterSlide, int inIndex = -1) override { - CString theNewName = GenerateUniqueSlideName(L"Slide", inMasterSlide, inIndex); + QString theNewName = GenerateUniqueSlideName(QStringLiteral("Slide"), inMasterSlide, + inIndex); Qt3DSDMSlideHandle theNewSlide = m_SlideSystem.DuplicateSlide(inMasterSlide, inIndex); Qt3DSDMInstanceHandle newInstance(m_SlideSystem.GetSlideInstance(theNewSlide)); m_DataCore.SetInstancePropertyValue(newInstance, m_Bridge.GetObjectDefinitions().m_Named.m_NameProp, - std::make_shared<CDataStr>(theNewName.c_str())); + std::make_shared<CDataStr>(theNewName)); m_Doc.SetActiveSlideWithTransaction(theNewSlide); int newSlideIndex = m_SlideSystem.GetSlideIndex(theNewSlide); m_SlideSystem.SetActiveSlide(inMasterSlide, newSlideIndex); @@ -3481,7 +3463,8 @@ public: int theIndex = m_SlideSystem.GetSlideIndex(inSlide); std::shared_ptr<IComposerSerializer> theSerializer = m_Doc.CreateSerializer(); - CString theNewName = GenerateUniqueSlideName(L"Slide", theMaster, theIndex + 1); + QString theNewName = GenerateUniqueSlideName(QStringLiteral("Slide"), theMaster, + theIndex + 1); Qt3DSDMSlideHandle theNewSlide = theSerializer->SerializeSlide( *theReader, m_Doc.GetDocumentDirectory(), theMaster, theIndex); @@ -3489,7 +3472,7 @@ public: Qt3DSDMInstanceHandle newInstance(m_SlideSystem.GetSlideInstance(theNewSlide)); m_DataCore.SetInstancePropertyValue(newInstance, m_Bridge.GetObjectDefinitions().m_Named.m_NameProp, - std::make_shared<CDataStr>(theNewName.c_str())); + std::make_shared<CDataStr>(theNewName)); // Ensure the active slide change gets recorded in the transaction system so that // undo will place us back at the old slide before things start reading from the object @@ -3555,7 +3538,7 @@ public: for (auto &instance : children) { const auto name = GetName(instance); - writeMaterialFile(getOrCreateMaterial(name), name.toQString(), false); + writeMaterialFile(getOrCreateMaterial(name), name, false); } } @@ -3568,21 +3551,21 @@ public: for (auto &instance : children) { auto name = GetName(instance); - if (name != "Default" && !filenames.contains(name.toQString())) + if (name != QLatin1String("Default") && !filenames.contains(name)) DeleteInstance(instance); } } } TInstanceHandle DoImport( - CFilePath inImportFilePath, Q3DStudio::CString importSrc, Qt3DSDMInstanceHandle inParent, - Qt3DSDMInstanceHandle inRoot, Qt3DSDMSlideHandle inSlide, Q3DStudio::CString inDocDir, + const QFileInfo &inImportFilePath, const QString &importSrc, Qt3DSDMInstanceHandle inParent, + Qt3DSDMInstanceHandle inRoot, Qt3DSDMSlideHandle inSlide, const QString &inDocDir, STranslationLog &inTranslationLog, - function<SImportResult(IComposerEditorInterface &, Q3DStudio::CString)> inImportFunction, + function<SImportResult(IComposerEditorInterface &, QString)> inImportFunction, DocumentEditorInsertType::Enum inInsertType, const CPt &inPosition, long inStartTime) { - CFilePath outputDir(inImportFilePath.GetDirectory()); - bool alwaysKeepDirectory = outputDir.Exists(); + QString outputDir(inImportFilePath.absolutePath()); + bool alwaysKeepDirectory = !inImportFilePath.path().isEmpty(); bool keepDirectory = false; Qt3DSDMInstanceHandle theRealParent = inInsertType == DocumentEditorInsertType::LastChild ? inParent @@ -3590,27 +3573,27 @@ public: // We have to pass in the real parent to the editor interface so that object lifetimes can // be setup correctly as the import tree is being built. std::shared_ptr<IComposerEditorInterface> importToComposer = - IComposerEditorInterface::CreateEditorInterface(*this, theRealParent, inRoot, inSlide, - inDocDir, inImportFilePath, inStartTime, - m_StringTable); + IComposerEditorInterface::CreateEditorInterface( + *this, theRealParent, inRoot, inSlide, inDocDir, + inImportFilePath.absoluteFilePath(), inStartTime); CDispatch &theDispatch(*m_Doc.GetCore()->GetDispatch()); - CFilePath theDestFile(importToComposer->GetDestImportFile()); + QString theDestFile(importToComposer->GetDestImportFile()); try { - theDispatch.FireOnProgressBegin(QObject::tr("Importing "), importSrc.toQString()); + theDispatch.FireOnProgressBegin(QObject::tr("Importing "), importSrc); SImportResult result = inImportFunction(*importToComposer, theDestFile); bool forceError = importToComposer->HasError(); if (!forceError) importToComposer->Finalize(result.m_FilePath); keepDirectory = alwaysKeepDirectory || forceError == false; theDispatch.FireOnProgressEnd(); - IDocumentEditor::DisplayImportErrors(importSrc.toQString(), result.m_Error, + IDocumentEditor::DisplayImportErrors(importSrc, result.m_Error, m_Doc.GetImportFailedHandler(), inTranslationLog, forceError); if (!forceError) { Qt3DSDMInstanceHandle theImportRoot = importToComposer->GetRoot(); - CFilePath theRelPath(m_Doc.GetRelativePathToDoc(theDestFile)); - SValue theSourcePathValue(std::make_shared<CDataStr>(theRelPath.toCString())); + QString theRelPath(m_Doc.GetRelativePathToDoc(QFileInfo(theDestFile))); + SValue theSourcePathValue(std::make_shared<CDataStr>(theRelPath)); Qt3DSDMPropertyHandle theProp(m_Bridge.GetObjectDefinitions().m_Asset.m_SourcePath); if (inSlide.Valid()) m_SlideCore.ForceSetInstancePropertyValue(inSlide, theImportRoot, theProp, @@ -3622,7 +3605,7 @@ public: Qt3DSDMInstanceHandle retval = FinalizeAddOrDrop(importToComposer->GetRoot(), inParent, inInsertType, inPosition, inStartTime == -1, true, false); - SetName(retval, theRelPath.GetFileStem(), true); + SetName(retval, QFileInfo(theRelPath).baseName(), true); updateMaterialFiles(); @@ -3635,100 +3618,102 @@ public: return 0; } - TInstanceHandle ImportDAE(const Q3DStudio::CString &inFullPathToDocument, - TInstanceHandle inParent, TSlideHandle inSlide, - const Q3DStudio::CString &inImportFileExtension, - DocumentEditorInsertType::Enum inDropType, - const CPt &inPosition = CPt(), long inStartTime = -1) override + TInstanceHandle ImportDAE(const QString &inFullPathToDocument, + TInstanceHandle inParent, TSlideHandle inSlide, + const QString &inImportFileExtension, + DocumentEditorInsertType::Enum inDropType, + const CPt &inPosition = CPt(), long inStartTime = -1) override { ScopedBoolean __ignoredDirs(m_IgnoreDirChange); // If we already have an import file that points back to this DAE then we need to // not import the DAE but import the import file again. - CFilePath importSrc = CFilePath(inFullPathToDocument); - if (importSrc.Exists() == false) + QFileInfo importSrc(inFullPathToDocument); + if (importSrc.exists() == false) return 0; - CFilePath theRelativeDAE = m_Doc.GetRelativePathToDoc(importSrc); + QString theRelativeDAE = m_Doc.GetRelativePathToDoc(importSrc); - CFilePath docPath(m_Doc.GetDocumentPath()); - CFilePath docDir(docPath.GetDirectory()); + QString docPath(m_Doc.GetDocumentPath()); + QString docDir(QFileInfo(docPath).canonicalPath()); std::shared_ptr<IImportFailedHandler> theHandler(m_Doc.GetImportFailedHandler()); if (docPath.size() == 0) { - if (theHandler) - theHandler->DisplayImportFailed(importSrc.toQString(), + if (theHandler) { + theHandler->DisplayImportFailed(importSrc.filePath(), QObject::tr("Qt3DSComposer Document Has No Path"), false); + } return 0; } - if (!importSrc.IsFile()) { - if (theHandler) - theHandler->DisplayImportFailed(importSrc.toQString(), + if (!importSrc.isFile()) { + if (theHandler) { + theHandler->DisplayImportFailed(importSrc.filePath(), QObject::tr("Source File Doesn't Exist"), false); + } return 0; } - Q3DStudio::CString fname = importSrc.GetFileStem(); + QString fname = importSrc.baseName(); - CFilePath importsDir = CFilePath::CombineBaseAndRelative(docDir, CFilePath(L"Imports")); - if (importsDir.Exists() == false) - importsDir.CreateDir(true); + QString importsDir = CFilePath::CombineBaseAndRelative(docDir, QStringLiteral("Imports")); + QFileInfo importInfo(importsDir); + if (!importInfo.exists()) + CFilePath::CreateDir(importsDir, true); - CFilePath outputDir = Q3DStudio::SFileTools::FindUniqueDestDirectory(importsDir, fname); - Q3DStudio::CString outputFileName(fname + L"." + inImportFileExtension); - SColladaTranslator translator(importSrc.toQString()); + QDir outputDir = Q3DStudio::SFileTools::FindUniqueDestDirectory(importsDir, fname); + const QString outputFileName = fname + QLatin1Char('.') + inImportFileExtension; + SColladaTranslator translator(importSrc.canonicalFilePath()); TInstanceHandle retval = - DoImport(CFilePath::CombineBaseAndRelative(outputDir, outputFileName), importSrc, + DoImport(CFilePath::CombineBaseAndRelative(outputDir.canonicalPath(), outputFileName), + importSrc.absoluteFilePath(), inParent, 0, inSlide, docDir, translator.m_TranslationLog, std::bind(CPerformImport::ImportToComposer, translator, std::placeholders::_1, std::placeholders::_2), inDropType, inPosition, inStartTime); if (retval.Valid()) { - CFilePath theRelativeImport = m_Doc.GetRelativePathToDoc(outputFileName); - m_ImportFileToDAEMap.insert( - make_pair(m_StringTable.RegisterStr(theRelativeImport.toCString()), - m_StringTable.RegisterStr(theRelativeDAE.toCString()))); + QString theRelativeImport = m_Doc.GetRelativePathToDoc(outputFileName); + m_ImportFileToDAEMap.insert(theRelativeImport, theRelativeDAE); } return retval; } - TInstanceHandle LoadImportFile(const Q3DStudio::CString &inFullPathToDocument, - TInstanceHandle inParent, TSlideHandle inSlide, - DocumentEditorInsertType::Enum inDropType, - const CPt &inPosition = CPt(), long inStartTime = -1) override + TInstanceHandle LoadImportFile(const QString &inFullPathToDocument, + TInstanceHandle inParent, TSlideHandle inSlide, + DocumentEditorInsertType::Enum inDropType, + const CPt &inPosition = CPt(), long inStartTime = -1) override { ScopedBoolean __ignoredDirs(m_IgnoreDirChange); - CFilePath docPath(m_Doc.GetDocumentPath()); - CFilePath docDir(docPath.GetDirectory()); + QString docPath(m_Doc.GetDocumentPath()); + QString docDir(m_Doc.GetDocumentDirectory()); STranslationLog log; - return DoImport(inFullPathToDocument, inFullPathToDocument, inParent, 0, inSlide, docDir, - log, std::bind(CPerformImport::ImportToComposerFromImportFile, + return DoImport(inFullPathToDocument, inFullPathToDocument, inParent, 0, inSlide, + docDir, log, std::bind(CPerformImport::ImportToComposerFromImportFile, std::placeholders::_1, std::placeholders::_2), inDropType, inPosition, inStartTime); } - TInstanceHandle AutomapImage(const Q3DStudio::CString &inFullPathToDocument, - TInstanceHandle inParent, TSlideHandle inSlide, - DocumentEditorInsertType::Enum inDropType, - const CPt &inPosition = CPt(), long inStartTime = -1) override + TInstanceHandle AutomapImage(const QString &inFullPathToDocument, + TInstanceHandle inParent, TSlideHandle inSlide, + DocumentEditorInsertType::Enum inDropType, + const CPt &inPosition = CPt(), long inStartTime = -1) override { (void)inStartTime; - CFilePath imageSrc(inFullPathToDocument); + QFileInfo imageSrc(inFullPathToDocument); std::shared_ptr<IImportFailedHandler> theHandler(m_Doc.GetImportFailedHandler()); - if (!imageSrc.IsFile()) { + if (!imageSrc.isFile()) { if (theHandler) - theHandler->DisplayImportFailed(imageSrc.toQString(), + theHandler->DisplayImportFailed(imageSrc.filePath(), QObject::tr("Image File Doesn't Exist"), false); return 0; } - CFilePath relativePath = m_Doc.GetRelativePathToDoc(imageSrc); + QString relativePath = m_Doc.GetRelativePathToDoc(imageSrc); Q3DSImageTextureData theImageBuffer = - m_Doc.GetBufferCache().GetOrCreateImageBuffer(relativePath.toQString()); + m_Doc.GetBufferCache().GetOrCreateImageBuffer(relativePath); if (!theImageBuffer.m_texture) { if (theHandler) - theHandler->DisplayImportFailed(imageSrc.toQString(), + theHandler->DisplayImportFailed(imageSrc.filePath(), QObject::tr("Can't Load Image File"), false); return 0; } @@ -3747,16 +3732,16 @@ public: inSlide); CFilePath theFilePath(inFullPathToDocument); // Create the reference material - auto imageMaterial = getOrCreateMaterial(theFilePath.GetFileStem()); + auto imageMaterial = getOrCreateMaterial(theFilePath.GetFileStem().toQString()); // Load the image as the child of the reference material qt3dsdm::Qt3DSDMInstanceHandle theImageInstance = SetInstancePropertyValueAsImage( imageMaterial, m_Bridge.GetDefaultMaterial().m_DiffuseMap1, relativePath); auto sourcePath = writeMaterialFile(imageMaterial, theFilePath.GetFileStem().toQString(), true); - setMaterialReferenceByName(theMaterialInstance, theFilePath.GetFileStem()); + setMaterialReferenceByName(theMaterialInstance, theFilePath.GetFileStem().toQString()); setMaterialSourcePath(theMaterialInstance, sourcePath); - SetName(theMaterialInstance, theFilePath.GetFileStem()); + SetName(theMaterialInstance, theFilePath.GetFileStem().toQString()); if (inStartTime != -1) SetStartTime(theModelInstance, inStartTime); @@ -3769,32 +3754,32 @@ public: m_PropertySystem.SetInstancePropertyValue(theModelInstance, m_Bridge.GetNode().m_Scale, theScale); - SetName(theModelInstance, theFilePath.GetFileStem(), true); + SetName(theModelInstance, theFilePath.GetFileStem().toQString(), true); // Set the image as the property of the first diffuse map. return FinalizeAddOrDrop(theModelInstance, inParent, inDropType, inPosition, inStartTime == -1); } - TInstanceHandle LoadMesh(const Q3DStudio::CString &inFullPathToDocument, - TInstanceHandle inParent, TSlideHandle inSlide, - DocumentEditorInsertType::Enum inDropType, - const CPt &inPosition = CPt(), long inStartTime = -1) override + TInstanceHandle LoadMesh(const QString &inFullPathToDocument, + TInstanceHandle inParent, TSlideHandle inSlide, + DocumentEditorInsertType::Enum inDropType, + const CPt &inPosition = CPt(), long inStartTime = -1) override { - CFilePath imageSrc(inFullPathToDocument); + QFileInfo imageSrc(inFullPathToDocument); std::shared_ptr<IImportFailedHandler> theHandler(m_Doc.GetImportFailedHandler()); - if (!imageSrc.IsFile()) { + if (!imageSrc.isFile()) { if (theHandler) - theHandler->DisplayImportFailed(imageSrc.toQString(), + theHandler->DisplayImportFailed(imageSrc.filePath(), QObject::tr("Source File Doesn't Exist"), false); return 0; } - Q3DStudio::CString theRelativePath(m_Doc.GetRelativePathToDoc(inFullPathToDocument)); + QString theRelativePath(m_Doc.GetRelativePathToDoc(imageSrc)); SModelBufferAndPath theModelBuffer = - m_Doc.GetBufferCache().GetOrCreateModelBuffer(theRelativePath.toQString()); + m_Doc.GetBufferCache().GetOrCreateModelBuffer(theRelativePath); if (!theModelBuffer.m_modelBuffer) { if (theHandler) - theHandler->DisplayImportFailed(imageSrc.toQString(), + theHandler->DisplayImportFailed(imageSrc.filePath(), QObject::tr("Could Not Load Model Buffer"), false); return 0; } @@ -3813,23 +3798,12 @@ public: CheckMeshSubsets(theModelInstance, m_Bridge.GetSourcePathProperty()); - SetName(theModelInstance, imageSrc.GetFileStem(), true); + SetName(theModelInstance, imageSrc.baseName(), true); return FinalizeAddOrDrop(theModelInstance, inParent, inDropType, inPosition, inStartTime == -1); } - static void *l_alloc(void *ud, void *ptr, size_t osize, size_t nsize) - { - (void)ud; - (void)osize; /* not used */ - if (nsize == 0) { - free(ptr); - return NULL; - } else - return realloc(ptr, nsize); - } - QString LoadScriptFile(const CFilePath &inFile) { QString retval; @@ -3889,10 +3863,8 @@ public: break; } - if (inWarnings[idx].m_ExtraInfo.size()) { - theMessageStr.append(" "); - theMessageStr.append(QString::fromStdWString(inWarnings[idx].m_ExtraInfo.wide_str())); - } + if (inWarnings[idx].m_ExtraInfo.size()) + theMessageStr += QLatin1Char(' ') + inWarnings[idx].m_ExtraInfo; const QString theBuffer = QStringLiteral("%1: %2\n").arg(theTypeStr).arg(theMessageStr); @@ -3922,37 +3894,36 @@ public: if (theInfo.m_CompleteType == CompleteMetaDataType::ObjectRef && GetValueType(theInfo.m_DefaultValue) == DataModelDataType::ObjectRef) { SObjectRefType theRef(get<SObjectRefType>(theInfo.m_DefaultValue)); - wstring theData; - wstring theOriginalData; + QString theData; + QString theOriginalData; if (theRef.GetReferenceType() == ObjectReferenceType::Relative) { TDataStrPtr theRefValue = get<TDataStrPtr>(theRef.m_Value); - if (theRefValue) { - theData.assign(theRefValue->GetData()); - } + if (theRefValue) + theData = theRefValue->toQString(); } theOriginalData = theData; - if (theData.find(L"Scene") == 0 || theData.size() == 0) { + if (!theData.contains(QStringLiteral("Scene")) || theData.size() == 0) { Qt3DSDMInstanceHandle currentInstance = inDynamicInstance; // Resolve this absolute reference string and override the default values // in the datacore to be this exact datatype - if (theData.find(L"Scene") == 0) { - wstring theItemName; + if (!theData.contains(QStringLiteral("Scene"))) { + QString theItemName; // Walk through the data and attempt to find each object in the asset graph // ignoring slides or anything else. - if (theData.size() > 6) - theData = theData.substr(6); + if (theData.length() > 6) + theData = theData.right(theData.length() - 6); else - theData = L""; + theData.clear(); currentInstance = m_Doc.GetSceneInstance(); while (theData.size() && currentInstance.Valid()) { - wstring::size_type thePos = theData.find(L"."); - if (thePos != wstring::npos) { - theItemName = theData.substr(0, thePos); - theData = theData.substr(thePos + 1); + int thePos = theData.indexOf(QLatin1Char('.')); + if (thePos != -1) { + theItemName = theData.left(thePos); + theData = theData.right(theData.length() - thePos + 1); } else { theItemName = theData; - theData = L""; + theData.clear(); } // Attempt to find the item in the asset graph. long theChildCount = m_AssetGraph.GetChildCount(currentInstance); @@ -3963,8 +3934,8 @@ public: ++childIdx) { Qt3DSDMInstanceHandle theChild = m_AssetGraph.GetChild(lastInstance, childIdx); - CString theName(GetName(theChild)); - if (theName.Compare(theItemName.c_str())) + QString theName(GetName(theChild)); + if (theName == theItemName) currentInstance = theChild; } } @@ -3992,16 +3963,16 @@ public: virtual Qt3DSDMInstanceHandle GetRootInstance() = 0; // returns an error if there was one. Empty string means no error. - virtual QString LoadInstanceData(const CFilePath &inAbsPath) = 0; + virtual QString LoadInstanceData(const QString &inAbsPath) = 0; virtual std::shared_ptr<IDOMReader> - ParseInstanceDefinition(const CFilePath &inFullPathToDocument, + ParseInstanceDefinition(const QString &inFullPathToDocument, std::shared_ptr<qt3dsdm::IStringTable> inStringTable, std::shared_ptr<IImportFailedHandler> inHandler, Q3DStudio::IInputStreamFactory &inInputStreamFactory) = 0; }; - virtual TInstanceHandle LoadDynamicInstance(const Q3DStudio::CString &inFullPathToDocument, + virtual TInstanceHandle LoadDynamicInstance(const QString &inFullPathToDocument, TInstanceHandle inParent, TSlideHandle inSlide, DocumentEditorInsertType::Enum inDropType, long inStartTime, @@ -4011,7 +3982,7 @@ public: ScopedBoolean __ignoredDirs(m_IgnoreDirChange); TInstanceHandleList existing; m_DataCore.GetInstancesDerivedFrom(existing, inSpecificInstance.GetRootInstance()); - CFilePath theRelativePath(m_Doc.GetRelativePathToDoc(inFullPathToDocument)); + QString theRelativePath(m_Doc.GetRelativePathToDoc(inFullPathToDocument)); TInstanceHandleList theParents; Qt3DSDMInstanceHandle theParentInstance; for (size_t idx = 0, end = existing.size(); idx < end && theParentInstance.Valid() == false; @@ -4022,7 +3993,7 @@ public: if (theParents.empty() || theParents[0] != inSpecificInstance.GetRootInstance()) continue; // Ensure this object is *directly* derived from behavior, not indirectly. - if (theRelativePath.toCString() == GetSourcePath(existing[idx])) + if (theRelativePath == GetSourcePath(existing[idx])) theParentInstance = existing[idx]; } @@ -4035,16 +4006,16 @@ public: m_DataCore.DeriveInstance(theParentInstance, inSpecificInstance.GetRootInstance()); m_DataCore.SetInstancePropertyValue( theParentInstance, m_Bridge.GetObjectDefinitions().m_Asset.m_SourcePath, - std::make_shared<CDataStr>(theRelativePath.toCString())); + std::make_shared<CDataStr>(theRelativePath)); m_DataCore.SetInstancePropertyValue( theParentInstance, m_Bridge.GetObjectDefinitions().m_Named.m_NameProp, - std::make_shared<CDataStr>(theRelativePath.GetFileStem().c_str())); + std::make_shared<CDataStr>(QFileInfo(theRelativePath).baseName())); std::vector<SMetaDataLoadWarning> theWarnings; m_MetaData.LoadInstance(*theReaderPtr, theParentInstance, - theRelativePath.GetFileStem().c_str(), theWarnings); + QFileInfo(theRelativePath).baseName(), theWarnings); QString theLoadError = inSpecificInstance.LoadInstanceData(inFullPathToDocument); - DisplayLoadWarnings(inFullPathToDocument.toQString(), theWarnings, theLoadError); + DisplayLoadWarnings(inFullPathToDocument, theWarnings, theLoadError); } } if (theParentInstance.Valid()) { @@ -4079,13 +4050,13 @@ public: return m_Editor.m_Bridge.GetObjectDefinitions().m_Behavior.m_Instance; } // returns an error if there was one. Empty string means no error. - QString LoadInstanceData(const CFilePath &inAbsPath) override + QString LoadInstanceData(const QString &inAbsPath) override { return m_Editor.LoadScriptFile(inAbsPath); } virtual std::shared_ptr<IDOMReader> - ParseInstanceDefinition(const CFilePath &inFullPathToDocument, + ParseInstanceDefinition(const QString &inFullPathToDocument, std::shared_ptr<qt3dsdm::IStringTable> inStringTable, std::shared_ptr<IImportFailedHandler> inHandler, Q3DStudio::IInputStreamFactory &inInputStreamFactory) override @@ -4095,13 +4066,13 @@ public: } }; - TInstanceHandle LoadBehavior(const Q3DStudio::CString &inFullPathToDocument, - TInstanceHandle inParent, TSlideHandle inSlide, - DocumentEditorInsertType::Enum inDropType, - long inStartTime) override + TInstanceHandle LoadBehavior(const QString &inFullPathToDocument, + TInstanceHandle inParent, TSlideHandle inSlide, + DocumentEditorInsertType::Enum inDropType, + long inStartTime) override { TInstanceHandle ret; - if (inFullPathToDocument.Find(".qml") != Q3DStudio::CString::ENDOFSTRING) { + if (inFullPathToDocument.endsWith(QStringLiteral(".qml"))) { CScriptDynamicInstanceLoader loader(*this); ret = LoadDynamicInstance(inFullPathToDocument, inParent, inSlide, inDropType, inStartTime, loader, true); @@ -4122,14 +4093,14 @@ public: return m_Editor.m_Bridge.GetObjectDefinitions().m_RenderPlugin.m_Instance; } // returns an error if there was one. Empty string means no error. - QString LoadInstanceData(const CFilePath &) override + QString LoadInstanceData(const QString &) override { // We would want to ask the render system to possibly load the dll at this point. return QString(); } virtual std::shared_ptr<IDOMReader> - ParseInstanceDefinition(const CFilePath &inFullPathToDocument, + ParseInstanceDefinition(const QString &inFullPathToDocument, std::shared_ptr<qt3dsdm::IStringTable> inStringTable, std::shared_ptr<IImportFailedHandler> inHandler, Q3DStudio::IInputStreamFactory &inInputStreamFactory) override @@ -4139,10 +4110,10 @@ public: } }; - TInstanceHandle LoadRenderPlugin(const Q3DStudio::CString &inFullPathToDocument, - TInstanceHandle inParent, TSlideHandle inSlide, - DocumentEditorInsertType::Enum inDropType, - long inStartTime) override + TInstanceHandle LoadRenderPlugin(const QString &inFullPathToDocument, + TInstanceHandle inParent, TSlideHandle inSlide, + DocumentEditorInsertType::Enum inDropType, + long inStartTime) override { CRenderPluginDynamicInstanceLoader loader(*this); TInstanceHandle retval = LoadDynamicInstance(inFullPathToDocument, inParent, inSlide, @@ -4152,31 +4123,33 @@ public: RearrangeObject(retval, m_AssetGraph.GetChild(inParent, 0), DocumentEditorInsertType::PreviousSibling); return retval; - }; + } - TInstanceHandle CreateText(const Q3DStudio::CString &inFullPathToDocument, + TInstanceHandle CreateText(const QString &inFullPathToDocument, TInstanceHandle inParent, TSlideHandle inSlide, DocumentEditorInsertType::Enum inDropType, const CPt &inPosition = CPt(), long inStartTime = -1) override { (void)inStartTime; - CFilePath theFontFile(inFullPathToDocument); + QFileInfo theFontFile(inFullPathToDocument); std::shared_ptr<IImportFailedHandler> theHandler(m_Doc.GetImportFailedHandler()); - if (!theFontFile.IsFile()) { - if (theHandler) - theHandler->DisplayImportFailed(theFontFile.toQString(), + if (!theFontFile.isFile()) { + if (theHandler) { + theHandler->DisplayImportFailed(theFontFile.fileName(), QObject::tr("Font File Doesn't Exist"), false); + } return 0; } // Get the font name of the font file - CString theFontName = m_Doc.GetProjectFontName(theFontFile); + QString theFontName = m_Doc.GetProjectFontName(theFontFile); if (theFontName.size() == 0) { - if (theHandler) - theHandler->DisplayImportFailed(theFontFile.toQString(), + if (theHandler) { + theHandler->DisplayImportFailed(theFontFile.fileName(), QObject::tr("Unable to load Font File"), false); + } return 0; } @@ -4202,13 +4175,13 @@ public: return handle; } - typedef void (IMetaData::*TDynamicObjectLoader)(const char *inShaderFile, + typedef void (IMetaData::*TDynamicObjectLoader)(const QString &inShaderFile, Qt3DSDMInstanceHandle inInstance, - const TCharStr &inName, + const QString &inName, std::vector<SMetaDataLoadWarning> &outWarnings, QFile &stream); - TInstanceHandle LoadDynamicObject(const Q3DStudio::CString &inFullPathToDocument, + TInstanceHandle LoadDynamicObject(const QString &inFullPathToDocument, TInstanceHandle inParent, TSlideHandle inSlide, DocumentEditorInsertType::Enum inDropType, long inStartTime, TDynamicObjectLoader inLoader, @@ -4218,19 +4191,19 @@ public: std::shared_ptr<IImportFailedHandler> theHandler(m_Doc.GetImportFailedHandler()); ScopedBoolean __ignoredDirs(m_IgnoreDirChange); - CFilePath theShaderFile(inFullPathToDocument); - if (theShaderFile.GetExtension() == "nvmpe") { + QFileInfo theShaderFile(inFullPathToDocument); + if (theShaderFile.suffix() == QLatin1String("nvmpe")) { // If user drag-drop nvmpe file, we find the corresponding glsl file and use it to load // the effect. - CString shaderFile = theShaderFile.toCString(); - CString newShaderFile = shaderFile.substr(0, shaderFile.Length() - 5); - newShaderFile.append("glsl"); - theShaderFile = CFilePath(newShaderFile); + QString shaderFile = inFullPathToDocument; + QString newShaderFile = shaderFile.left(shaderFile.length() - 5); + newShaderFile.append(QStringLiteral("glsl")); + theShaderFile = QFileInfo(newShaderFile); } TInstanceHandleList existing; m_DataCore.GetInstancesDerivedFrom(existing, inDerivationParent); - CFilePath theRelativePath(m_Doc.GetRelativePathToDoc(theShaderFile)); + QString theRelativePath(m_Doc.GetRelativePathToDoc(theShaderFile)); TInstanceHandleList theParents; Qt3DSDMInstanceHandle theParentInstance; for (size_t idx = 0, end = existing.size(); idx < end && theParentInstance.Valid() == false; @@ -4241,37 +4214,38 @@ public: if (theParents.empty() || theParents[0] != inDerivationParent) continue; // Ensure this object is *directly* derived from Effect, not indirectly. - if (theRelativePath.toCString() == GetSourcePath(existing[idx])) + if (theRelativePath == GetSourcePath(existing[idx])) theParentInstance = existing[idx]; } if (theParentInstance.Valid() == false) { - if (theShaderFile.Exists()) { + if (theShaderFile.exists()) { theParentInstance = m_DataCore.CreateInstance(); m_DataCore.DeriveInstance(theParentInstance, inDerivationParent); m_DataCore.SetInstancePropertyValue( theParentInstance, m_Bridge.GetObjectDefinitions().m_Asset.m_SourcePath, - std::make_shared<CDataStr>(theRelativePath.toCString())); + std::make_shared<CDataStr>(theRelativePath)); m_DataCore.SetInstancePropertyValue( theParentInstance, m_Bridge.GetObjectDefinitions().m_Named.m_NameProp, - std::make_shared<CDataStr>(theRelativePath.GetFileStem().c_str())); + std::make_shared<CDataStr>(QFileInfo(theRelativePath).baseName())); std::vector<SMetaDataLoadWarning> theWarnings; - QString shaderFile = theShaderFile.toQString(); + QString shaderFile = theShaderFile.filePath(); IRefCountedInputStream theStream( m_InputStreamFactory->getStreamForFile(shaderFile)); - (m_MetaData.*inLoader)(m_StringTable.GetNarrowStr(theRelativePath.toCString()), + (m_MetaData.*inLoader)(theRelativePath, theParentInstance, - theRelativePath.GetFileStem().c_str(), + QFileInfo(theRelativePath).baseName(), theWarnings, *theStream); DisplayLoadWarnings(shaderFile, theWarnings, QString()); } else { - if (theHandler) - theHandler->DisplayImportFailed(theShaderFile.toQString(), + if (theHandler) { + theHandler->DisplayImportFailed(theShaderFile.filePath(), QObject::tr("Unable to load Shader File"), false); + } return 0; } } @@ -4289,27 +4263,27 @@ public: return FinalizeAddOrDrop(retval, inParent, inDropType, CPt(), inStartTime == -1); } - TInstanceHandle LoadEffect(const Q3DStudio::CString &inFullPathToDocument, - TInstanceHandle inParent, TSlideHandle inSlide, - DocumentEditorInsertType::Enum inDropType, long inStartTime) override + TInstanceHandle LoadEffect(const QString &inFullPathToDocument, + TInstanceHandle inParent, TSlideHandle inSlide, + DocumentEditorInsertType::Enum inDropType, long inStartTime) override { return LoadDynamicObject(inFullPathToDocument, inParent, inSlide, inDropType, inStartTime, &IMetaData::LoadEffectInstance, m_Bridge.GetObjectDefinitions().m_Effect.m_Instance); } - TInstanceHandle LoadCustomMaterial(const Q3DStudio::CString &inFullPathToDocument, - TInstanceHandle inParent, TSlideHandle inSlide, - DocumentEditorInsertType::Enum inDropType, - long inStartTime, - TInstanceHandle inTargetId = TInstanceHandle()) override + TInstanceHandle LoadCustomMaterial(const QString &inFullPathToDocument, + TInstanceHandle inParent, TSlideHandle inSlide, + DocumentEditorInsertType::Enum inDropType, + long inStartTime, + TInstanceHandle inTargetId = TInstanceHandle()) override { return LoadDynamicObject(inFullPathToDocument, inParent, inSlide, inDropType, inStartTime, &IMetaData::LoadMaterialInstance, m_Bridge.GetObjectDefinitions().m_CustomMaterial.m_Instance, inTargetId); } - +#if RUNTIME_SPLIT_TEMPORARILY_REMOVED static void eatspace(const char8_t *str) { while (!isTrivial(str) && *str == ' ') { @@ -4320,7 +4294,7 @@ public: void SetUniqueName(TInstanceHandle inItem, const char8_t *inNameBase, eastl::vector<Q3DStudio::CString> &inExistingNames) { - Q3DStudio::CString theName(inNameBase); + QString theName(inNameBase); QT3DSU32 idx = 1; while (eastl::find(inExistingNames.begin(), inExistingNames.end(), theName) != inExistingNames.end()) { @@ -4335,7 +4309,7 @@ public: inExistingNames.push_back(theName); } - virtual TInstanceHandle LoadPathBuffer(const Q3DStudio::CString &inFullPathToDocument, + virtual TInstanceHandle LoadPathBuffer(const QString &inFullPathToDocument, TInstanceHandle inParent, TSlideHandle inSlide, DocumentEditorInsertType::Enum inDropType, long inStartTime) @@ -4363,13 +4337,13 @@ public: FinalizeAddOrDrop(retval, inParent, inDropType, CPt(), inStartTime == -1, false); return retval; } - +#endif TInstanceHandle ImportFile(DocumentEditorFileType::Enum inFileType, - const Q3DStudio::CString &inFullPathToDocument, - TInstanceHandle inParent, TSlideHandle inSlide, - const Q3DStudio::CString &inImportFileExtension, - DocumentEditorInsertType::Enum inDropType, - const CPt &inPosition = CPt(), long inStartTime = -1) override + const QString &inFullPathToDocument, + TInstanceHandle inParent, TSlideHandle inSlide, + const QString &inImportFileExtension, + DocumentEditorInsertType::Enum inDropType, + const CPt &inPosition = CPt(), long inStartTime = -1) override { std::shared_ptr<IImportFailedHandler> theHandler(m_Doc.GetImportFailedHandler()); switch (inFileType) { @@ -4396,10 +4370,10 @@ public: return LoadCustomMaterial(inFullPathToDocument, inParent, inSlide, inDropType, inStartTime); default: { - if (theHandler) - theHandler->DisplayImportFailed(inFullPathToDocument.toQString(), - QObject::tr("Unsupported Document Editor Type (at this time!)"), - false); + if (theHandler) { + theHandler->DisplayImportFailed(inFullPathToDocument, + QObject::tr("Unsupported Document Editor Type (at this time!)"), false); + } break; } } @@ -4409,11 +4383,11 @@ public: void DepthFirstAddImportChildren(TSlideHandle inSlide, TInstanceHandle inInstance, TIdMultiMap &inMap, std::unordered_set<int> &ioAddedChildren) { - TCharPtr theId = m_StringTable.RegisterStr(GetImportId(inInstance).c_str()); - if (!IsTrivial(theId) && m_SlideSystem.GetAssociatedSlide(inInstance) == inSlide) { - pair<TIdMultiMap::iterator, bool> theResult = - inMap.insert(make_pair(theId, vector<pair<TSlideHandle, TInstanceHandle>>())); - insert_unique(theResult.first->second, make_pair(inSlide, inInstance)); + QString theId = GetImportId(inInstance); + if (!theId.isEmpty() && m_SlideSystem.GetAssociatedSlide(inInstance) == inSlide) { + TIdMultiMap::iterator theResult = + inMap.insert(theId, QVector<QPair<TSlideHandle, TInstanceHandle>>()); + insert_unique_qt(*theResult, QPair<TSlideHandle, TInstanceHandle>(inSlide, inInstance)); ioAddedChildren.insert(inInstance); } @@ -4425,10 +4399,10 @@ public: // Precondition is that our source path to instance map // has all of the source-path-to-instance hooks already looked up. - void DoRefreshImport(const CFilePath &inOldFile, const CFilePath &inNewFile) + void DoRefreshImport(const QString &inOldFile, const QString &inNewFile) { ScopedBoolean __ignoredDirs(m_IgnoreDirChange); - vector<CFilePath> importFileList; + vector<QString> importFileList; // Find which import files use this dae file. for (TCharPtrToSlideInstanceMap::iterator theIter = m_SourcePathInstanceMap.begin(), @@ -4443,12 +4417,11 @@ public: == importFileList.end()) { ImportPtrOrError theImport = Import::Load(theFullPath.absoluteFilePath()); if (theImport.m_Value) { - CFilePath theSrcFile = CFilePath::CombineBaseAndRelative( - CFilePath(theImport.m_Value->GetDestDir()), - CFilePath(theImport.m_Value->GetSrcFile())); - if (theSrcFile.toCString().Compare( - inOldFile.toCString(), false)) - importFileList.push_back(theFullPath.filePath()); + QString theSrcFile = CFilePath::CombineBaseAndRelative( + theImport.m_Value->GetDestDir(), + theImport.m_Value->GetSrcFile()); + if (theSrcFile.compare(inOldFile, Qt::CaseInsensitive)) + importFileList.push_back(theFullPath.canonicalFilePath()); theImport.m_Value->Release(); } } @@ -4468,10 +4441,10 @@ public: TIdMultiMap theGroupIdMap; for (size_t importIdx = 0, end = importFileList.size(); importIdx < end; ++importIdx) { theGroupIdMap.clear(); - CFilePath theImportFilePath = importFileList[importIdx]; - CFilePath theImportRelativePath = m_Doc.GetRelativePathToDoc(theImportFilePath); + QString theImportFilePath = importFileList[importIdx]; + QString theImportRelativePath = m_Doc.GetRelativePathToDoc(theImportFilePath); TCharPtrToSlideInstanceMap::iterator theIter = - m_SourcePathInstanceMap.find(theImportRelativePath.toQString()); + m_SourcePathInstanceMap.find(theImportRelativePath); if (theIter == m_SourcePathInstanceMap.end()) continue; // First pass just build the group id entries. This avoids us copying hashtables which @@ -4486,12 +4459,11 @@ public: // For a depth first search of all children of this object *in this slide*, // if they have an import id then add them to the map. DepthFirstAddImportChildren(theSlide, theRoot, theGroupIdMap, theAddedInstances); - TIdMultiMap::iterator theGroupId = - theGroupIdMap - .insert(make_pair(m_StringTable.GetWideStr(GetImportId(theRoot)), - vector<pair<Qt3DSDMSlideHandle, Qt3DSDMInstanceHandle>>())) - .first; - insert_unique(theGroupId->second, make_pair(theSlide, theRoot)); + TIdMultiMap::iterator theGroupId + = theGroupIdMap.insert(GetImportId(theRoot), + QVector<QPair<Qt3DSDMSlideHandle, Qt3DSDMInstanceHandle>>()); + insert_unique_qt(*theGroupId, QPair<Qt3DSDMSlideHandle, Qt3DSDMInstanceHandle> + (theSlide, theRoot)); theAddedInstances.insert(theRoot); } // Since some objects may be completely free standing, we need to go through *all* @@ -4499,7 +4471,7 @@ public: // Unfortunately the first revision of the system didn't put import paths on objects so // we need both the above loop *and* to consider every object who's import path matches // out import document's relative path. - theIter = theImportPaths.find(theImportRelativePath.toQString()); + theIter = theImportPaths.find(theImportRelativePath); TSlideHandleList theAssociatedSlides; if (theIter != theImportPaths.end()) { vector<pair<Qt3DSDMSlideHandle, Qt3DSDMInstanceHandle>> &theInstances = *theIter; @@ -4512,15 +4484,14 @@ public: Qt3DSDMInstanceHandle theInstance(theInstances[freeInstanceIdx].second); GetAllAssociatedSlides(theInstance, theAssociatedSlides); TIdMultiMap::iterator theInstanceId = - theGroupIdMap - .insert( - make_pair(m_StringTable.GetWideStr(GetImportId(theInstance)), - vector<pair<Qt3DSDMSlideHandle, Qt3DSDMInstanceHandle>>())) - .first; + theGroupIdMap.insert(GetImportId(theInstance), + QVector<QPair<Qt3DSDMSlideHandle, Qt3DSDMInstanceHandle>>()); for (size_t slideIdx = 0, slideEnd = theAssociatedSlides.size(); - slideIdx < slideEnd; ++slideIdx) - insert_unique(theInstanceId->second, - make_pair(theAssociatedSlides[slideIdx], theInstance)); + slideIdx < slideEnd; ++slideIdx) { + insert_unique_qt(*theInstanceId, + QPair<Qt3DSDMSlideHandle, Qt3DSDMInstanceHandle>( + theAssociatedSlides[slideIdx], theInstance)); + } theAddedInstances.insert(theInstance); } } @@ -4529,65 +4500,64 @@ public: // OK, we have distinct maps sorted on a per-slide basis for all trees of children // of this asset. We now need to attempt to run the refresh algorithm. qt3dsimp::ImportPtrOrError theImportPtr - = qt3dsimp::Import::Load(theImportFilePath.toQString()); + = qt3dsimp::Import::Load(theImportFilePath); if (theImportPtr.m_Value == NULL) { QT3DS_ASSERT(false); continue; } - if (inNewFile.Exists() == false) { + QFileInfo newInfo(inNewFile); + if (newInfo.exists() == false) { QT3DS_ASSERT(false); continue; } + QFileInfo oldInfo(inOldFile); // Select correct translator according to file type ITranslator *translator = nullptr; STranslationLog *translationLog = nullptr; - Q3DStudio::CString newExtension(inNewFile.GetExtension()); - Q3DStudio::CString oldExtension(inOldFile.GetExtension()); - if (newExtension.Compare(CDialogs::GetWideDAEFileExtension(), - Q3DStudio::CString::ENDOFSTRING, false) - && oldExtension.Compare(CDialogs::GetWideDAEFileExtension(), - Q3DStudio::CString::ENDOFSTRING, false)) { - SColladaTranslator *colladaTranslator = new SColladaTranslator(inNewFile.toQString()); + QString newExtension(newInfo.suffix()); + QString oldExtension(oldInfo.suffix()); + if (newExtension.compare(CDialogs::GetDAEFileExtension(), Qt::CaseInsensitive) == 0 + && oldExtension.compare(CDialogs::GetDAEFileExtension(), Qt::CaseInsensitive) == 0) { + SColladaTranslator *colladaTranslator = new SColladaTranslator(inNewFile); translationLog = &(colladaTranslator->m_TranslationLog); translator = colladaTranslator; #ifdef QT_3DSTUDIO_FBX - } else if (newExtension.Compare(CDialogs::GetWideFbxFileExtension(), - Q3DStudio::CString::ENDOFSTRING, false) - && oldExtension.Compare(CDialogs::GetWideFbxFileExtension(), - Q3DStudio::CString::ENDOFSTRING, false)) { - SFbxTranslator *fbxTranslator = new SFbxTranslator(inNewFile.toQString()); + } else if (newExtension.compare(CDialogs::GetFbxFileExtension(), + Qt::CaseInsensitive) == 0 + && oldExtension.compare(CDialogs::GetFbxFileExtension(), + Qt::CaseInsensitive) == 0) { + SFbxTranslator *fbxTranslator = new SFbxTranslator(inNewFile); translationLog = &(fbxTranslator->m_TranslationLog); translator = fbxTranslator; #endif } else { STranslationLog emptyLog; - IDocumentEditor::DisplayImportErrors(inNewFile.toQString(), + IDocumentEditor::DisplayImportErrors(inNewFile, ImportErrorCodes::TranslationToImportFailed, m_Doc.GetImportFailedHandler(), emptyLog, true); continue; } std::shared_ptr<IComposerEditor> theComposer( - IComposerEditorInterface::CreateEditorInterface( - *this, theGroupIdMap, m_Doc.GetDocumentDirectory(), theImportFilePath, 0, - m_StringTable, m_AssetGraph)); + IComposerEditorInterface::CreateEditorInterface(*this, theGroupIdMap, + m_Doc.GetDocumentDirectory(), theImportFilePath, 0, m_AssetGraph)); SImportResult theImportResult = CPerformImport::RefreshToComposer( *translator, *theComposer, *theImportPtr.m_Value, theImportFilePath); - IDocumentEditor::DisplayImportErrors(inNewFile.toQString(), theImportResult.m_Error, + IDocumentEditor::DisplayImportErrors(inNewFile, theImportResult.m_Error, m_Doc.GetImportFailedHandler(), *translationLog, false); } } - void RefreshImport(const CFilePath &inOldFile, const CFilePath &inNewFile) override + void RefreshImport(const QString &inOldFile, const QString &inNewFile) override { CDispatch &theDispatch(*m_Doc.GetCore()->GetDispatch()); theDispatch.FireOnProgressBegin( - QObject::tr("Refreshing Import "), inOldFile.toQString()); + QObject::tr("Refreshing Import "), inOldFile); ScopedBoolean __ignoredDirs(m_IgnoreDirChange); try { m_SourcePathInstanceMap.clear(); @@ -4652,28 +4622,28 @@ public: return cleanedSome; } - +#if RUNTIME_SPLIT_TEMPORARILY_REMOVED void ExternalizePath(TInstanceHandle path) override { - CFilePath thePathsDirectory( - CFilePath::CombineBaseAndRelative(m_Doc.GetDocumentDirectory(), L"paths")); - thePathsDirectory.CreateDir(true); - Q3DStudio::CString theName = GetName(path); - CFilePath theTargetFileName(CFilePath::CombineBaseAndRelative(thePathsDirectory, theName)); - theTargetFileName.setFile(theTargetFileName.filePath() + ".path"); - if (theTargetFileName.Exists()) { - CString targetFile = theTargetFileName.toCString(); - CFilePath tempPath(targetFile.substr(0, targetFile.size() - 5)); + QString thePathsDirectory( + CFilePath::CombineBaseAndRelative(m_Doc.GetDocumentDirectory(), + QStringLiteral("paths"))); + CFilePath::CreateDir(thePathsDirectory, true); + QString theName = GetName(path); + QString theTargetFileName(CFilePath::CombineBaseAndRelative(thePathsDirectory, theName)); + theTargetFileName.append(QLatin1String(".path")); + QFileInfo info(theTargetFileName); + if (info.exists()) { + QString targetFileStem = theTargetFileName.left(theTargetFileName.length() - 5); + QString targetFile; QT3DSU32 index = 1; do { - wchar_t buffer[64]; - swprintf(buffer, 64, L"%d", index); - tempPath.setFile( - tempPath.filePath() + "_" + QString::fromWCharArray(buffer)); + targetFile = QStringLiteral("%1_%2%3").arg(targetFileStem) + .arg(index).arg(QStringLiteral(".path")); ++index; - } while (tempPath.Exists()); - theTargetFileName = tempPath; - theTargetFileName.setFile(theTargetFileName.filePath() + ".path"); + info = QFileInfo(targetFile); + } while (info.exists()); + theTargetFileName = targetFile; } NVScopedRefCounted<IPathBufferBuilder> theBuilder( IPathBufferBuilder::CreateBuilder(*this->m_Foundation.m_Foundation)); @@ -4876,7 +4846,7 @@ public: theLoadedBuffer->Free(m_Foundation.m_Foundation->getAllocator()); #endif } - +#endif void ReplaceTextFontNameWithTextFileStem(qt3ds::render::ITextRenderer &inRenderer) override { TInstanceHandleList theTextInstances; @@ -4964,33 +4934,28 @@ public: { for (size_t fileIdx = 0, fileEnd = inList.size(); fileIdx < fileEnd; ++fileIdx) { const SFileModificationRecord &theRecord(inList[fileIdx]); - CString theExtension = theRecord.m_File.GetExtension(); - bool isImport = theExtension.Compare(L"import", CString::ENDOFSTRING, false); - CFilePath theRelativePath(m_Doc.GetRelativePathToDoc(theRecord.m_File)); + QString theExtension = theRecord.m_File.suffix(); + bool isImport = theExtension.compare(QLatin1String("import"), Qt::CaseInsensitive) == 0; + QString theRelativePath(m_Doc.GetRelativePathToDoc(theRecord.m_File)); if (theRecord.m_ModificationType == FileModificationType::InfoChanged || theRecord.m_ModificationType == FileModificationType::Destroyed) { if (isImport) - m_ImportFileToDAEMap.erase(theRelativePath.toCString()); + m_ImportFileToDAEMap.erase(m_ImportFileToDAEMap.find(theRelativePath)); continue; } if (isImport) { qt3dsimp::ImportPtrOrError theImportPtr - = qt3dsimp::Import::Load(theRecord.m_File.toQString()); + = qt3dsimp::Import::Load(theRecord.m_File.canonicalFilePath()); if (theImportPtr.m_Value) { - CFilePath theDestDir = theImportPtr.m_Value->GetDestDir(); - CFilePath theSrcFile = theImportPtr.m_Value->GetSrcFile(); - CFilePath theFullSrcPath = - CFilePath::CombineBaseAndRelative(theDestDir, theSrcFile); - TCharPtr theDAERelativePath = - m_StringTable.RegisterStr(m_Doc.GetRelativePathToDoc(theFullSrcPath)); - pair<unordered_map<TCharPtr, TCharPtr>::iterator, bool> theInsertResult = - m_ImportFileToDAEMap.insert( - make_pair(m_StringTable.RegisterStr(theRelativePath.toCString()), - theDAERelativePath)); + QString theDestDir = theImportPtr.m_Value->GetDestDir(); + QString theSrcFile = theImportPtr.m_Value->GetSrcFile(); + QString theFullSrcPath + = CFilePath::CombineBaseAndRelative(theDestDir, theSrcFile); + QString theDAERelativePath = m_Doc.GetRelativePathToDoc(theFullSrcPath); + QHash<QString, QString>::iterator theInsertResult + = m_ImportFileToDAEMap.insert(theRelativePath, theDAERelativePath); theImportPtr.m_Value->Release(); - if (theInsertResult.second == false) - theInsertResult.first->second = theDAERelativePath; } } } @@ -5026,7 +4991,7 @@ public: bool requestRender = false; if (inList.size() == 1 - && m_Doc.GetDocumentPath().endsWith(inList[0].m_File.GetFileName().toQString()) + && m_Doc.GetDocumentPath().endsWith(inList[0].m_File.fileName()) && inList[0].m_ModificationType == FileModificationType::Modified) { if (!m_Doc.GetCore()->HasJustSaved()) { CDispatch &theDispatch(*m_Doc.GetCore()->GetDispatch()); @@ -5050,11 +5015,11 @@ public: for (size_t fileIdx = 0, fileEnd = inList.size(); fileIdx < fileEnd; ++fileIdx) { const SFileModificationRecord &theRecord(inList[fileIdx]); - CString theExtension = theRecord.m_File.GetExtension(); - bool isImport = theExtension.Compare(L"import", CString::ENDOFSTRING, false); - CFilePath theRelativePath(m_Doc.GetRelativePathToDoc(theRecord.m_File)); - const wchar_t *theString( - m_DataCore.GetStringTable().RegisterStr(theRelativePath.toCString())); + QString theExtension = theRecord.m_File.suffix(); + bool isImport = theExtension.compare(QLatin1String("import"), + Qt::CaseInsensitive) == 0; + QString theRelativePath(m_Doc.GetRelativePathToDoc(theRecord.m_File)); + #ifdef RUNTIME_SPLIT_TEMPORARILY_REMOVED if ((theExtension.CompareNoCase(L"ttf") || theExtension.CompareNoCase(L"otf")) // should use CDialogs::IsFontFileExtension @@ -5068,11 +5033,11 @@ public: if (theRecord.m_ModificationType == FileModificationType::InfoChanged || theRecord.m_ModificationType == FileModificationType::Destroyed) { if (isImport) - m_ImportFileToDAEMap.erase(theRelativePath.toCString()); + m_ImportFileToDAEMap.erase(m_ImportFileToDAEMap.find(theRelativePath)); continue; } - QDir modifiedPath = QDir::cleanPath(QString::fromWCharArray(theString)); + QDir modifiedPath = QDir::cleanPath(theRelativePath); TCharPtrToSlideInstanceMap::iterator theFind = m_SourcePathInstanceMap.end(); for (TCharPtrToSlideInstanceMap::iterator it = m_SourcePathInstanceMap.begin(); it != m_SourcePathInstanceMap.end(); ++it) { @@ -5092,29 +5057,24 @@ public: m_Doc.GetBufferCache().InvalidateBuffer(theRelativePath); } - qCInfo(qt3ds::TRACE_INFO) << "Change detected: " << theRelativePath.toQString() << " " + qCInfo(qt3ds::TRACE_INFO) << "Change detected: " << theRelativePath << " " << ModificationTypeToString(theRecord.m_ModificationType); if (isImport) { qt3dsimp::ImportPtrOrError theImportPtr - = qt3dsimp::Import::Load(theRecord.m_File.toQString()); + = qt3dsimp::Import::Load(theRecord.m_File.canonicalFilePath()); if (theImportPtr.m_Value) { ENSURE_PROGRESS; CFilePath theDestDir = theImportPtr.m_Value->GetDestDir(); CFilePath theSrcFile = theImportPtr.m_Value->GetSrcFile(); - CFilePath theFullSrcPath = - CFilePath::CombineBaseAndRelative(theDestDir, theSrcFile); - TCharPtr theDAERelativePath = - m_StringTable.RegisterStr(m_Doc.GetRelativePathToDoc(theFullSrcPath)); - pair<unordered_map<TCharPtr, TCharPtr>::iterator, bool> theInsertResult = - m_ImportFileToDAEMap.insert( - make_pair(m_StringTable.RegisterStr(theRelativePath.toCString()), - theDAERelativePath)); + CFilePath theFullSrcPath + = CFilePath::CombineBaseAndRelative(theDestDir, theSrcFile); + QString theDAERelativePath = m_Doc.GetRelativePathToDoc(theFullSrcPath); + QHash<QString, QString>::iterator theInsertResult + = m_ImportFileToDAEMap.insert(theRelativePath, theDAERelativePath); theImportPtr.m_Value->Release(); - if (theInsertResult.second == false) - theInsertResult.first->second = theDAERelativePath; } - } else if (theExtension.Compare(L"qml", CString::ENDOFSTRING, false) + } else if (theExtension.compare(QLatin1String("qml"), Qt::CaseInsensitive) == 0 && theRecord.m_ModificationType != FileModificationType::Created && theInstances.empty() == false) { // First, refresh the parent behavior. @@ -5139,7 +5099,7 @@ public: m_DataCore.RemoveCachedValues(theBehavior); } else { std::shared_ptr<IDOMReader> theReaderPtr; - theReaderPtr = ParseScriptFile(theRecord.m_File, + theReaderPtr = ParseScriptFile(theRecord.m_File.canonicalFilePath(), m_DataCore.GetStringTablePtr(), m_Doc.GetImportFailedHandler(), *m_InputStreamFactory); @@ -5149,27 +5109,28 @@ public: } else { std::vector<SMetaDataLoadWarning> theWarnings; m_MetaData.LoadInstance(*theReaderPtr, theBehavior, - theRelativePath.GetFileStem().c_str(), + theRelativePath, theWarnings); CScriptDynamicInstanceLoader inSpecificInstance(*this); QString theLoadError = - inSpecificInstance.LoadInstanceData(theRecord.m_File); - DisplayLoadWarnings(theRecord.m_File.toQString(), + inSpecificInstance.LoadInstanceData(theRecord.m_File + .canonicalFilePath()); + DisplayLoadWarnings(theRecord.m_File.canonicalFilePath(), theWarnings, theLoadError); } } } - } else if (theExtension.Compare(L"effect", CString::ENDOFSTRING, false) + } else if (theExtension.compare(QLatin1String("effect"), Qt::CaseInsensitive) == 0 && theRecord.m_ModificationType != FileModificationType::Created && theInstances.empty() == false) { - CString theNameStr = GetName(theInstances[0].second); + QString theNameStr = GetName(theInstances[0].second); std::vector<SMetaDataLoadWarning> theWarnings; IRefCountedInputStream theStream( - m_InputStreamFactory->getStreamForFile(theRecord.m_File.toQString())); + m_InputStreamFactory->getStreamForFile(theRecord.m_File.canonicalFilePath())); if (theStream.data()) { - m_MetaData.LoadEffectInstance(m_StringTable.GetNarrowStr(theRelativePath.toCString()), + m_MetaData.LoadEffectInstance(theRelativePath, theInstances[0].second, - TCharStr(theNameStr), + theNameStr, theWarnings, *theStream); } @@ -5200,7 +5161,7 @@ void IDocumentEditor::DisplayImportErrors(const QString &inImportSource, STranslationLog &inTranslationLog, bool inForceError) { bool isError = false; - Q3DStudio::CString resultDialogStr; + QString resultDialogStr; std::shared_ptr<IImportFailedHandler> theHandler(inHandler); if (inImportError == ImportErrorCodes::TranslationToImportFailed || inForceError) { isError = true; @@ -5208,39 +5169,39 @@ void IDocumentEditor::DisplayImportErrors(const QString &inImportSource, } for (size_t idx = 0; idx < inTranslationLog.m_Warnings.size(); ++idx) { - const std::pair<ESceneGraphWarningCode, Q3DStudio::CString> &warning( + const std::pair<ESceneGraphWarningCode, QString> &warning( inTranslationLog.m_Warnings[idx]); - const wchar_t *formatStr = L"Unrecognized warning"; + QString formatStr = QObject::tr("Unrecognized warning"); switch (warning.first) { case ESceneGraphWarningCode_OnlySupportTriangles: - formatStr = L"Model %ls contains geometric elements other than triangles"; + formatStr = QObject::tr("Model %1 contains geometric elements other than triangles"); + formatStr = formatStr.arg(warning.second); break; case ESceneGraphWarningCode_TrianglesDuplicateSemantic: - formatStr = L"Triangle contains duplicate semantics, ex: 1 triangle has multiple " - L"TEXCOORD (multiple UV maps)"; + formatStr = QObject::tr("Triangle contains duplicate semantics, ex: 1 triangle " \ + "has multiple TEXCOORD (multiple UV maps)"); break; case ESceneGraphWarningCode_MissingSourceFile: - formatStr = L"Couldn't find a source image file %ls"; + formatStr = QObject::tr("Couldn't find a source image file %1"); + formatStr = formatStr.arg(warning.second); break; case ESceneGraphWarningCode_LockedDestFile: - formatStr = L"An image or mesh file %ls is not writeable"; + formatStr = QObject::tr("An image or mesh file %ls is not writeable"); break; case ESceneGraphWarningCode_VertexBufferTooLarge: - formatStr = L"A single mesh exceeds the maximum vertex count of 65535"; + formatStr = QObject::tr("A single mesh exceeds the maximum vertex count of 65535"); break; default: break; } - wchar_t buf[1024] = { 0 }; - swprintf(buf, 1024, formatStr, warning.second.c_str()); if (resultDialogStr.size()) - resultDialogStr.append('\n'); - resultDialogStr.append(buf); + resultDialogStr += QLatin1Char('\n'); + resultDialogStr += formatStr; } if (resultDialogStr.size()) { if (theHandler) - theHandler->DisplayImportFailed(inImportSource, resultDialogStr.toQString(), !isError); + theHandler->DisplayImportFailed(inImportSource, resultDialogStr, !isError); } } @@ -5267,14 +5228,14 @@ void IDocumentEditor::UnlinkAlwaysUnlinkedProperties(Qt3DSDMInstanceHandle inIns } Qt3DSDMInstanceHandle IDocumentEditor::CreateSceneGraphInstance( - const wchar_t *inType, TInstanceHandle inParent, TSlideHandle inSlide, + const QString &inType, TInstanceHandle inParent, TSlideHandle inSlide, qt3dsdm::IDataCore &inDataCore, qt3dsdm::ISlideSystem &inSlideSystem, qt3dsdm::SComposerObjectDefinitions &inObjectDefs, Q3DStudio::CGraph &inAssetGraph, qt3dsdm::IMetaData &inMetaData, TInstanceHandle inTargetId, bool setTimeRange) { - return CreateSceneGraphInstance(inMetaData.GetCanonicalInstanceForType(inType), inParent, - inSlide, inDataCore, inSlideSystem, inObjectDefs, inAssetGraph, - inMetaData, inTargetId); + return CreateSceneGraphInstance(inMetaData.GetCanonicalInstanceForType(inType), + inParent, inSlide, inDataCore, inSlideSystem, inObjectDefs, + inAssetGraph, inMetaData, inTargetId); } Qt3DSDMInstanceHandle IDocumentEditor::CreateSceneGraphInstance( @@ -5283,7 +5244,7 @@ Qt3DSDMInstanceHandle IDocumentEditor::CreateSceneGraphInstance( qt3dsdm::SComposerObjectDefinitions &inObjectDefs, Q3DStudio::CGraph &inAssetGraph, qt3dsdm::IMetaData &inMetaData, TInstanceHandle inTargetId) { - Option<TCharStr> theTypeOpt = inMetaData.GetTypeForInstance(inMaster); + Option<QString> theTypeOpt = inMetaData.GetTypeForInstance(inMaster); if (theTypeOpt.hasValue() == false) return 0; @@ -5303,7 +5264,7 @@ Qt3DSDMInstanceHandle IDocumentEditor::CreateSceneGraphInstance( } Q3DStudio::CId theId; - if (ComposerObjectTypes::Convert(theTypeOpt->wide_str()) == qt3dsdm::ComposerObjectTypes::Scene) + if (ComposerObjectTypes::Convert(theTypeOpt) == qt3dsdm::ComposerObjectTypes::Scene) theId = SCENE_GUID; else theId.Generate(); @@ -5312,6 +5273,9 @@ Qt3DSDMInstanceHandle IDocumentEditor::CreateSceneGraphInstance( SLong4 theLong4Id(thePackedGuid.Data1, thePackedGuid.Data2, thePackedGuid.Data3, thePackedGuid.Data4); inDataCore.SetInstancePropertyValue(retval, theDefs.m_Guided.m_GuidProp, theLong4Id); + SValue outValue; + inDataCore.GetInstancePropertyValue(retval, theDefs.m_Guided.m_GuidProp, outValue); + SLong4 outLong4Id = qt3dsdm::get<qt3dsdm::SLong4>(outValue); return retval; } @@ -5368,24 +5332,23 @@ struct SScriptParser }; std::shared_ptr<IDOMReader> -IDocumentEditor::ParseScriptFile(const CFilePath &inFullPathToDocument, +IDocumentEditor::ParseScriptFile(const QString &inFullPathToDocument, std::shared_ptr<qt3dsdm::IStringTable> inStringTable, std::shared_ptr<IImportFailedHandler> inHandler, Q3DStudio::IInputStreamFactory &inInputStreamFactory) { std::shared_ptr<qt3dsdm::IStringTable> theStringTable(inStringTable); std::shared_ptr<IDOMFactory> theFactory(IDOMFactory::CreateDOMFactory(theStringTable)); - SImportXmlErrorHandler theXmlErrorHandler(inHandler, - inFullPathToDocument.toCString()); + SImportXmlErrorHandler theXmlErrorHandler(inHandler, inFullPathToDocument); std::shared_ptr<IDOMReader> theReaderPtr( SScriptParser::ParseScriptFile(theFactory, inStringTable, - inFullPathToDocument.toQString(), + inFullPathToDocument, theXmlErrorHandler, inInputStreamFactory)); if (!theReaderPtr) { QT3DS_ASSERT(false); if (inHandler) { - inHandler->DisplayImportFailed(inFullPathToDocument.toQString(), + inHandler->DisplayImportFailed(inFullPathToDocument, QObject::tr("Failed to parse script data"), false); } @@ -5404,7 +5367,7 @@ struct CRenderPluginParser static std::shared_ptr<qt3dsdm::IDOMReader> ParseFile(std::shared_ptr<qt3dsdm::IDOMFactory> inFactory, - std::shared_ptr<qt3dsdm::IStringTable> inStringTable, const char8_t *inFileData, + std::shared_ptr<qt3dsdm::IStringTable> inStringTable, const QString &inFileData, qt3dsdm::CXmlErrorHandler &inErrorHandler, IInputStreamFactory &inStreamFactory) { @@ -5464,50 +5427,48 @@ struct CCustomMaterialParser std::shared_ptr<IDOMReader> -IDocumentEditor::ParsePluginFile(const Q3DStudio::CFilePath &inFullPathToDocument, +IDocumentEditor::ParsePluginFile(const QString &inFullPathToDocument, std::shared_ptr<qt3dsdm::IStringTable> inStringTable, std::shared_ptr<IImportFailedHandler> inHandler, IInputStreamFactory &inInputStreamFactory) { std::shared_ptr<qt3dsdm::IStringTable> theStringTable(inStringTable); std::shared_ptr<IDOMFactory> theFactory(IDOMFactory::CreateDOMFactory(theStringTable)); - SImportXmlErrorHandler theXmlErrorHandler(inHandler, - inFullPathToDocument.toCString()); + SImportXmlErrorHandler theXmlErrorHandler(inHandler, inFullPathToDocument); std::shared_ptr<IDOMReader> theReaderPtr = CRenderPluginParser::ParseFile( - theFactory, theStringTable, theStringTable->GetNarrowStr(inFullPathToDocument.toCString()), + theFactory, theStringTable, inFullPathToDocument, theXmlErrorHandler, inInputStreamFactory); if (!theReaderPtr) { QT3DS_ASSERT(false); - if (inHandler) - inHandler->DisplayImportFailed(inFullPathToDocument.toQString(), - QObject::tr("Failed to parse plugin file"), - false); + if (inHandler) { + inHandler->DisplayImportFailed(inFullPathToDocument, + QObject::tr("Failed to parse plugin file"), false); + } } CRenderPluginParser::NavigateToMetadata(theReaderPtr); return theReaderPtr; } std::shared_ptr<IDOMReader> -IDocumentEditor::ParseCustomMaterialFile(const Q3DStudio::CFilePath &inFullPathToDocument, +IDocumentEditor::ParseCustomMaterialFile(const QString &inFullPathToDocument, std::shared_ptr<qt3dsdm::IStringTable> inStringTable, std::shared_ptr<IImportFailedHandler> inHandler, IInputStreamFactory &inInputStreamFactory) { std::shared_ptr<qt3dsdm::IStringTable> theStringTable(inStringTable); std::shared_ptr<IDOMFactory> theFactory(IDOMFactory::CreateDOMFactory(theStringTable)); - SImportXmlErrorHandler theXmlErrorHandler(inHandler, - inFullPathToDocument.toCString()); + SImportXmlErrorHandler theXmlErrorHandler(inHandler, inFullPathToDocument); std::shared_ptr<IDOMReader> theReaderPtr = CRenderPluginParser::ParseFile( - theFactory, theStringTable, theStringTable->GetNarrowStr(inFullPathToDocument.toCString()), + theFactory, theStringTable, inFullPathToDocument, theXmlErrorHandler, inInputStreamFactory); if (!theReaderPtr) { QT3DS_ASSERT(false); - if (inHandler) - inHandler->DisplayImportFailed(inFullPathToDocument.toQString(), - QObject::tr("Failed to parse material file"), - false); + if (inHandler) { + inHandler->DisplayImportFailed(inFullPathToDocument, + QObject::tr("Failed to parse material file"), false); + } } CCustomMaterialParser::NavigateToMetadata(theReaderPtr); return theReaderPtr; diff --git a/src/Authoring/Client/Code/Core/Doc/GraphUtils.cpp b/src/Authoring/Client/Code/Core/Doc/GraphUtils.cpp index 8c1ef511..a928dbce 100644 --- a/src/Authoring/Client/Code/Core/Doc/GraphUtils.cpp +++ b/src/Authoring/Client/Code/Core/Doc/GraphUtils.cpp @@ -390,6 +390,7 @@ Q3DStudio::TIdentifier GetSibling(const Q3DStudio::TIdentifier inNode, bool inAf /** * Prints the subtree of the asset */ +#ifdef RUNTIME_SPLIT_TEMPORARILY_REMOVED void PrintAssetSubTree(qt3dsdm::Qt3DSDMInstanceHandle inInstance, CDoc *inDoc, char *prefix) { CClientDataModelBridge *theBridge = inDoc->GetStudioSystem()->GetClientDataModelBridge(); @@ -424,3 +425,4 @@ void PrintSlideInfo(CDoc *m_Doc, char *prefix, qt3dsdm::Qt3DSDMSlideHandle theMa PrintAssetSubTree(slideInstance, m_Doc, prefix); } } +#endif diff --git a/src/Authoring/Client/Code/Core/Doc/GraphUtils.h b/src/Authoring/Client/Code/Core/Doc/GraphUtils.h index daa72ef1..9b6ee2a3 100644 --- a/src/Authoring/Client/Code/Core/Doc/GraphUtils.h +++ b/src/Authoring/Client/Code/Core/Doc/GraphUtils.h @@ -111,8 +111,9 @@ bool IsAscendant(Q3DStudio::TIdentifier inDescendant, Q3DStudio::TIdentifier inA Q3DStudio::TIdentifier GetSibling(const Q3DStudio::TIdentifier inNode, bool inAfter, const Q3DStudio::CGraphIterator &inIterator); - +#ifdef RUNTIME_SPLIT_TEMPORARILY_REMOVED void PrintAssetSubTree(qt3dsdm::Qt3DSDMInstanceHandle inInstance, CDoc *m_Doc, char *prefix); void PrintSlideInfo(CDoc *m_Doc, char *prefix, qt3dsdm::Qt3DSDMSlideHandle theMasterSlide); +#endif #endif // INCLUDED_GRAPH_UTILS_H diff --git a/src/Authoring/Client/Code/Core/Doc/IComposerEditorInterface.h b/src/Authoring/Client/Code/Core/Doc/IComposerEditorInterface.h index ba35b50f..2ec82e21 100644 --- a/src/Authoring/Client/Code/Core/Doc/IComposerEditorInterface.h +++ b/src/Authoring/Client/Code/Core/Doc/IComposerEditorInterface.h @@ -50,7 +50,7 @@ namespace ComposerImport { // For the children of this instance that are associated with this slide, // update their information. - typedef unordered_map<const wchar_t *, vector<pair<Qt3DSDMSlideHandle, Qt3DSDMInstanceHandle>>> + typedef QHash<QString, QVector<QPair<Qt3DSDMSlideHandle, Qt3DSDMInstanceHandle>>> TIdMultiMap; // Interface between the import library (which defines IComposerEditor) @@ -65,25 +65,24 @@ namespace ComposerImport { virtual bool HasError() = 0; // This file path contains the import document id. - virtual void Finalize(const Q3DStudio::CFilePath &inDestFilePath) = 0; + virtual void Finalize(const QString &inDestFilePath) = 0; virtual Qt3DSDMInstanceHandle FindInstance(TImportId inImportHdl) = 0; - virtual Qt3DSDMInstanceHandle GetRoot() = 0; - virtual const Q3DStudio::CFilePath &GetDestImportFile() = 0; + virtual Qt3DSDMInstanceHandle GetRoot() const = 0; + virtual const QString GetDestImportFile() const = 0; virtual void AddInstanceMap(Qt3DSDMInstanceHandle instanceHandle, TImportId inImportId) = 0; static std::shared_ptr<IComposerEditorInterface> CreateEditorInterface( - Q3DStudio::IDocumentEditor &editor, qt3dsdm::CDataModelHandle parent // Parent object - , - qt3dsdm::CDataModelHandle root, qt3dsdm::Qt3DSDMSlideHandle slide, - const Q3DStudio::CFilePath &docPath, const Q3DStudio::CFilePath &fullPathToImportFile, - long inStartTime, qt3dsdm::IStringTable &inStringTable); + Q3DStudio::IDocumentEditor &editor, qt3dsdm::CDataModelHandle parent, + qt3dsdm::CDataModelHandle root, qt3dsdm::Qt3DSDMSlideHandle slide, + const QString &docPath, const QString &fullPathToImportFile, + long inStartTime); // The refresh interface is setup to refresh multiple trees automatically static std::shared_ptr<IComposerEditor> CreateEditorInterface(Q3DStudio::IDocumentEditor &editor, TIdMultiMap &inRoots, - const Q3DStudio::CFilePath &docPath, - const Q3DStudio::CFilePath &fullPathToImportFile, long inStartTime, - qt3dsdm::IStringTable &inStringTable, CGraph &inAssetGraph); + const QString &docPath, + const QString &fullPathToImportFile, long inStartTime, + CGraph &inAssetGraph); }; } } diff --git a/src/Authoring/Client/Code/Core/Doc/IComposerSerializer.cpp b/src/Authoring/Client/Code/Core/Doc/IComposerSerializer.cpp index 34ed120b..3e3b7f9e 100644 --- a/src/Authoring/Client/Code/Core/Doc/IComposerSerializer.cpp +++ b/src/Authoring/Client/Code/Core/Doc/IComposerSerializer.cpp @@ -57,6 +57,20 @@ using namespace Q3DStudio; using namespace qt3ds; using namespace qt3ds::foundation; +QT_BEGIN_NAMESPACE + +uint qHash(const qt3dsdm::SLong4 &t, uint seed) +{ + QtPrivate::QHashCombine hash; + seed = hash(seed, t.m_Longs[0]); + seed = hash(seed, t.m_Longs[1]); + seed = hash(seed, t.m_Longs[2]); + seed = hash(seed, t.m_Longs[3]); + return seed; +} + +QT_END_NAMESPACE + namespace std { template <> struct hash<SLong4> @@ -258,13 +272,13 @@ struct SAttributeNameSorter bool operator()(const pair<Qt3DSDMPropertyHandle, SValue> &lhsPair, const pair<Qt3DSDMPropertyHandle, SValue> &rhsPair) { - TCharStr lhs(m_Core.GetProperty(lhsPair.first).m_Name); - TCharStr rhs(m_Core.GetProperty(rhsPair.first).m_Name); + QString lhs(m_Core.GetProperty(lhsPair.first).m_Name); + QString rhs(m_Core.GetProperty(rhsPair.first).m_Name); if (lhs == rhs) return false; - if (lhs == L"name") + if (lhs == QLatin1String("name")) return true; - if (rhs == L"name") + if (rhs == QLatin1String("name")) return false; return lhs.compare(rhs) < 0; } @@ -296,16 +310,16 @@ using std::tuple; // and write out the instances as we come to them. struct SComposerSerializerImpl : public IComposerSerializer { - typedef unordered_set<Qt3DSDMInstanceHandle, hash<int>> TInstanceSet; - typedef unordered_set<Qt3DSDMSlideHandle, hash<int>> TSlideSet; - typedef unordered_set<Qt3DSDMActionHandle, hash<int>> TActionSet; + typedef QSet<Qt3DSDMInstanceHandle> TInstanceSet; + typedef QSet<Qt3DSDMSlideHandle> TSlideSet; + typedef QSet<Qt3DSDMActionHandle> TActionSet; typedef vector<Qt3DSDMInstanceHandle> TInstanceList; - typedef unordered_map<int, TCharPtr> THandleToIdMap; - typedef unordered_map<TCharPtr, int> TIdToHandleMap; - typedef unordered_map<SLong4, int> TGUIDToHandleMap; - typedef unordered_map<int, SLong4> THandleToGUIDMap; - typedef unordered_map<Qt3DSDMInstanceHandle, int, hash<int>> TInstanceIntMap; - typedef unordered_map<Qt3DSDMInstanceHandle, TCharPtr, hash<int>> TInstanceToSiblingMap; + typedef QHash<int, QString> THandleToIdMap; + typedef QHash<QString, int> TIdToHandleMap; + typedef QHash<SLong4, int> TGUIDToHandleMap; + typedef QHash<int, SLong4> THandleToGUIDMap; + typedef QHash<Qt3DSDMInstanceHandle, int> TInstanceIntMap; + typedef QHash<Qt3DSDMInstanceHandle, QString> TInstanceToSiblingMap; IDataCore &m_DataCore; IMetaData &m_MetaData; @@ -351,7 +365,6 @@ struct SComposerSerializerImpl : public IComposerSerializer // These are cleared just before use MemoryBuffer<RawAllocator> m_TempBuffer; MemoryBuffer<RawAllocator> m_ValueBuffer; - eastl::string m_ConvertStr; Q3DStudio::Foundation::SStudioFoundation m_Foundation; TStreamFactoryPtr m_InputStreamFactory; @@ -363,6 +376,13 @@ struct SComposerSerializerImpl : public IComposerSerializer Option<int> m_UIPVersion; + QString idFromRef(const QString &ref) const + { + if (ref.startsWith(QLatin1Char('#'))) + return ref.right(ref.length() - 1); + return ref; + } + SComposerSerializerImpl(IDataCore &inDataCore, IMetaData &inMetaData, ISlideCore &inSlideCore, IAnimationCore &inAnimationCore, IActionCore &inActionCore, CGraph &inAssetGraph, ISlideSystem &inSlideSystem, @@ -422,97 +442,90 @@ struct SComposerSerializerImpl : public IComposerSerializer m_UIPVersion = Option<int>(); } - TCharPtr AddId(const wstring &inId, Qt3DSDMInstanceHandle inHandle) + QString AddId(const QString &inId, Qt3DSDMInstanceHandle inHandle) { - TCharPtr theIdStr = m_StringTable.RegisterStr(inId.c_str()); - m_IdToHandleMap.insert(make_pair(theIdStr, inHandle)); - m_HandleToIdMap.insert(make_pair(inHandle, theIdStr)); - if (m_PreserveFileIds) + QString theIdStr(inId); + m_IdToHandleMap.insert(theIdStr, inHandle); + m_HandleToIdMap.insert(inHandle, theIdStr); + if (m_PreserveFileIds) { m_DataCore.SetInstancePropertyValue(inHandle, m_ObjectDefinitions.m_Asset.m_FileId, - std::make_shared<CDataStr>(inId.c_str())); + std::make_shared<CDataStr>(inId)); + } return theIdStr; } - TCharPtr SetId(const wstring &inId, Qt3DSDMInstanceHandle inHandle) + QString SetId(const QString &inId, Qt3DSDMInstanceHandle inHandle) { - TCharPtr theIdStr = m_StringTable.RegisterStr(inId.c_str()); - m_IdToHandleMap.insert(make_pair(theIdStr, inHandle)).first->second = inHandle; - m_HandleToIdMap.insert(make_pair(inHandle, theIdStr)).first->second = theIdStr; - if (m_PreserveFileIds) + QString theIdStr = inId; + *m_IdToHandleMap.insert(theIdStr, inHandle) = inHandle; + *m_HandleToIdMap.insert(inHandle, theIdStr) = theIdStr; + if (m_PreserveFileIds) { m_DataCore.SetInstancePropertyValue(inHandle, m_ObjectDefinitions.m_Asset.m_FileId, - std::make_shared<CDataStr>(inId.c_str())); + std::make_shared<CDataStr>(inId)); + } return theIdStr; } - TCharPtr AddActionId(const wstring &inId, Qt3DSDMActionHandle inHandle) + QString AddActionId(const QString &inId, Qt3DSDMActionHandle inHandle) { - TCharPtr theIdStr = m_StringTable.RegisterStr(inId.c_str()); - m_IdToActionMap.insert(make_pair(theIdStr, inHandle)); - m_ActionToIdMap.insert(make_pair(inHandle, theIdStr)); + QString theIdStr(inId); + m_IdToActionMap.insert(theIdStr, inHandle); + m_ActionToIdMap.insert(inHandle, theIdStr); return theIdStr; } - TCharPtr AddSlideId(const wstring &inId, Qt3DSDMSlideHandle inHandle) + QString AddSlideId(const QString &inId, Qt3DSDMSlideHandle inHandle) { - TCharPtr theIdStr = m_StringTable.RegisterStr(inId.c_str()); - m_IdToSlideMap.insert(make_pair(theIdStr, inHandle)); - m_SlideToIdMap.insert(make_pair(inHandle, theIdStr)); + QString theIdStr(inId); + m_IdToSlideMap.insert(theIdStr, inHandle); + m_SlideToIdMap.insert(inHandle, theIdStr); return theIdStr; } - Qt3DSDMInstanceHandle GetInstanceById(TCharPtr inId) + Qt3DSDMInstanceHandle GetInstanceById(const QString &inId) { if (IsTrivial(inId)) return 0; - if (inId[0] == '#') - ++inId; - inId = m_StringTable.RegisterStr(inId); - TIdToHandleMap::iterator find = m_IdToHandleMap.find(inId); + TIdToHandleMap::iterator find = m_IdToHandleMap.find(idFromRef(inId)); if (find != m_IdToHandleMap.end()) - return find->second; + return *find; return 0; } - Qt3DSDMSlideHandle GetSlideById(TCharPtr inId) + Qt3DSDMSlideHandle GetSlideById(const QString &inId) { if (IsTrivial(inId)) return 0; - if (inId[0] == '#') - ++inId; - inId = m_StringTable.RegisterStr(inId); - TIdToHandleMap::iterator find = m_IdToSlideMap.find(inId); + TIdToHandleMap::iterator find = m_IdToSlideMap.find(idFromRef(inId)); if (find != m_IdToSlideMap.end()) - return find->second; + return *find; return 0; } - Qt3DSDMActionHandle GetActionById(TCharPtr inId) + Qt3DSDMActionHandle GetActionById(const QString &inId) { if (IsTrivial(inId)) return 0; - if (inId[0] == '#') - ++inId; - inId = m_StringTable.RegisterStr(inId); - TIdToHandleMap::iterator find = m_IdToActionMap.find(inId); + TIdToHandleMap::iterator find = m_IdToActionMap.find(idFromRef(inId)); if (find != m_IdToActionMap.end()) - return find->second; + return *find; return 0; } void AddGuid(SLong4 inId, int inHandle) { - m_GUIDToHandleMap.insert(make_pair(inId, inHandle)); - m_HandleToGUIDMap.insert(make_pair(inHandle, inId)); + m_GUIDToHandleMap.insert(inId, inHandle); + m_HandleToGUIDMap.insert(inHandle, inId); } SLong4 GetInstanceGuid(Qt3DSDMInstanceHandle inInstance) { THandleToGUIDMap::iterator find = m_HandleToGUIDMap.find(inInstance); if (find != m_HandleToGUIDMap.end()) - return find->second; + return *find; SValue theValue; if (m_DataCore.GetInstancePropertyValue(inInstance, m_ObjectDefinitions.m_Guided.m_GuidProp, theValue)) { @@ -523,7 +536,7 @@ struct SComposerSerializerImpl : public IComposerSerializer return SLong4(); } - TCharPtr GetInstanceName(Qt3DSDMInstanceHandle inInstance) + QString GetInstanceName(Qt3DSDMInstanceHandle inInstance) { Qt3DSDMSlideHandle theAssociatedSlide = m_SlideSystem.GetAssociatedSlide(inInstance); SValue theValue; @@ -532,88 +545,88 @@ struct SComposerSerializerImpl : public IComposerSerializer m_ObjectDefinitions.m_Named.m_NameProp, theValue)) { TDataStrPtr theName(get<TDataStrPtr>(theValue)); - TCharPtr retval = theName->GetData(); - if (!IsTrivial(retval)) + QString retval = theName->toQString(); + if (!retval.isEmpty()) return retval; } SValue theDCValue; if (m_DataCore.GetInstancePropertyValue(inInstance, m_ObjectDefinitions.m_Named.m_NameProp, theDCValue)) { TDataStrPtr theName(get<TDataStrPtr>(theDCValue)); - TCharPtr retval = theName->GetData(); - if (!IsTrivial(retval)) + QString retval = theName->toQString(); + if (!retval.isEmpty()) return retval; } - Option<TCharStr> theTypeStr = m_MetaData.GetTypeForInstance(inInstance); + Option<QString> theTypeStr = m_MetaData.GetTypeForInstance(inInstance); if (theTypeStr.hasValue()) - return m_StringTable.RegisterStr(theTypeStr->wide_str()); + return theTypeStr; QT3DS_ASSERT(false); - return L""; + return {}; } - TCharPtr GetInstanceName(Qt3DSDMInstanceHandle inInstance, Qt3DSDMSlideHandle inSlide) + QString GetInstanceName(Qt3DSDMInstanceHandle inInstance, Qt3DSDMSlideHandle inSlide) { SValue theValue; if (m_SlideCore.GetSpecificInstancePropertyValue( inSlide, inInstance, m_ObjectDefinitions.m_Named.m_NameProp, theValue)) { TDataStrPtr theName(get<TDataStrPtr>(theValue)); - TCharPtr retval = theName->GetData(); - if (!IsTrivial(retval)) + QString retval = theName->toQString(); + if (!retval.isEmpty()) return retval; } return GetInstanceName(inInstance); } - TCharPtr GetId(const wstring &inIdStem) + QString GetId(const QString &inIdStem) { // Create an ID for this instance - wstring theTypeStr(inIdStem); - wstring theTypeStem(theTypeStr); - wstring::size_type thePos = theTypeStem.find_last_of('_'); - if (thePos != wstring::npos && thePos < theTypeStem.size() - 2) { - if (theTypeStem[thePos + 1] >= '0' && theTypeStem[thePos + 1] <= '1') - theTypeStem = theTypeStem.substr(0, thePos); - } - QT3DSU32 idIdx = 1; - - while (m_IdToActionMap.find(m_StringTable.RegisterStr(theTypeStr.c_str())) - != m_IdToActionMap.end() - || m_IdToHandleMap.find(m_StringTable.RegisterStr(theTypeStr.c_str())) - != m_IdToHandleMap.end() - || m_IdToSlideMap.find(m_StringTable.RegisterStr(theTypeStr.c_str())) - != m_IdToSlideMap.end()) { - wchar_t theBuffer[16]; - swprintf(theBuffer, 16, L"_%03d", idIdx); - theTypeStr = theTypeStem + theBuffer; + QString theTypeStr(inIdStem); + QString theTypeStem(theTypeStr); + QStringList split = theTypeStr.split(QLatin1Char('_')); + // remove number from the end + if (split.size() > 1) { + bool ok = false; + split.last().toLong(&ok); + if (ok) + theTypeStr = theTypeStr.left(theTypeStr.length() - split.last().length() - 1); + } + + uint idIdx = 1; + + while (m_IdToActionMap.keys().contains(theTypeStr) + || m_IdToHandleMap.keys().contains(theTypeStr) + || m_IdToSlideMap.keys().contains(theTypeStr)) { + QString id = QString("_%1").arg(idIdx, 3, 10, QChar('0')); + theTypeStr = theTypeStem + id; ++idIdx; } - return m_StringTable.RegisterStr(theTypeStr.c_str()); + return theTypeStr; } - TCharPtr GetInstanceId(Qt3DSDMInstanceHandle inInstance) + QString GetInstanceId(Qt3DSDMInstanceHandle inInstance) { QT3DS_ASSERT(inInstance.Valid()); THandleToIdMap::iterator theFind(m_HandleToIdMap.find(inInstance)); if (theFind != m_HandleToIdMap.end()) - return theFind->second; + return *theFind; - TCharStr theName(GetInstanceName(inInstance)); - Option<TCharStr> theType = m_MetaData.GetTypeForInstance(inInstance); + QString theName(GetInstanceName(inInstance)); + Option<QString> theType = m_MetaData.GetTypeForInstance(inInstance); if (theType.hasValue() == false) { QT3DS_ASSERT(false); - return L""; + return {}; } // for most instances we just want a simple id based on the object name. // for images, however, we want do to something else. - TCharPtr theNewId = L""; + QString theNewId; if (m_DataCore.IsInstanceOrDerivedFrom(inInstance, m_ObjectDefinitions.m_Image.m_Instance)) { Qt3DSDMInstanceHandle theMaterial = m_AssetGraph.GetParent(inInstance); if (theMaterial.Valid()) { - wstring theIdStr(GetInstanceId(theMaterial)); + QString theIdStr(GetInstanceId(theMaterial)); SLong4 theGuid = GetInstanceGuid(inInstance); - theIdStr.append(L"_"); + theIdStr += QLatin1Char('_'); TPropertyHandleList theProperties; m_DataCore.GetAggregateInstanceProperties(theMaterial, theProperties); Qt3DSDMPropertyHandle theProperty; @@ -641,40 +654,40 @@ struct SComposerSerializerImpl : public IComposerSerializer } } if (theProperty.Valid()) { - theIdStr.append(m_DataCore.GetProperty(theProperty).m_Name.wide_str()); + theIdStr.append(m_DataCore.GetProperty(theProperty).m_Name); theNewId = GetId(theIdStr); } } } if (IsTrivial(theNewId)) - theNewId = GetId(theName.wide_str()); + theNewId = GetId(theName); return AddId(theNewId, inInstance); } - TCharPtr GetActionId(Qt3DSDMActionHandle inAction, Qt3DSDMSlideHandle inSlide, + QString GetActionId(Qt3DSDMActionHandle inAction, Qt3DSDMSlideHandle inSlide, Qt3DSDMInstanceHandle inInstance) { QT3DS_ASSERT(inAction.Valid()); THandleToIdMap::iterator theFind(m_ActionToIdMap.find(inAction)); if (theFind != m_ActionToIdMap.end()) - return theFind->second; + return *theFind; - wstring theActionName(GetInstanceName(inInstance, inSlide)); - theActionName.append(L"-Action"); + QString theActionName(GetInstanceName(inInstance, inSlide)); + theActionName.append(QStringLiteral("-Action")); - TCharPtr theNewId = GetId(theActionName); + QString theNewId = GetId(theActionName); return AddActionId(theNewId, inAction); } // If this function is called with an invalid instance and we don't already have an id // then we assume we have an external reference and lookup the instance via the component id. - TCharPtr GetSlideId(Qt3DSDMSlideHandle inSlide, Qt3DSDMInstanceHandle inInstance) + QString GetSlideId(Qt3DSDMSlideHandle inSlide, Qt3DSDMInstanceHandle inInstance) { QT3DS_ASSERT(inSlide.Valid()); THandleToIdMap::iterator theFind(m_SlideToIdMap.find(inSlide)); if (theFind != m_SlideToIdMap.end()) - return theFind->second; + return *theFind; if (inInstance.Valid() == false) { m_ExternalSlides.insert(inSlide); @@ -688,11 +701,9 @@ struct SComposerSerializerImpl : public IComposerSerializer QT3DS_ASSERT(inInstance.Valid()); } - wstring theSlideName(GetInstanceName(inInstance)); - theSlideName.append(L"-"); - theSlideName.append(GetSlideName(inSlide)); - - TCharPtr theNewId = GetId(theSlideName); + const QString theSlideName = GetInstanceName(inInstance) + QLatin1Char('-') + + GetSlideName(inSlide); + const QString theNewId = GetId(theSlideName); return AddSlideId(theNewId, inSlide); } @@ -732,9 +743,9 @@ struct SComposerSerializerImpl : public IComposerSerializer SValue theInstanceIdValue; if (m_DataCore.GetInstancePropertyValue( theInstance, m_ObjectDefinitions.m_Asset.m_FileId, theInstanceIdValue)) { - TDataStrPtr theNamePtr = qt3dsdm::get<TDataStrPtr>(theInstanceIdValue); - if (theNamePtr && !IsTrivial(theNamePtr->GetData())) { - const wchar_t *theId = GetId(theNamePtr->GetData()); + QString theName = qt3dsdm::get<TDataStrPtr>(theInstanceIdValue)->toQString(); + if (IsTrivial(theName)) { + const QString theId = GetId(theName); AddId(theId, theInstance); } } @@ -765,10 +776,9 @@ struct SComposerSerializerImpl : public IComposerSerializer if (m_DataCore.GetInstancePropertyValue( theMaster, m_ObjectDefinitions.m_Asset.m_SourcePath, theValue)) { TDataStrPtr theStr(get<TDataStrPtr>(theValue)); - const wchar_t *thePath(theStr->GetData()); + QString thePath(theStr->toQString()); if (!IsTrivial(thePath)) - m_SourcePathToMasterInstances.insert( - make_pair(m_StringTable.RegisterStr(thePath), theMaster)); + m_SourcePathToMasterInstances.insert(thePath, theMaster); } } } @@ -782,11 +792,11 @@ struct SComposerSerializerImpl : public IComposerSerializer TGUIDToHandleMap::iterator theIter(m_GUIDToHandleMap.find(theGuid)); if (theIter != m_GUIDToHandleMap.end()) - return theIter->second; + return *theIter; return 0; } - const wchar_t *WriteDataModelValue(const SValue &_inValue, TCharStr &theValueStr) + const QString WriteDataModelValue(const SValue &_inValue, QString &theValueStr) { DataModelDataType::Value theValueType(GetValueType(_inValue)); SValue theValue(_inValue); @@ -808,9 +818,8 @@ struct SComposerSerializerImpl : public IComposerSerializer const SStringOrInt &theData(get<SStringOrInt>(theValue)); if (theData.GetType() == SStringOrIntTypes::Int) { Qt3DSDMSlideHandle theHandle(get<long>(theData.m_Value)); - wstring theSlideId(L"#"); - theSlideId.append(GetSlideId(theHandle, 0)); - theValue = std::make_shared<CDataStr>(theSlideId.c_str()); + const QString theSlideId(QLatin1Char('#') + GetSlideId(theHandle, 0)); + theValue = std::make_shared<CDataStr>(theSlideId); } else theValue = get<TDataStrPtr>(theData.m_Value); } @@ -818,11 +827,10 @@ struct SComposerSerializerImpl : public IComposerSerializer if (GetValueType(theValue) == DataModelDataType::Long4) { SLong4 theDataValue = get<SLong4>(theValue); Qt3DSDMInstanceHandle theInstance = FindInstanceByGUID(theDataValue); - if (theInstance.Valid() == false) - theValueStr = L""; - else { - theValueStr.assign(L"#"); - theValueStr.append(GetInstanceId(theInstance)); + if (theInstance.Valid() == false) { + theValueStr.clear(); + } else { + theValueStr = QLatin1Char('#') + GetInstanceId(theInstance); if (m_InstanceSet.find(theInstance) == m_InstanceSet.end()) m_ExternalReferences.insert(theInstance); } @@ -834,13 +842,13 @@ struct SComposerSerializerImpl : public IComposerSerializer if (GetValueType(theValue) == DataModelDataType::String || m_TempBuffer.size()) { char buffer[] = { 0, 0, 0, 0 }; m_TempBuffer.write(buffer, 4); - theValueStr.assign((const wchar_t *)m_TempBuffer.begin()); + theValueStr = QString::fromWCharArray((const wchar_t *)m_TempBuffer.begin()); } } - return theValueStr.wide_str(); + return theValueStr; } - SValue ParseValue(DataModelDataType::Value inType, TCharPtr inValue) + SValue ParseValue(DataModelDataType::Value inType, const QString &inValue) { if (IsTrivial(inValue)) { SValue retval; @@ -852,8 +860,8 @@ struct SComposerSerializerImpl : public IComposerSerializer return ParseObjectRef(inValue); if (inType == DataModelDataType::StringOrInt) { - if (inValue[0] == '#') { - Qt3DSDMSlideHandle theSlide = GetSlideById(inValue + 1); + if (inValue.startsWith(QLatin1Char('#'))) { + Qt3DSDMSlideHandle theSlide = GetSlideById(idFromRef(inValue)); QT3DS_ASSERT(theSlide.Valid()); return SStringOrInt((long)theSlide.GetHandleValue()); } else @@ -863,36 +871,33 @@ struct SComposerSerializerImpl : public IComposerSerializer if (inType == DataModelDataType::String) return std::make_shared<CDataStr>(inValue); - qt3ds::foundation::ConvertUTF( - reinterpret_cast<const qt3ds::foundation::TWCharEASTLConverter::TCharType *>(inValue), 0, - m_ConvertStr); - // Create a destructible value - m_ValueBuffer.clear(); - m_ValueBuffer.write(m_ConvertStr.c_str(), m_ConvertStr.size() + 1); - // Clear the destination buffer - m_TempBuffer.clear(); - DataModelDataType::Value theParseType(inType); if (inType == DataModelDataType::Long4) theParseType = DataModelDataType::StringRef; + QByteArray data(inValue.toLatin1()); + m_ValueBuffer.clear(); + m_ValueBuffer.write(data.data(), data.size() + 1); + m_TempBuffer.clear(); + WCharTReader theReader((char8_t *)m_ValueBuffer.begin(), m_TempBuffer, m_StringTable); SValue retval = WStrOps<SValue>().BufTo(theParseType, theReader); if (inType == DataModelDataType::Long4) { SLong4 theFinalValue; SStringRef theRef(get<SStringRef>(retval)); - Qt3DSDMInstanceHandle theRefInstance(GetInstanceById(theRef.m_Id)); + Qt3DSDMInstanceHandle theRefInstance( + GetInstanceById(QString::fromWCharArray(theRef.m_Id))); if (theRefInstance.Valid()) { THandleToGUIDMap::iterator theGuidFind = m_HandleToGUIDMap.find(theRefInstance); if (theGuidFind != m_HandleToGUIDMap.end()) - theFinalValue = theGuidFind->second; + theFinalValue = *theGuidFind; } return theFinalValue; } return retval; } - const wchar_t *WriteObjectRef(const SObjectRefType &inValue, TCharStr &ioValueStr) + const QString WriteObjectRef(const SObjectRefType &inValue, QString &ioValueStr) { return WriteDataModelValue(SValue(inValue), ioValueStr); } @@ -904,7 +909,22 @@ struct SComposerSerializerImpl : public IComposerSerializer return SObjectRefType(SLong4()); if (inValue[0] == '#') { // absolute reference. - Qt3DSDMInstanceHandle theInstance = GetInstanceById(inValue + 1); + Qt3DSDMInstanceHandle theInstance + = GetInstanceById(QString::fromWCharArray(inValue + 1)); + return theInstance.Valid() ? GetInstanceGuid(theInstance) : 0; + } else { + return std::make_shared<CDataStr>(inValue); + } + } + + SObjectRefType ParseObjectRef(const QString &inValue) + { + // One of two things, either an ID reference *or* pure string. + if (IsTrivial(inValue)) + return SObjectRefType(SLong4()); + if (inValue.startsWith(QLatin1Char('#'))) { + // absolute reference. + Qt3DSDMInstanceHandle theInstance = GetInstanceById(idFromRef(inValue)); return theInstance.Valid() ? GetInstanceGuid(theInstance) : 0; } else { return std::make_shared<CDataStr>(inValue); @@ -915,14 +935,14 @@ struct SComposerSerializerImpl : public IComposerSerializer { sort(inList.begin(), inList.end(), SAttributeNameSorter(m_DataCore)); - TCharStr theValueStr; + QString theValueStr; for (size_t idx = 0, end = inList.size(); idx < end; ++idx) { const pair<Qt3DSDMPropertyHandle, SValue> &theValue(inList[idx]); - TCharStr theName(m_DataCore.GetProperty(theValue.first).m_Name); + QString theName(m_DataCore.GetProperty(theValue.first).m_Name); WriteDataModelValue(theValue.second, theValueStr); if (GetValueType(theValue.second) == DataModelDataType::String || theValueStr.size()) - inWriter.Att(theName.wide_str(), theValueStr.wide_str()); + inWriter.Att(theName, theValueStr); } } @@ -969,27 +989,28 @@ struct SComposerSerializerImpl : public IComposerSerializer SMetaDataPropertyInfo thePropertyInfo( m_MetaData.GetMetaDataPropertyInfo(theMetaDataProperty)); - wstring theName = thePropertyInfo.m_Name.wide_str(); + QString theName = thePropertyInfo.m_Name; size_t theArity = get<1>(GetDatatypeAnimatableAndArity(thePropertyInfo.GetDataType())); if (theArity > 1) { - theName.append(L"."); + theName.append(QLatin1Char('.')); switch (theInfo.m_Index) { case 0: - theName.append(L"x"); + theName.append(QLatin1Char('x')); break; case 1: - theName.append(L"y"); + theName.append(QLatin1Char('y')); break; case 2: - theName.append(L"z"); + theName.append(QLatin1Char('z')); break; case 3: - theName.append(L"w"); + theName.append(QLatin1Char('w')); break; } } - inWriter.Att(L"property", theName.c_str()); - inWriter.Att(L"type", theInfo.m_AnimationType); + const QString name(theName); + inWriter.Att(QStringLiteral("property"), name); + inWriter.Att(QStringLiteral("type"), theInfo.m_AnimationType); if (theInfo.m_DynamicFirstKeyframe) inWriter.Att("dynamic", true); @@ -1068,7 +1089,8 @@ struct SComposerSerializerImpl : public IComposerSerializer } } Qt3DSDMMetaDataPropertyHandle theProperty = - m_MetaData.GetMetaDataProperty(inInstance, thePropertyName); + m_MetaData.GetMetaDataProperty(inInstance, + QString::fromWCharArray(thePropertyName.wide_str())); if (theProperty.Valid() == false) { QT3DS_ASSERT(false); return; @@ -1140,7 +1162,7 @@ struct SComposerSerializerImpl : public IComposerSerializer void SerializeAction(IDOMWriter &inWriter, Qt3DSDMSlideHandle inSlide, Qt3DSDMInstanceHandle inInstance, Qt3DSDMActionHandle inAction) { - TCharStr valueStr; + QString valueStr; IDOMWriter::Scope __actionScope(inWriter, L"Action"); Qt3DSDMActionHandle theAction(inAction); @@ -1153,13 +1175,13 @@ struct SComposerSerializerImpl : public IComposerSerializer inWriter.Att(L"triggerObject", valueStr); if (theInfo.m_Event.size()) - inWriter.Att(L"event", theInfo.m_Event.c_str()); + inWriter.Att(L"event", theInfo.m_Event); WriteObjectRef(theInfo.m_TargetObject, valueStr); inWriter.Att(L"targetObject", valueStr); if (theInfo.m_Handler.size()) { - inWriter.Att(L"handler", theInfo.m_Handler.c_str()); + inWriter.Att(L"handler", theInfo.m_Handler); for (size_t handlerArgIdx = 0, handlerArgEnd = theInfo.m_HandlerArgs.size(); handlerArgIdx < handlerArgEnd; ++handlerArgIdx) { @@ -1174,7 +1196,7 @@ struct SComposerSerializerImpl : public IComposerSerializer theArgType = DataModelDataType::String; auto theEventHandle = get<qt3ds::QT3DSI32>(theArgInfo.m_Value); theArgValue = SValue(std::make_shared<CDataStr>( - m_MetaData.GetEventInfo(theEventHandle)->m_Name.wide_str())); + m_MetaData.GetEventInfo(theEventHandle)->m_Name)); } if (theArgType != DataModelDataType::Float) @@ -1215,35 +1237,36 @@ struct SComposerSerializerImpl : public IComposerSerializer TDataStrPtr theStrPtr(get<TDataStrPtr>(inRef.m_Value)); if (theStrPtr == NULL) return 0; - wstring theParseStr(theStrPtr->GetData()); + QString theParseStr(theStrPtr->toQString()); // Get rid of this or this. since it's referrng to inInstance - wstring theThisStr(L"this"); - if (theParseStr.substr(0, theThisStr.size()) == theThisStr) { - theParseStr = theParseStr.substr(theThisStr.size()); - if (theParseStr[0] == L'.') - theParseStr = theParseStr.substr(1); + QString theThisStr(QStringLiteral("this")); + if (theParseStr.left(theThisStr.size()) == theThisStr) { + theParseStr = theParseStr.left(theParseStr.length() - theThisStr.size()); + if (theParseStr[0] == QLatin1Char('.')) + theParseStr = theParseStr.right(theParseStr.length() - 1); } - wstring theParentStr(L"parent."); + QString theParentStr(QStringLiteral("parent.")); Qt3DSDMInstanceHandle theSourceInstance(inInstance); - while (theParseStr.find(theParentStr) != wstring::npos) { + while (theParseStr.indexOf(theParentStr) != -1) { Qt3DSDMInstanceHandle theParentInstance = m_AssetGraph.GetParent(inInstance); // this check is here since scene has no parent, see Bug#6532 if (theParentInstance.Valid()) theSourceInstance = theParentInstance; else return Qt3DSDMInstanceHandle(0); - theParseStr = theParseStr.substr(theParentStr.size()); + theParseStr = theParseStr.right(theParseStr.length() - theParentStr.size()); } while (theParseStr.size()) { - wstring::size_type periodPos = theParseStr.find('.'); - wstring theNameStr = theParseStr; - if (periodPos != wstring::npos) { - theNameStr = theParseStr.substr(0, periodPos); - theParseStr = theParseStr.substr(periodPos + 1); - } else - theParseStr = L""; + int periodPos = theParseStr.indexOf(QChar('.')); + QString theNameStr = theParseStr; + if (periodPos != -1) { + theNameStr = theParseStr.left(periodPos); + theParseStr = theParseStr.right(theParseStr.length() - periodPos + 1); + } else { + theParseStr.clear(); + } Qt3DSDMInstanceHandle theParent(theSourceInstance); bool theFound = false; for (long childIdx = 0, childEnd = m_AssetGraph.GetChildCount(theSourceInstance); @@ -1265,7 +1288,7 @@ struct SComposerSerializerImpl : public IComposerSerializer { IDOMReader::Scope __actionScope(inReader); Qt3DSDMActionHandle theAction; - TCharPtr theActionId; + QString theActionId; bool isRef = false; if (inReader.Att(L"id", theActionId)) { theAction = m_ActionSystem.CreateAction(inSlide, inInstance, SLong4()); @@ -1282,7 +1305,7 @@ struct SComposerSerializerImpl : public IComposerSerializer if (isRef) return theAction; - const wchar_t *tempStr; + QString tempStr; if (inReader.Att(L"triggerObject", tempStr)) m_ActionCore.SetTriggerObject(theAction, ParseObjectRef(tempStr)); if (inReader.Att(L"event", tempStr)) @@ -1299,15 +1322,14 @@ struct SComposerSerializerImpl : public IComposerSerializer for (bool success = inReader.MoveToFirstChild(); success; success = inReader.MoveToNextSibling()) { - TCharStr theName; + QString theName; inReader.Att(L"name", theName); DataModelDataType::Value theDataType(DataModelDataType::Float); inReader.Att(L"type", theDataType); HandlerArgumentType::Value theArgType(HandlerArgumentType::None); inReader.Att(L"argtype", theArgType); - tempStr = NULL; - inReader.UnregisteredAtt(L"value", tempStr); + inReader.Att(L"value", tempStr); SValue theValue = ParseValue(theDataType, tempStr); if (theArgType == HandlerArgumentType::Event) { TDataStrPtr theStr; @@ -1318,13 +1340,13 @@ struct SComposerSerializerImpl : public IComposerSerializer ResolveObjectRef(inInstance, theTargetRef); Qt3DSDMEventHandle theEvent = 0; if (theTargetInstance.Valid()) - theEvent = m_MetaData.FindEvent(theTargetInstance, theStr->GetData()); + theEvent = m_MetaData.FindEvent(theTargetInstance, theStr->toQString()); theValue = SValue((qt3ds::QT3DSI32) theEvent); } } Qt3DSDMHandlerArgHandle theArgHandle = m_ActionCore.AddHandlerArgument( - theAction, theName.wide_str(), theArgType, theDataType); + theAction, theName, theArgType, theDataType); m_ActionCore.SetHandlerArgumentValue(theArgHandle, theValue); } } @@ -1385,19 +1407,19 @@ struct SComposerSerializerImpl : public IComposerSerializer } } - TCharPtr GetSlideName(Qt3DSDMSlideHandle inSlide) + QString GetSlideName(Qt3DSDMSlideHandle inSlide) { if (inSlide.Valid() == false) - return L""; + return {}; Qt3DSDMInstanceHandle theSlideInstance(m_SlideCore.GetSlideInstance(inSlide)); SValue theValue; if (m_DataCore.GetInstancePropertyValue(theSlideInstance, m_ObjectDefinitions.m_Named.m_NameProp, theValue)) { TDataStrPtr theName = get<TDataStrPtr>(theValue); if (theName) - return theName->GetData(); + return theName->toQString(); } - return L""; + return {}; } Qt3DSDMSlideHandle GetAssociatedSlide(Qt3DSDMInstanceHandle inInstance) @@ -1466,7 +1488,8 @@ struct SComposerSerializerImpl : public IComposerSerializer } Option<pair<Qt3DSDMPropertyHandle, SValue>> ParseValue(Qt3DSDMInstanceHandle inInstance, - TCharPtr inPropName, TCharPtr inValue) + const QString &inPropName, + const QString &inValue) { Qt3DSDMPropertyHandle theProperty = m_DataCore.GetAggregateInstancePropertyByName(inInstance, inPropName); @@ -1478,7 +1501,7 @@ struct SComposerSerializerImpl : public IComposerSerializer } void ParseInstanceProperties(IDOMReader &inReader, Qt3DSDMInstanceHandle inInstance, - vector<pair<TCharPtr, TCharPtr>> &outExtraAttributes, + vector<pair<QString, QString>> &outExtraAttributes, TPropertyHandleValuePairList &outProperties) { bool hasNoLifetime = @@ -1487,7 +1510,7 @@ struct SComposerSerializerImpl : public IComposerSerializer || m_DataCore.IsInstanceOrDerivedFrom(inInstance, m_ObjectDefinitions.m_Material.m_Instance); - for (eastl::pair<TCharPtr, TCharPtr> theAtt = inReader.GetFirstAttribute(); + for (std::pair<QString, QString> theAtt = inReader.GetFirstAttribute(); !IsTrivial(theAtt.first); theAtt = inReader.GetNextAttribute()) { Option<pair<Qt3DSDMPropertyHandle, SValue>> theValue = ParseValue(inInstance, theAtt.first, theAtt.second); @@ -1505,7 +1528,7 @@ struct SComposerSerializerImpl : public IComposerSerializer void ParseAndSetInstanceProperties(IDOMReader &inReader, Qt3DSDMSlideHandle inSlide, Qt3DSDMInstanceHandle inInstance, - vector<pair<TCharPtr, TCharPtr>> &outExtraAttributes, + vector<pair<QString, QString>> &outExtraAttributes, TPropertyHandleValuePairList &ioProperties) { outExtraAttributes.clear(); @@ -1551,13 +1574,13 @@ struct SComposerSerializerImpl : public IComposerSerializer == false) return false; - Option<TCharStr> theType = m_MetaData.GetTypeForInstance(inInstance); + Option<QString> theType = m_MetaData.GetTypeForInstance(inInstance); if (theType.hasValue() == false) { QT3DS_ASSERT(false); return false; } - wstring theMasterRef; + QString theMasterRef; TInstanceHandleList theParents; m_DataCore.GetInstanceParents(inInstance, theParents); @@ -1567,25 +1590,25 @@ struct SComposerSerializerImpl : public IComposerSerializer // we need to save them out into the master classes section QT3DS_ASSERT(theParents.size() == 1); if (!theParents.empty()) { - Option<TCharStr> theCanonicalType = + Option<QString> theCanonicalType = m_MetaData.GetTypeForCanonicalInstance(theParents[0]); // Meaning this isn't a canonical instance if (theCanonicalType.hasValue() == false) { Qt3DSDMInstanceHandle theMaster(theParents[0]); m_MasterObjectsSet.insert(theParents[0]); - theMasterRef = L"#"; + theMasterRef = "#"; theMasterRef.append(GetInstanceId(theMaster)); } } - IDOMWriter::Scope __instanceScope(inWriter, theType->wide_str()); + IDOMWriter::Scope __instanceScope(inWriter, theType); inWriter.Att(L"id", GetInstanceId(inInstance)); m_InstanceSet.insert(inInstance); Qt3DSDMSlideHandle theAssociatedSlide = GetAssociatedSlide(inInstance); - if (theAssociatedSlide.Valid()) + if (theAssociatedSlide.Valid() && !m_SlideSet.contains(theAssociatedSlide)) m_SlideSet.insert(theAssociatedSlide); bool isSlideOwner = m_DataCore.IsInstanceOrDerivedFrom( @@ -1593,14 +1616,17 @@ struct SComposerSerializerImpl : public IComposerSerializer if (isSlideOwner) { // Ensure we mark all of those slides. SLong4 theGuid = GetGuid(inInstance, m_ObjectDefinitions.m_Guided.m_GuidProp); - Qt3DSDMSlideHandle theMasterSlide = m_SlideSystem.GetMasterSlideByComponentGuid(theGuid); + Qt3DSDMSlideHandle theMasterSlide(m_SlideSystem.GetMasterSlideByComponentGuid(theGuid)); if (theMasterSlide.Valid()) { TSlideHandleList theChildSlides; m_SlideCore.GetChildSlides(theMasterSlide, theChildSlides); - m_SlideSet.insert(theMasterSlide); + if (!m_SlideSet.contains(theMasterSlide)) + m_SlideSet.insert(theMasterSlide); for (size_t slideIdx = 0, slideEnd = theChildSlides.size(); slideIdx < slideEnd; - ++slideIdx) - m_SlideSet.insert(theChildSlides[slideIdx]); + ++slideIdx) { + if (!m_SlideSet.contains(theChildSlides[slideIdx])) + m_SlideSet.insert(theChildSlides[slideIdx]); + } } } ///////////////////////////////////////////////////////////////////////// @@ -1613,23 +1639,23 @@ struct SComposerSerializerImpl : public IComposerSerializer SerializePropertyList(inWriter, theValues); if (theMasterRef.size()) - inWriter.Att(L"class", theMasterRef.c_str()); + inWriter.Att(QStringLiteral("class"), theMasterRef); if (inWriteParentRefs) { Qt3DSDMInstanceHandle theParent(m_AssetGraph.GetParent(inInstance)); if (theParent.Valid()) { - wstring theParentRef(L"#"); + QString theParentRef("#"); theParentRef.append(GetInstanceId(theParent)); m_ExternalReferences.insert(theParent); - inWriter.Att(L"graphparent", theParentRef.c_str()); + inWriter.Att(QStringLiteral("graphparent"), theParentRef); } Qt3DSDMInstanceHandle theSibling = m_AssetGraph.GetSibling(inInstance, true); if (theSibling.Valid()) { - wstring theSiblingRef(L"#"); + QString theSiblingRef("#"); theSiblingRef.append(GetInstanceId(theSibling)); m_ExternalReferences.insert(theSibling); - inWriter.Att(L"graphsibling", theSiblingRef.c_str()); + inWriter.Att(QStringLiteral("graphsibling"), theSiblingRef); } } @@ -1674,30 +1700,31 @@ struct SComposerSerializerImpl : public IComposerSerializer success = inReader.MoveToNextSibling()) { qt3dsdm::Qt3DSDMInstanceHandle theNewInstance; - TCharPtr theParentRef = L""; + QString theParentRef; if (inReader.Att(L"graphparent", theParentRef)) - inParent = GetInstanceById(theParentRef + 1); - TCharPtr theSiblingRef = L""; + inParent = GetInstanceById(idFromRef(theParentRef)); + QString theSiblingRef; bool theSilbingExists = false; if (inReader.Att(L"graphsibling", theSiblingRef)) theSilbingExists = true; - TCharPtr theId; + QString theId; inReader.Att(L"id", theId); - TCharPtr theMasterRef; - if (inReader.Att(L"class", theMasterRef) && GetInstanceById(theMasterRef + 1).Valid()) { + QString theMasterRef; + if (inReader.Att(L"class", theMasterRef) + && GetInstanceById(idFromRef(theMasterRef)).Valid()) { theNewInstance = IDocumentEditor::CreateSceneGraphInstance( - GetInstanceById(theMasterRef + 1), inParent, 0, m_DataCore, m_SlideSystem, - m_ObjectDefinitions, m_AssetGraph, m_MetaData); + GetInstanceById(idFromRef(theMasterRef)), inParent, 0, m_DataCore, + m_SlideSystem, m_ObjectDefinitions, m_AssetGraph, m_MetaData); } else { - TCharPtr theType(inReader.GetElementName()); + QString theType(inReader.GetElementName()); theNewInstance = IDocumentEditor::CreateSceneGraphInstance( theType, inParent, 0, m_DataCore, m_SlideSystem, m_ObjectDefinitions, m_AssetGraph, m_MetaData); } if (theSilbingExists) - m_NewInstancesToSiblings.insert(std::make_pair(theNewInstance, theSiblingRef + 1)); + m_NewInstancesToSiblings.insert(theNewInstance, idFromRef(theSiblingRef)); SLong4 theGuid = GetGuid(theNewInstance, m_ObjectDefinitions.m_Guided.m_GuidProp); if (m_PreserveFileIds) @@ -1718,7 +1745,7 @@ struct SComposerSerializerImpl : public IComposerSerializer { TInstanceToSiblingMap::iterator itr = m_NewInstancesToSiblings.find(inNewInstance); if (itr != m_NewInstancesToSiblings.end()) { - Qt3DSDMInstanceHandle theSibling = GetInstanceById((*itr).second); + Qt3DSDMInstanceHandle theSibling = GetInstanceById(*itr); if (theSibling.Valid()) { _MoveNewInstanceToItsPlaceRecursive(theSibling); @@ -1734,8 +1761,8 @@ struct SComposerSerializerImpl : public IComposerSerializer IDOMReader::Scope __childScope(inReader); for (bool success = inReader.MoveToFirstChild(); success; success = inReader.MoveToNextSibling()) { - TCharPtr theId; - inReader.Att(L"id", theId); + QString theId; + inReader.Att(QStringLiteral("id"), theId); Qt3DSDMInstanceHandle theNewInstance = GetInstanceById(theId); if (theNewInstance.Valid() == false) { @@ -1744,7 +1771,7 @@ struct SComposerSerializerImpl : public IComposerSerializer } TPropertyHandleValuePairList theValues; - vector<pair<TCharPtr, TCharPtr>> theExtraAtts; + vector<pair<QString, QString>> theExtraAtts; ParseAndSetInstanceProperties(inReader, 0, theNewInstance, theExtraAtts, theValues); ReadInstanceProperties(inReader); @@ -1792,20 +1819,19 @@ struct SComposerSerializerImpl : public IComposerSerializer m_ExternalReferences.insert(inInstance); IDOMWriter::Scope __instanceScope(inWriter, L"Set"); - wstring theRef = GetInstanceId(inInstance); - theRef.insert(0, L"#"); - inWriter.Att(L"ref", theRef.c_str()); + const QString theRef(QLatin1Char('#') + GetInstanceId(inInstance)); + inWriter.Att(QStringLiteral("ref"), theRef); SerializePropertyList(inWriter, theValues); SerializeAnimations(inWriter, theAnimations); SerializeActions(inWriter, inSlide, inInstance, theActions); for (size_t idx = 0, end = theEyeballChanges.size(); idx < end; ++idx) { Qt3DSDMActionHandle theAction(theMasterActions[theEyeballChanges[idx].first]); IDOMWriter::Scope __actionScope(inWriter, L"Action"); - wstring theRef(L"#"); bool hadAction = m_ActionToIdMap.find(theAction) != m_ActionToIdMap.end(); - theRef.append(GetActionId(theAction, inParent, inInstance)); - inWriter.Att(L"ref", theRef.c_str()); - inWriter.Att("eyeball", theEyeballChanges[idx].second); + const QString theRef(QLatin1Char('#') + GetActionId(theAction, inParent, + inInstance)); + inWriter.Att(QStringLiteral("ref"), theRef); + inWriter.Att(QStringLiteral("eyeball"), theEyeballChanges[idx].second); if (!hadAction) m_ExternalActions.insert(theAction); } @@ -1829,16 +1855,15 @@ struct SComposerSerializerImpl : public IComposerSerializer theActions); // When copying slides, we don't automatically add all the instances like we do when we // cut/paste - const wchar_t *commandName = L"Set"; + QString commandName = QStringLiteral("Set"); if (inSlide == m_ActiveSlide || inSlide == m_SlideSystem.GetAssociatedSlide(inInstance)) - commandName = L"Add"; + commandName = QStringLiteral("Add"); - if (AreEqual(commandName, L"Add") || theValues.size() || theAnimations.size() + if (commandName == QStringLiteral("Add") || theValues.size() || theAnimations.size() || theActions.size()) { IDOMWriter::Scope __instanceScope(inWriter, commandName); - wstring theRef = GetInstanceId(inInstance); - theRef.insert(0, L"#"); - inWriter.Att(L"ref", theRef.c_str()); + const QString theRef(QLatin1Char('#') + GetInstanceId(inInstance)); + inWriter.Att(QStringLiteral("ref"), theRef); SerializePropertyList(inWriter, theValues); SerializeAnimations(inWriter, theAnimations); SerializeActions(inWriter, inSlide, inInstance, theActions); @@ -1890,7 +1915,7 @@ struct SComposerSerializerImpl : public IComposerSerializer { TInstanceIntMap::const_iterator theIter = m_DepthMap.find(inHdl); if (theIter != m_DepthMap.end()) - return theIter->second; + return *theIter; return QT3DS_MAX_I32; } bool operator()(Qt3DSDMInstanceHandle lhs, Qt3DSDMInstanceHandle rhs) const @@ -1913,8 +1938,8 @@ struct SComposerSerializerImpl : public IComposerSerializer void SerializeSlides(IDOMWriter &inWriter, bool inSlideCopy = false) { if (m_ActiveSlide.Valid()) { - m_SlideSet.erase(m_ActiveSlide); - m_SlideSet.erase(m_ActiveSlideParent); + m_SlideSet.remove(m_ActiveSlide); + m_SlideSet.remove(m_ActiveSlideParent); IDOMWriter::Scope __writeScope(inWriter, L"ActiveState"); @@ -1962,7 +1987,7 @@ struct SComposerSerializerImpl : public IComposerSerializer theIter != end; ++theIter) { Qt3DSDMSlideHandle theSlide = *theIter; Qt3DSDMSlideHandle theMasterSlide = m_SlideCore.GetParentSlide(theSlide); - if (theMasterSlide.Valid() && theMasterSlideSet.insert(theMasterSlide).second) { + if (theMasterSlide.Valid() && *theMasterSlideSet.insert(theMasterSlide)) { Qt3DSDMInstanceHandle theSlideOwner(GetSlideComponent(theMasterSlide)); if (theSlideOwner.Valid()) theSerializationSlides.push_back(std::make_pair(theMasterSlide, theSlideOwner)); @@ -1977,10 +2002,9 @@ struct SComposerSerializerImpl : public IComposerSerializer Qt3DSDMInstanceHandle theComponent = theSerializationSlides[slideSetIdx].second; IDOMWriter::Scope __masterScope(inWriter, L"State"); - inWriter.Att(L"name", GetSlideName(theMasterSlide)); - wstring theComponentRef = L"#"; - theComponentRef.append(GetInstanceId(theComponent)); - inWriter.Att(L"component", theComponentRef.c_str()); + inWriter.Att(QStringLiteral("name"), GetSlideName(theMasterSlide)); + const QString theComponentRef(QLatin1Char('#') + GetInstanceId(theComponent)); + inWriter.Att(QStringLiteral("component"), theComponentRef); TPropertyHandleValuePairList theValues; GetSlidePropertyValues(theMasterSlide, theValues); @@ -2008,7 +2032,7 @@ struct SComposerSerializerImpl : public IComposerSerializer } for (size_t idx = 0, end = theChildren.size(); idx < end; ++idx) { Qt3DSDMSlideHandle theChildSlide(theChildren[idx]); - m_SlideSet.erase(theChildSlide); + m_SlideSet.remove(theChildSlide); IDOMWriter::Scope __childSlideScope(inWriter, L"State"); inWriter.Att(L"id", GetSlideId(theChildSlide, theComponent)); inWriter.Att(L"name", GetSlideName(theChildSlide)); @@ -2067,7 +2091,7 @@ struct SComposerSerializerImpl : public IComposerSerializer { IDOMReader::Scope __stateScope(inReader); TPropertyHandleValuePairList theValues; - vector<pair<TCharPtr, TCharPtr>> theExtraAtts; + vector<pair<QString, QString>> theExtraAtts; ParseAndSetInstanceProperties(inReader, 0, m_SlideCore.GetSlideInstance(inSlide), theExtraAtts, theValues); // Slides require a two-pass parsing system because slides can refer to each other via id. @@ -2080,8 +2104,8 @@ struct SComposerSerializerImpl : public IComposerSerializer // references to other slides // via id *in* the slide data. { - const wchar_t *theId = L""; - inReader.Att(L"Id", theId); + QString theId; + inReader.Att(QStringLiteral("Id"), theId); pair<Qt3DSDMSlideHandle, Qt3DSDMInstanceHandle> theChildSlideInstPair = CreateSlide(); m_SlideCore.DeriveSlide(theChildSlideInstPair.first, inSlide); @@ -2103,11 +2127,11 @@ struct SComposerSerializerImpl : public IComposerSerializer for (bool success = inReader.MoveToFirstChild(); success; success = inReader.MoveToNextSibling()) { - if (AreEqual(inReader.GetElementName(), L"Set") - || AreEqual(inReader.GetElementName(), L"Add")) { - TCharPtr theRef; - inReader.Att(L"ref", theRef); - Qt3DSDMInstanceHandle theInstance = GetInstanceById(theRef + 1); + if (inReader.GetElementName() == QLatin1String("Set") + || inReader.GetElementName() == QLatin1String("Add")) { + QString theRef; + inReader.Att(QStringLiteral("ref"), theRef); + Qt3DSDMInstanceHandle theInstance = GetInstanceById(idFromRef(theRef)); if (theInstance.Valid() == false) { QT3DS_ASSERT(false); continue; @@ -2132,14 +2156,14 @@ struct SComposerSerializerImpl : public IComposerSerializer IDOMReader::Scope __instanceScope(inReader); for (bool childSuccess = inReader.MoveToFirstChild(); childSuccess; childSuccess = inReader.MoveToNextSibling()) { - if (AreEqual(inReader.GetElementName(), L"AnimationTrack")) + if (inReader.GetElementName() == QLatin1String("AnimationTrack")) ParseAnimation(inReader, inSlide, theInstance); - else if (AreEqual(inReader.GetElementName(), L"Action")) + else if (inReader.GetElementName() == QLatin1String("Action")) inUnparsedActions.push_back( SActionParseRecord(inReader.GetScope(), inSlide, theInstance)); } - } else if (AreEqual(inReader.GetElementName(), L"State")) { - const wchar_t *theId = L""; + } else if (inReader.GetElementName() == QLatin1String("State")) { + QString theId; inReader.Att(L"Id", theId); Qt3DSDMSlideHandle theSlide; if (!IsTrivial(theId)) @@ -2165,7 +2189,7 @@ struct SComposerSerializerImpl : public IComposerSerializer IDOMReader::Scope __logicScope(inReader); for (bool success = inReader.MoveToFirstChild(); success; success = inReader.MoveToNextSibling()) { - if (AreEqual(inReader.GetElementName(), L"ActiveState")) { + if (inReader.GetElementName() == QLatin1String("ActiveState")) { if (m_ActiveSlide.Valid() == false) { QT3DS_ASSERT(false); continue; @@ -2176,10 +2200,10 @@ struct SComposerSerializerImpl : public IComposerSerializer SLong4 theSceneGuid(thePackedGuid.Data1, thePackedGuid.Data2, thePackedGuid.Data3, thePackedGuid.Data4); ParseSlide(inReader, m_ActiveSlide, theSceneGuid, theUnparsedActions); - } else if (AreEqual(inReader.GetElementName(), L"State")) { - TCharPtr componentRef = L""; + } else if (inReader.GetElementName() == QLatin1String("State")) { + QString componentRef; inReader.Att(L"component", componentRef); - Qt3DSDMInstanceHandle component = GetInstanceById(componentRef + 1); + Qt3DSDMInstanceHandle component = GetInstanceById(idFromRef(componentRef)); if (component.Valid() == false) { QT3DS_ASSERT(false); continue; @@ -2235,42 +2259,30 @@ struct SComposerSerializerImpl : public IComposerSerializer { // First filter the external references via the instance set for (TInstanceSet::iterator theIter = m_InstanceSet.begin(), end = m_InstanceSet.end(); - theIter != end; ++theIter) - m_ExternalReferences.erase(*theIter); + theIter != end; ++theIter) { + m_ExternalReferences.remove(*theIter); + } if (m_ExternalReferences.empty() && m_ExternalActions.empty() && m_ExternalSlides.empty()) return; IDOMWriter::Scope __refScope(inWriter, L"ExternalReferences"); - wstring theWriteBuf; - wstring theId; - wchar_t tempBuf[256]; for (TInstanceSet::iterator theIter = m_ExternalReferences.begin(), theEnd = m_ExternalReferences.end(); theIter != theEnd; ++theIter) { IDOMWriter::Scope __refScope(inWriter, L"Reference"); - theId.assign(L"#"); - theId.append(GetInstanceId(*theIter)); - inWriter.Att(L"ref", theId.c_str()); - theWriteBuf.clear(); + const QString theId(QLatin1Char('#') + GetInstanceId(*theIter)); + inWriter.Att(L"ref", theId); SLong4 theGuid = GetInstanceGuid(*theIter); - for (size_t idx = 0; idx < 4; ++idx) { - WStrOps<qt3ds::QT3DSU32>().ToStr(theGuid.m_Longs[idx], toDataRef(tempBuf, 256)); - if (idx) - theWriteBuf.append(L" "); - theWriteBuf.append(tempBuf); - } - inWriter.Att(L"guid", theWriteBuf.c_str()); + inWriter.Att(L"guid", theGuid.toQString()); } for (TActionSet::iterator theIter = m_ExternalActions.begin(), theEnd = m_ExternalActions.end(); theIter != theEnd; ++theIter) { Qt3DSDMActionHandle theAction(*theIter); IDOMWriter::Scope __refScope(inWriter, L"ActionReference"); - theId.assign(L"#"); - theId.append(GetActionId(theAction, 0, 0)); - inWriter.Att(L"ref", theId.c_str()); - + const QString theId(QLatin1Char('#') + GetActionId(theAction, 0, 0)); + inWriter.Att(L"ref", theId); inWriter.Att(L"handle", (int)theAction); } for (TSlideSet::iterator theIter = m_ExternalSlides.begin(), @@ -2278,9 +2290,8 @@ struct SComposerSerializerImpl : public IComposerSerializer theIter != theEnd; ++theIter) { Qt3DSDMSlideHandle theSlide(*theIter); IDOMWriter::Scope __refScope(inWriter, L"SlideReference"); - theId.assign(L"#"); - theId.append(GetSlideId(theSlide, 0)); - inWriter.Att(L"ref", theId.c_str()); + const QString theId(QLatin1Char('#') + GetSlideId(theSlide, 0)); + inWriter.Att(L"ref", theId); inWriter.Att(L"handle", (int)theSlide); } } @@ -2299,16 +2310,15 @@ struct SComposerSerializerImpl : public IComposerSerializer SValue lhsValue, rhsValue; m_DataCore.GetInstancePropertyValue(lhs, m_SourcePathProperty, lhsValue); m_DataCore.GetInstancePropertyValue(rhs, m_SourcePathProperty, rhsValue); - TDataStrPtr lhsStr = qt3dsdm::get<TDataStrPtr>(lhsValue); - TDataStrPtr rhsStr = qt3dsdm::get<TDataStrPtr>(rhsValue); - return QString::compare(QString::fromWCharArray(lhsStr->GetData()), QString::fromWCharArray(rhsStr->GetData())) < 0; + QString lhsStr = qt3dsdm::get<TDataStrPtr>(lhsValue)->toQString(); + QString rhsStr = qt3dsdm::get<TDataStrPtr>(rhsValue)->toQString(); + return QString::compare(lhsStr, rhsStr) < 0; } }; void AddGraphInstanceToOrderMap(Qt3DSDMInstanceHandle inInstance) { - m_InstanceToGraphDepthMap.insert( - std::make_pair(inInstance, (int)m_InstanceToGraphDepthMap.size())); + m_InstanceToGraphDepthMap.insert(inInstance, (int)m_InstanceToGraphDepthMap.size()); } void BuildGraphOrderMap(const Qt3DSDMInstanceHandle *inTopInstances, QT3DSU32 inCount) @@ -2364,12 +2374,12 @@ struct SComposerSerializerImpl : public IComposerSerializer end = theMasterObjectsList.end(); theIter != end; ++theIter) { Qt3DSDMInstanceHandle theMaster(*theIter); - Option<TCharStr> theType = m_MetaData.GetTypeForInstance(theMaster); + Option<QString> theType = m_MetaData.GetTypeForInstance(theMaster); if (theType.hasValue() == false) { QT3DS_ASSERT(false); continue; } - IDOMWriter::Scope instScope(inWriter, theType->wide_str()); + IDOMWriter::Scope instScope(inWriter, theType); inWriter.Att(L"id", GetInstanceId(theMaster)); // Write out all the properties that are on the instance but are not on *this* // instance in the meta data. @@ -2396,165 +2406,140 @@ struct SComposerSerializerImpl : public IComposerSerializer IDOMReader::Scope __externalReferencesScope(inReader); if (inReader.MoveToFirstChild(L"ExternalReferences")) { GetAllInstanceGuids(); - TCharStr theRef; - TCharStr theGuidBuf; + QString theRef; + QString theGuidBuf; for (bool success = inReader.MoveToFirstChild(); success; success = inReader.MoveToNextSibling()) { - if (AreEqual(inReader.GetElementName(), L"Reference")) { + if (inReader.GetElementName() == QLatin1String("Reference")) { inReader.Att(L"ref", theRef); inReader.Att(L"guid", theGuidBuf); SLong4 theGuid; - const wchar_t *theStartPtr(theGuidBuf.wide_str()); - wchar_t *theEndPtr(NULL); - for (size_t idx = 0; idx < 4; ++idx) { - theGuid.m_Longs[idx] = wcstol(theStartPtr, &theEndPtr, 10); - theStartPtr = theEndPtr; - } + QStringList split(theGuidBuf.split(QLatin1Char(' '))); + theGuid.m_Longs[0] = split[0].toLong(); + theGuid.m_Longs[1] = split[1].toLong(); + theGuid.m_Longs[2] = split[2].toLong(); + theGuid.m_Longs[3] = split[3].toLong(); Qt3DSDMInstanceHandle theInstance = FindInstanceByGUID(theGuid); if (theInstance.Valid()) - AddId(theRef.wide_str() + 1, theInstance); - } else if (AreEqual(inReader.GetElementName(), L"ActionReference")) { + AddId(idFromRef(theRef), theInstance); + } else if (inReader.GetElementName() == QLatin1String("ActionReference")) { inReader.Att(L"ref", theRef); inReader.Att(L"handle", theGuidBuf); - long theHandleValue(wcstol(theGuidBuf.wide_str(), NULL, 10)); + long theHandleValue(theGuidBuf.toLong()); Qt3DSDMActionHandle theAction(theHandleValue); QT3DS_ASSERT(m_ActionCore.HandleValid(theAction)); - AddActionId(theRef.wide_str() + 1, theAction); - } else if (AreEqual(inReader.GetElementName(), L"SlideReference")) { + AddActionId(idFromRef(theRef), theAction); + } else if (inReader.GetElementName() == QLatin1String("SlideReference")) { inReader.Att(L"ref", theRef); inReader.Att(L"handle", theGuidBuf); - long theHandleValue(wcstol(theGuidBuf.wide_str(), NULL, 10)); + long theHandleValue(theGuidBuf.toLong()); Qt3DSDMSlideHandle theSlide(theHandleValue); QT3DS_ASSERT(m_SlideCore.IsSlide(theSlide)); - AddSlideId(theRef.wide_str() + 1, theSlide); + AddSlideId(idFromRef(theRef), theSlide); } } } } + Qt3DSDMInstanceHandle loadSourcePathFile( + IDOMReader &inReader, const QString &inDocumentDirectory, const QString &theSourcePath) + { + Qt3DSDMInstanceHandle theMaster; + QString theFullPath(CFilePath::CombineBaseAndRelative(inDocumentDirectory, theSourcePath)); + QString theType(inReader.GetElementName()); + Qt3DSDMInstanceHandle theCanonicalType(m_MetaData.GetCanonicalInstanceForType(theType)); + + if (theCanonicalType.Valid() == false) { + QT3DS_ASSERT(false); + return theMaster; + } + + theMaster = m_DataCore.CreateInstance(); + m_DataCore.DeriveInstance(theMaster, theCanonicalType); + m_SourcePathToMasterInstances.insert(theSourcePath, theMaster); + QFileInfo info(theFullPath); + if (!info.exists()) { + QT3DS_ASSERT(false); + return theMaster; + } + const QString suffix(info.suffix()); + if (suffix.compare(QLatin1String("qml"), Qt::CaseInsensitive) == 0) { + std::shared_ptr<IDOMReader> theScriptPtr + = IDocumentEditor::ParseScriptFile(theFullPath, m_DataCore.GetStringTablePtr(), + m_ImportFailedHandler, + *m_InputStreamFactory); + if (theScriptPtr) { + std::vector<SMetaDataLoadWarning> warnings; + m_MetaData.LoadInstance(*theScriptPtr, theMaster, info.baseName(), warnings); + } + } else if (suffix.compare(QLatin1String("glsl"), Qt::CaseInsensitive) == 0 + || suffix.compare(QLatin1String("effect"), Qt::CaseInsensitive) == 0) { + std::vector<SMetaDataLoadWarning> warnings; + Q3DStudio::IRefCountedInputStream theStream + = m_InputStreamFactory->getStreamForFile(theFullPath); + if (theStream) { + m_MetaData.LoadEffectInstance(theSourcePath, theMaster, info.baseName(), + warnings, *theStream); + } + } else if (suffix.compare(QLatin1String("plugin"), Qt::CaseInsensitive) == 0) { + std::shared_ptr<IDOMReader> thePluginPtr + = IDocumentEditor::ParsePluginFile(theFullPath, m_DataCore.GetStringTablePtr(), + m_ImportFailedHandler, + *m_InputStreamFactory); + if (thePluginPtr) { + std::vector<SMetaDataLoadWarning> warnings; + m_MetaData.LoadInstance(*thePluginPtr, theMaster, info.baseName(), warnings); + } + } else if (suffix.compare(QLatin1String("material"), Qt::CaseInsensitive) == 0) { + std::vector<SMetaDataLoadWarning> warnings; + IRefCountedInputStream theStream = m_InputStreamFactory->getStreamForFile(theFullPath); + if (theStream) { + m_MetaData.LoadMaterialInstance(theSourcePath, theMaster, info.baseName(), + warnings, *theStream); + } + } else { + QT3DS_ASSERT(false); + } + return theMaster; + } + qt3dsdm::TInstanceHandleList DoSerializeScene(IDOMReader &inReader, - const CFilePath &inDocumentDirectory, - Qt3DSDMInstanceHandle inNewRoot) + const QString &inDocumentDirectory, + Qt3DSDMInstanceHandle inNewRoot) { // Attempt to work correctly whether we are pointing to the project or not. IDOMReader::Scope __outerScope(inReader); - if (AreEqual(inReader.GetElementName(), L"UIP")) - inReader.MoveToFirstChild(L"Project"); + if (inReader.GetElementName() == QLatin1String("UIP")) + inReader.MoveToFirstChild(QStringLiteral("Project")); { ReadExternalReferences(inReader); IDOMReader::Scope __masterScope(inReader); - if (inReader.MoveToFirstChild(L"Classes")) { + if (inReader.MoveToFirstChild(QStringLiteral("Classes"))) { BuildSourcePathMasterObjectMap(); for (bool success = inReader.MoveToFirstChild(); success; success = inReader.MoveToNextSibling()) { - const wchar_t *theSourcePath; + QString theSourcePath; // Ignore master objects that already exist in the project. - if (inReader.Att(L"sourcepath", theSourcePath) == false) { + if (inReader.Att(QStringLiteral("sourcepath"), theSourcePath) == false) { QT3DS_ASSERT(false); continue; } Qt3DSDMInstanceHandle theMaster; - TIdToHandleMap::iterator theFind(m_SourcePathToMasterInstances.find( - m_StringTable.RegisterStr(theSourcePath))); + TIdToHandleMap::iterator theFind(m_SourcePathToMasterInstances + .find(theSourcePath)); if (theFind != m_SourcePathToMasterInstances.end()) { - theMaster = theFind->second; + theMaster = *theFind; } else { - CFilePath theFullPath = CFilePath::CombineBaseAndRelative( - inDocumentDirectory, CFilePath(theSourcePath)); - - const wchar_t *theType(inReader.GetElementName()); - Qt3DSDMInstanceHandle theCanonicalType( - m_MetaData.GetCanonicalInstanceForType(theType)); - if (theCanonicalType.Valid() == false) { - QT3DS_ASSERT(false); - continue; - } - - theMaster = m_DataCore.CreateInstance(); - m_DataCore.DeriveInstance(theMaster, theCanonicalType); TPropertyHandleValuePairList theValues; - vector<pair<TCharPtr, TCharPtr>> theExtraAtts; - m_SourcePathToMasterInstances.insert( - make_pair(m_StringTable.RegisterStr(theSourcePath), theMaster)); - - if (theFullPath.Exists()) { - if (theFullPath.GetExtension().Compare(L"qml", - CString::ENDOFSTRING, false)) { - std::shared_ptr<IDOMReader> theScriptPtr = - IDocumentEditor::ParseScriptFile( - theFullPath, m_DataCore.GetStringTablePtr(), - m_ImportFailedHandler, *m_InputStreamFactory); - if (theScriptPtr) { - std::vector<SMetaDataLoadWarning> warnings; - m_MetaData.LoadInstance(*theScriptPtr, theMaster, - theFullPath.GetFileStem().c_str(), - warnings); - } - } else if (theFullPath.GetExtension().Compare( - L"glsl", CString::ENDOFSTRING, false) - || theFullPath.GetExtension().Compare( - L"effect", CString::ENDOFSTRING, false)) { - if (theFullPath.Exists()) { - std::vector<SMetaDataLoadWarning> warnings; - // Now the magic section - Q3DStudio::IRefCountedInputStream - theStream = m_InputStreamFactory->getStreamForFile( - theFullPath.toQString()); - if (theStream) { - m_MetaData.LoadEffectInstance( - m_StringTable.GetNarrowStr(theSourcePath), - theMaster, - theFullPath.GetFileStem().c_str(), - warnings, - *theStream); - } - } else { - QT3DS_ASSERT(false); - } - } else if (theFullPath.GetExtension().Compare( - L"plugin", CString::ENDOFSTRING, false)) { - std::shared_ptr<IDOMReader> thePluginPtr = - IDocumentEditor::ParsePluginFile( - theFullPath, m_DataCore.GetStringTablePtr(), - m_ImportFailedHandler, *m_InputStreamFactory); - if (thePluginPtr) { - std::vector<SMetaDataLoadWarning> warnings; - // Now the magic section - m_MetaData.LoadInstance(*thePluginPtr, theMaster, - theFullPath.GetFileStem().c_str(), - warnings); - } - } else if (theFullPath.GetExtension().Compare( - L"material", CString::ENDOFSTRING, false)) { - if (theFullPath.Exists()) { - std::vector<SMetaDataLoadWarning> warnings; - IRefCountedInputStream - theStream = m_InputStreamFactory->getStreamForFile( - theFullPath.toQString()); - if (theStream) { - // Now the magic section - m_MetaData.LoadMaterialInstance( - m_StringTable.GetNarrowStr(theSourcePath), - theMaster, - theFullPath.GetFileStem().c_str(), - warnings, - *theStream); - } - } else { - QT3DS_ASSERT(false); - } - } else { - QT3DS_ASSERT(false); - } - } else { - QT3DS_ASSERT(false); - } + vector<pair<QString, QString>> theExtraAtts; + theMaster = loadSourcePathFile(inReader, inDocumentDirectory, + theSourcePath); ParseAndSetInstanceProperties(inReader, 0, theMaster, theExtraAtts, theValues); } - const wchar_t *theId; - inReader.Att(L"id", theId); + QString theId; + inReader.Att(QStringLiteral("id"), theId); AddId(theId, theMaster); } } @@ -2649,7 +2634,7 @@ struct SComposerSerializerImpl : public IComposerSerializer } } - void SerializeScene(IDOMReader &inReader, const CFilePath &inDocumentDirectory, + void SerializeScene(IDOMReader &inReader, const QString &inDocumentDirectory, int inUIPVersion) override { reset(); @@ -2674,7 +2659,7 @@ struct SComposerSerializerImpl : public IComposerSerializer // Read a partial serialization into this slide, attaching the instance as the last child of the // new root. virtual qt3dsdm::TInstanceHandleList - SerializeSceneGraphObject(IDOMReader &inReader, const CFilePath &inDocumentDirectory, + SerializeSceneGraphObject(IDOMReader &inReader, const QString &inDocumentDirectory, Qt3DSDMInstanceHandle inNewRoot, Qt3DSDMSlideHandle inActiveSlide) override { reset(); @@ -2784,8 +2769,8 @@ struct SComposerSerializerImpl : public IComposerSerializer } Qt3DSDMSlideHandle SerializeSlide(qt3dsdm::IDOMReader &inReader, - const CFilePath &inDocumentDirectory, - qt3dsdm::Qt3DSDMSlideHandle inMaster, int newIndex) override + const QString &inDocumentDirectory, + qt3dsdm::Qt3DSDMSlideHandle inMaster, int newIndex) override { reset(); m_PreserveFileIds = false; diff --git a/src/Authoring/Client/Code/Core/Doc/IComposerSerializer.h b/src/Authoring/Client/Code/Core/Doc/IComposerSerializer.h index 4434a0ff..301a8144 100644 --- a/src/Authoring/Client/Code/Core/Doc/IComposerSerializer.h +++ b/src/Authoring/Client/Code/Core/Doc/IComposerSerializer.h @@ -69,7 +69,7 @@ public: // inActiveSlide may be zero if the top item we find happens to be a scene or a component. // The graph roots hold the top items virtual void SerializeScene(qt3dsdm::IDOMReader &inReader, - const Q3DStudio::CFilePath &inDocumentDirectory, + const QString &inDocumentDirectory, int inUIPVersion) = 0; // Write this instance and its children (and possibly its slides) to a writer. @@ -81,7 +81,7 @@ public: // Read a partial serialization into this slide, attaching the instance as the last child of the // new root. virtual qt3dsdm::TInstanceHandleList SerializeSceneGraphObject( - qt3dsdm::IDOMReader &inReader, const Q3DStudio::CFilePath &inDocumentDirectory, + qt3dsdm::IDOMReader &inReader, const QString &inDocumentDirectory, qt3dsdm::Qt3DSDMInstanceHandle inNewRoot, qt3dsdm::Qt3DSDMSlideHandle inActiveSlide) = 0; // Save and load just a single action @@ -95,7 +95,7 @@ public: virtual void SerializeSlide(qt3dsdm::IDOMWriter &inWriter, qt3dsdm::Qt3DSDMSlideHandle inSlide) = 0; virtual qt3dsdm::Qt3DSDMSlideHandle SerializeSlide(qt3dsdm::IDOMReader &inReader, - const CFilePath &inDocumentDirectory, + const QString &inDocumentDirectory, qt3dsdm::Qt3DSDMSlideHandle inMaster, int inNewIndex = -1) = 0; diff --git a/src/Authoring/Client/Code/Core/Doc/IDoc.h b/src/Authoring/Client/Code/Core/Doc/IDoc.h index 609b91f9..955c364c 100644 --- a/src/Authoring/Client/Code/Core/Doc/IDoc.h +++ b/src/Authoring/Client/Code/Core/Doc/IDoc.h @@ -104,12 +104,12 @@ public: virtual qt3dsdm::IPropertySystem *GetPropertySystem() = 0; virtual qt3dsdm::IAnimationCore *GetAnimationCore() = 0; virtual void SetInstancePropertyValue(qt3dsdm::Qt3DSDMInstanceHandle inInstance, - const std::wstring &inPropertyName, + const QString &inPropertyName, const qt3dsdm::SValue &inValue) = 0; virtual void SetInstancePropertyControlled(qt3dsdm::Qt3DSDMInstanceHandle instance, - Q3DStudio::CString instancepath, + const QString &instancepath, qt3dsdm::Qt3DSDMPropertyHandle propName, - Q3DStudio::CString controller, + const QString &controller, bool controlled, bool batch = false) = 0; virtual void RemoveDatainputBindings( const QMultiMap<QString, QPair<qt3dsdm::Qt3DSDMInstanceHandle, @@ -154,7 +154,7 @@ public: // Create a DOM reader and check that the top element's version is correct. Opens the reader // to the project element. virtual std::shared_ptr<qt3dsdm::IDOMReader> - CreateDOMReader(const Q3DStudio::CString &inFilePath, qt3ds::QT3DSI32 &outVersion) = 0; + CreateDOMReader(const QString &inFilePath, qt3ds::QT3DSI32 &outVersion) = 0; virtual CCore *GetCore() const = 0; }; diff --git a/src/Authoring/Client/Code/Core/Doc/IDocumentEditor.h b/src/Authoring/Client/Code/Core/Doc/IDocumentEditor.h index 789bb15c..b19d1c65 100644 --- a/src/Authoring/Client/Code/Core/Doc/IDocumentEditor.h +++ b/src/Authoring/Client/Code/Core/Doc/IDocumentEditor.h @@ -40,7 +40,7 @@ #include "DocumentEditorEnumerations.h" #include "IDocumentReader.h" #include "Qt3DSDMComposerTypeDefinitions.h" -#include "CColor.h" +#include <QtGui/qcolor.h> #include "Qt3DSDMHandles.h" #pragma once @@ -68,7 +68,6 @@ namespace render { } namespace Q3DStudio { -using std::wstring; class CGraph; class IInternalDocumentEditor; class IInputStreamFactory; @@ -121,7 +120,7 @@ public: // Function callable without a document editor instance, used when loading document static TInstanceHandle - CreateSceneGraphInstance(const wchar_t *inType, TInstanceHandle parent, TSlideHandle inSlide, + CreateSceneGraphInstance(const QString &inType, TInstanceHandle parent, TSlideHandle inSlide, qt3dsdm::IDataCore &inDataCore, qt3dsdm::ISlideSystem &inSlideSystem, qt3dsdm::SComposerObjectDefinitions &inObjectDefs, Q3DStudio::CGraph &inAssetGraph, qt3dsdm::IMetaData &inMetaData, @@ -160,8 +159,8 @@ public: bool setTimeRange = true) = 0; virtual void setInstanceImagePropertyValueAsRenderable(TInstanceHandle instance, TPropertyHandle prop, - const CString &pId) = 0; - virtual void addRectForSubpresentation(const CString &pId, TSlideHandle slide, + const QString &pId) = 0; + virtual void addRectForSubpresentation(const QString &pId, TSlideHandle slide, const CPt &pos = CPt(), long startTime = -1) = 0; virtual void DeleteInstances(const qt3dsdm::TInstanceHandleList &instances) = 0; @@ -175,10 +174,10 @@ public: DeleteInstances(theInstances); } - virtual Q3DStudio::CString writeMaterialFile(Qt3DSDMInstanceHandle instance, - const QString &materialName, - bool createNewFile, - const QString &sourcePath = {}) = 0; + virtual QString writeMaterialFile(Qt3DSDMInstanceHandle instance, + const QString &materialName, + bool createNewFile, + const QString &sourcePath = {}) = 0; virtual void updateMaterialInstances(const QStringList &filenames) = 0; @@ -188,8 +187,8 @@ public: virtual Qt3DSDMInstanceHandle getMaterialContainer() const = 0; - virtual Qt3DSDMInstanceHandle getMaterial(const Q3DStudio::CString &materialName) = 0; - virtual Qt3DSDMInstanceHandle getOrCreateMaterial(const Q3DStudio::CString &materialName) = 0; + virtual Qt3DSDMInstanceHandle getMaterial(const QString &materialName) = 0; + virtual Qt3DSDMInstanceHandle getOrCreateMaterial(const QString &materialName) = 0; virtual void getMaterialReference(Qt3DSDMInstanceHandle instance, Qt3DSDMInstanceHandle &reference) const = 0; @@ -206,7 +205,7 @@ public: TPropertyHandle inProperty, const SValue &value) = 0; void SetSpecificInstancePropertyValue(TSlideHandle inSlide, TInstanceHandle instance, - const wchar_t *inProperty, const SValue &value) + const QString &inProperty, const SValue &value) { SetSpecificInstancePropertyValue(inSlide, instance, FindProperty(instance, inProperty), value); @@ -227,29 +226,29 @@ public: // the we will return 0 from this function. virtual TInstanceHandle SetInstancePropertyValueAsImage(TInstanceHandle instance, TPropertyHandle propName, - const Q3DStudio::CString &inSourcePath) = 0; + const QString &inSourcePath) = 0; // If sourcepath resolves to a valid plugin file, we create a renderable item and add it as a // child to the image. // else we return nothing and just set the value as is. virtual TInstanceHandle SetInstancePropertyValueAsRenderable(TInstanceHandle instance, TPropertyHandle propName, - const Q3DStudio::CString &inSourcePath) = 0; + const QString &inSourcePath) = 0; virtual void SetMaterialType(TInstanceHandle instance, - const Q3DStudio::CString &inRelativePathToMaterialFile) = 0; + const QString &inRelativePathToMaterialFile) = 0; virtual void setMaterialProperties(TInstanceHandle instance, const QString &materialName, - const Q3DStudio::CString &materialSourcePath, + const QString &materialSourcePath, const QMap<QString, QString> &values, const QMap<QString, QMap<QString, QString>> &textureValues) = 0; virtual void setMaterialReferenceByName(TInstanceHandle instance, - const Q3DStudio::CString &materialName) = 0; + const QString &materialName) = 0; virtual void setMaterialSourcePath(TInstanceHandle instance, - const Q3DStudio::CString &materialSourcePath) = 0; + const QString &materialSourcePath) = 0; virtual void setMaterialValues(const QString &materialName, const QMap<QString, QString> &values, @@ -264,7 +263,7 @@ public: virtual void SetSlideName(TInstanceHandle instance, TPropertyHandle propName, const wchar_t *inOldName, const wchar_t *inNewName) = 0; - virtual void SetName(Qt3DSDMInstanceHandle inInstance, const CString &inName, + virtual void SetName(Qt3DSDMInstanceHandle inInstance, const QString &inName, bool inMakeUnique = false) = 0; // Linking/unlinking properties. Functions take care of creating/destroying @@ -282,7 +281,7 @@ public: // called when the user hits '[' or ']'. virtual void TruncateTimeRange(TInstanceHandle inInstance, bool inSetStart, long inTime) = 0; - virtual void SetTimebarColor(TInstanceHandle inInstance, ::CColor inColor) = 0; + virtual void SetTimebarColor(TInstanceHandle inInstance, const QColor &inColor) = 0; virtual void SetTimebarText(TInstanceHandle inInstance, const Q3DStudio::CString &inComment) = 0; @@ -297,11 +296,11 @@ public: // time space is expected to be normalized to the object's start time when being input to this // function. virtual Qt3DSDMAnimationHandle - CreateOrSetAnimation(TSlideHandle inSlide, TInstanceHandle instance, const wchar_t *propName, + CreateOrSetAnimation(TSlideHandle inSlide, TInstanceHandle instance,const QString &propName, long subIndex, qt3dsdm::EAnimationType animType, const float *keyframeValues, long numValues, bool inUserEdited = true) = 0; virtual bool RemoveAnimation(TSlideHandle inSlide, TInstanceHandle instance, - const wchar_t *propName, long subIndex) = 0; + const QString &propName, long subIndex) = 0; virtual void SetKeyframeTime(TKeyframeHandle inKeyframe, long inTimeInMilliseconds) = 0; virtual void DeleteAllKeyframes(Qt3DSDMAnimationHandle inAnimation) = 0; virtual void KeyframeProperty(Qt3DSDMInstanceHandle inInstance, Qt3DSDMPropertyHandle inProperty, @@ -314,12 +313,12 @@ public: // Paste a scene graph object into this system at this location. Returns the new object //(but it sets the new object as the selected object so clients probably don't need this) virtual qt3dsdm::TInstanceHandleList - PasteSceneGraphObject(const CFilePath &inFilePath, Qt3DSDMInstanceHandle inNewRoot, + PasteSceneGraphObject(const QString &inFilePath, Qt3DSDMInstanceHandle inNewRoot, bool inGenerateUniqueName, DocumentEditorInsertType::Enum inInsertType, const CPt &inPosition) = 0; virtual qt3dsdm::TInstanceHandleList PasteSceneGraphObjectMaster( - const CFilePath &inFilePath, Qt3DSDMInstanceHandle inNewRoot, bool inGenerateUniqueName, + const QString &inFilePath, Qt3DSDMInstanceHandle inNewRoot, bool inGenerateUniqueName, DocumentEditorInsertType::Enum inInsertType, const CPt &inPosition) = 0; virtual void RearrangeObjects(const qt3dsdm::TInstanceHandleList &inInstances, @@ -366,12 +365,12 @@ public: } virtual Qt3DSDMActionHandle AddAction(Qt3DSDMSlideHandle inSlide, Qt3DSDMInstanceHandle inOwner, - const wstring &inEvent, const wstring &inHandler) = 0; + const QString &inEvent, const QString &inHandler) = 0; virtual void DeleteAction(Qt3DSDMActionHandle inAction) = 0; // Paste a given action into this new root object. - virtual Qt3DSDMActionHandle PasteAction(const CFilePath &inFilePath, + virtual Qt3DSDMActionHandle PasteAction(const QString &inFilePath, Qt3DSDMInstanceHandle inNewRoot) = 0; virtual Qt3DSDMSlideHandle AddSlide(Qt3DSDMSlideHandle inMasterSlide, int inIndex = -1) = 0; @@ -394,89 +393,89 @@ public: // Returns an invalid handle (0) if the import fails. // This is the only true import operation. The rest don't move the files into the // document at this point. - virtual TInstanceHandle ImportDAE(const Q3DStudio::CString &inFullPathToDocument, + virtual TInstanceHandle ImportDAE(const QString &inFullPathToDocument, TInstanceHandle inParent, TSlideHandle inSlide, - const Q3DStudio::CString &inImportFileExtension, + const QString &inImportFileExtension, DocumentEditorInsertType::Enum inDropType, const CPt &inPosition = CPt(), long inStartTime = -1) = 0; - virtual TInstanceHandle LoadImportFile(const Q3DStudio::CString &inFullPathToDocument, + virtual TInstanceHandle LoadImportFile(const QString &inFullPathToDocument, TInstanceHandle inParent, TSlideHandle inSlide, DocumentEditorInsertType::Enum inDropType, const CPt &inPosition = CPt(), long inStartTime = -1) = 0; // Automap an image into the scene - virtual TInstanceHandle AutomapImage(const Q3DStudio::CString &inFullPathToDocument, + virtual TInstanceHandle AutomapImage(const QString &inFullPathToDocument, TInstanceHandle inParent, TSlideHandle inSlide, DocumentEditorInsertType::Enum inDropType, const CPt &inPosition = CPt(), long inStartTime = -1) = 0; - virtual TInstanceHandle LoadMesh(const Q3DStudio::CString &inFullPathToDocument, + virtual TInstanceHandle LoadMesh(const QString &inFullPathToDocument, TInstanceHandle inParent, TSlideHandle inSlide, DocumentEditorInsertType::Enum inDropType, const CPt &inPosition = CPt(), long inStartTime = -1) = 0; - virtual TInstanceHandle LoadBehavior(const Q3DStudio::CString &inFullPathToDocument, + virtual TInstanceHandle LoadBehavior(const QString &inFullPathToDocument, TInstanceHandle inParent, TSlideHandle inSlide, DocumentEditorInsertType::Enum inDropType, long inStartTime) = 0; - virtual TInstanceHandle LoadRenderPlugin(const Q3DStudio::CString &inFullPathToDocument, + virtual TInstanceHandle LoadRenderPlugin(const QString &inFullPathToDocument, TInstanceHandle inParent, TSlideHandle inSlide, DocumentEditorInsertType::Enum inDropType, long inStartTime) = 0; - virtual TInstanceHandle LoadCustomMaterial(const Q3DStudio::CString &inFullPathToDocument, + virtual TInstanceHandle LoadCustomMaterial(const QString &inFullPathToDocument, TInstanceHandle inParent, TSlideHandle inSlide, DocumentEditorInsertType::Enum inDropType, long inStartTime, TInstanceHandle inTargetId = TInstanceHandle()) = 0; // Create text from the font file - virtual TInstanceHandle CreateText(const Q3DStudio::CString &inFullPathToDocument, + virtual TInstanceHandle CreateText(const QString &inFullPathToDocument, TInstanceHandle inParent, TSlideHandle inSlide, DocumentEditorInsertType::Enum inDropType, const CPt &inPosition = CPt(), long inStartTime = -1) = 0; - virtual TInstanceHandle LoadEffect(const Q3DStudio::CString &inFullPathToDocument, + virtual TInstanceHandle LoadEffect(const QString &inFullPathToDocument, TInstanceHandle inParent, TSlideHandle inSlide, DocumentEditorInsertType::Enum inDropType, long inStartTime) = 0; virtual TInstanceHandle ImportFile(DocumentEditorFileType::Enum inFileType, - const Q3DStudio::CString &inFullPathToDocument, TInstanceHandle inParent, - TSlideHandle inSlide, const Q3DStudio::CString &inImportFileExtension, + const QString &inFullPathToDocument, TInstanceHandle inParent, + TSlideHandle inSlide, const QString &inImportFileExtension, DocumentEditorInsertType::Enum inDropType = DocumentEditorInsertType::LastChild, const CPt &inPosition = CPt(), long inStartTime = -1) = 0; // Refresh an import or dae file // Absolute path to the file. - virtual void RefreshImport(const CFilePath &inOldFile, const CFilePath &inNewFile) = 0; + virtual void RefreshImport(const QString &inOldFile, const QString &inNewFile) = 0; virtual bool CleanUpMeshes() = 0; virtual void ReplaceTextFontNameWithTextFileStem(qt3ds::render::ITextRenderer &inRenderer) = 0; - +#if RUNTIME_SPLIT_TEMPORARILY_REMOVED virtual void ExternalizePath(TInstanceHandle path) = 0; virtual void InternalizePath(TInstanceHandle path) = 0; - +#endif virtual void toggleBoolPropertyOnSelected(TPropertyHandle property) = 0; static std::shared_ptr<IDOMReader> - ParseScriptFile(const Q3DStudio::CFilePath &inFullPathToDocument, + ParseScriptFile(const QString &inFullPathToDocument, std::shared_ptr<qt3dsdm::IStringTable> inStringTable, std::shared_ptr<IImportFailedHandler> inHandler, Q3DStudio::IInputStreamFactory &inInputStreamFactory); static std::shared_ptr<IDOMReader> - ParsePluginFile(const Q3DStudio::CFilePath &inFullPathToDocument, + ParsePluginFile(const QString &inFullPathToDocument, std::shared_ptr<qt3dsdm::IStringTable> inStringTable, std::shared_ptr<IImportFailedHandler> inHandler, Q3DStudio::IInputStreamFactory &inInputStreamFactory); static std::shared_ptr<IDOMReader> - ParseCustomMaterialFile(const Q3DStudio::CFilePath &inFullPathToDocument, + ParseCustomMaterialFile(const QString &inFullPathToDocument, std::shared_ptr<qt3dsdm::IStringTable> inStringTable, std::shared_ptr<IImportFailedHandler> inHandler, Q3DStudio::IInputStreamFactory &inInputStreamFactory); diff --git a/src/Authoring/Client/Code/Core/Doc/IDocumentReader.h b/src/Authoring/Client/Code/Core/Doc/IDocumentReader.h index ea508074..bb394476 100644 --- a/src/Authoring/Client/Code/Core/Doc/IDocumentReader.h +++ b/src/Authoring/Client/Code/Core/Doc/IDocumentReader.h @@ -57,7 +57,7 @@ using std::shared_ptr; typedef std::vector<std::pair<qt3dsdm::Qt3DSDMSlideHandle, qt3dsdm::Qt3DSDMInstanceHandle>> TSlideInstanceList; -typedef std::vector<std::pair<qt3dsdm::Qt3DSDMSlideHandle, Q3DStudio::CString>> TSlideStringList; +typedef std::vector<std::pair<qt3dsdm::Qt3DSDMSlideHandle, QString>> TSlideStringList; typedef QHash<QString, TSlideInstanceList> TCharPtrToSlideInstanceMap; using qt3ds::foundation::Option; using qt3dsdm::Qt3DSDMInstanceHandle; @@ -93,7 +93,7 @@ public: virtual bool IsInstance(TInstanceHandle inInstance) const = 0; virtual bool IsCurrentlyActive(TInstanceHandle inInstance) const = 0; // Find a property on an instance by name. Searches derivation parents as well - virtual TPropertyHandle FindProperty(TInstanceHandle instance, const wchar_t *inName) const = 0; + virtual TPropertyHandle FindProperty(TInstanceHandle instance, const QString &inName) const = 0; // Get the instance property value by going through the current slide // This will convert image properties to source paths. If this is not desired, then use virtual Option<SValue> GetInstancePropertyValue(TInstanceHandle instance, @@ -111,11 +111,11 @@ public: TInstanceHandle instance, TPropertyHandle inProperty) const = 0; - virtual Q3DStudio::CString GetObjectTypeName(TInstanceHandle instance) const = 0; + virtual QString GetObjectTypeName(TInstanceHandle instance) const = 0; - virtual CString GetName(Qt3DSDMInstanceHandle inInstance) const = 0; + virtual QString GetName(Qt3DSDMInstanceHandle inInstance) const = 0; virtual TInstanceHandle GetFirstBaseClass(Qt3DSDMInstanceHandle inInstance) const = 0; - virtual CString GetSourcePath(Qt3DSDMInstanceHandle inInstance) const = 0; + virtual QString GetSourcePath(Qt3DSDMInstanceHandle inInstance) const = 0; template <typename TDataType> inline Option<TDataType> GetTypedInstancePropertyValue(TInstanceHandle instance, @@ -171,8 +171,8 @@ public: TPropertyHandle inProperty) const = 0; // Return true if this instance is an imported instance. virtual bool IsImported(TInstanceHandle inInstance) const = 0; - virtual CString GetImportId(TInstanceHandle inInstance) const = 0; - virtual CString GetFileId(TInstanceHandle inInstance) const = 0; + virtual QString GetImportId(TInstanceHandle inInstance) const = 0; + virtual QString GetFileId(TInstanceHandle inInstance) const = 0; // Return (start,end), inclusive, that represent this instance's lifetime. virtual std::pair<long, long> GetTimeRange(TInstanceHandle instance) const = 0; @@ -197,9 +197,9 @@ public: virtual bool IsPathInternalizeable(TInstanceHandle path) const = 0; virtual bool AnimationExists(TSlideHandle inSlide, TInstanceHandle instance, - const wchar_t *propName, long subIndex) = 0; + const QString &propName, long subIndex) = 0; virtual bool IsAnimationArtistEdited(TSlideHandle inSlide, TInstanceHandle instance, - const wchar_t *propName, long subIndex) = 0; + const QString &propName, long subIndex) = 0; virtual qt3dsdm::TGuideHandleList GetGuides() const = 0; virtual qt3dsdm::SGuideInfo GetGuideInfo(qt3dsdm::Qt3DSDMGuideHandle inGuide) const = 0; @@ -227,10 +227,10 @@ public: virtual CFilePath CopyAction(Qt3DSDMActionHandle inAction, Qt3DSDMSlideHandle inSlide) = 0; - virtual void ParseSourcePathsOutOfEffectFile(Q3DStudio::CString inFile, - std::vector<Q3DStudio::CString> &outFilePaths) = 0; + virtual void ParseSourcePathsOutOfEffectFile(const QString &inFile, + std::vector<QString> &outFilePaths) = 0; - virtual Q3DStudio::CString GetCustomMaterialName(const Q3DStudio::CString &inFullPathToFile) const = 0; + virtual QString GetCustomMaterialName(const QString &inFullPathToFile) const = 0; virtual void getMaterialInfo(const QString &inFullPathToFile, QString &outName, QMap<QString, QString> &outValues, QMap<QString, QMap<QString, QString>> &outTextureValues) = 0; diff --git a/src/Authoring/Client/Code/Core/Doc/INamable.h b/src/Authoring/Client/Code/Core/Doc/INamable.h index 533dc895..8bec27a8 100644 --- a/src/Authoring/Client/Code/Core/Doc/INamable.h +++ b/src/Authoring/Client/Code/Core/Doc/INamable.h @@ -42,8 +42,8 @@ class INamable { public: - virtual Q3DStudio::CString GetName() const = 0; - virtual void SetName(const Q3DStudio::CString &inName) = 0; + virtual QString GetName() const = 0; + virtual void SetName(const QString &inName) = 0; }; #endif // #ifndef __INAMABLE_H__ diff --git a/src/Authoring/Client/Code/Core/Doc/RelativePathTools.cpp b/src/Authoring/Client/Code/Core/Doc/RelativePathTools.cpp index 5d347916..43b44315 100644 --- a/src/Authoring/Client/Code/Core/Doc/RelativePathTools.cpp +++ b/src/Authoring/Client/Code/Core/Doc/RelativePathTools.cpp @@ -99,7 +99,7 @@ CRelativePathTools::GetPathType(const qt3dsdm::SObjectRefType &inObjectRefValue) /** * Build a object reference path, via Ids */ -Q3DStudio::CString +QString CRelativePathTools::BuildReferenceString(const qt3dsdm::Qt3DSDMInstanceHandle inInstance, const qt3dsdm::Qt3DSDMInstanceHandle inRootInstance, EPathType inPathType, CDoc *inDoc) @@ -110,7 +110,7 @@ CRelativePathTools::BuildReferenceString(const qt3dsdm::Qt3DSDMInstanceHandle in case EPATHTYPE_RELATIVE: return BuildRelativeReferenceString(inInstance, inRootInstance, inDoc); }; - return L""; + return {}; } //============================================================================= @@ -118,14 +118,14 @@ CRelativePathTools::BuildReferenceString(const qt3dsdm::Qt3DSDMInstanceHandle in * Note that this uses object names rather than nice names, because script access is via *property names, in the runtime. */ -Q3DStudio::CString +QString CRelativePathTools::BuildAbsoluteReferenceString(const qt3dsdm::Qt3DSDMInstanceHandle inInstance, CDoc *inDoc) { if (inInstance.Valid() == false) - return L""; - Q3DStudio::CString theNameStart; - Q3DStudio::CString theNameEnd( + return {}; + QString theNameStart; + QString theNameEnd( CPathConstructionHelper::EscapeAssetName(LookupObjectName(inInstance, inDoc))); qt3dsdm::Qt3DSDMInstanceHandle theParentInstance = @@ -136,13 +136,13 @@ CRelativePathTools::BuildAbsoluteReferenceString(const qt3dsdm::Qt3DSDMInstanceH return theNameStart; } -Q3DStudio::CString +QString CRelativePathTools::BuildRelativeReferenceString(const qt3dsdm::Qt3DSDMInstanceHandle inInstance, const qt3dsdm::Qt3DSDMInstanceHandle inRootInstance, CDoc *inDoc) { - Q3DStudio::CString theAbsRelPath(BuildAbsoluteReferenceString(inInstance, inDoc)); - Q3DStudio::CString theAbsRootPath(BuildAbsoluteReferenceString(inRootInstance, inDoc)); + QString theAbsRelPath(BuildAbsoluteReferenceString(inInstance, inDoc)); + QString theAbsRootPath(BuildAbsoluteReferenceString(inRootInstance, inDoc)); return CPathConstructionHelper::BuildRelativeReferenceString(theAbsRelPath, theAbsRootPath); } @@ -160,19 +160,19 @@ CRelativePathTools::BuildRelativeReferenceString(const qt3dsdm::Qt3DSDMInstanceH */ qt3dsdm::Qt3DSDMInstanceHandle CRelativePathTools::FindAssetInstanceByObjectPath( CDoc *inDoc, const qt3dsdm::Qt3DSDMInstanceHandle &inRootInstance, - const Q3DStudio::CString &inString, EPathType &outPathType, bool &outIsResolved, + const QString &inString, EPathType &outPathType, bool &outIsResolved, const IObjectReferenceHelper *inHelper, bool ignoreMaterialProperties) { CClientDataModelBridge *theBridge = inDoc->GetStudioSystem()->GetClientDataModelBridge(); - CStackTokenizer theTokenizer(inString, CPathConstructionHelper::GetPathDelimiter().GetAt(0), - CPathConstructionHelper::GetEscapeChar().GetAt(0)); + CStackTokenizer theTokenizer(inString, CPathConstructionHelper::GetPathDelimiter().at(0), + CPathConstructionHelper::GetEscapeChar().at(0)); // Default to the scene if asset cannot be found. qt3dsdm::Qt3DSDMInstanceHandle theFoundInstance; if (theTokenizer.HasNextPartition()) { - Q3DStudio::CString theCurrentToken(theTokenizer.GetCurrentPartition()); + QString theCurrentToken(theTokenizer.GetCurrentPartition()); // this is the default path type outPathType = EPATHTYPE_RELATIVE; @@ -180,15 +180,18 @@ qt3dsdm::Qt3DSDMInstanceHandle CRelativePathTools::FindAssetInstanceByObjectPath outIsResolved = false; // Start parsing from this object - if (theCurrentToken.Compare(CPathConstructionHelper::GetThisString(), false)) { + if (theCurrentToken.compare(CPathConstructionHelper::GetThisString(), + Qt::CaseInsensitive) == 0) { outIsResolved = true; theFoundInstance = inRootInstance; outPathType = EPATHTYPE_RELATIVE; - } else if (theCurrentToken.Compare(CPathConstructionHelper::GetSceneString(), false)) { + } else if (theCurrentToken.compare(CPathConstructionHelper::GetSceneString(), + Qt::CaseInsensitive) == 0) { outIsResolved = true; theFoundInstance = inRootInstance; outPathType = EPATHTYPE_RELATIVE; - } else if (theCurrentToken.Compare(CPathConstructionHelper::GetParentString(), false)) { + } else if (theCurrentToken.compare(CPathConstructionHelper::GetParentString(), + Qt::CaseInsensitive) == 0) { outIsResolved = true; theFoundInstance = theBridge->GetParentInstance(inRootInstance); outPathType = EPATHTYPE_RELATIVE; @@ -267,11 +270,12 @@ qt3dsdm::Qt3DSDMInstanceHandle CRelativePathTools::DoFindAssetInstanceByObjectPa qt3dsdm::Qt3DSDMInstanceHandle theFoundInstance = inRootInstance; // There is another object to parse if (inRootInstance.Valid() && ioTokenizer.HasNextPartition()) { - Q3DStudio::CString theCurrentToken(ioTokenizer.GetCurrentPartition()); - if (theCurrentToken.Length()) { + QString theCurrentToken(ioTokenizer.GetCurrentPartition()); + if (theCurrentToken.length()) { outIsResolved = false; // Parent asset - if (theCurrentToken.Compare(CPathConstructionHelper::GetParentString(), false)) { + if (theCurrentToken.compare(CPathConstructionHelper::GetParentString(), + Qt::CaseInsensitive) == 0) { ++ioTokenizer; qt3dsdm::Qt3DSDMInstanceHandle theParentInstance = theBridge->GetParentInstance(inRootInstance); @@ -284,7 +288,7 @@ qt3dsdm::Qt3DSDMInstanceHandle CRelativePathTools::DoFindAssetInstanceByObjectPa } // Find the asset by name else { - Q3DStudio::CString theDesiredAssetName(ioTokenizer.GetCurrentPartition()); + QString theDesiredAssetName(ioTokenizer.GetCurrentPartition()); if (!outIsResolved && inHelper) { qt3dsdm::TInstanceHandleList theChildList; @@ -292,9 +296,10 @@ qt3dsdm::Qt3DSDMInstanceHandle CRelativePathTools::DoFindAssetInstanceByObjectPa inTimeParentInstance, ignoreMaterialProperties)) { for (size_t theIndex = 0; theIndex < theChildList.size(); ++theIndex) { - Q3DStudio::CString theCurrentAssetName( + QString theCurrentAssetName( LookupObjectName(theChildList[theIndex], inDoc)); - if (theDesiredAssetName.Compare(theCurrentAssetName, false)) { + if (theDesiredAssetName.compare(theCurrentAssetName, + Qt::CaseInsensitive) == 0) { ++ioTokenizer; outIsResolved = true; theFoundInstance = DoFindAssetInstanceByObjectPath( @@ -316,7 +321,7 @@ qt3dsdm::Qt3DSDMInstanceHandle CRelativePathTools::DoFindAssetInstanceByObjectPa /** * Figures out the object name, used for script access. so that paths are valid in the runtime. */ -Q3DStudio::CString +QString CRelativePathTools::LookupObjectName(const qt3dsdm::Qt3DSDMInstanceHandle inInstance, CDoc *inDoc) { qt3dsdm::IPropertySystem *thePropertySystem = inDoc->GetStudioSystem()->GetPropertySystem(); @@ -328,13 +333,11 @@ CRelativePathTools::LookupObjectName(const qt3dsdm::Qt3DSDMInstanceHandle inInst theProperty)) theClientBridge->GetLayerFromImageProbeInstance(inInstance, theParentInstance, theProperty); - qt3dsdm::TCharStr theName = thePropertySystem->GetName(theProperty); - return theName.c_str(); + return thePropertySystem->GetName(theProperty); } else { qt3dsdm::SValue theNameValue; thePropertySystem->GetInstancePropertyValue(inInstance, theClientBridge->GetNameProperty(), theNameValue); - qt3dsdm::TDataStrPtr theName = qt3dsdm::get<qt3dsdm::TDataStrPtr>(theNameValue); - return theName->GetData(); + return qt3dsdm::get<qt3dsdm::TDataStrPtr>(theNameValue)->toQString(); } } diff --git a/src/Authoring/Client/Code/Core/Doc/RelativePathTools.h b/src/Authoring/Client/Code/Core/Doc/RelativePathTools.h index b4e9c1a2..0fefd65e 100644 --- a/src/Authoring/Client/Code/Core/Doc/RelativePathTools.h +++ b/src/Authoring/Client/Code/Core/Doc/RelativePathTools.h @@ -60,17 +60,17 @@ public: static bool IsRelativePath(const qt3dsdm::SObjectRefType &inObjectRefValue); static EPathType GetPathType(const qt3dsdm::SObjectRefType &inObjectRefValue); - static Q3DStudio::CString BuildReferenceString(const qt3dsdm::Qt3DSDMInstanceHandle inInstance, - const qt3dsdm::Qt3DSDMInstanceHandle inRootInstance, - EPathType inPathType, CDoc *inDoc); - static Q3DStudio::CString + static QString BuildReferenceString(const qt3dsdm::Qt3DSDMInstanceHandle inInstance, + const qt3dsdm::Qt3DSDMInstanceHandle inRootInstance, + EPathType inPathType, CDoc *inDoc); + static QString BuildAbsoluteReferenceString(const qt3dsdm::Qt3DSDMInstanceHandle inInstance, CDoc *inDoc); - static Q3DStudio::CString + static QString BuildRelativeReferenceString(const qt3dsdm::Qt3DSDMInstanceHandle inInstance, const qt3dsdm::Qt3DSDMInstanceHandle inRootInstance, CDoc *inDoc); static qt3dsdm::Qt3DSDMInstanceHandle FindAssetInstanceByObjectPath(CDoc *inDoc, const qt3dsdm::Qt3DSDMInstanceHandle &inRootInstance, - const Q3DStudio::CString &inString, EPathType &outPathType, + const QString &inString, EPathType &outPathType, bool &outIsResolved, const IObjectReferenceHelper *inHelper = nullptr, bool ignoreMaterialProperties = false); @@ -86,8 +86,7 @@ protected: qt3dsdm::Qt3DSDMSlideHandle inSlide, CStackTokenizer &ioTokenizer, bool &outIsResolved, const IObjectReferenceHelper *inHelper, bool ignoreMaterialProperties = false); - static Q3DStudio::CString LookupObjectName(const qt3dsdm::Qt3DSDMInstanceHandle inInstance, - CDoc *inDoc); + static QString LookupObjectName(const qt3dsdm::Qt3DSDMInstanceHandle inInstance, CDoc *inDoc); }; #endif // INCLUDED_RELATIVEPATHTOOLS_H diff --git a/src/Authoring/Client/Code/Core/Doc/StudioProjectSettings.cpp b/src/Authoring/Client/Code/Core/Doc/StudioProjectSettings.cpp index eed803e0..0265bdd7 100644 --- a/src/Authoring/Client/Code/Core/Doc/StudioProjectSettings.cpp +++ b/src/Authoring/Client/Code/Core/Doc/StudioProjectSettings.cpp @@ -37,7 +37,7 @@ #include "CommonConstants.h" #include "StudioPreferences.h" #include "Qt3DSLargeInteger.h" -#include "CColor.h" +#include <QtGui/qcolor.h> #include "Qt3DSColor.h" ///////////////////////////////////////////////////////////////////////////// diff --git a/src/Authoring/Client/Code/Core/Doc/StudioProjectSettings.h b/src/Authoring/Client/Code/Core/Doc/StudioProjectSettings.h index 275cfbc7..caa423f8 100644 --- a/src/Authoring/Client/Code/Core/Doc/StudioProjectSettings.h +++ b/src/Authoring/Client/Code/Core/Doc/StudioProjectSettings.h @@ -37,7 +37,7 @@ //============================================================================== #include "Pt.h" -#include "CColor.h" +#include <QtGui/qcolor.h> //============================================================================== // Forwards diff --git a/src/Authoring/Client/Code/Core/Runtime2Integration/Q3DSRenderBufferManager.cpp b/src/Authoring/Client/Code/Core/Runtime2Integration/Q3DSRenderBufferManager.cpp index 53bd0032..b6e55080 100644 --- a/src/Authoring/Client/Code/Core/Runtime2Integration/Q3DSRenderBufferManager.cpp +++ b/src/Authoring/Client/Code/Core/Runtime2Integration/Q3DSRenderBufferManager.cpp @@ -59,14 +59,14 @@ Q3DSRenderMesh *Q3DSRenderBufferManager::LoadMesh(const QString &inSourcePath) return nullptr; } -//Q3DSRenderMesh *Q3DSRenderBufferManager::CreateMesh(const char *inSourcePath, void *inVertData, -// unsigned int inNumVerts, unsigned int inVertStride, -// unsigned int *inIndexData, -// unsigned int inIndexCount -// /*, qt3ds::NVBounds3 inBounds*/) -//{ - -//} +Q3DSRenderMesh *Q3DSRenderBufferManager::CreateMesh(const char *inSourcePath, void *inVertData, + unsigned int inNumVerts, unsigned int inVertStride, + unsigned int *inIndexData, + unsigned int inIndexCount + /*, qt3ds::NVBounds3 inBounds*/) +{ + return nullptr; +} void Q3DSRenderBufferManager::Clear() { @@ -78,6 +78,12 @@ void Q3DSRenderBufferManager::InvalidateBuffer(const QString &inSourcePath) } +void Q3DSRenderBufferManager::SetImageHasTransparency(const QString &inSourcePath, + bool inHasTransparency) +{ + m_engine->presentation()->registerImageBuffer(inSourcePath, inHasTransparency); +} + QSharedPointer<Q3DSRenderBufferManager> Q3DSRenderBufferManager::Create(Q3DSEngine *engine, IInputStreamFactory &inInputStreamFactory) { diff --git a/src/Authoring/Client/Code/Core/Runtime2Integration/Q3DSRenderBufferManager.h b/src/Authoring/Client/Code/Core/Runtime2Integration/Q3DSRenderBufferManager.h index e59cb62d..48bf956b 100644 --- a/src/Authoring/Client/Code/Core/Runtime2Integration/Q3DSRenderBufferManager.h +++ b/src/Authoring/Client/Code/Core/Runtime2Integration/Q3DSRenderBufferManager.h @@ -48,61 +48,65 @@ namespace Q3DStudio { - class Q3DSRenderBufferManager - { - protected: - virtual ~Q3DSRenderBufferManager() {} - public: - // Path manipulation used to get the final path form a base path plus relative extension - /*virtual QString CombineBaseAndRelative(const char8_t *inBase, - const char8_t *inRelative) = 0;*/ - virtual void SetImageHasTransparency(const QString &inSourcePath, - bool inHasTransparency) = 0; - virtual bool GetImageHasTransparency(const QString & inSourcePath) const = 0; - virtual void SetImageTransparencyToFalseIfNotSet(const QString & inSourcePath) = 0; - virtual void SetInvertImageUVCoords(const QString & inSourcePath, - bool inShouldInvertCoords) = 0; +class Q3DSRenderBufferManager +{ +public: + Q3DSRenderBufferManager(Q3DSEngine *engine, IInputStreamFactory &inInputStreamFactory); + virtual ~Q3DSRenderBufferManager() {} + // Path manipulation used to get the final path form a base path plus relative extension + /*virtual QString CombineBaseAndRelative(const char8_t *inBase, + const char8_t *inRelative) = 0;*/ + virtual void SetImageHasTransparency(const QString &inSourcePath, + bool inHasTransparency); +// virtual bool GetImageHasTransparency(const QString & inSourcePath) const = 0; +// virtual void SetImageTransparencyToFalseIfNotSet(const QString & inSourcePath) = 0; +// virtual void SetInvertImageUVCoords(const QString & inSourcePath, +// bool inShouldInvertCoords) = 0; - // Returns true if this image has been loaded into memory - // This call is threadsafe. Nothing else on this object is guaranteed to be. - virtual bool IsImageLoaded(const QString & inSourcePath) = 0; + // Returns true if this image has been loaded into memory + // This call is threadsafe. Nothing else on this object is guaranteed to be. +// virtual bool IsImageLoaded(const QString & inSourcePath) = 0; - // Alias one image path with another image path. Optionally this object will ignore the - // call if the source path is already loaded. Aliasing is currently used to - // allow a default image to be shown in place of an image that is loading offline. - // Returns true if the image was aliased, false otherwise. - virtual bool AliasImagePath(const QString & inSourcePath, const QString & inAliasPath, - bool inIgnoreIfLoaded) = 0; - virtual void UnaliasImagePath(const QString & inSourcePath) = 0; + // Alias one image path with another image path. Optionally this object will ignore the + // call if the source path is already loaded. Aliasing is currently used to + // allow a default image to be shown in place of an image that is loading offline. + // Returns true if the image was aliased, false otherwise. +// virtual bool AliasImagePath(const QString & inSourcePath, const QString & inAliasPath, +// bool inIgnoreIfLoaded) = 0; +// virtual void UnaliasImagePath(const QString & inSourcePath) = 0; - // Returns the given source path unless the source path is aliased; in which case returns - // the aliased path. - virtual QString GetImagePath(const QString &inSourcePath) = 0; - // Returns a texture and a boolean indicating if this texture has transparency in it or not. - // Can't name this LoadImage because that gets mangled by windows to LoadImageA (uggh) - // In some cases we need to only scan particular images for transparency. - /*virtual Q3DSImageTextureData LoadRenderImage(const QString & inImagePath, - SLoadedTexture &inTexture, - bool inForceScanForTransparency = false, - bool inBsdfMipmaps = false) = 0;*/ - virtual Q3DSImageTextureData LoadRenderImage(const QString & inSourcePath, - bool inForceScanForTransparency = false, - bool inBsdfMipmaps = false) = 0; - virtual Q3DSRenderMesh *LoadMesh(const QString & inSourcePath) = 0; + // Returns the given source path unless the source path is aliased; in which case returns + // the aliased path. + virtual QString GetImagePath(const QString &inSourcePath); + // Returns a texture and a boolean indicating if this texture has transparency in it or not. + // Can't name this LoadImage because that gets mangled by windows to LoadImageA (uggh) + // In some cases we need to only scan particular images for transparency. + /*virtual Q3DSImageTextureData LoadRenderImage(const QString & inImagePath, + SLoadedTexture &inTexture, + bool inForceScanForTransparency = false, + bool inBsdfMipmaps = false) = 0;*/ + virtual Q3DSImageTextureData LoadRenderImage(const QString & inSourcePath, + bool inForceScanForTransparency = false, + bool inBsdfMipmaps = false); + virtual Q3DSRenderMesh *LoadMesh(const QString & inSourcePath); - virtual Q3DSRenderMesh *CreateMesh(const char *inSourcePath, void *inVertData, - unsigned int inNumVerts, unsigned int inVertStride, - unsigned int *inIndexData, - unsigned int inIndexCount - /*, qt3ds::NVBounds3 inBounds*/) = 0; + virtual Q3DSRenderMesh *CreateMesh(const char *inSourcePath, void *inVertData, + unsigned int inNumVerts, unsigned int inVertStride, + unsigned int *inIndexData, + unsigned int inIndexCount + /*, qt3ds::NVBounds3 inBounds*/); - // Remove *all* buffers from the buffer manager; - virtual void Clear() = 0; - virtual void InvalidateBuffer(const QString &inSourcePath) = 0; + // Remove *all* buffers from the buffer manager; + virtual void Clear(); + virtual void InvalidateBuffer(const QString &inSourcePath); + + static QSharedPointer<Q3DSRenderBufferManager> Create(Q3DSEngine *engine, + IInputStreamFactory &inInputStreamFactory); +private: + Q3DSEngine *m_engine; + IInputStreamFactory &m_inputStreamFactory; +}; - static Q3DSRenderBufferManager &Create(Q3DSEngine *engine, - IInputStreamFactory &inInputStreamFactory); - }; } // namespace Q3DStudio #endif diff --git a/src/Authoring/Client/Code/Core/Runtime2Integration/Q3DSStringTable.h b/src/Authoring/Client/Code/Core/Runtime2Integration/Q3DSStringTable.h index 133a7ab3..f1a63c45 100644 --- a/src/Authoring/Client/Code/Core/Runtime2Integration/Q3DSStringTable.h +++ b/src/Authoring/Client/Code/Core/Runtime2Integration/Q3DSStringTable.h @@ -161,20 +161,20 @@ public: { return m_renderStringTable.GetWideStr(inStr); } - virtual const char8_t *RegisterStr(const char8_t *inStr) override + const char8_t *RegisterStr(const char8_t *inStr) override { return m_renderStringTable.GetNarrowStr(inStr); } // Get the utf-8 or utf-(sizeof wchar_t) converted strings - virtual const wchar_t *GetWideStr(const char8_t *inStr) override + const wchar_t *GetWideStr(const char8_t *inStr) override { return m_renderStringTable.GetWideStr(inStr); } - virtual const char8_t *GetNarrowStr(const wchar_t *inStr) override + const char8_t *GetNarrowStr(const wchar_t *inStr) override { return m_renderStringTable.GetNarrowStr(inStr); } - virtual qt3ds::foundation::IStringTable &GetRenderStringTable() override + qt3ds::foundation::IStringTable &GetRenderStringTable() override { return m_renderStringTable; } diff --git a/src/Authoring/Client/Code/Core/Utility/ColorConversion.h b/src/Authoring/Client/Code/Core/Utility/ColorConversion.h index 3ef58487..007e88d4 100644 --- a/src/Authoring/Client/Code/Core/Utility/ColorConversion.h +++ b/src/Authoring/Client/Code/Core/Utility/ColorConversion.h @@ -45,4 +45,4 @@ public: static long MakeRGBA(long inRed, long inGreen, long inBlue, long inAlpha = 255); }; -#endif // __CCOLORCONVERSION_H_
\ No newline at end of file +#endif // __CCOLORCONVERSION_H_ diff --git a/src/Authoring/Client/Code/Core/Utility/DataModelObjectReferenceHelper.cpp b/src/Authoring/Client/Code/Core/Utility/DataModelObjectReferenceHelper.cpp index 82f1d90d..75a38094 100644 --- a/src/Authoring/Client/Code/Core/Utility/DataModelObjectReferenceHelper.cpp +++ b/src/Authoring/Client/Code/Core/Utility/DataModelObjectReferenceHelper.cpp @@ -89,7 +89,7 @@ CObjectReferenceHelper::GetInfo(const qt3dsdm::Qt3DSDMInstanceHandle &inInstance inInstance, theClientBridge->GetNameProperty(), theNameValue); TDataStrPtr theName = qt3dsdm::get<TDataStrPtr>(theNameValue); if (theName) - theInfo.m_Name = theName->GetData(); + theInfo.m_Name = theName->toQString(); } else { qt3dsdm::Qt3DSDMInstanceHandle theParentInstance; qt3dsdm::Qt3DSDMPropertyHandle theProperty; @@ -99,7 +99,7 @@ CObjectReferenceHelper::GetInfo(const qt3dsdm::Qt3DSDMInstanceHandle &inInstance theProperty); if (theParentInstance.Valid() && theProperty.Valid()) theInfo.m_Name = - thePropertySystem->GetFormalName(theParentInstance, theProperty).c_str(); + thePropertySystem->GetFormalName(theParentInstance, theProperty); } // Master, by checking if guid property is linked. theInfo.m_Master = m_Doc->GetStudioSystem()->GetSlideSystem()->IsPropertyLinked( @@ -163,7 +163,7 @@ bool CObjectReferenceHelper::GetChildInstanceList( /** * Figures out the object (displayed) name for a given instance */ -Q3DStudio::CString +QString CObjectReferenceHelper::LookupObjectFormalName(const qt3dsdm::Qt3DSDMInstanceHandle inInstance) const { qt3dsdm::IPropertySystem *thePropertySystem = m_Doc->GetStudioSystem()->GetPropertySystem(); @@ -175,18 +175,18 @@ CObjectReferenceHelper::LookupObjectFormalName(const qt3dsdm::Qt3DSDMInstanceHan theProperty)) theClientBridge->GetLayerFromImageProbeInstance(inInstance, theParentInstance, theProperty); - qt3dsdm::TCharStr theFormalName = + QString theFormalName = thePropertySystem->GetFormalName(theParentInstance, theProperty); - return theFormalName.c_str(); + return theFormalName; } else { qt3dsdm::SValue theNameValue; thePropertySystem->GetInstancePropertyValue(inInstance, theClientBridge->GetNameProperty(), theNameValue); if (GetValueType(theNameValue) == qt3dsdm::DataModelDataType::String) { qt3dsdm::TDataStrPtr theName = qt3dsdm::get<qt3dsdm::TDataStrPtr>(theNameValue); - return theName->GetData(); + return theName->toQString(); } - return L""; + return {}; } } @@ -194,7 +194,7 @@ CObjectReferenceHelper::LookupObjectFormalName(const qt3dsdm::Qt3DSDMInstanceHan /** * String returned for displaying relative path values in the Object Ref Picker */ -Q3DStudio::CString CObjectReferenceHelper::GetObjectReferenceString( +QString CObjectReferenceHelper::GetObjectReferenceString( const qt3dsdm::Qt3DSDMInstanceHandle &inBaseInstance, CRelativePathTools::EPathType inPathType, const qt3dsdm::Qt3DSDMInstanceHandle &inInstance) const { @@ -207,7 +207,7 @@ Q3DStudio::CString CObjectReferenceHelper::GetObjectReferenceString( * objects. */ bool CObjectReferenceHelper::ResolvePath(const qt3dsdm::Qt3DSDMInstanceHandle &inInstance, - const Q3DStudio::CString &inPathValue, + const QString &inPathValue, CRelativePathTools::EPathType &outType, qt3dsdm::Qt3DSDMInstanceHandle &outResolvedInstance, bool ignoreMaterialProperties) @@ -252,7 +252,7 @@ CObjectReferenceHelper::Resolve(const qt3dsdm::SValue &inObjectRefValue, bool theFullResolvedFlag = false; CRelativePathTools::EPathType theUnusedPathType; return CRelativePathTools::FindAssetInstanceByObjectPath( - m_Doc, inBaseInstance, qt3dsdm::get<qt3dsdm::TDataStrPtr>(theRefValue)->GetData(), + m_Doc, inBaseInstance, qt3dsdm::get<qt3dsdm::TDataStrPtr>(theRefValue)->toQString(), theUnusedPathType, theFullResolvedFlag, this); } else if (theValueType == qt3dsdm::DataModelDataType::Long) { return qt3dsdm::get<qt3ds::QT3DSI32>(theRefValue); diff --git a/src/Authoring/Client/Code/Core/Utility/DataModelObjectReferenceHelper.h b/src/Authoring/Client/Code/Core/Utility/DataModelObjectReferenceHelper.h index 6f3285b4..a2fa34c3 100644 --- a/src/Authoring/Client/Code/Core/Utility/DataModelObjectReferenceHelper.h +++ b/src/Authoring/Client/Code/Core/Utility/DataModelObjectReferenceHelper.h @@ -64,15 +64,15 @@ public: qt3dsdm::Qt3DSDMSlideHandle inSlide, const qt3dsdm::Qt3DSDMInstanceHandle &inOwningInstance, bool ignoreMaterialProperties = false) const override; - virtual Q3DStudio::CString + virtual QString LookupObjectFormalName(const qt3dsdm::Qt3DSDMInstanceHandle inInstance) const override; - virtual Q3DStudio::CString + virtual QString GetObjectReferenceString(const qt3dsdm::Qt3DSDMInstanceHandle &inBaseInstance, CRelativePathTools::EPathType inPathType, const qt3dsdm::Qt3DSDMInstanceHandle &inInstance) const override; bool ResolvePath(const qt3dsdm::Qt3DSDMInstanceHandle &inInstance, - const Q3DStudio::CString &inPathValue, + const QString &inPathValue, CRelativePathTools::EPathType &outType, qt3dsdm::Qt3DSDMInstanceHandle &outResolveInstance, bool ignoreMaterialProperties = false) override; diff --git a/src/Authoring/Client/Code/Core/Utility/IObjectReferenceHelper.h b/src/Authoring/Client/Code/Core/Utility/IObjectReferenceHelper.h index f685efcf..e35e96f6 100644 --- a/src/Authoring/Client/Code/Core/Utility/IObjectReferenceHelper.h +++ b/src/Authoring/Client/Code/Core/Utility/IObjectReferenceHelper.h @@ -49,11 +49,11 @@ class IObjectReferenceHelper public: struct SObjectRefInfo { - Q3DStudio::CString m_Name; + QString m_Name; EStudioObjectType m_Type; bool m_Master; - SObjectRefInfo(Q3DStudio::CString inName, EStudioObjectType inType, bool inMaster) + SObjectRefInfo(const QString &inName, EStudioObjectType inType, bool inMaster) : m_Name(inName) , m_Type(inType) , m_Master(inMaster) @@ -79,15 +79,15 @@ public: qt3dsdm::TInstanceHandleList &outlist, qt3dsdm::Qt3DSDMSlideHandle inSlide, const qt3dsdm::Qt3DSDMInstanceHandle &inOwningInstance, bool ignoreMaterialProperties = false) const = 0; - virtual Q3DStudio::CString + virtual QString LookupObjectFormalName(const qt3dsdm::Qt3DSDMInstanceHandle inInstance) const = 0; - virtual Q3DStudio::CString + virtual QString GetObjectReferenceString(const qt3dsdm::Qt3DSDMInstanceHandle &inBaseInstance, CRelativePathTools::EPathType inPathType, const qt3dsdm::Qt3DSDMInstanceHandle &inInstance) const = 0; virtual bool ResolvePath(const qt3dsdm::Qt3DSDMInstanceHandle &inInstance, - const Q3DStudio::CString &inPathValue, + const QString &inPathValue, CRelativePathTools::EPathType &outType, qt3dsdm::Qt3DSDMInstanceHandle &outResolvedInstance, bool ignoreMaterialProperties = false) = 0; diff --git a/src/Authoring/Client/Code/Core/Utility/PathConstructionHelper.cpp b/src/Authoring/Client/Code/Core/Utility/PathConstructionHelper.cpp index a1cbef0e..33d4f627 100644 --- a/src/Authoring/Client/Code/Core/Utility/PathConstructionHelper.cpp +++ b/src/Authoring/Client/Code/Core/Utility/PathConstructionHelper.cpp @@ -37,23 +37,23 @@ //============================================================================== //// Constants //============================================================================== -static const Q3DStudio::CString SOURCEPATHDELIMITER(L"."); // can only be single char! -static const Q3DStudio::CString SOURCEPATHESCAPECHAR(L"\\"); // can only be single char! -static const Q3DStudio::CString SOURCEPATHSCENE(L"Scene"); -static const Q3DStudio::CString SOURCEPATHPARENT(L"parent"); -static const Q3DStudio::CString SOURCEPATHTHIS(L"this"); +static const QString SOURCEPATHDELIMITER = QStringLiteral("."); // can only be single char! +static const QString SOURCEPATHESCAPECHAR = QStringLiteral("\\"); // can only be single char! +static const QString SOURCEPATHSCENE = QStringLiteral("Scene"); +static const QString SOURCEPATHPARENT = QStringLiteral("parent"); +static const QString SOURCEPATHTHIS = QStringLiteral("this"); //============================================================================= /** * Create a absolute path reference string */ -Q3DStudio::CString +QString CPathConstructionHelper::BuildAbsoluteReferenceString(CDoc *inDoc, qt3dsdm::Qt3DSDMInstanceHandle inInstance) { CClientDataModelBridge *theBridge = inDoc->GetStudioSystem()->GetClientDataModelBridge(); - Q3DStudio::CString theNameStart; - Q3DStudio::CString theNameEnd = EscapeAssetName(theBridge->GetName(inInstance)); + QString theNameStart; + QString theNameEnd = EscapeAssetName(theBridge->GetName(inInstance)); qt3dsdm::Qt3DSDMInstanceHandle theParentInstance = theBridge->GetParentInstance(inInstance); if (theParentInstance.Valid()) { @@ -69,29 +69,29 @@ CPathConstructionHelper::BuildAbsoluteReferenceString(CDoc *inDoc, /** * Create a relative path reference string */ -Q3DStudio::CString CPathConstructionHelper::BuildRelativeReferenceString( +QString CPathConstructionHelper::BuildRelativeReferenceString( CDoc *inDoc, qt3dsdm::Qt3DSDMInstanceHandle inInstance, qt3dsdm::Qt3DSDMInstanceHandle inRootInstance) { - Q3DStudio::CString theAbsRelPath = BuildAbsoluteReferenceString(inDoc, inInstance); - Q3DStudio::CString theAbsRootPath = BuildAbsoluteReferenceString(inDoc, inRootInstance); + QString theAbsRelPath = BuildAbsoluteReferenceString(inDoc, inInstance); + QString theAbsRootPath = BuildAbsoluteReferenceString(inDoc, inRootInstance); return CPathConstructionHelper::BuildRelativeReferenceString(theAbsRelPath, theAbsRootPath); } //============================================================================= /** - * helper method to create therelative path reference string based on it's - * absolute path string and the root object absolute path string + * helper method to create the relative path reference string based on its + * absolute path string and the root object absolute path string */ -Q3DStudio::CString -CPathConstructionHelper::BuildRelativeReferenceString(Q3DStudio::CString &inAbsObjPath, - Q3DStudio::CString &inAbsRootPath) +QString +CPathConstructionHelper::BuildRelativeReferenceString(const QString &inAbsObjPath, + const QString &inAbsRootPath) { - Q3DStudio::CString theRelPath = ""; // SOURCEPATHTHIS; - CStackTokenizer theAbsRelTokenizer(inAbsObjPath, SOURCEPATHDELIMITER.GetAt(0), - SOURCEPATHESCAPECHAR.GetAt(0)); - CStackTokenizer theAbsRootTokenizer(inAbsRootPath, SOURCEPATHDELIMITER.GetAt(0), - SOURCEPATHESCAPECHAR.GetAt(0)); + QString theRelPath; // SOURCEPATHTHIS; + CStackTokenizer theAbsRelTokenizer(inAbsObjPath, SOURCEPATHDELIMITER.at(0), + SOURCEPATHESCAPECHAR.at(0)); + CStackTokenizer theAbsRootTokenizer(inAbsRootPath, SOURCEPATHDELIMITER.at(0), + SOURCEPATHESCAPECHAR.at(0)); // Validate the strings if (theAbsRelTokenizer.HasNextPartition() && theAbsRootTokenizer.HasNextPartition()) { @@ -104,7 +104,7 @@ CPathConstructionHelper::BuildRelativeReferenceString(Q3DStudio::CString &inAbsO } // Grab the remaining path from the relative item - Q3DStudio::CString theRelPathRemaining; + QString theRelPathRemaining; while (theAbsRelTokenizer.HasNextPartition()) { theRelPathRemaining += SOURCEPATHDELIMITER; theRelPathRemaining += @@ -114,25 +114,21 @@ CPathConstructionHelper::BuildRelativeReferenceString(Q3DStudio::CString &inAbsO // Add the appropriate number of "parents" and a "this" while (theAbsRootTokenizer.HasNextPartition()) { - if (theRelPath.Length() > 0) + if (!theRelPath.isEmpty()) theRelPath += SOURCEPATHDELIMITER; theRelPath += SOURCEPATHPARENT; ++theAbsRootTokenizer; } // Append the remaining path, if neccessary - if (theRelPathRemaining.Length()) { + if (!theRelPathRemaining.isEmpty()) theRelPath += theRelPathRemaining; - } } - if (theRelPath.Length() == 0) - theRelPath = SOURCEPATHTHIS; - else if (theRelPath[(long)0] == '.') { - Q3DStudio::CString theTempString = theRelPath; + if (theRelPath.isEmpty()) theRelPath = SOURCEPATHTHIS; - theRelPath += theTempString; - } + else if (theRelPath.startsWith(QLatin1Char('.'))) + theRelPath = SOURCEPATHTHIS + theRelPath; return theRelPath; } @@ -141,21 +137,22 @@ CPathConstructionHelper::BuildRelativeReferenceString(Q3DStudio::CString &inAbsO /** * Format the string correctly by appending the appropriate escape character */ -Q3DStudio::CString CPathConstructionHelper::EscapeAssetName(Q3DStudio::CString inAssetName) +QString CPathConstructionHelper::EscapeAssetName(const QString &inAssetName) { - static Q3DStudio::CString theEscapedEscape(SOURCEPATHESCAPECHAR + SOURCEPATHESCAPECHAR); - inAssetName.Replace(SOURCEPATHESCAPECHAR, theEscapedEscape); // move these to const strings + static QString theEscapedEscape(SOURCEPATHESCAPECHAR + SOURCEPATHESCAPECHAR); + QString asset = inAssetName; + asset.replace(SOURCEPATHESCAPECHAR, theEscapedEscape); // move these to const strings - static Q3DStudio::CString theEscapedDelimiter(SOURCEPATHESCAPECHAR + SOURCEPATHDELIMITER); - inAssetName.Replace(SOURCEPATHDELIMITER, theEscapedDelimiter); - return inAssetName; + static QString theEscapedDelimiter(SOURCEPATHESCAPECHAR + SOURCEPATHDELIMITER); + asset.replace(SOURCEPATHDELIMITER, theEscapedDelimiter); + return asset; } //============================================================================= /** * Return the string value that specifies "this" */ -const Q3DStudio::CString &CPathConstructionHelper::GetThisString() +const QString &CPathConstructionHelper::GetThisString() { return SOURCEPATHTHIS; } @@ -164,7 +161,7 @@ const Q3DStudio::CString &CPathConstructionHelper::GetThisString() /** * Return the string value that specifies the escape character */ -const Q3DStudio::CString &CPathConstructionHelper::GetEscapeChar() +const QString &CPathConstructionHelper::GetEscapeChar() { return SOURCEPATHESCAPECHAR; } @@ -173,7 +170,7 @@ const Q3DStudio::CString &CPathConstructionHelper::GetEscapeChar() /** * Return the string value that specifies "Scene" */ -const Q3DStudio::CString &CPathConstructionHelper::GetSceneString() +const QString &CPathConstructionHelper::GetSceneString() { return SOURCEPATHSCENE; } @@ -182,7 +179,7 @@ const Q3DStudio::CString &CPathConstructionHelper::GetSceneString() /** * Return the string value that specifies "parent" */ -const Q3DStudio::CString &CPathConstructionHelper::GetParentString() +const QString &CPathConstructionHelper::GetParentString() { return SOURCEPATHPARENT; } @@ -191,7 +188,7 @@ const Q3DStudio::CString &CPathConstructionHelper::GetParentString() /** * Return the string value that specifies teh delimiter */ -const Q3DStudio::CString &CPathConstructionHelper::GetPathDelimiter() +const QString &CPathConstructionHelper::GetPathDelimiter() { return SOURCEPATHDELIMITER; } diff --git a/src/Authoring/Client/Code/Core/Utility/PathConstructionHelper.h b/src/Authoring/Client/Code/Core/Utility/PathConstructionHelper.h index f08f33bb..2d39d590 100644 --- a/src/Authoring/Client/Code/Core/Utility/PathConstructionHelper.h +++ b/src/Authoring/Client/Code/Core/Utility/PathConstructionHelper.h @@ -53,20 +53,20 @@ class CPathConstructionHelper // Static Methods //============================================================================== public: - static Q3DStudio::CString BuildAbsoluteReferenceString(CDoc *inDoc, - qt3dsdm::Qt3DSDMInstanceHandle inInstance); - static Q3DStudio::CString + static QString BuildAbsoluteReferenceString(CDoc *inDoc, + qt3dsdm::Qt3DSDMInstanceHandle inInstance); + static QString BuildRelativeReferenceString(CDoc *inDoc, qt3dsdm::Qt3DSDMInstanceHandle inInstance, qt3dsdm::Qt3DSDMInstanceHandle inRootInstance); - static Q3DStudio::CString BuildRelativeReferenceString(Q3DStudio::CString &inAbsObjPath, - Q3DStudio::CString &inAbsRootPath); - static Q3DStudio::CString EscapeAssetName(Q3DStudio::CString inAssetName); + static QString BuildRelativeReferenceString(const QString &inAbsObjPath, + const QString &inAbsRootPath); + static QString EscapeAssetName(const QString &inAssetName); - static const Q3DStudio::CString &GetThisString(); - static const Q3DStudio::CString &GetEscapeChar(); - static const Q3DStudio::CString &GetSceneString(); - static const Q3DStudio::CString &GetParentString(); - static const Q3DStudio::CString &GetPathDelimiter(); + static const QString &GetThisString(); + static const QString &GetEscapeChar(); + static const QString &GetSceneString(); + static const QString &GetParentString(); + static const QString &GetPathDelimiter(); }; #endif // INCLUDED_PATHCONSTRUCTIONHELPER_H diff --git a/src/Authoring/Client/Code/Core/Utility/StudioPreferences.cpp b/src/Authoring/Client/Code/Core/Utility/StudioPreferences.cpp index 802809ce..581f9635 100644 --- a/src/Authoring/Client/Code/Core/Utility/StudioPreferences.cpp +++ b/src/Authoring/Client/Code/Core/Utility/StudioPreferences.cpp @@ -31,20 +31,20 @@ #include "StudioPreferences.h" #include "Preferences.h" -#include "CColor.h" +#include <QtGui/qcolor.h> #include "MasterP.h" #include "CommonConstants.h" #include <QtGui/qpalette.h> #include <QtQml/qqmlcontext.h> -static ::CColor s_BaseColor; -static ::CColor s_DarkBaseColor; -static ::CColor s_NormalColor; -static ::CColor s_MasterColor; -static ::CColor s_MouseOverHighlightColor; -static ::CColor s_ButtonDownColor; -static ::CColor s_DisabledTextColor; +static QColor s_BaseColor; +static QColor s_DarkBaseColor; +static QColor s_NormalColor; +static QColor s_MasterColor; +static QColor s_MouseOverHighlightColor; +static QColor s_ButtonDownColor; +static QColor s_DisabledTextColor; static QColor s_studioColor1; static QColor s_studioColor2; @@ -90,7 +90,7 @@ static int s_guideSize; #define STRINGIFY2(x) #x // Statics -const ::CColor CStudioPreferences::EDITVIEW_DEFAULTBGCOLOR = ::CColor("#262829"); +const QColor CStudioPreferences::EDITVIEW_DEFAULTBGCOLOR = QColor("#262829"); std::unique_ptr<CPreferences> CStudioPreferences::m_preferences = nullptr; CStudioPreferences::CStudioPreferences() @@ -101,6 +101,21 @@ CStudioPreferences::~CStudioPreferences() { } +static void setColorLuminance(QColor &color, qreal luminance) +{ + qreal h, s, l; + color.getHslF(&h, &s, &l); + l = luminance; + color.setHslF(h, s, l); +} + +static qreal getColorLuminance(const QColor &color) +{ + qreal h, s, l; + color.getHslF(&h, &s, &l); + return l; +} + //============================================================================== /** * Loads the default preferences from the registry. Must be called after the @@ -113,25 +128,26 @@ void CStudioPreferences::LoadPreferences(const QString &filePath) m_preferences->SetPreferencesFile(filePath); - s_BaseColor = m_preferences->GetColorValue(QStringLiteral("BaseColor"), ::CColor("#262829"), + s_BaseColor = m_preferences->GetColorValue(QStringLiteral("BaseColor"), QColor("#262829"), QStringLiteral("Preferences")); - s_NormalColor = m_preferences->GetColorValue(QStringLiteral("NormalColor"), ::CColor("#ffffff"), + s_NormalColor = m_preferences->GetColorValue(QStringLiteral("NormalColor"), QColor("#ffffff"), QStringLiteral("Preferences")); - s_MasterColor = m_preferences->GetColorValue(QStringLiteral("MasterColor"), ::CColor("#5caa15"), + s_MasterColor = m_preferences->GetColorValue(QStringLiteral("MasterColor"), QColor("#5caa15"), QStringLiteral("Preferences")); s_DarkBaseColor = s_BaseColor; - s_DarkBaseColor.SetLuminance(s_DarkBaseColor.GetLuminance() - 0.10f); + setColorLuminance(s_DarkBaseColor, getColorLuminance(s_DarkBaseColor) - 0.10f); s_MouseOverHighlightColor = s_BaseColor; - s_MouseOverHighlightColor.SetLuminance(s_MouseOverHighlightColor.GetLuminance() - 0.05f); + setColorLuminance(s_MouseOverHighlightColor, + getColorLuminance(s_MouseOverHighlightColor) - 0.05f); s_ButtonDownColor = s_DarkBaseColor; // CPreferences::GetUserPreferences( "Preferences" - // ).GetColorValue( "ButtonDownColor", ::CColor( 118, 202, + // ).GetColorValue( "ButtonDownColor", QColor( 118, 202, // 8 ) ); - s_DisabledTextColor = ::CColor(128, 128, 128); + s_DisabledTextColor = QColor(128, 128, 128); s_studioColor1 = QColor("#262829"); s_studioColor2 = QColor("#404244"); @@ -678,7 +694,7 @@ void CStudioPreferences::SetBigTimeAdvanceAmount(long inTime) * Retrieves the color that should be used when the mouse goes over a row, such * as in the timeline or inspector palettes. */ -::CColor CStudioPreferences::GetMouseOverHighlightColor() +QColor CStudioPreferences::GetMouseOverHighlightColor() { return s_MouseOverHighlightColor; } @@ -686,7 +702,7 @@ void CStudioPreferences::SetBigTimeAdvanceAmount(long inTime) /** * Returns the normal color used for non-master items and text throughout the UI */ -::CColor CStudioPreferences::GetNormalColor() +QColor CStudioPreferences::GetNormalColor() { return s_NormalColor; } @@ -695,7 +711,7 @@ void CStudioPreferences::SetBigTimeAdvanceAmount(long inTime) /** * Returns the color for master items and text throughout the UI */ -::CColor CStudioPreferences::GetMasterColor() +QColor CStudioPreferences::GetMasterColor() { return s_MasterColor; } @@ -704,7 +720,7 @@ void CStudioPreferences::SetBigTimeAdvanceAmount(long inTime) /** * Returns the color for inactive items and text throughout the UI */ -::CColor CStudioPreferences::GetInactiveColor() +QColor CStudioPreferences::GetInactiveColor() { return s_disabledColor; } @@ -713,24 +729,24 @@ void CStudioPreferences::SetBigTimeAdvanceAmount(long inTime) * @return default color for object timebars in the timeline (if not specified by one of these other * functions) */ -::CColor CStudioPreferences::GetObjectTimebarColor() +QColor CStudioPreferences::GetObjectTimebarColor() { - return ::CColor("#788ac5"); + return QColor("#788ac5"); } //============================================================================= /** * @return default colors for specific timebars in the timeline */ -::CColor CStudioPreferences::GetLayerTimebarColor() +QColor CStudioPreferences::GetLayerTimebarColor() { - return ::CColor("#e7e0cd"); + return QColor("#e7e0cd"); } /** * Color when text is disabled */ -::CColor CStudioPreferences::GetDisabledTextColor() +QColor CStudioPreferences::GetDisabledTextColor() { return s_DisabledTextColor; } @@ -739,47 +755,47 @@ void CStudioPreferences::SetBigTimeAdvanceAmount(long inTime) /** * Colors for bounding boxes */ -::CColor CStudioPreferences::GetSingleBoundingBoxColor() +QColor CStudioPreferences::GetSingleBoundingBoxColor() { - return ::CColor("#ff0000"); + return QColor("#ff0000"); } -::CColor CStudioPreferences::GetGroupBoundingBoxColor() +QColor CStudioPreferences::GetGroupBoundingBoxColor() { - return ::CColor("#ff0000"); + return QColor("#ff0000"); } /** * Colors for rulers and guides */ -::CColor CStudioPreferences::GetRulerBackgroundColor() +QColor CStudioPreferences::GetRulerBackgroundColor() { return s_studioColor1; } -::CColor CStudioPreferences::GetRulerTickColor() +QColor CStudioPreferences::GetRulerTickColor() { return s_studioColor3; } -::CColor CStudioPreferences::GetGuideColor() +QColor CStudioPreferences::GetGuideColor() { - return ::CColor("#7a5f02"); // #f4be04 plus faked alpha 50% + return QColor("#7a5f02"); // #f4be04 plus faked alpha 50% } -::CColor CStudioPreferences::GetGuideSelectedColor() +QColor CStudioPreferences::GetGuideSelectedColor() { return s_guideColor; } -::CColor CStudioPreferences::GetGuideFillColor() +QColor CStudioPreferences::GetGuideFillColor() { - return ::CColor("#140F00"); // #f4be04 plus faked alpha 8% + return QColor("#140F00"); // #f4be04 plus faked alpha 8% } -::CColor CStudioPreferences::GetGuideFillSelectedColor() +QColor CStudioPreferences::GetGuideFillSelectedColor() { - return ::CColor("#7a5f02"); // #f4be04 plus faked alpha 50% + return QColor("#7a5f02"); // #f4be04 plus faked alpha 50% } //============================================================================== @@ -817,7 +833,7 @@ void CStudioPreferences::setQmlContextProperties(QQmlContext *qml) qml->setContextProperty(QStringLiteral("_studioColor2"), s_studioColor2); qml->setContextProperty(QStringLiteral("_studioColor3"), s_studioColor3); qml->setContextProperty(QStringLiteral("_backgroundColor"), s_backgroundColor); - qml->setContextProperty(QStringLiteral("_buttonDownColor"), s_ButtonDownColor.getQColor()); + qml->setContextProperty(QStringLiteral("_buttonDownColor"), s_ButtonDownColor); qml->setContextProperty(QStringLiteral("_guideColor"), s_guideColor); qml->setContextProperty(QStringLiteral("_selectionColor"), s_selectionColor); qml->setContextProperty(QStringLiteral("_textColor"), s_textColor); diff --git a/src/Authoring/Client/Code/Core/Utility/StudioPreferences.h b/src/Authoring/Client/Code/Core/Utility/StudioPreferences.h index c5a8ac7c..7663c7ec 100644 --- a/src/Authoring/Client/Code/Core/Utility/StudioPreferences.h +++ b/src/Authoring/Client/Code/Core/Utility/StudioPreferences.h @@ -130,25 +130,25 @@ public: static QString GetPreviewProperty(const QString &inName); static void SetPreviewProperty(const QString &inName, const QString &inValue); - static ::CColor GetNormalColor(); - static ::CColor GetMasterColor(); - static ::CColor GetInactiveColor(); + static QColor GetNormalColor(); + static QColor GetMasterColor(); + static QColor GetInactiveColor(); - static ::CColor GetMouseOverHighlightColor(); + static QColor GetMouseOverHighlightColor(); - static ::CColor GetObjectTimebarColor(); - static ::CColor GetLayerTimebarColor(); - static ::CColor GetDisabledTextColor(); + static QColor GetObjectTimebarColor(); + static QColor GetLayerTimebarColor(); + static QColor GetDisabledTextColor(); - static ::CColor GetSingleBoundingBoxColor(); - static ::CColor GetGroupBoundingBoxColor(); + static QColor GetSingleBoundingBoxColor(); + static QColor GetGroupBoundingBoxColor(); - static ::CColor GetRulerBackgroundColor(); - static ::CColor GetRulerTickColor(); - static ::CColor GetGuideColor(); - static ::CColor GetGuideSelectedColor(); - static ::CColor GetGuideFillColor(); - static ::CColor GetGuideFillSelectedColor(); + static QColor GetRulerBackgroundColor(); + static QColor GetRulerTickColor(); + static QColor GetGuideColor(); + static QColor GetGuideSelectedColor(); + static QColor GetGuideFillColor(); + static QColor GetGuideFillSelectedColor(); static QString GetFontFaceName(); @@ -200,7 +200,7 @@ public: // Default values that Studio will start out with or to restore static const long GUTTER_SIZE = 10; - static const ::CColor EDITVIEW_DEFAULTBGCOLOR; + static const QColor EDITVIEW_DEFAULTBGCOLOR; static const long PREFERREDSTARTUP_DEFAULTINDEX = -1; static const long DEFAULT_SNAPRANGE = 10; static const long DEFAULT_LIFETIME = 10000; diff --git a/src/Authoring/Common/Code/Preferences.h b/src/Authoring/Common/Code/Preferences.h index d694de33..20b535e0 100644 --- a/src/Authoring/Common/Code/Preferences.h +++ b/src/Authoring/Common/Code/Preferences.h @@ -30,7 +30,7 @@ #ifndef INCLUDED_PREFERENCES_H #define INCLUDED_PREFERENCES_H -#include "CColor.h" +#include <QtGui/qcolor.h> #include <QtXml/qdom.h> class CPreferences @@ -52,8 +52,8 @@ public: void SetValue(const QString &inKey, double inValue, const QString &group = {}); double GetValue(const QString &inKey, double inDefaultValue, const QString &group = {}); - void SetColorValue(const QString &inKey, ::CColor inValue, const QString &group = {}); - ::CColor GetColorValue(const QString &inKey, ::CColor inDefaultValue, + void SetColorValue(const QString &inKey, const QColor &inValue, const QString &group = {}); + QColor GetColorValue(const QString &inKey, const QColor &inDefaultValue, const QString &group = {}); void SetPreferencesFile(const QString &inFileName); diff --git a/src/Authoring/Common/Code/Qt3DSCommonPrecompile.h b/src/Authoring/Common/Code/Qt3DSCommonPrecompile.h index 93f06bf2..0c0dc267 100644 --- a/src/Authoring/Common/Code/Qt3DSCommonPrecompile.h +++ b/src/Authoring/Common/Code/Qt3DSCommonPrecompile.h @@ -80,6 +80,7 @@ //============================================================================== // Common Player Includes //============================================================================== +#include "Qt3DSHash.h" #include "Qt3DSMath.h" #include "Qt3DSPoint.h" #include "Qt3DSRect.h" diff --git a/src/Authoring/Common/Code/Qt3DSFileTools.cpp b/src/Authoring/Common/Code/Qt3DSFileTools.cpp index 0e0056b1..264d2dd1 100644 --- a/src/Authoring/Common/Code/Qt3DSFileTools.cpp +++ b/src/Authoring/Common/Code/Qt3DSFileTools.cpp @@ -125,6 +125,16 @@ void CFilePath::normalizeAndSetPath(const QString &path) setFile(ret); } +QString CFilePath::stripIdentifier(const QString &path) +{ + QString ret = normalizeAndCleanPath(path); + if (ret.contains(identifierSep)) { + int i = ret.indexOf(identifierSep); + ret.truncate(i); + } + return ret; +} + CFilePath CFilePath::GetDirectory() const { return CFilePath(path()); @@ -208,6 +218,15 @@ CString CFilePath::MakeSafeFileStem(const CString &name) return CString::fromQString(ret); } +QString CFilePath::MakeSafeFileStem(const QString &name) +{ + QString ret = normalizeAndCleanPath(name); + + ret = ret.replace(illegalChar, replaceChar); + + return ret; +} + bool CFilePath::CreateDir(bool recurse) const { QDir d(filePath()); @@ -220,6 +239,19 @@ bool CFilePath::CreateDir(bool recurse) const return d.mkdir(fileName()); } +bool CFilePath::CreateDir(const QString &path, bool recurse) +{ + QFileInfo info(path); + QDir d(info.dir()); + if (d.exists()) + return true; + + if (recurse) + return d.mkpath(info.path()); + d.cdUp(); + return d.mkdir(info.fileName()); +} + bool CFilePath::IsDirectory() const { return isDir(); @@ -258,51 +290,47 @@ bool CFilePath::DeleteThisDirectory(bool recurse) return d.mkdir(fileName()); } -void CFilePath::ListFilesAndDirectories(std::vector<CFilePath> &files) const +void CFilePath::ListFilesAndDirectories(const QString &directory, std::vector<QFileInfo> &files) { - if (!IsDirectory()) - return; - - CString findPath = CString::fromQString(filePath()); - QDirIterator di(findPath.toQString(), QDir::NoDotAndDotDot | QDir::AllEntries); + QDirIterator di(directory, QDir::NoDotAndDotDot | QDir::AllEntries); while (di.hasNext()) - files.push_back(CString::fromQString(di.next())); + files.push_back(di.next()); } -void CFilePath::RecursivelyFindFilesOfType(const wchar_t **inExtensionList, - std::vector<CFilePath> &files, bool inMakeRelative, - bool inIncludeDirectories) const +bool compare(const QFileInfo &a, const QFileInfo &b) { - if (!IsDirectory()) { - QT3DS_ASSERT(false); - return; - } - std::vector<CFilePath> directoryVector; - std::vector<CFilePath> nextDirectoryVector; - std::vector<CFilePath> resultsVector; + return a.filePath() < b.filePath(); +} - directoryVector.push_back(*this); +void CFilePath::RecursivelyFindFilesOfType(const QFileInfo &dir, const QStringList &inExtensionList, + std::vector<QFileInfo> &files, bool inMakeRelative, + bool inIncludeDirectories) +{ + std::vector<QFileInfo> directoryVector; + std::vector<QFileInfo> nextDirectoryVector; + std::vector<QFileInfo> resultsVector; + + directoryVector.push_back(dir); // breadth first search. while (directoryVector.empty() == false && files.size() < 10000) { for (size_t dirIdx = 0, dirEnd = directoryVector.size(); dirIdx < dirEnd && files.size() < 10000; ++dirIdx) { resultsVector.clear(); - directoryVector[dirIdx].ListFilesAndDirectories(resultsVector); + ListFilesAndDirectories(directoryVector[dirIdx].canonicalPath(), resultsVector); for (size_t resultIdx = 0, resultEnd = resultsVector.size(); resultIdx < resultEnd; ++resultIdx) { - const CFilePath &result(resultsVector[resultIdx]); - if (result.IsDirectory()) { + const QFileInfo &result(resultsVector[resultIdx]); + if (result.isDir()) { nextDirectoryVector.push_back(result); if (inIncludeDirectories) files.push_back(result); } else { - Q3DStudio::CString extension(result.GetExtension()); - if (inExtensionList == NULL || *inExtensionList == NULL) { + QString extension(result.suffix()); + if (inExtensionList.isEmpty()) { files.push_back(result); } else { - for (const wchar_t **specificExt = inExtensionList; *specificExt; - ++specificExt) { - if (extension == *specificExt) { + for (const QString &ext : qAsConst(inExtensionList)) { + if (extension == ext) { files.push_back(result); break; } @@ -314,10 +342,10 @@ void CFilePath::RecursivelyFindFilesOfType(const wchar_t **inExtensionList, std::swap(directoryVector, nextDirectoryVector); nextDirectoryVector.clear(); } - std::stable_sort(files.begin(), files.end()); + std::stable_sort(files.begin(), files.end(), compare); if (inMakeRelative) { for (size_t idx = 0, end = files.size(); idx < end; ++idx) - files[idx] = GetRelativePathFromBase(*this, files[idx]); + files[idx] = GetRelativePathFromBase(dir, files[idx]); } } @@ -667,6 +695,30 @@ SFileErrorCodeAndNumBytes SFileTools::Copy(const CFilePath &destFile, FileOpenFl return FileErrorCodes::DestNotWriteable; } +SFileErrorCodeAndNumBytes SFileTools::Copy(const QString &destFile, FileOpenFlags fileFlags, + const QString &srcFile) +{ + QFileInfo src(srcFile); + QFileInfo dst(destFile); + if (!src.exists()) + return FileErrorCodes::SourceNotExist; + + if (!src.isReadable()) + return FileErrorCodes::SourceNotReadable; + + if (dst.exists()) { + bool ok = QFile::remove(destFile); + if (!ok) + return FileErrorCodes::DestNotWriteable; + } + + bool ok = QFile::copy(srcFile, destFile); + if (ok) + return dst.size(); + + return FileErrorCodes::DestNotWriteable; +} + // Find a unique dest file based on the src file stem and extension but in the destination directory // then copy that file. Return the file name // this -> points to destination directory diff --git a/src/Authoring/Common/Code/Qt3DSFileTools.h b/src/Authoring/Common/Code/Qt3DSFileTools.h index 53248cbf..dcf8e61e 100644 --- a/src/Authoring/Common/Code/Qt3DSFileTools.h +++ b/src/Authoring/Common/Code/Qt3DSFileTools.h @@ -98,13 +98,20 @@ public: { m_identifier = identifier.toQString(); } void ConvertToRelative(const CFilePath &inBaseAbsolute); - static CFilePath GetRelativePathFromBase(const CFilePath &inBase, const CFilePath &inPath) + + static QString GetRelativePathFromBase(const QFileInfo &inBase, const QFileInfo &inPath) { - CFilePath retval(inPath); - retval.ConvertToRelative(inBase); - return retval; + QFileInfo basePath(inBase); + QFileInfo relPath(inPath); + QT3DS_ASSERT(basePath.isAbsolute()); + QT3DS_ASSERT(!relPath.isRelative()); + QDir basePathDir = basePath.absoluteFilePath(); + QString outPath = basePathDir.relativeFilePath(relPath.absoluteFilePath()); + return outPath; } + static QString stripIdentifier(const QString &path); + /** * Return true if this string is in subdirectory of inBasePath * For example, basepath is C:\Folder\Project.uip @@ -125,6 +132,15 @@ public: return retval; } + static QString CombineBaseAndRelative(const QString &base, const QString &inRelative) + { + QFileInfo basePath(base); + QT3DS_ASSERT(basePath.isAbsolute()); + QDir basePathDir = basePath.absoluteFilePath(); + QString absPath = basePathDir.absoluteFilePath(inRelative); + return QDir::cleanPath(absPath); + } + bool IsAbsolute() const; bool ConvertToAbsolute(); static CFilePath GetAbsolutePath(const CFilePath &inBaseFilePath) @@ -136,10 +152,12 @@ public: // Make a save file stem from this string. Involves replacing characters // that are illegal (:,\\,//,etc). static CString MakeSafeFileStem(const CString &name); + static QString MakeSafeFileStem(const QString &name); // Create this directory, recursively creating parent directories // if necessary. bool CreateDir(bool recurse) const; + static bool CreateDir(const QString &path, bool recurse); // Returns true if exists and is directory bool IsDirectory() const; // returns true if exists and is a file @@ -159,7 +177,7 @@ public: // ignore special files ".\\" and "..\\" // Returns absolute paths combined with this // this.combineBaseAndRelative( result ); - void ListFilesAndDirectories(std::vector<CFilePath> &files) const; + static void ListFilesAndDirectories(const QString &directory, std::vector<QFileInfo> &files); // Returns absolute paths // This object has to be a directory @@ -171,8 +189,9 @@ public: // ExtensionList should not contain the "." in ".png" for example. // It should just contain { L"png", NULL } // An empty extension list means return all files. - void RecursivelyFindFilesOfType(const wchar_t **inExtensionList, std::vector<CFilePath> &files, - bool inMakeRelative, bool inIncludeDirectories = false) const; + static void RecursivelyFindFilesOfType(const QFileInfo &dir, const QStringList &inExtensionList, + std::vector<QFileInfo> &files, bool inMakeRelative, + bool inIncludeDirectories = false); // Given the list of differences from last time this function was called (which may be empty) // and the list of new differences to put new results into, recursively diff this directory's @@ -206,7 +225,7 @@ private: struct SFileModificationRecord { - CFilePath m_File; + QFileInfo m_File; SFileInfoFlags m_FileInfo; SFileData m_FileData; FileModificationType::Enum m_ModificationType; @@ -216,7 +235,7 @@ struct SFileModificationRecord { } - SFileModificationRecord(const CFilePath &inFile, const SFileInfoFlags &inFileInfo, + SFileModificationRecord(const QFileInfo &inFile, const SFileInfoFlags &inFileInfo, const SFileData &inFileData, FileModificationType::Enum modType) : m_File(inFile) , m_FileInfo(inFileInfo) @@ -359,6 +378,8 @@ struct SFileTools // Same file flags as SFile::OpenForWrite static SFileErrorCodeAndNumBytes Copy(const CFilePath &destFile, FileOpenFlags fileFlags, const CFilePath &srcFile); + static SFileErrorCodeAndNumBytes Copy(const QString &destFile, FileOpenFlags fileFlags, + const QString &srcFile); // Find a unique dest file based on the src file stem and extension but in the destination // directory diff --git a/src/Authoring/Common/Code/Qt3DSHash.h b/src/Authoring/Common/Code/Qt3DSHash.h new file mode 100644 index 00000000..4c3cc8ff --- /dev/null +++ b/src/Authoring/Common/Code/Qt3DSHash.h @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt 3D Studio. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef __QT3DS_HASH_H__ +#define __QT3DS_HASH_H__ + +#include <QtCore/qhashfunctions.h> + +namespace qt3dsdm { +struct SLong4; +} + +QT_BEGIN_NAMESPACE + +inline uint qHash(const qt3dsdm::SLong4 &v, uint seed); + +QT_END_NAMESPACE + +#endif diff --git a/src/Authoring/Common/Code/StackTokenizer.cpp b/src/Authoring/Common/Code/StackTokenizer.cpp index 59c58c78..246a9e2a 100644 --- a/src/Authoring/Common/Code/StackTokenizer.cpp +++ b/src/Authoring/Common/Code/StackTokenizer.cpp @@ -39,14 +39,14 @@ using namespace Q3DStudio; * @param inToken single char token * @param inEscapeChar single char escape char */ -CStackTokenizer::CStackTokenizer(const Q3DStudio::CString &inString, Q3DStudio::Qt3DSChar inDelimiter, - Q3DStudio::Qt3DSChar inEscapeChar) +CStackTokenizer::CStackTokenizer(const QString &inString, const QChar &inDelimiter, + const QChar &inEscapeChar) : m_String(inString) , m_Delimiter(inDelimiter) , m_EscapeChar(inEscapeChar) , m_Index(0) , m_LastIndex(0) - , m_StringLength(inString.Length()) + , m_StringLength(inString.length()) { } @@ -63,7 +63,7 @@ CStackTokenizer::~CStackTokenizer() * Returns true if string contains another token that can be read. * @return bool true of there is another token to be read */ -bool CStackTokenizer::HasNextPartition() +bool CStackTokenizer::HasNextPartition() const { if (m_Index >= m_StringLength) return false; @@ -77,19 +77,19 @@ bool CStackTokenizer::HasNextPartition() * @return Q3DStudio::CString the string value of the token */ -Q3DStudio::CString CStackTokenizer::GetCurrentPartition() +QString CStackTokenizer::GetCurrentPartition() { - std::deque<Q3DStudio::Qt3DSChar> theStack; + std::deque<QChar> theStack; bool theIgnoreEscapeChar = false; bool theFoundToken = false; long theCurrentIndex = m_Index; - Q3DStudio::CString theResult; + QString theResult; - if (!m_String.IsEmpty()) { + if (!m_String.isEmpty()) { while (!theFoundToken) { // get the char at this index - Q3DStudio::Qt3DSChar theChar = m_String.GetAt(theCurrentIndex++); + QChar theChar = m_String.at(theCurrentIndex++); if (theChar == m_Delimiter) { if (theStack.size() != 0) { @@ -121,7 +121,7 @@ Q3DStudio::CString CStackTokenizer::GetCurrentPartition() m_LastIndex = theCurrentIndex; // update the last 'tokenized' position while (theStack.size() != 0) { - theResult.Concat(theStack.back()); // put everything back into a string + theResult.append(theStack.back()); // put everything back into a string theStack.pop_back(); } } diff --git a/src/Authoring/Common/Code/StackTokenizer.h b/src/Authoring/Common/Code/StackTokenizer.h index ee00e5fa..ca533271 100644 --- a/src/Authoring/Common/Code/StackTokenizer.h +++ b/src/Authoring/Common/Code/StackTokenizer.h @@ -52,21 +52,21 @@ class CStackTokenizer { public: - CStackTokenizer(const Q3DStudio::CString &inString, Q3DStudio::Qt3DSChar inDelimiter, - Q3DStudio::Qt3DSChar inEscapeChar); + CStackTokenizer(const QString &inString, const QChar &inDelimiter, + const QChar &inEscapeChar); virtual ~CStackTokenizer(); - bool HasNextPartition(); - Q3DStudio::CString GetCurrentPartition(); + bool HasNextPartition() const; + QString GetCurrentPartition(); void operator++(); protected: - Q3DStudio::CString m_String; ///< contains the string to tokenize - Q3DStudio::Qt3DSChar m_Delimiter; ///< single char delimiter - Q3DStudio::Qt3DSChar m_EscapeChar; ///< single char escape char + QString m_String; ///< contains the string to tokenize + QChar m_Delimiter; ///< single char delimiter + QChar m_EscapeChar; ///< single char escape char long m_Index; ///< index to begin tokenizing the string from long m_LastIndex; ///< index of the string since last tokenize operation const long m_StringLength; ///< length of the string to tokenize }; -#endif // INCLUDED_STACKTOKENIZER_H_
\ No newline at end of file +#endif // INCLUDED_STACKTOKENIZER_H_ diff --git a/src/Authoring/Common/Code/_Win32/Preferences.cpp b/src/Authoring/Common/Code/_Win32/Preferences.cpp index ae2d44a7..0a006af4 100644 --- a/src/Authoring/Common/Code/_Win32/Preferences.cpp +++ b/src/Authoring/Common/Code/_Win32/Preferences.cpp @@ -124,24 +124,26 @@ void CPreferences::SetValue(const QString &key, double value, const QString &gro double CPreferences::GetValue(const QString &key, double defaultValue, const QString &group) { - QString theStrValue = GetStringValue(key, {}, group); + const QString theStrValue(GetStringValue(key, {}, group)); return theStrValue.isEmpty() ? defaultValue : theStrValue.toDouble(); } -CColor CPreferences::GetColorValue(const QString &key, CColor defaultColor, const QString &group) +QColor CPreferences::GetColorValue(const QString &key, const QColor &defaultColor, + const QString &group) { - QString theColorString = GetStringValue(key, {}, group); + const QString theColorString(GetStringValue(key, {}, group)); if (!theColorString.isEmpty()) { - QStringList rgb = theColorString.split(QStringLiteral(" ")); - return ::CColor(rgb.at(0).toInt(), rgb.at(1).toInt(), rgb.at(2).toInt()); + QStringList rgb = theColorString.split(QLatin1Char(' ')); + return QColor(rgb.at(0).toInt(), rgb.at(1).toInt(), rgb.at(2).toInt()); } return defaultColor; } -void CPreferences::SetColorValue(const QString &key, CColor value, const QString &group) +void CPreferences::SetColorValue(const QString &key, const QColor &value, const QString &group) { - QString rgbStr = QString("%1 %2 %2").arg(value.red).arg(value.green).arg(value.blue); + const QString rgbStr(QStringLiteral("%1 %2 %2").arg(value.red()).arg(value.green()) + .arg(value.blue())); setValue(key, rgbStr, group); } diff --git a/src/Authoring/Common/Common.pro b/src/Authoring/Common/Common.pro index 8db0e5d6..c25cc7b4 100644 --- a/src/Authoring/Common/Common.pro +++ b/src/Authoring/Common/Common.pro @@ -35,7 +35,6 @@ INCLUDEPATH += \ PRECOMPILED_HEADER += Code/Qt3DSCommonPrecompile.h SOURCES += \ - ../../3rdparty/color/CColor.cpp \ Code/HiResTimer.cpp \ Code/MasterP.cpp \ Code/MethProf.cpp \ @@ -81,4 +80,5 @@ SOURCES += \ ../Client/Code/Core/Runtime2Integration/Q3DSStringTable.cpp HEADERS = Code/Literals.h \ - ../Client/Code/Core/Runtime2Integration/Q3DSStringTable.h + ../Client/Code/Core/Runtime2Integration/Q3DSStringTable.h \ + Code/Qt3DSHash.h diff --git a/src/Authoring/CoreLib/CoreLib.pro b/src/Authoring/CoreLib/CoreLib.pro index c8bcf665..f3bd6caa 100644 --- a/src/Authoring/CoreLib/CoreLib.pro +++ b/src/Authoring/CoreLib/CoreLib.pro @@ -140,7 +140,8 @@ SOURCES += \ ../Client/Code/Core/Utility/q3dsdirsystem.cpp \ ../Client/Code/Core/Utility/q3dsdirwatcher.cpp \ ../Client/Code/Core/Runtime2Integration/Q3DSDocumentBufferCache.cpp \ - ../Client/Code/Core/Runtime2Integration/Q3DSInputStreamFactory.cpp + ../Client/Code/Core/Runtime2Integration/Q3DSInputStreamFactory.cpp \ + ../Client/Code/Core/Runtime2Integration/Q3DSRenderBufferManager.cpp HEADERS += \ ../Client/Code/Core/Utility/q3dsdirsystem.h \ diff --git a/src/Authoring/QT3DSDM/QT3DSDM.pro b/src/Authoring/QT3DSDM/QT3DSDM.pro index d54a46c9..af8beefa 100644 --- a/src/Authoring/QT3DSDM/QT3DSDM.pro +++ b/src/Authoring/QT3DSDM/QT3DSDM.pro @@ -13,6 +13,7 @@ INCLUDEPATH += \ \ Systems \ Systems/Cores \ + ../Client/Code/Core/Runtime2Integration \ ../../Runtime/Source/System/Include \ ../../Runtime/Source/Qt3DSFoundation/Include \ ../../Runtime/Source/Qt3DSRuntimeRender/Include \ diff --git a/src/Authoring/QT3DSDM/Systems/Cores/ActionCoreProducer.cpp b/src/Authoring/QT3DSDM/Systems/Cores/ActionCoreProducer.cpp index c262c239..696354b1 100644 --- a/src/Authoring/QT3DSDM/Systems/Cores/ActionCoreProducer.cpp +++ b/src/Authoring/QT3DSDM/Systems/Cores/ActionCoreProducer.cpp @@ -125,7 +125,7 @@ void CActionCoreProducer::SetTargetObject(Qt3DSDMActionHandle inAction, GetSignalSender()->SendTargetObjectSet(inAction, theAction->m_ActionInfo.m_TargetObject); } -void CActionCoreProducer::SetEvent(Qt3DSDMActionHandle inAction, const wstring &inEventHandle) +void CActionCoreProducer::SetEvent(Qt3DSDMActionHandle inAction, const QString &inEventHandle) { SAction *theAction = CSimpleActionCore::GetActionNF(inAction, m_Data->m_Objects); if (m_Consumer) { @@ -138,7 +138,7 @@ void CActionCoreProducer::SetEvent(Qt3DSDMActionHandle inAction, const wstring & GetSignalSender()->SendEventSet(inAction, inEventHandle); } -void CActionCoreProducer::SetHandler(Qt3DSDMActionHandle inAction, const wstring &inHandlerHandle) +void CActionCoreProducer::SetHandler(Qt3DSDMActionHandle inAction, const QString &inHandlerHandle) { SAction *theAction = CSimpleActionCore::GetActionNF(inAction, m_Data->m_Objects); if (m_Consumer) { @@ -152,7 +152,7 @@ void CActionCoreProducer::SetHandler(Qt3DSDMActionHandle inAction, const wstring } Qt3DSDMHandlerArgHandle CActionCoreProducer::AddHandlerArgument(Qt3DSDMActionHandle inAction, - const TCharStr &inName, + const QString &inName, HandlerArgumentType::Value inArgType, DataModelDataType::Value inValueType) { @@ -244,24 +244,24 @@ TSignalConnectionPtr CActionCoreProducer::ConnectTargetObjectSet( return GetSignalProvider()->ConnectTargetObjectSet(inCallback); } TSignalConnectionPtr CActionCoreProducer::ConnectEventSet( - const std::function<void(Qt3DSDMActionHandle, const wstring &)> &inCallback) + const std::function<void(Qt3DSDMActionHandle, const QString &)> &inCallback) { return GetSignalProvider()->ConnectEventSet(inCallback); } TSignalConnectionPtr CActionCoreProducer::ConnectHandlerSet( - const std::function<void(Qt3DSDMActionHandle, const wstring &)> &inCallback) + const std::function<void(Qt3DSDMActionHandle, const QString &)> &inCallback) { return GetSignalProvider()->ConnectHandlerSet(inCallback); } TSignalConnectionPtr CActionCoreProducer::ConnectHandlerArgumentAdded( - const std::function<void(Qt3DSDMActionHandle, Qt3DSDMHandlerArgHandle, const TCharStr &, + const std::function<void(Qt3DSDMActionHandle, Qt3DSDMHandlerArgHandle, const QString &, HandlerArgumentType::Value, DataModelDataType::Value)> &inCallback) { return GetSignalProvider()->ConnectHandlerArgumentAdded(inCallback); } TSignalConnectionPtr CActionCoreProducer::ConnectHandlerArgumentRemoved( - const std::function<void(Qt3DSDMActionHandle, Qt3DSDMHandlerArgHandle, const TCharStr &, + const std::function<void(Qt3DSDMActionHandle, Qt3DSDMHandlerArgHandle, const QString &, HandlerArgumentType::Value, DataModelDataType::Value)> &inCallback) { return GetSignalProvider()->ConnectHandlerArgumentRemoved(inCallback); diff --git a/src/Authoring/QT3DSDM/Systems/Cores/ActionCoreProducer.h b/src/Authoring/QT3DSDM/Systems/Cores/ActionCoreProducer.h index bf65a387..576404ad 100644 --- a/src/Authoring/QT3DSDM/Systems/Cores/ActionCoreProducer.h +++ b/src/Authoring/QT3DSDM/Systems/Cores/ActionCoreProducer.h @@ -74,11 +74,11 @@ public: // Action Properties void SetTriggerObject(Qt3DSDMActionHandle inAction, const SObjectRefType &inTriggerObject) override; void SetTargetObject(Qt3DSDMActionHandle inAction, const SObjectRefType &inTargetObject) override; - void SetEvent(Qt3DSDMActionHandle inAction, const wstring &inEventHandle) override; - void SetHandler(Qt3DSDMActionHandle inAction, const wstring &inHandlerHandle) override; + void SetEvent(Qt3DSDMActionHandle inAction, const QString &inEventHandle) override; + void SetHandler(Qt3DSDMActionHandle inAction, const QString &inHandlerHandle) override; // Action Argument - Qt3DSDMHandlerArgHandle AddHandlerArgument(Qt3DSDMActionHandle inAction, const TCharStr &inName, + Qt3DSDMHandlerArgHandle AddHandlerArgument(Qt3DSDMActionHandle inAction, const QString &inName, HandlerArgumentType::Value inArgType, DataModelDataType::Value inValueType) override; void RemoveHandlerArgument(Qt3DSDMHandlerArgHandle inHandlerArgument) override; @@ -88,8 +88,10 @@ public: THandlerArgHandleList &outHandlerArguments) const override; // Action Argument Properties - void GetHandlerArgumentValue(Qt3DSDMHandlerArgHandle inHandlerArgument, SValue &outValue) const override; - void SetHandlerArgumentValue(Qt3DSDMHandlerArgHandle inHandlerArgument, const SValue &inValue) override; + void GetHandlerArgumentValue( + Qt3DSDMHandlerArgHandle inHandlerArgument, SValue &outValue) const override; + void SetHandlerArgumentValue( + Qt3DSDMHandlerArgHandle inHandlerArgument, const SValue &inValue) override; // CHandleBase bool HandleValid(int inHandle) const override; @@ -102,16 +104,20 @@ public: TSignalConnectionPtr ConnectTargetObjectSet( const std::function<void(Qt3DSDMActionHandle, SObjectRefType &)> &inCallback) override; virtual TSignalConnectionPtr - ConnectEventSet(const std::function<void(Qt3DSDMActionHandle, const wstring &)> &inCallback) override; + ConnectEventSet(const std::function<void(Qt3DSDMActionHandle, const QString &)> + &inCallback) override; virtual TSignalConnectionPtr - ConnectHandlerSet(const std::function<void(Qt3DSDMActionHandle, const wstring &)> &inCallback) override; + ConnectHandlerSet(const std::function<void(Qt3DSDMActionHandle, const QString &)> + &inCallback) override; TSignalConnectionPtr ConnectHandlerArgumentAdded( - const std::function<void(Qt3DSDMActionHandle, Qt3DSDMHandlerArgHandle, const TCharStr &, - HandlerArgumentType::Value, DataModelDataType::Value)> &inCallback) override; + const std::function<void(Qt3DSDMActionHandle, Qt3DSDMHandlerArgHandle, const QString &, + HandlerArgumentType::Value, DataModelDataType::Value)> + &inCallback) override; TSignalConnectionPtr ConnectHandlerArgumentRemoved( - const std::function<void(Qt3DSDMActionHandle, Qt3DSDMHandlerArgHandle, const TCharStr &, - HandlerArgumentType::Value, DataModelDataType::Value)> &inCallback) override; + const std::function<void(Qt3DSDMActionHandle, Qt3DSDMHandlerArgHandle, const QString &, + HandlerArgumentType::Value, DataModelDataType::Value)> + &inCallback) override; TSignalConnectionPtr ConnectHandlerArgumentValueSet( const std::function<void(Qt3DSDMHandlerArgHandle, const SValue &)> &inCallback) override; diff --git a/src/Authoring/QT3DSDM/Systems/Cores/DataCoreProducer.cpp b/src/Authoring/QT3DSDM/Systems/Cores/DataCoreProducer.cpp index 5c3cc924..15ad2329 100644 --- a/src/Authoring/QT3DSDM/Systems/Cores/DataCoreProducer.cpp +++ b/src/Authoring/QT3DSDM/Systems/Cores/DataCoreProducer.cpp @@ -54,7 +54,7 @@ inline void SignalPropertyRemoved(Qt3DSDMInstanceHandle inInstance, tuple<Qt3DSDMPropertyHandle, Qt3DSDMPropertyDefinition> inData, IDataCoreSignalSender *inSender) { - inSender->SignalPropertyRemoved(inInstance, get<0>(inData), get<1>(inData).m_Name.wide_str(), + inSender->SignalPropertyRemoved(inInstance, get<0>(inData), get<1>(inData).m_Name, get<1>(inData).m_Type); } @@ -148,7 +148,8 @@ void CDataCoreProducer::GetInstanceParents(Qt3DSDMInstanceHandle inHandle, } Qt3DSDMPropertyHandle CDataCoreProducer::AddProperty(Qt3DSDMInstanceHandle inInstance, - TCharPtr inName, DataModelDataType::Value inPropType) + const QString &inName, + DataModelDataType::Value inPropType) { Qt3DSDMPropertyHandle retval = m_Data->AddProperty(inInstance, inName, inPropType); TDataModelInstancePtr theInstance = @@ -184,7 +185,7 @@ void CDataCoreProducer::RemoveProperty(Qt3DSDMPropertyHandle inProperty) theInstance->m_Properties); CREATE_HANDLE_DELETE_TRANSACTION(m_Consumer, inProperty, m_Data->m_Objects); GetDataCoreSender()->SignalPropertyRemoved(theDef.m_Instance, inProperty, - theDef.m_Name.wide_str(), theDef.m_Type); + theDef.m_Name, theDef.m_Type); m_Data->RemoveProperty(inProperty); } else { throw PropertyNotFound(L""); @@ -277,7 +278,7 @@ void CDataCoreProducer::CopyInstanceProperties(Qt3DSDMInstanceHandle inSrcInstan Qt3DSDMPropertyHandle CDataCoreProducer::GetAggregateInstancePropertyByName(Qt3DSDMInstanceHandle inInstance, - const TCharStr &inStr) const + const QString &inStr) const { return m_Data->GetAggregateInstancePropertyByName(inInstance, inStr); } @@ -415,14 +416,14 @@ TSignalConnectionPtr CDataCoreProducer::ConnectInstanceParentRemoved( } TSignalConnectionPtr CDataCoreProducer::ConnectPropertyAdded( - const std::function<void(Qt3DSDMInstanceHandle, Qt3DSDMPropertyHandle, TCharPtr, + const std::function<void(Qt3DSDMInstanceHandle, Qt3DSDMPropertyHandle, const QString &, DataModelDataType::Value)> &inCallback) { return GetDataCoreProvider()->ConnectPropertyAdded(inCallback); } TSignalConnectionPtr CDataCoreProducer::ConnectPropertyRemoved( - const std::function<void(Qt3DSDMInstanceHandle, Qt3DSDMPropertyHandle, TCharPtr, + const std::function<void(Qt3DSDMInstanceHandle, Qt3DSDMPropertyHandle, const QString &, DataModelDataType::Value)> &inCallback) { return GetDataCoreProvider()->ConnectPropertyRemoved(inCallback); diff --git a/src/Authoring/QT3DSDM/Systems/Cores/DataCoreProducer.h b/src/Authoring/QT3DSDM/Systems/Cores/DataCoreProducer.h index 8d89bfab..fedc00c1 100644 --- a/src/Authoring/QT3DSDM/Systems/Cores/DataCoreProducer.h +++ b/src/Authoring/QT3DSDM/Systems/Cores/DataCoreProducer.h @@ -73,7 +73,7 @@ public: // IInstancePropertyCore //=============================================================== Qt3DSDMPropertyHandle GetAggregateInstancePropertyByName(Qt3DSDMInstanceHandle inInstance, - const TCharStr &inStr) const override; + const QString &inStr) const override; void GetAggregateInstanceProperties(Qt3DSDMInstanceHandle inInstance, TPropertyHandleList &outProperties) const override; void GetSpecificInstancePropertyValues(Qt3DSDMInstanceHandle inHandle, @@ -103,7 +103,7 @@ public: bool IsInstanceOrDerivedFrom(Qt3DSDMInstanceHandle inInstance, Qt3DSDMInstanceHandle inParent) const override; - Qt3DSDMPropertyHandle AddProperty(Qt3DSDMInstanceHandle inInstance, TCharPtr inName, + Qt3DSDMPropertyHandle AddProperty(Qt3DSDMInstanceHandle inInstance, const QString &inName, DataModelDataType::Value inPropType) override; void GetInstanceProperties(Qt3DSDMInstanceHandle inInstance, TPropertyHandleList &outProperties) const override; @@ -149,10 +149,10 @@ public: const std::function<void(Qt3DSDMInstanceHandle, Qt3DSDMInstanceHandle)> &inCallback) override; virtual TSignalConnectionPtr ConnectPropertyAdded(const std::function<void(Qt3DSDMInstanceHandle, Qt3DSDMPropertyHandle, - TCharPtr, DataModelDataType::Value)> &inCallback) override; + const QString &, DataModelDataType::Value)> &inCallback) override; virtual TSignalConnectionPtr ConnectPropertyRemoved(const std::function<void(Qt3DSDMInstanceHandle, Qt3DSDMPropertyHandle, - TCharPtr, DataModelDataType::Value)> &inCallback) override; + const QString &, DataModelDataType::Value)> &inCallback) override; private: CDataCoreProducer(const CDataCoreProducer&) = delete; diff --git a/src/Authoring/QT3DSDM/Systems/Cores/SimpleActionCore.cpp b/src/Authoring/QT3DSDM/Systems/Cores/SimpleActionCore.cpp index b2f35538..3b7dcb9e 100644 --- a/src/Authoring/QT3DSDM/Systems/Cores/SimpleActionCore.cpp +++ b/src/Authoring/QT3DSDM/Systems/Cores/SimpleActionCore.cpp @@ -145,13 +145,13 @@ void CSimpleActionCore::SetTargetObject(Qt3DSDMActionHandle inAction, theAction->m_ActionInfo.m_TargetObject = inTargetObject; } -void CSimpleActionCore::SetEvent(Qt3DSDMActionHandle inAction, const wstring &inEventHandle) +void CSimpleActionCore::SetEvent(Qt3DSDMActionHandle inAction, const QString &inEventHandle) { SAction *theAction = GetActionNF(inAction, m_Objects); theAction->m_ActionInfo.m_Event = inEventHandle; } -void CSimpleActionCore::SetHandler(Qt3DSDMActionHandle inAction, const wstring &inHandlerHandle) +void CSimpleActionCore::SetHandler(Qt3DSDMActionHandle inAction, const QString &inHandlerHandle) { SAction *theAction = GetActionNF(inAction, m_Objects); theAction->m_ActionInfo.m_Handler = inHandlerHandle; @@ -159,7 +159,7 @@ void CSimpleActionCore::SetHandler(Qt3DSDMActionHandle inAction, const wstring & // Action Argument Qt3DSDMHandlerArgHandle CSimpleActionCore::AddHandlerArgument(Qt3DSDMActionHandle inAction, - const TCharStr &inName, + const QString &inName, HandlerArgumentType::Value inArgType, DataModelDataType::Value inValueType) { @@ -226,7 +226,8 @@ Qt3DSDMActionHandle CSimpleActionCore::CreateActionWithHandle(int inHandle, Qt3DSDMHandlerArgHandle CSimpleActionCore::AddHandlerArgumentWithHandle(int inHandle, Qt3DSDMActionHandle inAction, - const TCharStr &inName, HandlerArgumentType::Value inArgType, + const QString &inName, + HandlerArgumentType::Value inArgType, DataModelDataType::Value inValueType) { if (HandleValid(inHandle)) diff --git a/src/Authoring/QT3DSDM/Systems/Cores/SimpleActionCore.h b/src/Authoring/QT3DSDM/Systems/Cores/SimpleActionCore.h index 1e229f18..4167cdfa 100644 --- a/src/Authoring/QT3DSDM/Systems/Cores/SimpleActionCore.h +++ b/src/Authoring/QT3DSDM/Systems/Cores/SimpleActionCore.h @@ -58,7 +58,7 @@ struct SHandlerArgument : public CHandleObject SHandlerArgument() {} - SHandlerArgument(int inHandle, Qt3DSDMActionHandle inAction, const TCharStr &inName, + SHandlerArgument(int inHandle, Qt3DSDMActionHandle inAction, const QString &inName, HandlerArgumentType::Value inArgType, DataModelDataType::Value inValueType) : CHandleObject(inHandle) , m_HandlerArgInfo(inAction, inName, inArgType, inValueType) @@ -100,11 +100,11 @@ public: // Use // Action Properties void SetTriggerObject(Qt3DSDMActionHandle inAction, const SObjectRefType &inTriggerObject) override; void SetTargetObject(Qt3DSDMActionHandle inAction, const SObjectRefType &inTargetObject) override; - void SetEvent(Qt3DSDMActionHandle inAction, const wstring &inEvent) override; - void SetHandler(Qt3DSDMActionHandle inAction, const wstring &inHandler) override; + void SetEvent(Qt3DSDMActionHandle inAction, const QString &inEvent) override; + void SetHandler(Qt3DSDMActionHandle inAction, const QString &inHandler) override; // Action Argument - Qt3DSDMHandlerArgHandle AddHandlerArgument(Qt3DSDMActionHandle inAction, const TCharStr &inName, + Qt3DSDMHandlerArgHandle AddHandlerArgument(Qt3DSDMActionHandle inAction, const QString &inName, HandlerArgumentType::Value inArgType, DataModelDataType::Value inValueType) override; void RemoveHandlerArgument(Qt3DSDMHandlerArgHandle inHandlerArgument) override; @@ -125,7 +125,7 @@ public: // Use Qt3DSDMSlideHandle inSlide, Qt3DSDMInstanceHandle inOwner); Qt3DSDMHandlerArgHandle AddHandlerArgumentWithHandle(int inHandle, Qt3DSDMActionHandle inAction, - const TCharStr &inName, + const QString &inName, HandlerArgumentType::Value inArgType, DataModelDataType::Value inValueType); diff --git a/src/Authoring/QT3DSDM/Systems/Cores/SimpleDataCore.cpp b/src/Authoring/QT3DSDM/Systems/Cores/SimpleDataCore.cpp index d6a1470b..909a1aef 100644 --- a/src/Authoring/QT3DSDM/Systems/Cores/SimpleDataCore.cpp +++ b/src/Authoring/QT3DSDM/Systems/Cores/SimpleDataCore.cpp @@ -118,7 +118,7 @@ void CSimpleDataCore::GetInstanceParents(Qt3DSDMInstanceHandle inHandle, outParents.push_back(theParent->first); } -inline bool ComparePropertyNames(const TCharStr &inName, int inPropHandle, +inline bool ComparePropertyNames(const QString &inName, int inPropHandle, const THandleObjectMap &inObjects) { if (CSimpleDataCore::GetPropertyDefinitionNF(inPropHandle, inObjects)->m_Definition.m_Name @@ -127,19 +127,15 @@ inline bool ComparePropertyNames(const TCharStr &inName, int inPropHandle, return false; } -inline const wchar_t *SafeStrPtr(const wchar_t *inData) -{ - return inData == NULL ? L"" : inData; -} - // Properties -Qt3DSDMPropertyHandle CSimpleDataCore::AddProperty(Qt3DSDMInstanceHandle inInstance, TCharPtr inName, - DataModelDataType::Value inPropType) +Qt3DSDMPropertyHandle CSimpleDataCore::AddProperty(Qt3DSDMInstanceHandle inInstance, + const QString &inName, + DataModelDataType::Value inPropType) { QT3DSDM_LOG_FUNCTION("CSimpleDataCore::AddProperty"); - QT3DSDM_DEBUG_LOG(m_StringTable->GetNarrowStr(inName)); + QT3DSDM_DEBUG_LOG(inName); TDataModelInstancePtr theInstance = GetInstanceNF(inInstance, m_Objects); - TCharStr theName(inName); + QString theName(inName); if (find_if<TIntList::iterator>( theInstance->m_Properties, std::bind(ComparePropertyNames, std::ref(theName), @@ -205,7 +201,7 @@ inline void CopyInstanceProperty(Qt3DSDMPropertyHandle inSrcPropertyHandle, // create the property definition that matches the source const Qt3DSDMPropertyDefinition &theProperty = inDataCore.GetProperty(inSrcPropertyHandle); Qt3DSDMPropertyHandle theNewProperty = - inDataCore.AddProperty(inInstanceHandle, theProperty.m_Name.wide_str(), theProperty.m_Type); + inDataCore.AddProperty(inInstanceHandle, theProperty.m_Name, theProperty.m_Type); // copy the value if one exists on the src. SValue theValue; if (GetInstanceValue(inSrcInstanceHandle, inSrcPropertyHandle, inDataCore, theValue)) @@ -288,7 +284,7 @@ RecurseFindProperty(const TDataModelInstancePtr inInstance, TPredicate inPredica } inline bool PropertyNameMatches(int inProperty, const THandleObjectMap &inObjects, - const TCharStr &inStr) + const QString &inStr) { const CDataModelPropertyDefinitionObject *theProp = CSimpleDataCore::GetPropertyDefinitionNF(inProperty, inObjects); @@ -297,7 +293,7 @@ inline bool PropertyNameMatches(int inProperty, const THandleObjectMap &inObject Qt3DSDMPropertyHandle CSimpleDataCore::GetAggregateInstancePropertyByName(Qt3DSDMInstanceHandle inInstance, - const TCharStr &inStr) const + const QString &inStr) const { const TDataModelInstancePtr theInstance = GetInstanceNF(inInstance, m_Objects); return get<2>( @@ -466,11 +462,11 @@ Qt3DSDMInstanceHandle CSimpleDataCore::CreateInstanceWithHandle(int inHandle) Qt3DSDMPropertyHandle CSimpleDataCore::AddPropertyWithHandle(int inHandle, Qt3DSDMInstanceHandle inInstance, - TCharPtr inName, + const QString &inName, DataModelDataType::Value inPropType) { QT3DSDM_DEBUG_LOG("CSimpleDataCore::AddPropertyWithHandle Enter"); - QT3DSDM_DEBUG_LOG(m_StringTable->GetNarrowStr(inName)); + QT3DSDM_DEBUG_LOG(inName); if (HandleValid(inHandle)) { if (g_DataModelDebugLogger) { g_DataModelDebugLogger("CSimpleDataCore::AddPropertyWithHandle Handle Exists!!"); @@ -484,7 +480,7 @@ Qt3DSDMPropertyHandle CSimpleDataCore::AddPropertyWithHandle(int inHandle, TDataModelInstancePtr theInstance = GetInstanceNF(inInstance, m_Objects); - Qt3DSDMPropertyDefinition theDefinition(inInstance, SafeStrPtr(inName), inPropType); + Qt3DSDMPropertyDefinition theDefinition(inInstance, inName, inPropType); THandleObjectPtr theHandleObjectPtr( new CDataModelPropertyDefinitionObject(inHandle, theDefinition)); const pair<int, THandleObjectPtr> thePair(std::make_pair(inHandle, theHandleObjectPtr)); diff --git a/src/Authoring/QT3DSDM/Systems/Cores/SimpleDataCore.h b/src/Authoring/QT3DSDM/Systems/Cores/SimpleDataCore.h index 2664dab4..b4b0325a 100644 --- a/src/Authoring/QT3DSDM/Systems/Cores/SimpleDataCore.h +++ b/src/Authoring/QT3DSDM/Systems/Cores/SimpleDataCore.h @@ -211,19 +211,19 @@ public: // IInstancePropertyCore Qt3DSDMPropertyHandle GetAggregateInstancePropertyByName(Qt3DSDMInstanceHandle inInstance, - const TCharStr &inStr) const override; + const QString &inStr) const override; void GetAggregateInstanceProperties(Qt3DSDMInstanceHandle inInstance, - TPropertyHandleList &outProperties) const override; + TPropertyHandleList &outProperties) const override; void GetSpecificInstancePropertyValues(Qt3DSDMInstanceHandle inHandle, - TPropertyHandleValuePairList &outValues) override; + TPropertyHandleValuePairList &outValues) override; bool HasAggregateInstanceProperty(Qt3DSDMInstanceHandle inInstance, - Qt3DSDMPropertyHandle inProperty) const override; + Qt3DSDMPropertyHandle inProperty) const override; void CheckValue(Qt3DSDMInstanceHandle inInstance, Qt3DSDMPropertyHandle inProperty, - const SValue &inValue) const override; + const SValue &inValue) const override; bool GetInstancePropertyValue(Qt3DSDMInstanceHandle inHandle, - Qt3DSDMPropertyHandle inProperty, SValue &outValue) const override; + Qt3DSDMPropertyHandle inProperty, SValue &outValue) const override; void SetInstancePropertyValue(Qt3DSDMInstanceHandle inHandle, - Qt3DSDMPropertyHandle inProperty, const SValue &inValue) override; + Qt3DSDMPropertyHandle inProperty, const SValue &inValue) override; // IDataCore //=============================================================== @@ -231,24 +231,24 @@ public: void DeleteInstance(Qt3DSDMInstanceHandle inHandle) override; void GetInstances(TInstanceHandleList &outInstances) const override; void GetInstancesDerivedFrom(TInstanceHandleList &outInstances, - Qt3DSDMInstanceHandle inParentHandle) const override; + Qt3DSDMInstanceHandle inParentHandle) const override; void DeriveInstance(Qt3DSDMInstanceHandle inInstance, Qt3DSDMInstanceHandle inParent) override; void GetInstanceParents(Qt3DSDMInstanceHandle inHandle, - TInstanceHandleList &outParents) const override; + TInstanceHandleList &outParents) const override; // Returns true if inParent == inInstance || inInstance is derived from inParent somehow. // Recursive. bool IsInstanceOrDerivedFrom(Qt3DSDMInstanceHandle inInstance, - Qt3DSDMInstanceHandle inParent) const override; + Qt3DSDMInstanceHandle inParent) const override; - Qt3DSDMPropertyHandle AddProperty(Qt3DSDMInstanceHandle inClass, TCharPtr inName, - DataModelDataType::Value inPropType) override; + Qt3DSDMPropertyHandle AddProperty(Qt3DSDMInstanceHandle inClass, const QString &inName, + DataModelDataType::Value inPropType) override; const Qt3DSDMPropertyDefinition &GetProperty(Qt3DSDMPropertyHandle inProperty) const override; void GetInstanceProperties(Qt3DSDMInstanceHandle inInstance, - TPropertyHandleList &outProperties) const override; + TPropertyHandleList &outProperties) const override; void RemoveProperty(Qt3DSDMPropertyHandle inProperty) override; void CopyInstanceProperties(Qt3DSDMInstanceHandle inSrcInstance, - Qt3DSDMInstanceHandle inDestInstance) override; + Qt3DSDMInstanceHandle inDestInstance) override; void RemoveCachedValues(Qt3DSDMInstanceHandle inInstance) override; bool IsInstance(int inHandle) const override; @@ -359,7 +359,8 @@ protected: // This is used for special cases of serialization Qt3DSDMInstanceHandle CreateInstanceWithHandle(int inHandle); Qt3DSDMPropertyHandle AddPropertyWithHandle(int inHandle, Qt3DSDMInstanceHandle inClass, - TCharPtr inName, DataModelDataType::Value inPropType); + const QString &inName, + DataModelDataType::Value inPropType); void UncheckedSetSpecificInstancePropertyValue(Qt3DSDMInstanceHandle inInstance, Qt3DSDMPropertyHandle inProperty, diff --git a/src/Authoring/QT3DSDM/Systems/Qt3DSDMActionCore.h b/src/Authoring/QT3DSDM/Systems/Qt3DSDMActionCore.h index a9201462..e054745a 100644 --- a/src/Authoring/QT3DSDM/Systems/Qt3DSDMActionCore.h +++ b/src/Authoring/QT3DSDM/Systems/Qt3DSDMActionCore.h @@ -72,12 +72,12 @@ public: const SObjectRefType &inTriggerObject) = 0; virtual void SetTargetObject(Qt3DSDMActionHandle inAction, const SObjectRefType &inTargetObject) = 0; - virtual void SetEvent(Qt3DSDMActionHandle inAction, const wstring &inEventName) = 0; - virtual void SetHandler(Qt3DSDMActionHandle inAction, const wstring &inHandlerName) = 0; + virtual void SetEvent(Qt3DSDMActionHandle inAction, const QString &inEventName) = 0; + virtual void SetHandler(Qt3DSDMActionHandle inAction, const QString &inHandlerName) = 0; // Handler Argument virtual Qt3DSDMHandlerArgHandle AddHandlerArgument(Qt3DSDMActionHandle inAction, - const TCharStr &inName, + const QString &inName, HandlerArgumentType::Value inArgType, DataModelDataType::Value inValueType) = 0; virtual void RemoveHandlerArgument(Qt3DSDMHandlerArgHandle inHandlerArgument) = 0; diff --git a/src/Authoring/QT3DSDM/Systems/Qt3DSDMActionInfo.h b/src/Authoring/QT3DSDM/Systems/Qt3DSDMActionInfo.h index 0c77b9c4..ee4d1917 100644 --- a/src/Authoring/QT3DSDM/Systems/Qt3DSDMActionInfo.h +++ b/src/Authoring/QT3DSDM/Systems/Qt3DSDMActionInfo.h @@ -47,12 +47,12 @@ struct SActionInfo // Trigger object SObjectRefType m_TriggerObject; // trigger object - wstring m_Event; // the list of applicable events is based on object type and stored, by type, + QString m_Event; // the list of applicable events is based on object type and stored, by type, // in metadata // Target object SObjectRefType m_TargetObject; // target object - wstring m_Handler; // the list of applicable action handlers is loaded from metadata xml file + QString m_Handler; // the list of applicable action handlers is loaded from metadata xml file // and based on object type THandlerArgHandleList m_HandlerArgs; // the list of applicable action arguments is dependent on // the handler and loaded from the metadata xml file. @@ -71,7 +71,7 @@ struct SActionInfo struct SHandlerArgumentInfo { Qt3DSDMActionHandle m_Action; // Action that owns this Action Argument - TCharStr m_Name; // Name of the Action Argument + QString m_Name; // Name of the Action Argument HandlerArgumentType::Value m_ArgType; // m_ArgType will override m_ValueType DataModelDataType::Value m_ValueType; // m_ValueType is ignored if ArgType is specified SValue m_Value; // Value of the Action Argument @@ -82,7 +82,7 @@ struct SHandlerArgumentInfo { } - SHandlerArgumentInfo(Qt3DSDMActionHandle inAction, const TCharStr &inName, + SHandlerArgumentInfo(Qt3DSDMActionHandle inAction, const QString &inName, HandlerArgumentType::Value inArgType, DataModelDataType::Value inValueType) : m_Action(inAction) , m_Name(inName) diff --git a/src/Authoring/QT3DSDM/Systems/Qt3DSDMComposerTypeDefinitions.cpp b/src/Authoring/QT3DSDM/Systems/Qt3DSDMComposerTypeDefinitions.cpp index 98712791..7b47ec89 100644 --- a/src/Authoring/QT3DSDM/Systems/Qt3DSDMComposerTypeDefinitions.cpp +++ b/src/Authoring/QT3DSDM/Systems/Qt3DSDMComposerTypeDefinitions.cpp @@ -95,224 +95,224 @@ struct DataConstructor<SObjectRefType> }; } -#define QT3DS_WCHAR_T_Typed L"Typed" -#define QT3DS_WCHAR_T_Guided L"Guided" -#define QT3DS_WCHAR_T_Named L"Named" -#define QT3DS_WCHAR_T_SlideOwner L"SlideOwner" -#define QT3DS_WCHAR_T_Slide L"Slide" -#define QT3DS_WCHAR_T_Action L"Action" -#define QT3DS_WCHAR_T_Asset L"Asset" -#define QT3DS_WCHAR_T_Scene L"Scene" -#define QT3DS_WCHAR_T_Image L"Image" -#define QT3DS_WCHAR_T_Material L"Material" -#define QT3DS_WCHAR_T_Behavior L"Behavior" -#define QT3DS_WCHAR_T_Node L"Node" -#define QT3DS_WCHAR_T_Layer L"Layer" -#define QT3DS_WCHAR_T_Group L"Group" -#define QT3DS_WCHAR_T_Model L"Model" -#define QT3DS_WCHAR_T_Light L"Light" -#define QT3DS_WCHAR_T_Camera L"Camera" -#define QT3DS_WCHAR_T_Component L"Component" -#define QT3DS_WCHAR_T_Text L"Text" -#define QT3DS_WCHAR_T_Effect L"Effect" -#define QT3DS_WCHAR_T_RenderPlugin L"RenderPlugin" -#define QT3DS_WCHAR_T_MaterialBase L"MaterialBase" -#define QT3DS_WCHAR_T_CustomMaterial L"CustomMaterial" -#define QT3DS_WCHAR_T_ReferencedMaterial L"ReferencedMaterial" -#define QT3DS_WCHAR_T_Alias L"Alias" -#define QT3DS_WCHAR_T_Lightmaps L"Lightmaps" - -#define QT3DS_WCHAR_T_type L"type" -#define QT3DS_WCHAR_T_id L"id" -#define QT3DS_WCHAR_T_name L"name" -#define QT3DS_WCHAR_T_componentid L"componentid" -#define QT3DS_WCHAR_T_playmode L"playmode" -#define QT3DS_WCHAR_T_playthroughto L"playthroughto" -#define QT3DS_WCHAR_T_initialplaystate L"initialplaystate" -#define QT3DS_WCHAR_T_actioneyeball L"actioneyeball" -#define QT3DS_WCHAR_T_sourcepath L"sourcepath" -#define QT3DS_WCHAR_T_importid L"importid" -#define QT3DS_WCHAR_T_starttime L"starttime" -#define QT3DS_WCHAR_T_endtime L"endtime" -#define QT3DS_WCHAR_T_eyeball L"eyeball" -#define QT3DS_WCHAR_T_shy L"shy" -#define QT3DS_WCHAR_T_locked L"locked" -#define QT3DS_WCHAR_T_timebarcolor L"timebarcolor" -#define QT3DS_WCHAR_T_timebartext L"timebartext" -#define QT3DS_WCHAR_T_bgcolorenable L"bgcolorenable" -#define QT3DS_WCHAR_T_background L"background" -#define QT3DS_WCHAR_T_backgroundcolor L"backgroundcolor" -#define QT3DS_WCHAR_T_blendtype L"blendtype" -#define QT3DS_WCHAR_T_scaleu L"scaleu" -#define QT3DS_WCHAR_T_scalev L"scalev" -#define QT3DS_WCHAR_T_mappingmode L"mappingmode" -#define QT3DS_WCHAR_T_tilingmodehorz L"tilingmodehorz" -#define QT3DS_WCHAR_T_tilingmodevert L"tilingmodevert" -#define QT3DS_WCHAR_T_rotationuv L"rotationuv" -#define QT3DS_WCHAR_T_positionu L"positionu" -#define QT3DS_WCHAR_T_positionv L"positionv" -#define QT3DS_WCHAR_T_pivotu L"pivotu" -#define QT3DS_WCHAR_T_pivotv L"pivotv" -#define QT3DS_WCHAR_T_subpresentation L"subpresentation" -#define QT3DS_WCHAR_T_iblprobe L"iblprobe" -#define QT3DS_WCHAR_T_shaderlighting L"shaderlighting" -#define QT3DS_WCHAR_T_blendmode L"blendmode" -#define QT3DS_WCHAR_T_vertexcolors L"vertexcolors" -#define QT3DS_WCHAR_T_diffuse L"diffuse" -#define QT3DS_WCHAR_T_diffusemap L"diffusemap" -#define QT3DS_WCHAR_T_diffusemap2 L"diffusemap2" -#define QT3DS_WCHAR_T_diffusemap3 L"diffusemap3" -#define QT3DS_WCHAR_T_specularreflection L"specularreflection" -#define QT3DS_WCHAR_T_specularmap L"specularmap" -#define QT3DS_WCHAR_T_specularmodel L"specularmodel" -#define QT3DS_WCHAR_T_speculartint L"speculartint" -#define QT3DS_WCHAR_T_ior L"ior" -#define QT3DS_WCHAR_T_specularamount L"specularamount" -#define QT3DS_WCHAR_T_specularroughness L"specularroughness" -#define QT3DS_WCHAR_T_roughnessmap L"roughnessmap" -#define QT3DS_WCHAR_T_opacitymap L"opacitymap" -#define QT3DS_WCHAR_T_emissivepower L"emissivepower" -#define QT3DS_WCHAR_T_emissivecolor L"emissivecolor" -#define QT3DS_WCHAR_T_emissivemap L"emissivemap" -#define QT3DS_WCHAR_T_emissivemap2 L"emissivemap2" -#define QT3DS_WCHAR_T_normalmap L"normalmap" -#define QT3DS_WCHAR_T_normalstrength L"normalstrength" -#define QT3DS_WCHAR_T_position L"position" -#define QT3DS_WCHAR_T_rotation L"rotation" -#define QT3DS_WCHAR_T_scale L"scale" -#define QT3DS_WCHAR_T_pivot L"pivot" -#define QT3DS_WCHAR_T_opacity L"opacity" -#define QT3DS_WCHAR_T_rotationorder L"rotationorder" -#define QT3DS_WCHAR_T_orientation L"orientation" -#define QT3DS_WCHAR_T_progressiveaa L"progressiveaa" -#define QT3DS_WCHAR_T_multisampleaa L"multisampleaa" -#define QT3DS_WCHAR_T_disabledepthtest L"disabledepthtest" -#define QT3DS_WCHAR_T_disabledepthprepass L"disabledepthprepass" -#define QT3DS_WCHAR_T_layerwidth L"layerwidth" -#define QT3DS_WCHAR_T_layerheight L"layerheight" -#define QT3DS_WCHAR_T_lighttype L"lighttype" -#define QT3DS_WCHAR_T_lightdiffuse L"lightdiffuse" -#define QT3DS_WCHAR_T_lightspecular L"lightspecular" -#define QT3DS_WCHAR_T_lightambient L"lightambient" -#define QT3DS_WCHAR_T_brightness L"brightness" -#define QT3DS_WCHAR_T_linearfade L"linearfade" -#define QT3DS_WCHAR_T_expfade L"expfade" -#define QT3DS_WCHAR_T_areawidth L"areawidth" -#define QT3DS_WCHAR_T_areaheight L"areaheight" -#define QT3DS_WCHAR_T_castshadow L"castshadow" -#define QT3DS_WCHAR_T_shdwbias L"shdwbias" -#define QT3DS_WCHAR_T_shdwfactor L"shdwfactor" -#define QT3DS_WCHAR_T_shdwmapres L"shdwmapres" -#define QT3DS_WCHAR_T_shdwmapfar L"shdwmapfar" -#define QT3DS_WCHAR_T_shdwmapfov L"shdwmapfov" -#define QT3DS_WCHAR_T_shdwfilter L"shdwfilter" -#define QT3DS_WCHAR_T_orthographic L"orthographic" -#define QT3DS_WCHAR_T_fov L"fov" -#define QT3DS_WCHAR_T_fovhorizontal L"fovhorizontal" -#define QT3DS_WCHAR_T_clipnear L"clipnear" -#define QT3DS_WCHAR_T_clipfar L"clipfar" -#define QT3DS_WCHAR_T_lookatlock L"lookatlock" -#define QT3DS_WCHAR_T_lookatpoint L"lookatpoint" -#define QT3DS_WCHAR_T_textstring L"textstring" -#define QT3DS_WCHAR_T_textcolor L"textcolor" -#define QT3DS_WCHAR_T_font L"font" -#define QT3DS_WCHAR_T_size L"size" -#define QT3DS_WCHAR_T_horzalign L"horzalign" -#define QT3DS_WCHAR_T_vertalign L"vertalign" -#define QT3DS_WCHAR_T_leading L"leading" -#define QT3DS_WCHAR_T_tracking L"tracking" -#define QT3DS_WCHAR_T_enableacceleratedfont L"enableacceleratedfont" -#define QT3DS_WCHAR_T_importfile L"importfile" -#define QT3DS_WCHAR_T_fileid L"fileid" -#define QT3DS_WCHAR_T_size L"size" -#define QT3DS_WCHAR_T_location L"location" -#define QT3DS_WCHAR_T_boneid L"boneid" -#define QT3DS_WCHAR_T_poseroot L"poseroot" -#define QT3DS_WCHAR_T_ignoresparent L"ignoresparent" -#define QT3DS_WCHAR_T_tessellation L"tessellation" -#define QT3DS_WCHAR_T_edgetess L"edgetess" -#define QT3DS_WCHAR_T_innertess L"innertess" -#define QT3DS_WCHAR_T_scalemode L"scalemode" -#define QT3DS_WCHAR_T_scaleanchor L"scaleanchor" -#define QT3DS_WCHAR_T_horzfields L"horzfields" -#define QT3DS_WCHAR_T_left L"left" -#define QT3DS_WCHAR_T_leftunits L"leftunits" -#define QT3DS_WCHAR_T_width L"width" -#define QT3DS_WCHAR_T_widthunits L"widthunits" -#define QT3DS_WCHAR_T_right L"right" -#define QT3DS_WCHAR_T_rightunits L"rightunits" -#define QT3DS_WCHAR_T_vertfields L"vertfields" -#define QT3DS_WCHAR_T_top L"top" -#define QT3DS_WCHAR_T_topunits L"topunits" -#define QT3DS_WCHAR_T_height L"height" -#define QT3DS_WCHAR_T_heightunits L"heightunits" -#define QT3DS_WCHAR_T_bottom L"bottom" -#define QT3DS_WCHAR_T_bottomunits L"bottomunits" -#define QT3DS_WCHAR_T_aostrength L"aostrength" -#define QT3DS_WCHAR_T_aodistance L"aodistance" -#define QT3DS_WCHAR_T_aosoftness L"aosoftness" -#define QT3DS_WCHAR_T_aobias L"aobias" -#define QT3DS_WCHAR_T_aosamplerate L"aosamplerate" -#define QT3DS_WCHAR_T_aodither L"aodither" -#define QT3DS_WCHAR_T_shadowstrength L"shadowstrength" -#define QT3DS_WCHAR_T_shadowdist L"shadowdist" -#define QT3DS_WCHAR_T_shadowsoftness L"shadowsoftness" -#define QT3DS_WCHAR_T_shadowbias L"shadowbias" -#define QT3DS_WCHAR_T_source L"source" -#define QT3DS_WCHAR_T_referencedmaterial L"referencedmaterial" -#define QT3DS_WCHAR_T_lightprobe L"lightprobe" -#define QT3DS_WCHAR_T_probebright L"probebright" -#define QT3DS_WCHAR_T_fastibl L"fastibl" -#define QT3DS_WCHAR_T_probehorizon L"probehorizon" -#define QT3DS_WCHAR_T_probefov L"probefov" -#define QT3DS_WCHAR_T_lightprobe2 L"lightprobe2" -#define QT3DS_WCHAR_T_probe2fade L"probe2fade" -#define QT3DS_WCHAR_T_probe2window L"probe2window" -#define QT3DS_WCHAR_T_probe2pos L"probe2pos" -#define QT3DS_WCHAR_T_bumpmap L"bumpmap" -#define QT3DS_WCHAR_T_bumpamount L"bumpamount" -#define QT3DS_WCHAR_T_normalmap L"normalmap" -#define QT3DS_WCHAR_T_displacementmap L"displacementmap" -#define QT3DS_WCHAR_T_displaceamount L"displaceamount" -#define QT3DS_WCHAR_T_translucencymap L"translucencymap" -#define QT3DS_WCHAR_T_translucentfalloff L"translucentfalloff" -#define QT3DS_WCHAR_T_diffuselightwrap L"diffuselightwrap" -#define QT3DS_WCHAR_T_fresnelPower L"fresnelPower" -#define QT3DS_WCHAR_T_referencednode L"referencednode" -#define QT3DS_WCHAR_T_temporalaa L"temporalaa" -#define QT3DS_WCHAR_T_scope L"scope" -#define QT3DS_WCHAR_T_Path L"Path" -#define QT3DS_WCHAR_T_pathdata L"pathdata" -#define QT3DS_WCHAR_T_PathAnchorPoint L"PathAnchorPoint" -#define QT3DS_WCHAR_T_incomingangle L"incomingangle" -#define QT3DS_WCHAR_T_incomingdistance L"incomingdistance" -#define QT3DS_WCHAR_T_outgoingdistance L"outgoingdistance" -#define QT3DS_WCHAR_T_linearerror L"linearerror" -#define QT3DS_WCHAR_T_edgetessamount L"edgetessamount" -#define QT3DS_WCHAR_T_innertessamount L"innertessamount" -#define QT3DS_WCHAR_T_begincap L"begincap" -#define QT3DS_WCHAR_T_begincapoffset L"begincapoffset" -#define QT3DS_WCHAR_T_begincapopacity L"begincapopacity" -#define QT3DS_WCHAR_T_begincapwidth L"begincapwidth" -#define QT3DS_WCHAR_T_endcap L"endcap" -#define QT3DS_WCHAR_T_endcapoffset L"endcapoffset" -#define QT3DS_WCHAR_T_endcapopacity L"endcapopacity" -#define QT3DS_WCHAR_T_endcapwidth L"endcapwidth" -#define QT3DS_WCHAR_T_pathtype L"pathtype" -#define QT3DS_WCHAR_T_closed L"closed" -#define QT3DS_WCHAR_T_paintstyle L"paintstyle" -#define QT3DS_WCHAR_T_SubPath L"SubPath" -#define QT3DS_WCHAR_T_lightmapindirect L"lightmapindirect" -#define QT3DS_WCHAR_T_lightmapradiosity L"lightmapradiosity" -#define QT3DS_WCHAR_T_lightmapshadow L"lightmapshadow" -#define QT3DS_WCHAR_T_controlledproperty L"controlledproperty" - -const wchar_t *ComposerObjectTypes::Convert(ComposerObjectTypes::Enum inType) +#define QT3DS_PROPNAME_Typed "Typed" +#define QT3DS_PROPNAME_Guided "Guided" +#define QT3DS_PROPNAME_Named "Named" +#define QT3DS_PROPNAME_SlideOwner "SlideOwner" +#define QT3DS_PROPNAME_Slide "Slide" +#define QT3DS_PROPNAME_Action "Action" +#define QT3DS_PROPNAME_Asset "Asset" +#define QT3DS_PROPNAME_Scene "Scene" +#define QT3DS_PROPNAME_Image "Image" +#define QT3DS_PROPNAME_Material "Material" +#define QT3DS_PROPNAME_Behavior "Behavior" +#define QT3DS_PROPNAME_Node "Node" +#define QT3DS_PROPNAME_Layer "Layer" +#define QT3DS_PROPNAME_Group "Group" +#define QT3DS_PROPNAME_Model "Model" +#define QT3DS_PROPNAME_Light "Light" +#define QT3DS_PROPNAME_Camera "Camera" +#define QT3DS_PROPNAME_Component "Component" +#define QT3DS_PROPNAME_Text "Text" +#define QT3DS_PROPNAME_Effect "Effect" +#define QT3DS_PROPNAME_RenderPlugin "RenderPlugin" +#define QT3DS_PROPNAME_MaterialBase "MaterialBase" +#define QT3DS_PROPNAME_CustomMaterial "CustomMaterial" +#define QT3DS_PROPNAME_ReferencedMaterial "ReferencedMaterial" +#define QT3DS_PROPNAME_Alias "Alias" +#define QT3DS_PROPNAME_Lightmaps "Lightmaps" + +#define QT3DS_PROPNAME_type "type" +#define QT3DS_PROPNAME_id "id" +#define QT3DS_PROPNAME_name "name" +#define QT3DS_PROPNAME_componentid "componentid" +#define QT3DS_PROPNAME_playmode "playmode" +#define QT3DS_PROPNAME_playthroughto "playthroughto" +#define QT3DS_PROPNAME_initialplaystate "initialplaystate" +#define QT3DS_PROPNAME_actioneyeball "actioneyeball" +#define QT3DS_PROPNAME_sourcepath "sourcepath" +#define QT3DS_PROPNAME_importid "importid" +#define QT3DS_PROPNAME_starttime "starttime" +#define QT3DS_PROPNAME_endtime "endtime" +#define QT3DS_PROPNAME_eyeball "eyeball" +#define QT3DS_PROPNAME_shy "shy" +#define QT3DS_PROPNAME_locked "locked" +#define QT3DS_PROPNAME_timebarcolor "timebarcolor" +#define QT3DS_PROPNAME_timebartext "timebartext" +#define QT3DS_PROPNAME_bgcolorenable "bgcolorenable" +#define QT3DS_PROPNAME_background "background" +#define QT3DS_PROPNAME_backgroundcolor "backgroundcolor" +#define QT3DS_PROPNAME_blendtype "blendtype" +#define QT3DS_PROPNAME_scaleu "scaleu" +#define QT3DS_PROPNAME_scalev "scalev" +#define QT3DS_PROPNAME_mappingmode "mappingmode" +#define QT3DS_PROPNAME_tilingmodehorz "tilingmodehorz" +#define QT3DS_PROPNAME_tilingmodevert "tilingmodevert" +#define QT3DS_PROPNAME_rotationuv "rotationuv" +#define QT3DS_PROPNAME_positionu "positionu" +#define QT3DS_PROPNAME_positionv "positionv" +#define QT3DS_PROPNAME_pivotu "pivotu" +#define QT3DS_PROPNAME_pivotv "pivotv" +#define QT3DS_PROPNAME_subpresentation "subpresentation" +#define QT3DS_PROPNAME_iblprobe "iblprobe" +#define QT3DS_PROPNAME_shaderlighting "shaderlighting" +#define QT3DS_PROPNAME_blendmode "blendmode" +#define QT3DS_PROPNAME_vertexcolors "vertexcolors" +#define QT3DS_PROPNAME_diffuse "diffuse" +#define QT3DS_PROPNAME_diffusemap "diffusemap" +#define QT3DS_PROPNAME_diffusemap2 "diffusemap2" +#define QT3DS_PROPNAME_diffusemap3 "diffusemap3" +#define QT3DS_PROPNAME_specularreflection "specularreflection" +#define QT3DS_PROPNAME_specularmap "specularmap" +#define QT3DS_PROPNAME_specularmodel "specularmodel" +#define QT3DS_PROPNAME_speculartint "speculartint" +#define QT3DS_PROPNAME_ior "ior" +#define QT3DS_PROPNAME_specularamount "specularamount" +#define QT3DS_PROPNAME_specularroughness "specularroughness" +#define QT3DS_PROPNAME_roughnessmap "roughnessmap" +#define QT3DS_PROPNAME_opacitymap "opacitymap" +#define QT3DS_PROPNAME_emissivepower "emissivepower" +#define QT3DS_PROPNAME_emissivecolor "emissivecolor" +#define QT3DS_PROPNAME_emissivemap "emissivemap" +#define QT3DS_PROPNAME_emissivemap2 "emissivemap2" +#define QT3DS_PROPNAME_normalmap "normalmap" +#define QT3DS_PROPNAME_normalstrength "normalstrength" +#define QT3DS_PROPNAME_position "position" +#define QT3DS_PROPNAME_rotation "rotation" +#define QT3DS_PROPNAME_scale "scale" +#define QT3DS_PROPNAME_pivot "pivot" +#define QT3DS_PROPNAME_opacity "opacity" +#define QT3DS_PROPNAME_rotationorder "rotationorder" +#define QT3DS_PROPNAME_orientation "orientation" +#define QT3DS_PROPNAME_progressiveaa "progressiveaa" +#define QT3DS_PROPNAME_multisampleaa "multisampleaa" +#define QT3DS_PROPNAME_disabledepthtest "disabledepthtest" +#define QT3DS_PROPNAME_disabledepthprepass "disabledepthprepass" +#define QT3DS_PROPNAME_layerwidth "layerwidth" +#define QT3DS_PROPNAME_layerheight "layerheight" +#define QT3DS_PROPNAME_lighttype "lighttype" +#define QT3DS_PROPNAME_lightdiffuse "lightdiffuse" +#define QT3DS_PROPNAME_lightspecular "lightspecular" +#define QT3DS_PROPNAME_lightambient "lightambient" +#define QT3DS_PROPNAME_brightness "brightness" +#define QT3DS_PROPNAME_linearfade "linearfade" +#define QT3DS_PROPNAME_expfade "expfade" +#define QT3DS_PROPNAME_areawidth "areawidth" +#define QT3DS_PROPNAME_areaheight "areaheight" +#define QT3DS_PROPNAME_castshadow "castshadow" +#define QT3DS_PROPNAME_shdwbias "shdwbias" +#define QT3DS_PROPNAME_shdwfactor "shdwfactor" +#define QT3DS_PROPNAME_shdwmapres "shdwmapres" +#define QT3DS_PROPNAME_shdwmapfar "shdwmapfar" +#define QT3DS_PROPNAME_shdwmapfov "shdwmapfov" +#define QT3DS_PROPNAME_shdwfilter "shdwfilter" +#define QT3DS_PROPNAME_orthographic "orthographic" +#define QT3DS_PROPNAME_fov "fov" +#define QT3DS_PROPNAME_fovhorizontal "fovhorizontal" +#define QT3DS_PROPNAME_clipnear "clipnear" +#define QT3DS_PROPNAME_clipfar "clipfar" +#define QT3DS_PROPNAME_lookatlock "lookatlock" +#define QT3DS_PROPNAME_lookatpoint "lookatpoint" +#define QT3DS_PROPNAME_textstring "textstring" +#define QT3DS_PROPNAME_textcolor "textcolor" +#define QT3DS_PROPNAME_font "font" +#define QT3DS_PROPNAME_size "size" +#define QT3DS_PROPNAME_horzalign "horzalign" +#define QT3DS_PROPNAME_vertalign "vertalign" +#define QT3DS_PROPNAME_leading "leading" +#define QT3DS_PROPNAME_tracking "tracking" +#define QT3DS_PROPNAME_enableacceleratedfont "enableacceleratedfont" +#define QT3DS_PROPNAME_importfile "importfile" +#define QT3DS_PROPNAME_fileid "fileid" +#define QT3DS_PROPNAME_size "size" +#define QT3DS_PROPNAME_location "location" +#define QT3DS_PROPNAME_boneid "boneid" +#define QT3DS_PROPNAME_poseroot "poseroot" +#define QT3DS_PROPNAME_ignoresparent "ignoresparent" +#define QT3DS_PROPNAME_tessellation "tessellation" +#define QT3DS_PROPNAME_edgetess "edgetess" +#define QT3DS_PROPNAME_innertess "innertess" +#define QT3DS_PROPNAME_scalemode "scalemode" +#define QT3DS_PROPNAME_scaleanchor "scaleanchor" +#define QT3DS_PROPNAME_horzfields "horzfields" +#define QT3DS_PROPNAME_left "left" +#define QT3DS_PROPNAME_leftunits "leftunits" +#define QT3DS_PROPNAME_width "width" +#define QT3DS_PROPNAME_widthunits "widthunits" +#define QT3DS_PROPNAME_right "right" +#define QT3DS_PROPNAME_rightunits "rightunits" +#define QT3DS_PROPNAME_vertfields "vertfields" +#define QT3DS_PROPNAME_top "top" +#define QT3DS_PROPNAME_topunits "topunits" +#define QT3DS_PROPNAME_height "height" +#define QT3DS_PROPNAME_heightunits "heightunits" +#define QT3DS_PROPNAME_bottom "bottom" +#define QT3DS_PROPNAME_bottomunits "bottomunits" +#define QT3DS_PROPNAME_aostrength "aostrength" +#define QT3DS_PROPNAME_aodistance "aodistance" +#define QT3DS_PROPNAME_aosoftness "aosoftness" +#define QT3DS_PROPNAME_aobias "aobias" +#define QT3DS_PROPNAME_aosamplerate "aosamplerate" +#define QT3DS_PROPNAME_aodither "aodither" +#define QT3DS_PROPNAME_shadowstrength "shadowstrength" +#define QT3DS_PROPNAME_shadowdist "shadowdist" +#define QT3DS_PROPNAME_shadowsoftness "shadowsoftness" +#define QT3DS_PROPNAME_shadowbias "shadowbias" +#define QT3DS_PROPNAME_source "source" +#define QT3DS_PROPNAME_referencedmaterial "referencedmaterial" +#define QT3DS_PROPNAME_lightprobe "lightprobe" +#define QT3DS_PROPNAME_probebright "probebright" +#define QT3DS_PROPNAME_fastibl "fastibl" +#define QT3DS_PROPNAME_probehorizon "probehorizon" +#define QT3DS_PROPNAME_probefov "probefov" +#define QT3DS_PROPNAME_lightprobe2 "lightprobe2" +#define QT3DS_PROPNAME_probe2fade "probe2fade" +#define QT3DS_PROPNAME_probe2window "probe2window" +#define QT3DS_PROPNAME_probe2pos "probe2pos" +#define QT3DS_PROPNAME_bumpmap "bumpmap" +#define QT3DS_PROPNAME_bumpamount "bumpamount" +#define QT3DS_PROPNAME_normalmap "normalmap" +#define QT3DS_PROPNAME_displacementmap "displacementmap" +#define QT3DS_PROPNAME_displaceamount "displaceamount" +#define QT3DS_PROPNAME_translucencymap "translucencymap" +#define QT3DS_PROPNAME_translucentfalloff "translucentfalloff" +#define QT3DS_PROPNAME_diffuselightwrap "diffuselightwrap" +#define QT3DS_PROPNAME_fresnelPower "fresnelPower" +#define QT3DS_PROPNAME_referencednode "referencednode" +#define QT3DS_PROPNAME_temporalaa "temporalaa" +#define QT3DS_PROPNAME_scope "scope" +#define QT3DS_PROPNAME_Path "Path" +#define QT3DS_PROPNAME_pathdata "pathdata" +#define QT3DS_PROPNAME_PathAnchorPoint "PathAnchorPoint" +#define QT3DS_PROPNAME_incomingangle "incomingangle" +#define QT3DS_PROPNAME_incomingdistance "incomingdistance" +#define QT3DS_PROPNAME_outgoingdistance "outgoingdistance" +#define QT3DS_PROPNAME_linearerror "linearerror" +#define QT3DS_PROPNAME_edgetessamount "edgetessamount" +#define QT3DS_PROPNAME_innertessamount "innertessamount" +#define QT3DS_PROPNAME_begincap "begincap" +#define QT3DS_PROPNAME_begincapoffset "begincapoffset" +#define QT3DS_PROPNAME_begincapopacity "begincapopacity" +#define QT3DS_PROPNAME_begincapwidth "begincapwidth" +#define QT3DS_PROPNAME_endcap "endcap" +#define QT3DS_PROPNAME_endcapoffset "endcapoffset" +#define QT3DS_PROPNAME_endcapopacity "endcapopacity" +#define QT3DS_PROPNAME_endcapwidth "endcapwidth" +#define QT3DS_PROPNAME_pathtype "pathtype" +#define QT3DS_PROPNAME_closed "closed" +#define QT3DS_PROPNAME_paintstyle "paintstyle" +#define QT3DS_PROPNAME_SubPath "SubPath" +#define QT3DS_PROPNAME_lightmapindirect "lightmapindirect" +#define QT3DS_PROPNAME_lightmapradiosity "lightmapradiosity" +#define QT3DS_PROPNAME_lightmapshadow "lightmapshadow" +#define QT3DS_PROPNAME_controlledproperty "controlledproperty" + +QString ComposerObjectTypes::Convert(ComposerObjectTypes::Enum inType) { switch (inType) { #define HANDLE_COMPOSER_OBJECT_TYPE(name, propmacro) \ case name: \ - return QT3DS_WCHAR_T_##name; + return QStringLiteral(QT3DS_PROPNAME_##name); ITERATE_COMPOSER_OBJECT_TYPES #undef HANDLE_COMPOSER_OBJECT_TYPE default: @@ -320,14 +320,14 @@ const wchar_t *ComposerObjectTypes::Convert(ComposerObjectTypes::Enum inType) } QT3DS_ASSERT(false); - return L"Unknown"; + return QStringLiteral("Unknown"); } -ComposerObjectTypes::Enum ComposerObjectTypes::Convert(const wchar_t *inType) +ComposerObjectTypes::Enum ComposerObjectTypes::Convert(const QString &inType) { #define HANDLE_COMPOSER_OBJECT_TYPE(name, propmacro) \ - if (AreEqual(QT3DS_WCHAR_T_##name, inType)) \ + if (inType == QLatin1String(QT3DS_PROPNAME_##name)) \ return ComposerObjectTypes::name; ITERATE_COMPOSER_OBJECT_TYPES #undef HANDLE_COMPOSER_OBJECT_TYPE @@ -336,66 +336,13 @@ ComposerObjectTypes::Enum ComposerObjectTypes::Convert(const wchar_t *inType) return ComposerObjectTypes::Unknown; } -ComposerObjectTypes::Enum ComposerObjectTypes::Convert(const char8_t *inType) -{ - -#define HANDLE_COMPOSER_OBJECT_TYPE(name, propmacro) \ - if (AreEqual(#name, inType)) \ - return ComposerObjectTypes::name; - ITERATE_COMPOSER_OBJECT_TYPES -#undef HANDLE_COMPOSER_OBJECT_TYPE - - QT3DS_ASSERT(false); - return ComposerObjectTypes::Unknown; -} - -const wchar_t *ComposerPropertyNames::Convert(ComposerPropertyNames::Enum inType) -{ - switch (inType) { -#define HANDLE_COMPOSER_PROPERTY_DUPLICATE(name, memberName, type, defaultValue) -#define HANDLE_COMPOSER_PROPERTY_NO_DEFAULT(name, memberName, type) \ - case name: \ - return QT3DS_WCHAR_T_##name; -#define HANDLE_COMPOSER_PROPERTY(name, memberName, type, defaultValue) \ - HANDLE_COMPOSER_PROPERTY_NO_DEFAULT(name, memberName, type) -#define HANDLE_COMPOSER_OBJECT_TYPE(name, propmacro) propmacro - ITERATE_COMPOSER_OBJECT_TYPES -#undef HANDLE_COMPOSER_OBJECT_TYPE -#undef HANDLE_COMPOSER_PROPERTY -#undef HANDLE_COMPOSER_PROPERTY_NO_DEFAULT -#undef HANDLE_COMPOSER_PROPERTY_DUPLICATE - default: - break; - } - QT3DS_ASSERT(false); - return L"Unknown"; -} - -ComposerPropertyNames::Enum ComposerPropertyNames::Convert(const wchar_t *inType) -{ -#define HANDLE_COMPOSER_PROPERTY_DUPLICATE(name, memberName, type, defaultValue) -#define HANDLE_COMPOSER_PROPERTY_NO_DEFAULT(name, memberName, type) \ - if (AreEqual(inType, QT3DS_WCHAR_T_##name)) \ - return name; -#define HANDLE_COMPOSER_PROPERTY(name, memberName, type, defaultValue) \ - HANDLE_COMPOSER_PROPERTY_NO_DEFAULT(name, memberName, type) -#define HANDLE_COMPOSER_OBJECT_TYPE(name, propmacro) propmacro - ITERATE_COMPOSER_OBJECT_TYPES -#undef HANDLE_COMPOSER_OBJECT_TYPE -#undef HANDLE_COMPOSER_PROPERTY -#undef HANDLE_COMPOSER_PROPERTY_NO_DEFAULT -#undef HANDLE_COMPOSER_PROPERTY_DUPLICATE - QT3DS_ASSERT(false); - return ComposerPropertyNames::Unknown; -} - -const char8_t *ComposerPropertyNames::ConvertNarrow(ComposerPropertyNames::Enum inType) +QString ComposerPropertyNames::Convert(ComposerPropertyNames::Enum inType) { switch (inType) { #define HANDLE_COMPOSER_PROPERTY_DUPLICATE(name, memberName, type, defaultValue) #define HANDLE_COMPOSER_PROPERTY_NO_DEFAULT(name, memberName, type) \ case name: \ - return #name; + return QStringLiteral(QT3DS_PROPNAME_##name); #define HANDLE_COMPOSER_PROPERTY(name, memberName, type, defaultValue) \ HANDLE_COMPOSER_PROPERTY_NO_DEFAULT(name, memberName, type) #define HANDLE_COMPOSER_OBJECT_TYPE(name, propmacro) propmacro @@ -408,14 +355,14 @@ const char8_t *ComposerPropertyNames::ConvertNarrow(ComposerPropertyNames::Enum break; } QT3DS_ASSERT(false); - return "Unknown"; + return QStringLiteral("Unknown"); } -ComposerPropertyNames::Enum ComposerPropertyNames::Convert(const char8_t *inType) +ComposerPropertyNames::Enum ComposerPropertyNames::Convert(const QString &inType) { #define HANDLE_COMPOSER_PROPERTY_DUPLICATE(name, memberName, type, defaultValue) #define HANDLE_COMPOSER_PROPERTY_NO_DEFAULT(name, memberName, type) \ - if (AreEqual(inType, #name)) \ + if (inType == QLatin1String(QT3DS_PROPNAME_##name)) \ return name; #define HANDLE_COMPOSER_PROPERTY(name, memberName, type, defaultValue) \ HANDLE_COMPOSER_PROPERTY_NO_DEFAULT(name, memberName, type) @@ -462,7 +409,7 @@ void ComposerTypeDefinitionsHelper::SetInstanceAsCanonical(IMetaData &inMetaData void ComposerTypeDefinitionsHelper::SetInstancePropertyValue(IDataCore &inDataCore, Qt3DSDMInstanceHandle inInstance, Qt3DSDMPropertyHandle inProperty, - const wchar_t *inPropValue) + const QString &inPropValue) { inDataCore.SetInstancePropertyValue(inInstance, inProperty, make_shared<CDataStr>(inPropValue)); } diff --git a/src/Authoring/QT3DSDM/Systems/Qt3DSDMComposerTypeDefinitions.h b/src/Authoring/QT3DSDM/Systems/Qt3DSDMComposerTypeDefinitions.h index d72eea1e..dafb337f 100644 --- a/src/Authoring/QT3DSDM/Systems/Qt3DSDMComposerTypeDefinitions.h +++ b/src/Authoring/QT3DSDM/Systems/Qt3DSDMComposerTypeDefinitions.h @@ -320,9 +320,8 @@ struct ComposerObjectTypes ITERATE_COMPOSER_OBJECT_TYPES #undef HANDLE_COMPOSER_OBJECT_TYPE }; - static const wchar_t *Convert(ComposerObjectTypes::Enum inType); - static ComposerObjectTypes::Enum Convert(const wchar_t *inType); - static ComposerObjectTypes::Enum Convert(const char8_t *inType); + static QString Convert(ComposerObjectTypes::Enum inType); + static ComposerObjectTypes::Enum Convert(const QString &inType); }; struct ComposerPropertyNames @@ -340,10 +339,8 @@ struct ComposerPropertyNames #undef HANDLE_COMPOSER_PROPERTY_DUPLICATE }; - static const wchar_t *Convert(ComposerPropertyNames::Enum inType); - static ComposerPropertyNames::Enum Convert(const wchar_t *inType); - static const char8_t *ConvertNarrow(ComposerPropertyNames::Enum inType); - static ComposerPropertyNames::Enum Convert(const char8_t *inType); + static QString Convert(ComposerPropertyNames::Enum inType); + static ComposerPropertyNames::Enum Convert(const QString &inType); }; template <typename TDataType> @@ -452,7 +449,7 @@ struct ComposerTypeDefinitionsHelper ComposerObjectTypes::Enum inObjectType); static void SetInstancePropertyValue(IDataCore &inDataCore, Qt3DSDMInstanceHandle inInstance, Qt3DSDMPropertyHandle inProperty, - const wchar_t *inPropValue); + const QString &inPropValue); static void DeriveInstance(IDataCore &inDataCore, Qt3DSDMInstanceHandle inInstance, Qt3DSDMInstanceHandle inParent); }; diff --git a/src/Authoring/QT3DSDM/Systems/Qt3DSDMDataCore.h b/src/Authoring/QT3DSDM/Systems/Qt3DSDMDataCore.h index 37aebd88..d9e9fca4 100644 --- a/src/Authoring/QT3DSDM/Systems/Qt3DSDMDataCore.h +++ b/src/Authoring/QT3DSDM/Systems/Qt3DSDMDataCore.h @@ -50,7 +50,7 @@ public: */ virtual Qt3DSDMPropertyHandle GetAggregateInstancePropertyByName(Qt3DSDMInstanceHandle inInstance, - const TCharStr &inStr) const = 0; + const QString &inStr) const = 0; /** * Get the entire list of instance properties; */ @@ -177,8 +177,9 @@ public: * error - ValueTypeError if the default value exists and is if a different type than *inPropType */ - virtual Qt3DSDMPropertyHandle AddProperty(Qt3DSDMInstanceHandle inInstance, TCharPtr inName, - DataModelDataType::Value inPropType) = 0; + virtual Qt3DSDMPropertyHandle AddProperty(Qt3DSDMInstanceHandle inInstance, + const QString &inName, + DataModelDataType::Value inPropType) = 0; /** * Return the property definition that corresponds to a given property value. */ @@ -239,12 +240,13 @@ public: virtual void GetInstances(TInstanceHandleList &outInstances) const = 0; - virtual Qt3DSDMPropertyHandle AddProperty(Qt3DSDMInstanceHandle inInstance, TCharPtr inName, - DataModelDataType::Value inPropType) = 0; + virtual Qt3DSDMPropertyHandle AddProperty(Qt3DSDMInstanceHandle inInstance, + const QString &inName, + DataModelDataType::Value inPropType) = 0; virtual Qt3DSDMPropertyHandle GetAggregateInstancePropertyByName(Qt3DSDMInstanceHandle inInstance, - const TCharStr &inStr) const = 0; + const QString &inStr) const = 0; virtual void GetAggregateInstanceProperties(Qt3DSDMInstanceHandle inInstance, TPropertyHandleList &outProperties) const = 0; virtual bool HasAggregateInstanceProperty(Qt3DSDMInstanceHandle inInstance, @@ -261,9 +263,9 @@ public: Qt3DSDMInstanceHandle inParent) const = 0; virtual DataModelDataType::Value GetDataType(Qt3DSDMPropertyHandle inProperty) const = 0; - virtual TCharStr GetName(Qt3DSDMPropertyHandle inProperty) const = 0; - virtual TCharStr GetFormalName(Qt3DSDMInstanceHandle inInstance, - Qt3DSDMPropertyHandle inProperty) const = 0; + virtual QString GetName(Qt3DSDMPropertyHandle inProperty) const = 0; + virtual QString GetFormalName(Qt3DSDMInstanceHandle inInstance, + Qt3DSDMPropertyHandle inProperty) const = 0; virtual AdditionalMetaDataType::Value GetAdditionalMetaDataType(Qt3DSDMInstanceHandle inInstance, Qt3DSDMPropertyHandle inProperty) const = 0; @@ -294,7 +296,7 @@ inline TDataType GetSpecificInstancePropertyValue(TCoreType inDataCore, template <typename TDataType, typename TCoreType> inline TDataType GetNamedInstancePropertyValue(TCoreType inDataCore, Qt3DSDMInstanceHandle inInstance, - const TCharStr &inName) + const QString &inName) { Qt3DSDMPropertyHandle theProperty = inDataCore->GetAggregateInstancePropertyByName(inInstance, inName); @@ -303,9 +305,10 @@ inline TDataType GetNamedInstancePropertyValue(TCoreType inDataCore, } inline Qt3DSDMPropertyHandle AddPropertyWithValue(IPropertySystem &inPropertySystem, - Qt3DSDMInstanceHandle inInstance, TCharPtr inName, - DataModelDataType::Value inDataType, - const SValue &inValue) + Qt3DSDMInstanceHandle inInstance, + const QString &inName, + DataModelDataType::Value inDataType, + const SValue &inValue) { Qt3DSDMPropertyHandle theProperty(inPropertySystem.AddProperty(inInstance, inName, inDataType)); inPropertySystem.SetInstancePropertyValue(inInstance, theProperty, inValue); diff --git a/src/Authoring/QT3DSDM/Systems/Qt3DSDMDataTypes.h b/src/Authoring/QT3DSDM/Systems/Qt3DSDMDataTypes.h index 924b4ea5..01deccc9 100644 --- a/src/Authoring/QT3DSDM/Systems/Qt3DSDMDataTypes.h +++ b/src/Authoring/QT3DSDM/Systems/Qt3DSDMDataTypes.h @@ -350,6 +350,11 @@ struct SLong4 retval = retval || m_Longs[0] > 0; return retval; } + QString toQString() const + { + return QStringLiteral("%1 %2 %3 %4").arg(m_Longs[0]).arg(m_Longs[1]) + .arg(m_Longs[2]).arg(m_Longs[3]); + } }; typedef std::vector<SLong4> TLong4Vec; @@ -424,6 +429,10 @@ inline bool IsTrivial(const char8_t *inStr) { return inStr == NULL || *inStr == 0; } +inline bool IsTrivial(const QString &inStr) +{ + return inStr.isEmpty(); +} inline const char8_t *NonNull(const char8_t *inStr) { return inStr ? inStr : ""; @@ -820,7 +829,7 @@ inline bool SetDefault(DataModelDataType::Value inDataType, TDataType &outValue) return SDefaulter<TDataType>().SetDefault(inDataType, outValue); } -typedef void (*Qt3DSDMDebugLogFunction)(const char *message); +typedef void (*Qt3DSDMDebugLogFunction)(const QString &message); // UICDMSimpleDataCore.cpp extern Qt3DSDMDebugLogFunction g_DataModelDebugLogger; diff --git a/src/Authoring/QT3DSDM/Systems/Qt3DSDMMetaData.cpp b/src/Authoring/QT3DSDM/Systems/Qt3DSDMMetaData.cpp index 7b8c207e..3c41e71a 100644 --- a/src/Authoring/QT3DSDM/Systems/Qt3DSDMMetaData.cpp +++ b/src/Authoring/QT3DSDM/Systems/Qt3DSDMMetaData.cpp @@ -37,6 +37,7 @@ #include <unordered_map> #include <memory> #include <unordered_set> +#include <QtCore/qhash.h> #include "Qt3DSDMTransactions.h" #include "VectorTransactions.h" #include "Qt3DSDMSignals.h" @@ -72,31 +73,34 @@ typedef Qt3DSDMMetaDataPropertyHandle TMetaDataPropertyHandle; typedef Qt3DSDMCategoryHandle TCategoryHandle; namespace qt3dsdm { -#define QT3DS_WCHAR_T_None L"None" -#define QT3DS_WCHAR_T_StringList L"StringList" -#define QT3DS_WCHAR_T_Range L"Range" -#define QT3DS_WCHAR_T_Image L"Image" -#define QT3DS_WCHAR_T_Color L"Color" -#define QT3DS_WCHAR_T_Rotation L"Rotation" -#define QT3DS_WCHAR_T_Font L"Font" -#define QT3DS_WCHAR_T_FontSize L"FontSize" -#define QT3DS_WCHAR_T_MultiLine L"MultiLine" -#define QT3DS_WCHAR_T_ObjectRef L"ObjectRef" -#define QT3DS_WCHAR_T_Mesh L"Mesh" -#define QT3DS_WCHAR_T_Import L"Import" -#define QT3DS_WCHAR_T_Texture L"Texture" -#define QT3DS_WCHAR_T_Image2D L"Image2D" -#define QT3DS_WCHAR_T_Buffer L"Buffer" -#define QT3DS_WCHAR_T_Property L"Property" -#define QT3DS_WCHAR_T_Dependent L"Dependent" -#define QT3DS_WCHAR_T_Slide L"Slide" -#define QT3DS_WCHAR_T_Event L"Event" -#define QT3DS_WCHAR_T_Object L"Object" -#define QT3DS_WCHAR_T_Signal L"Signal" -#define QT3DS_WCHAR_T_Renderable L"Renderable" -#define QT3DS_WCHAR_T_PathBuffer L"PathBuffer" -#define QT3DS_WCHAR_T_ShadowMapResolution L"ShadowMapResolution" -#define QT3DS_WCHAR_T_String L"String" +#define QT3DS_PROPNAME_None "None" +#define QT3DS_PROPNAME_StringList "StringList" +#define QT3DS_PROPNAME_Range "Range" +#define QT3DS_PROPNAME_Image "Image" +#define QT3DS_PROPNAME_Color "Color" +#define QT3DS_PROPNAME_Rotation "Rotation" +#define QT3DS_PROPNAME_Font "Font" +#define QT3DS_PROPNAME_FontSize "FontSize" +#define QT3DS_PROPNAME_MultiLine "MultiLine" +#define QT3DS_PROPNAME_ObjectRef "ObjectRef" +#define QT3DS_PROPNAME_Mesh "Mesh" +#define QT3DS_PROPNAME_Import "Import" +#define QT3DS_PROPNAME_Texture "Texture" +#define QT3DS_PROPNAME_Image2D "Image2D" +#define QT3DS_PROPNAME_Buffer "Buffer" +#define QT3DS_PROPNAME_Property "Property" +#define QT3DS_PROPNAME_Dependent "Dependent" +#define QT3DS_PROPNAME_Slide "Slide" +#define QT3DS_PROPNAME_Event "Event" +#define QT3DS_PROPNAME_Object "Object" +#define QT3DS_PROPNAME_Signal "Signa" +#define QT3DS_PROPNAME_Renderable "Renderable" +#define QT3DS_PROPNAME_PathBuffer "PathBuffer" +#define QT3DS_PROPNAME_ShadowMapResolution "ShadowMapResolution" +#define QT3DS_PROPNAME_String "String" + +#define LSTR2(x) L ## x +#define LSTR(x) LSTR2(x) #define ITERATE_ADDITIONAL_META_DATA_TYPES \ HANDLE_ADDITIONAL_META_DATA_TYPE(None) \ @@ -123,8 +127,8 @@ struct WStrOps<AdditionalMetaDataType::Value> { switch (item) { #define HANDLE_ADDITIONAL_META_DATA_TYPE(name) \ - case AdditionalMetaDataType::name: \ - wcscpy_s(buffer.begin(), buffer.size(), QT3DS_WCHAR_T_##name); \ + case AdditionalMetaDataType::name: \ + wcscpy_s(buffer.begin(), buffer.size(), LSTR(QT3DS_PROPNAME_##name)); \ return 1; ITERATE_ADDITIONAL_META_DATA_TYPES #undef HANDLE_ADDITIONAL_META_DATA_TYPE @@ -134,9 +138,9 @@ struct WStrOps<AdditionalMetaDataType::Value> bool StrTo(const wchar_t *buffer, AdditionalMetaDataType::Value &item) { #define HANDLE_ADDITIONAL_META_DATA_TYPE(name) \ - if (AreEqual(buffer, QT3DS_WCHAR_T_##name)) { \ - item = AdditionalMetaDataType::name; \ - return true; \ + if (AreEqual(buffer, LSTR(QT3DS_PROPNAME_##name))) { \ + item = AdditionalMetaDataType::name; \ + return true; \ } ITERATE_ADDITIONAL_META_DATA_TYPES #undef HANDLE_ADDITIONAL_META_DATA_TYPE @@ -155,12 +159,13 @@ struct WStrOps<AdditionalMetaDataType::Value> HANDLE_HANDLER_ARG_TYPE(Object) \ HANDLE_HANDLER_ARG_TYPE(Signal) -QT3DSU32 WStrOps<HandlerArgumentType::Value>::ToStr(HandlerArgumentType::Value item, NVDataRef<wchar_t> buffer) +QT3DSU32 WStrOps<HandlerArgumentType::Value>::ToStr(HandlerArgumentType::Value item, + NVDataRef<wchar_t> buffer) { switch (item) { #define HANDLE_HANDLER_ARG_TYPE(name) \ - case HandlerArgumentType::name: \ - wcscpy_s(buffer.begin(), buffer.size(), QT3DS_WCHAR_T_##name); \ + case HandlerArgumentType::name: \ + wcscpy_s(buffer.begin(), buffer.size(), LSTR(QT3DS_PROPNAME_##name)); \ return 1; ITERATE_HANDLER_ARG_TYPES #undef HANDLE_HANDLER_ARG_TYPE @@ -168,26 +173,57 @@ QT3DSU32 WStrOps<HandlerArgumentType::Value>::ToStr(HandlerArgumentType::Value i return 0; } -bool WStrOps<HandlerArgumentType::Value>::StrTo(const wchar_t *buffer, HandlerArgumentType::Value &item) +QT3DSU32 WStrOps<HandlerArgumentType::Value>::ToStr(HandlerArgumentType::Value item, + NVDataRef<char8_t> buffer) { + switch (item) { #define HANDLE_HANDLER_ARG_TYPE(name) \ - if (AreEqual(buffer, QT3DS_WCHAR_T_##name)) { \ - item = HandlerArgumentType::name; \ - return true; \ + case HandlerArgumentType::name: \ + _snprintf(buffer.begin(), buffer.size(), "%s", QT3DS_PROPNAME_##name); \ + return 1; + ITERATE_HANDLER_ARG_TYPES + #undef HANDLE_HANDLER_ARG_TYPE + } + return 0; } + +bool WStrOps<HandlerArgumentType::Value>::StrTo(const wchar_t *buffer, + HandlerArgumentType::Value &item) +{ +#define HANDLE_HANDLER_ARG_TYPE(name) \ + if (AreEqual(buffer, LSTR(QT3DS_PROPNAME_##name))) { \ + item = HandlerArgumentType::name; \ + return true; \ + } ITERATE_HANDLER_ARG_TYPES #undef HANDLE_HANDLER_ARG_TYPE return false; } -#define QT3DS_WCHAR_T_FloatRange L"FloatRange" -#define QT3DS_WCHAR_T_LongRange L"LongRange" -#define QT3DS_WCHAR_T_Vector L"Vector" -#define QT3DS_WCHAR_T_MultiLineString L"MultiLineString" -#define QT3DS_WCHAR_T_Boolean L"Boolean" -#define QT3DS_WCHAR_T_Guid L"Guid" -#define QT3DS_WCHAR_T_StringListOrInt L"StringListOrInt" -#define QT3DS_WCHAR_T_Scale L"Scale" +bool WStrOps<HandlerArgumentType::Value>::StrTo(const char8_t *buffer, + HandlerArgumentType::Value &item) +{ +#define HANDLE_HANDLER_ARG_TYPE(name) \ + if (AreEqual(buffer, QT3DS_PROPNAME_##name)) { \ + item = HandlerArgumentType::name; \ + return true; \ + } + ITERATE_HANDLER_ARG_TYPES + #undef HANDLE_HANDLER_ARG_TYPE + return false; +} + +#define QT3DS_PROPNAME_FloatRange "FloatRange" +#define QT3DS_PROPNAME_LongRange "LongRange" +#define QT3DS_PROPNAME_Vector "Vector" +#define QT3DS_PROPNAME_MultiLineString "MultiLineString" +#define QT3DS_PROPNAME_Boolean "Boolean" +#define QT3DS_PROPNAME_Guid "Guid" +#define QT3DS_PROPNAME_StringListOrInt "StringListOrInt" +#define QT3DS_PROPNAME_Scale "Scale" +#define QT3DS_PROPNAME_Float "Float" +#define QT3DS_PROPNAME_Float2 "Float2" +#define QT3DS_PROPNAME_Long "Long" #define ITERATE_QT3DSDM_COMPLETE_TYPES \ HANDLE_QT3DSDM_COMPLETE_NONE_TYPE \ @@ -278,13 +314,33 @@ QT3DSU32 WStrOps<CompleteMetaDataType::Enum>::ToStr(CompleteMetaDataType::Enum i NVDataRef<wchar_t> buffer) { switch (item) { -#define HANDLE_QT3DSDM_COMPLETE_NONE_TYPE \ +#define HANDLE_QT3DSDM_COMPLETE_NONE_TYPE \ case CompleteMetaDataType::Unknown: \ - wcscpy_s(buffer.begin(), buffer.size(), L"None"); \ + wcscpy_s(buffer.begin(), buffer.size(), L"None"); \ return 1; -#define HANDLE_QT3DSDM_COMPLETE_TYPE(name, addtype, dtype) \ +#define HANDLE_QT3DSDM_COMPLETE_TYPE(name, addtype, dtype) \ + case CompleteMetaDataType::name: \ + wcscpy_s(buffer.begin(), buffer.size(), LSTR(QT3DS_PROPNAME_##name)); \ + return 1; + + ITERATE_QT3DSDM_COMPLETE_TYPES + #undef HANDLE_QT3DSDM_COMPLETE_NONE_TYPE + #undef HANDLE_QT3DSDM_COMPLETE_TYPE + } + QT3DS_ASSERT(false); + return 0; +} +QT3DSU32 WStrOps<CompleteMetaDataType::Enum>::ToStr(CompleteMetaDataType::Enum item, + NVDataRef<char8_t> buffer) +{ + switch (item) { +#define HANDLE_QT3DSDM_COMPLETE_NONE_TYPE \ + case CompleteMetaDataType::Unknown: \ + _snprintf(buffer.begin(), buffer.size(), "%s", "None"); \ + return 1; +#define HANDLE_QT3DSDM_COMPLETE_TYPE(name, addtype, dtype) \ case CompleteMetaDataType::name: \ - wcscpy_s(buffer.begin(), buffer.size(), QT3DS_WCHAR_T_##name); \ + _snprintf(buffer.begin(), buffer.size(), "%s", QT3DS_PROPNAME_##name); \ return 1; ITERATE_QT3DSDM_COMPLETE_TYPES @@ -298,24 +354,45 @@ bool WStrOps<CompleteMetaDataType::Enum>::StrTo(const wchar_t *buffer, CompleteMetaDataType::Enum &item) { -#define HANDLE_QT3DSDM_COMPLETE_NONE_TYPE \ +#define HANDLE_QT3DSDM_COMPLETE_NONE_TYPE \ if (AreEqual(buffer, L"None")) { \ - item = CompleteMetaDataType::Unknown; \ - return true; \ -} -#define HANDLE_QT3DSDM_COMPLETE_TYPE(name, addtype, dtype) \ - if (AreEqual(buffer, QT3DS_WCHAR_T_##name)) { \ - item = CompleteMetaDataType::name; \ - return true; \ -} + item = CompleteMetaDataType::Unknown; \ + return true; \ + } +#define HANDLE_QT3DSDM_COMPLETE_TYPE(name, addtype, dtype) \ + if (AreEqual(buffer, LSTR(QT3DS_PROPNAME_##name))) { \ + item = CompleteMetaDataType::name; \ + return true; \ + } ITERATE_QT3DSDM_COMPLETE_TYPES #undef HANDLE_QT3DSDM_COMPLETE_NONE_TYPE #undef HANDLE_QT3DSDM_COMPLETE_TYPE return false; } +bool WStrOps<CompleteMetaDataType::Enum>::StrTo(const char8_t *buffer, + CompleteMetaDataType::Enum &item) +{ + +#define HANDLE_QT3DSDM_COMPLETE_NONE_TYPE \ + if (AreEqual(buffer, "None")) { \ + item = CompleteMetaDataType::Unknown; \ + return true; \ + } +#define HANDLE_QT3DSDM_COMPLETE_TYPE(name, addtype, dtype) \ + if (AreEqual(buffer, QT3DS_PROPNAME_##name)) { \ + item = CompleteMetaDataType::name; \ + return true; \ + } + + ITERATE_QT3DSDM_COMPLETE_TYPES + #undef HANDLE_QT3DSDM_COMPLETE_NONE_TYPE + #undef HANDLE_QT3DSDM_COMPLETE_TYPE + return false; } +} // namespace qt3dsdm + namespace { #ifndef QT3DSDM_META_DATA_NO_SIGNALS @@ -337,7 +414,6 @@ struct SNullFunc #endif -typedef TCharStr TStrType; using std::hash; struct InstanceHandleVecHash @@ -354,10 +430,10 @@ struct InstanceHandleVecHash struct SEventAndHandlerBase { Qt3DSDMInstanceHandle m_Instance; - TStrType m_Name; - TStrType m_FormalName; - TStrType m_Category; - TStrType m_Description; + QString m_Name; + QString m_FormalName; + QString m_Category; + QString m_Description; SEventAndHandlerBase() {} SEventAndHandlerBase(Qt3DSDMInstanceHandle hdl) : m_Instance(hdl) @@ -388,29 +464,30 @@ struct SHandler : public SEventAndHandlerBase // These have the property that pointer comparison also indicates string equality. struct SInstanceStrHash { - size_t operator()(const pair<TInstanceHandle, TCharPtr> &inPair) const + size_t operator()(const pair<TInstanceHandle, QString> &inPair) const { - return hash<int>()(inPair.first) ^ hash<const void *>()(inPair.second); + return hash<int>()(inPair.first) ^ qHash(inPair.second); } }; -template <typename TDataType> -NVConstDataRef<TDataType> VecToCRef(const eastl::vector<TDataType> &inType) -{ - return NVConstDataRef<TDataType>(inType.data(), (QT3DSU32)inType.size()); -} - struct SMetaDataDynamicObjectImpl { -private: - SMetaDataDynamicObjectImpl &operator=(const SMetaDataDynamicObjectImpl &inOther); - public: - TCharStr m_Name; - TCharStr m_SourcePath; - eastl::vector<SMetaDataShader> m_Shaders; - eastl::vector<qt3ds::render::dynamic::SPropertyDefinition> m_Properties; - eastl::vector<eastl::vector<qt3ds::foundation::CRegisteredString> *> m_EnumValueNames; + SMetaDataDynamicObjectImpl &operator=(const SMetaDataDynamicObjectImpl &inOther) + { + m_Name = inOther.m_Name; + m_SourcePath = inOther.m_SourcePath; + m_Shaders = inOther.m_Shaders; + m_Properties = inOther.m_Properties; + m_EnumValueNames = inOther.m_EnumValueNames; + return *this; + } + + QString m_Name; + QString m_SourcePath; + QVector<SMetaDataShader> m_Shaders; + QVector<qt3ds::render::dynamic::SPropertyDefinition> m_Properties; + QVector<QStringList *> m_EnumValueNames; ~SMetaDataDynamicObjectImpl() { ClearEnumValueNames(); } void ClearEnumValueNames() @@ -423,33 +500,43 @@ public: struct SMetaDataEffectImpl : public SMetaDataDynamicObjectImpl { -private: - SMetaDataEffectImpl &operator=(const SMetaDataEffectImpl &inOther); - public: - eastl::vector<qt3ds::render::dynamic::SCommand *> m_EffectCommands; + SMetaDataEffectImpl &operator=(const SMetaDataEffectImpl &inOther) + { + SMetaDataDynamicObjectImpl::operator=(inOther); + m_EffectCommands = inOther.m_EffectCommands; + return *this; + } + QVector<qt3ds::render::dynamic::SCommand *> m_EffectCommands; void ClearEffectCommands() { for (QT3DSU32 idx = 0, end = m_EnumValueNames.size(); idx < end; ++idx) - free(m_EffectCommands[idx]); + delete m_EffectCommands[idx]; m_EffectCommands.clear(); } SMetaDataEffect ToEffect() const { - return SMetaDataEffect(m_Name, VecToCRef(m_Shaders), VecToCRef(m_Properties), - VecToCRef(m_EffectCommands)); + return SMetaDataEffect(m_Name, m_Shaders, m_Properties, + m_EffectCommands); } }; struct SMetaDataCustomMaterialImpl : public SMetaDataDynamicObjectImpl { -private: - SMetaDataCustomMaterialImpl &operator=(const SMetaDataCustomMaterialImpl &); - public: - eastl::vector<qt3ds::render::dynamic::SCommand *> - m_CustomerMaterialCommands; ///< our command stream used for rendering + SMetaDataCustomMaterialImpl &operator=(const SMetaDataCustomMaterialImpl &inOther) + { + SMetaDataDynamicObjectImpl::operator=(inOther); + m_CustomerMaterialCommands = inOther.m_CustomerMaterialCommands; + m_HasTransparency = inOther.m_HasTransparency; + m_HasRefraction = inOther.m_HasRefraction; + m_AlwaysDirty = inOther.m_AlwaysDirty; + m_ShaderKey = inOther.m_ShaderKey; + m_LayerCount = inOther.m_LayerCount; + return *this; + } + QVector<qt3ds::render::dynamic::SCommand *> m_CustomerMaterialCommands; bool m_HasTransparency; ///< this material is transparent bool m_HasRefraction; ///< this material is refractive (e.g glass) bool m_AlwaysDirty; @@ -458,17 +545,16 @@ public: void ClearEffectCommands() { - for (QT3DSU32 idx = 0, end = m_EnumValueNames.size(); idx < end; ++idx) { - free(m_CustomerMaterialCommands[idx]); - } + for (QT3DSU32 idx = 0, end = m_EnumValueNames.size(); idx < end; ++idx) + delete m_CustomerMaterialCommands[idx]; m_CustomerMaterialCommands.clear(); } SMetaDataCustomMaterial ToMaterial() const { - return SMetaDataCustomMaterial(m_Name, VecToCRef(m_Shaders), VecToCRef(m_Properties), - VecToCRef(m_CustomerMaterialCommands), m_HasTransparency, + return SMetaDataCustomMaterial(m_Name, m_Shaders, m_Properties, + m_CustomerMaterialCommands, m_HasTransparency, m_HasRefraction, m_AlwaysDirty, m_ShaderKey, m_LayerCount); } }; @@ -482,40 +568,40 @@ class SNewMetaDataImpl : public IMetaData { #endif public: - typedef unordered_map<TCharPtr, TInstanceHandle> TStrInstanceMap; - typedef unordered_map<TInstanceHandle, TCharPtr, hash<int>> TInstanceStrMap; + typedef QHash<QString, TInstanceHandle> TStrInstanceMap; + typedef QHash<TInstanceHandle, QString> TInstanceStrMap; // Caching the derivation chain lookup so we can quickly lookup the entire list of // derived instances (and have it ordered, somewhat). typedef unordered_map<vector<TInstanceHandle>, vector<TInstanceHandle>, InstanceHandleVecHash> TDerivationMap; typedef unordered_map<TCategoryHandle, SCategoryInfo, hash<int>> TCategoryMap; - typedef unordered_map<TCharPtr, TCategoryHandle> TNameCategoryMap; + typedef QHash<QString, TCategoryHandle> TNameCategoryMap; typedef unordered_map<TMetaDataPropertyHandle, SMetaDataPropertyInfo, hash<int>> TMetaDataPropertyMap; typedef unordered_map<TInstanceHandle, vector<TMetaDataPropertyHandle>, hash<int>> TInstancePropertyMap; - typedef unordered_map<pair<TInstanceHandle, TCharPtr>, TMetaDataPropertyHandle, + typedef unordered_map<pair<TInstanceHandle, QString>, TMetaDataPropertyHandle, SInstanceStrHash> TInstancePropertyNamePropertyMap; typedef unordered_map<TMetaDataPropertyHandle, eastl::vector<SPropertyFilterInfo>, hash<int>> TMetaDataPropertyFilterMap; - typedef unordered_map<TInstanceHandle, vector<TCharPtr>, hash<int>> TInstanceGroupMap; + typedef unordered_map<TInstanceHandle, vector<QString>, hash<int>> TInstanceGroupMap; typedef unordered_map<TEventHandle, SEvent, hash<int>> TEventMap; typedef unordered_map<TInstanceHandle, vector<TEventHandle>, hash<int>> TInstanceEventMap; - typedef unordered_map<pair<TInstanceHandle, TCharPtr>, TEventHandle, SInstanceStrHash> + typedef unordered_map<pair<TInstanceHandle, QString>, TEventHandle, SInstanceStrHash> TInstanceEventNameEventMap; typedef unordered_map<THandlerHandle, SHandler, hash<int>> THandlerMap; typedef unordered_map<TInstanceHandle, vector<THandlerHandle>, hash<int>> TInstanceHandlerMap; - typedef unordered_map<pair<TInstanceHandle, TCharPtr>, THandlerHandle, SInstanceStrHash> + typedef unordered_map<pair<TInstanceHandle, QString>, THandlerHandle, SInstanceStrHash> TInstanceHandlerNameHandlerMap; - typedef unordered_map<TInstanceHandle, vector<TCharPtr>, hash<int>> TInstanceStringListMap; - typedef unordered_map<TCharPtr, SMetaDataEffectImpl> TEffectMap; - typedef unordered_map<TCharPtr, SMetaDataCustomMaterialImpl> TCustomMaterialMap; + typedef QHash<TInstanceHandle, vector<QString>> TInstanceStringListMap; + typedef QHash<QString, SMetaDataEffectImpl> TEffectMap; + typedef QHash<QString, SMetaDataCustomMaterialImpl> TCustomMaterialMap; std::shared_ptr<IDataCore> m_DataCore; IStringTable &m_StringTable; @@ -556,9 +642,7 @@ public: MemoryBuffer<RawAllocator> m_TempBuffer; MemoryBuffer<RawAllocator> m_ReadBuffer; - eastl::string m_ConvertStr; - - TCharStr m_ObjectName; + QString m_ObjectName; TEffectMap m_EffectMap; TCustomMaterialMap m_CustomMaterials; @@ -604,9 +688,6 @@ public: //////////////////////////////////////////////////////////////////////////// // Helper Functions - const wchar_t *Intern(TStrType inData) { return m_StringTable.RegisterStr(inData.wide_str()); } - const wchar_t *Intern(const char *inData) { return m_StringTable.GetWideStr(inData); } - inline int GetNextId() { int retval = m_NextId; @@ -634,6 +715,27 @@ public: return offset; } + template <typename TMapType, typename THandleType> + static void AddQHashItemToInstanceList(TInstanceHandle inInstance, THandleType inHandle, + QT3DSU32 inIdx, TMapType &ioMap) + { + typename TMapType::iterator inserter + = ioMap.insert(inInstance, vector<THandleType>()); + inserter->insert(inserter->begin() + inIdx, inHandle); + } + + template <typename TMapType, typename THandleType> + static QT3DSU32 AddQHashItemToInstanceList(TInstanceHandle inInstance, THandleType inHandle, + TMapType &ioMap) + { + typename TMapType::iterator inserter + = ioMap.insert(inInstance, vector<THandleType>()); + QT3DSU32 offset = (QT3DSU32)inserter->size(); + inserter->push_back(inHandle); + return offset; + } + + template <typename TItemType> struct VectorEqualPred { @@ -666,6 +768,26 @@ public: return QT3DS_MAX_U32; } + template <typename THandleType, typename TMapType> + static QT3DSU32 DoQHashRemoveItemFromInstanceList(TInstanceHandle inInstance, + THandleType inHandle, TMapType &ioMap) + { + typename TMapType::iterator find = ioMap.find(inInstance); + if (find != ioMap.end()) { + typename vector<THandleType>::iterator theVecFind = + std::find(find->begin(), find->end(), inHandle); + if (theVecFind != find->end()) { + QT3DSU32 retval = (QT3DSU32)(theVecFind - find->begin()); + find->erase(theVecFind); + if (find->empty()) + ioMap.erase(find); + return retval; + } + } + QT3DS_ASSERT(false); + return QT3DS_MAX_U32; + } + template <typename TMapType, typename THandleType> struct InstanceListTransaction : ITransaction { @@ -711,6 +833,52 @@ public: } }; + template <typename TMapType, typename THandleType> + struct InstanceListQHashTransaction : ITransaction + { + TInstanceHandle m_Instance; + THandleType m_Handle; + TMapType &m_Map; + QT3DSU32 m_Idx; + bool m_InsertOnDo; + + InstanceListQHashTransaction(const char *inFile, int inLine, TInstanceHandle inst, + THandleType handle, TMapType &map, QT3DSU32 inIdx, + bool inInsertOnDo) + : ITransaction(inFile, inLine) + , m_Instance(inst) + , m_Handle(handle) + , m_Map(map) + , m_Idx(inIdx) + , m_InsertOnDo(inInsertOnDo) + { + } + + void insert() + { + SNewMetaDataImpl::AddQHashItemToInstanceList(m_Instance, m_Handle, m_Idx, m_Map); + } + void remove() + { + SNewMetaDataImpl::DoQHashRemoveItemFromInstanceList(m_Instance, m_Handle, m_Map); + } + + void Do() override + { + if (m_InsertOnDo) + insert(); + else + remove(); + } + void Undo() override + { + if (m_InsertOnDo) + remove(); + else + insert(); + } + }; + template <typename THandleType, typename TMapType> void RemoveItemFromInstanceList(const char *inFile, int inLine, TInstanceHandle inInstance, THandleType inHandle, TMapType &ioMap) @@ -718,7 +886,7 @@ public: typename TMapType::iterator find = ioMap.find(inInstance); if (find != ioMap.end()) { QT3DSU32 idx = DoRemoveItemFromInstanceList(inInstance, inHandle, ioMap); - if (m_Consumer != NULL) { + if (m_Consumer != nullptr) { m_Consumer->OnTransaction( std::make_shared<InstanceListTransaction<TMapType, THandleType>>( inFile, inLine, inInstance, inHandle, std::ref(ioMap), idx, false)); @@ -752,12 +920,13 @@ public: ioHash.find(inHandle); if (find != ioHash.end()) return &find->second; - return NULL; + return nullptr; } template <typename THandleType, typename TMapType> - static void DoReplaceNamedItem(TInstanceHandle inInst, TCharPtr inOldName, TCharPtr inNewName, - THandleType inNewHandle, TMapType &ioMap) + static void DoReplaceNamedItem(TInstanceHandle inInst, const QString &inOldName, + const QString &inNewName, THandleType inNewHandle, + TMapType &ioMap) { ioMap.erase(make_pair(inInst, inOldName)); bool success = ioMap.insert(make_pair(make_pair(inInst, inNewName), inNewHandle)).second; @@ -769,13 +938,13 @@ public: struct ReplaceNamedItemTransaction : ITransaction { TInstanceHandle m_Instance; - TCharPtr m_OldName; - TCharPtr m_NewName; + QString m_OldName; + QString m_NewName; THandleType m_OldHandle; THandleType m_NewHandle; TMapType &m_Map; ReplaceNamedItemTransaction(const char *inFile, int inLine, TInstanceHandle inst, - TCharPtr oldNm, TCharPtr newNm, THandleType oldHdl, + const QString &oldNm, const QString &newNm, THandleType oldHdl, THandleType newHdl, TMapType &map) : ITransaction(inFile, inLine) , m_Instance(inst) @@ -800,8 +969,8 @@ public: template <typename THandleType, typename TMapType> void ReplaceNamedItem(const char *inFile, int inLine, TInstanceHandle inInst, - TCharPtr inOldName, TCharPtr inNewName, THandleType inNewHandle, - TMapType &ioMap) + const QString &inOldName, const QString &inNewName, + THandleType inNewHandle, TMapType &ioMap) { typename TMapType::iterator find = ioMap.find(std::make_pair(inInst, inOldName)); THandleType oldHandle; @@ -822,12 +991,12 @@ public: } template <typename THandleType, typename TMapType> - void DestroyNamedItem(const char *inFile, int inLine, TInstanceHandle inInst, TCharPtr inName, - TMapType &ioMap) + void DestroyNamedItem(const char *inFile, int inLine, TInstanceHandle inInst, + const QString &inName, TMapType &ioMap) { typename TMapType::iterator iter = ioMap.find(make_pair(inInst, inName)); if (iter != ioMap.end()) { - pair<pair<TInstanceHandle, TCharPtr>, THandleType> existing(*iter); + pair<pair<TInstanceHandle, QString>, THandleType> existing(*iter); ioMap.erase(iter); CreateHashMapEraseTransaction(inFile, inLine, m_Consumer, existing, ioMap); } @@ -837,8 +1006,8 @@ public: void SetItemInfo(const char *inFile, int inLine, THandleType inItem, const TInfoType &oldInfo, const TInfoType &newInfo, TMapType &inMap, TNamedMapType &inNamedMap) { - TCharPtr newName = Intern(newInfo.m_Name.wide_str()); - TCharPtr oldName = Intern(oldInfo.m_Name.wide_str()); + QString newName = (newInfo.m_Name); + QString oldName = (oldInfo.m_Name); ReplaceNamedItem(inFile, inLine, newInfo.m_Instance, oldName, newName, inItem, inNamedMap); CreateHashMapSwapTransaction(inFile, inLine, m_Consumer, inItem, oldInfo, newInfo, inMap); } @@ -881,7 +1050,7 @@ public: } template <typename THandleType, typename TMapType> - THandleType FindItemByName(TInstanceHandle inInst, TCharPtr inName, TMapType &ioMap) + THandleType FindItemByName(TInstanceHandle inInst, const QString &inName, TMapType &ioMap) { typename TMapType::iterator find(ioMap.find(make_pair(inInst, inName))); if (find != ioMap.end()) @@ -935,6 +1104,36 @@ public: } } + template <typename TListMapType, typename TSizeTOpType, typename TVectorType> + void DoGetQHashHandleList(Qt3DSDMInstanceHandle inInstance, TListMapType &inMap, + TVectorType &outHandles, TSizeTOpType inOperator) + { + typename TListMapType::iterator find; + GetDerivationChain(inInstance); + for (size_t idx = 0, end = m_DerivationChain.size(); idx < end; ++idx) { + // Add base classes to the list first + find = inMap.find(m_DerivationChain[end - idx - 1]); + if (find != inMap.end()) + AddListMapItems(*find, outHandles); + } + find = inMap.find(inInstance); + if (find != inMap.end()) + AddListMapItems(*find, outHandles); + m_SizeTSet.clear(); + for (size_t ridx = 0; ridx < outHandles.size(); ++ridx) { + size_t idx = outHandles.size() - ridx - 1; + // Run through the list backwards, making sure that items further in the list + // completely overshadow items earlier in the list. + + // Create unique key from the item that we can check against + size_t item = inOperator(outHandles[idx]); + if (m_SizeTSet.insert(item).second == false) { + outHandles.erase(outHandles.begin() + idx); + --ridx; + } + } + } + template <typename THandleType, typename TMapType> struct NameSizeTOpType { @@ -948,7 +1147,7 @@ public: size_t operator()(THandleType inHandle) { - return reinterpret_cast<size_t>(m_Impl.Intern(m_Map[inHandle].m_Name)); + return size_t(qHash(m_Map[inHandle].m_Name)); } }; @@ -970,7 +1169,7 @@ public: if (find == inMap.end()) return false; DestroyNamedItem<THandleType>(inFile, inLine, find->second.m_Instance, - Intern(find->second.m_Name.wide_str()), inNameMap); + find->second.m_Name, inNameMap); RemoveItemFromInstanceList(inFile, inLine, find->second.m_Instance, inItem, inListMap); CreateHashMapEraseTransaction(inFile, inLine, m_Consumer, make_pair(find->first, find->second), inMap); @@ -1015,7 +1214,7 @@ public: SHandler *theHandler(FindHandler(inHandler)); if (theHandler && theHandler->m_Arguments.size() > inIdx) return &theHandler->m_Arguments[inIdx]; - return NULL; + return nullptr; } void OnPropertyRemoved(Qt3DSDMInstanceHandle inInstance, Qt3DSDMPropertyHandle inProperty) @@ -1055,6 +1254,25 @@ public: } template <typename TEntryType, typename TMapType> + void InsertQWithTransaction(const char *inFile, int inLine, const TEntryType &inEntry, + TMapType &inMap) + { + inMap.insert(inEntry.first, inEntry.second); + CreateQHashInsertTransaction(inFile, inLine, m_Consumer, inEntry, inMap); + } + + template <typename TKeyType, typename TMapType> + void EraseQWithTransaction(const char *inFile, int inLine, TKeyType inKey, TMapType &inMap) + { + typename TMapType::iterator find(inMap.find(inKey)); + if (find != inMap.end()) { + CreateQHashEraseTransaction(inFile, inLine, m_Consumer, + std::make_pair(inKey, *find), inMap); + inMap.erase(find); + } + } + + template <typename TEntryType, typename TMapType> void InsertOrUpdateWithTransaction(const TEntryType &inEntry, TMapType &inMap) { pair<typename TMapType::iterator, bool> inserter = inMap.insert(inEntry); @@ -1079,44 +1297,44 @@ public: //////////////////////////////////////////////////////////////////////////////////// // Canonical Instances - void SetInstanceAsCanonical(Qt3DSDMInstanceHandle inInstance, TStrType inTypename) override + void SetInstanceAsCanonical(Qt3DSDMInstanceHandle inInstance, + const QString &inTypename) override { - const wchar_t *theTypename(Intern(inTypename)); if (g_DataModelDebugLogger) g_DataModelDebugLogger("IMetaData::SetInstanceAsCanonical Enter"); if (g_DataModelDebugLogger) - g_DataModelDebugLogger(GetStringTable().GetNarrowStr(inTypename.wide_str())); - m_CanonicalTypeToInstances.insert(make_pair(theTypename, inInstance)); - m_InstancesToCanonicalType.insert(make_pair(inInstance, theTypename)); - CreateHashMapInsertTransaction(__FILE__, __LINE__, m_Consumer, - make_pair(theTypename, inInstance), + g_DataModelDebugLogger(inTypename); + m_CanonicalTypeToInstances.insert(inTypename, inInstance); + m_InstancesToCanonicalType.insert(inInstance, inTypename); + CreateQHashInsertTransaction(__FILE__, __LINE__, m_Consumer, + make_pair(inTypename, inInstance), m_CanonicalTypeToInstances); - CreateHashMapInsertTransaction(__FILE__, __LINE__, m_Consumer, - make_pair(inInstance, theTypename), + CreateQHashInsertTransaction(__FILE__, __LINE__, m_Consumer, + make_pair(inInstance, inTypename), m_InstancesToCanonicalType); if (g_DataModelDebugLogger) g_DataModelDebugLogger("IMetaData::SetInstanceAsCanonical Leave"); } - Qt3DSDMInstanceHandle GetCanonicalInstanceForType(TStrType inTypename) override + Qt3DSDMInstanceHandle GetCanonicalInstanceForType(const QString &inTypename) override { - TStrInstanceMap::iterator find = m_CanonicalTypeToInstances.find(Intern(inTypename)); + TStrInstanceMap::iterator find = m_CanonicalTypeToInstances.find(inTypename); if (find != m_CanonicalTypeToInstances.end()) - return find->second; + return *find; return 0; } - Option<TCharStr> GetTypeForCanonicalInstance(Qt3DSDMInstanceHandle inInstance) override + Option<QString> GetTypeForCanonicalInstance(Qt3DSDMInstanceHandle inInstance) override { TInstanceStrMap::iterator find = m_InstancesToCanonicalType.find(inInstance); if (find != m_InstancesToCanonicalType.end()) - return TCharStr(find->second); + return *find; return Empty(); } - Option<TCharStr> GetTypeForInstance(Qt3DSDMInstanceHandle inInstance) override + Option<QString> GetTypeForInstance(Qt3DSDMInstanceHandle inInstance) override { - Option<TCharStr> theType = GetTypeForCanonicalInstance(inInstance); + Option<QString> theType = GetTypeForCanonicalInstance(inInstance); if (theType.hasValue()) return theType; GetDerivationChain(inInstance); @@ -1130,27 +1348,27 @@ public: QT3DSU32 GetGroupCountForInstance(Qt3DSDMInstanceHandle inInstance) override { - std::vector<TCharStr> outNames; + std::vector<QString> outNames; QT3DSU32 count = GetGroupNamesForInstance(inInstance, outNames); return (count == 0) ? 1 : count; } QT3DSU32 GetGroupNamesForInstance(Qt3DSDMInstanceHandle inInstance, - std::vector<TCharStr> &outNames) override + std::vector<QString> &outNames) override { TInstanceStrMap::iterator canonicalFind = m_InstancesToCanonicalType.find(inInstance); if (canonicalFind != m_InstancesToCanonicalType.end()) { TInstanceGroupMap::iterator find = m_InstanceGroupMap.find(inInstance); if (find != m_InstanceGroupMap.end()) { pair<typename TInstanceGroupMap::iterator, bool> inserter = - m_InstanceGroupMap.insert(make_pair(inInstance, vector<TCharPtr>())); - vector<TCharPtr> &itemList = inserter.first->second; + m_InstanceGroupMap.insert(make_pair(inInstance, vector<QString>())); + vector<QString> &itemList = inserter.first->second; for (size_t i = 0, j = itemList.size(); i < j; ++i) { bool alreadyInList = false; // discard duplicates for (size_t k = 0, l = outNames.size(); k < l; ++k) { - TCharStr curListName = itemList[i]; - if (curListName == outNames[k].wide_str()) { + QString curListName = itemList[i]; + if (curListName == outNames[k]) { alreadyInList = true; break; } @@ -1169,14 +1387,14 @@ public: if (find != m_InstanceGroupMap.end()) { pair<typename TInstanceGroupMap::iterator, bool> inserter = m_InstanceGroupMap.insert( - make_pair(m_DerivationChain[idx], vector<TCharPtr>())); - vector<TCharPtr> &itemList = inserter.first->second; + make_pair(m_DerivationChain[idx], vector<QString>())); + vector<QString> &itemList = inserter.first->second; for (size_t i = 0, j = itemList.size(); i < j; ++i) { bool alreadyInList = false; // discard duplicates for (size_t k = 0, l = outNames.size(); k < l; ++k) { - TCharStr curListName = itemList[i]; - if (curListName == outNames[k].wide_str()) { + QString curListName = itemList[i]; + if (curListName == outNames[k]) { alreadyInList = true; break; } @@ -1190,10 +1408,10 @@ public: return (QT3DSU32)outNames.size(); } - Option<TCharStr> GetGroupFilterNameForInstance(Qt3DSDMInstanceHandle inInstance, + Option<QString> GetGroupFilterNameForInstance(Qt3DSDMInstanceHandle inInstance, long inIndex) override { - std::vector<TCharStr> outNames; + std::vector<QString> outNames; QT3DSU32 count = GetGroupNamesForInstance(inInstance, outNames); if (count > (QT3DSU32)inIndex) return outNames[inIndex]; @@ -1204,25 +1422,25 @@ public: //////////////////////////////////////////////////////////////////////////////////// // Categories - std::pair<Qt3DSDMCategoryHandle, bool> GetOrCreateCategory(TStrType inName) override + std::pair<Qt3DSDMCategoryHandle, bool> GetOrCreateCategory(const QString &inName) override { - TCharPtr theName(Intern(inName)); + QString theName(inName); TNameCategoryMap::iterator find = m_NameToCategories.find(theName); if (find != m_NameToCategories.end()) - return make_pair(find->second, false); + return make_pair(*find, false); TCategoryHandle retval(GetNextId()); InsertWithTransaction(__FILE__, __LINE__, make_pair(retval, SCategoryInfo(inName)), m_Categories); - InsertWithTransaction(__FILE__, __LINE__, make_pair(theName, retval), m_NameToCategories); + InsertQWithTransaction(__FILE__, __LINE__, make_pair(theName, retval), m_NameToCategories); return make_pair(retval, true); } - void SetCategoryInfo(Qt3DSDMCategoryHandle inCategory, TStrType inIcon, - TStrType inHighlight, TStrType inDescription) override + void SetCategoryInfo(Qt3DSDMCategoryHandle inCategory, const QString &inIcon, + const QString &inHighlight, const QString &inDescription) override { SCategoryInfo *infoPtr(FindCategory(inCategory)); - if (infoPtr == NULL) { + if (infoPtr == nullptr) { QT3DS_ASSERT(false); return; } @@ -1239,11 +1457,11 @@ public: void DestroyCategory(Qt3DSDMCategoryHandle inCategory) override { SCategoryInfo *infoPtr(FindCategory(inCategory)); - if (infoPtr == NULL) { + if (infoPtr == nullptr) { QT3DS_ASSERT(false); return; } - EraseWithTransaction(__FILE__, __LINE__, Intern(infoPtr->m_Name), m_NameToCategories); + EraseQWithTransaction(__FILE__, __LINE__, infoPtr->m_Name, m_NameToCategories); EraseWithTransaction(__FILE__, __LINE__, inCategory, m_Categories); } Option<SCategoryInfo> GetCategoryInfo(Qt3DSDMCategoryHandle inCategory) override @@ -1253,12 +1471,12 @@ public: return *infoPtr; return Empty(); } - Qt3DSDMCategoryHandle FindCategoryByName(TStrType inName) override + Qt3DSDMCategoryHandle FindCategoryByName(const QString &inName) override { - TCharPtr theName(Intern(inName)); + QString theName((inName)); TNameCategoryMap::iterator find = m_NameToCategories.find(theName); if (find != m_NameToCategories.end()) - return find->second; + return *find; return 0; } @@ -1269,12 +1487,12 @@ public: outCategories.push_back(iter->first); } - Option<SCategoryInfo> GetEventCategory(TStrType inName) override + Option<SCategoryInfo> GetEventCategory(const QString &inName) override { return GetCategoryInfo(FindCategoryByName(inName)); } - Option<SCategoryInfo> GetHandlerCategory(TStrType inName) override + Option<SCategoryInfo> GetHandlerCategory(const QString &inName) override { return GetCategoryInfo(FindCategoryByName(inName)); } @@ -1308,7 +1526,7 @@ public: // Finally, if we don't have a property at this point, create a new property if (theExistingProperty.Valid() == false) theExistingProperty = m_DataCore->AddProperty( - newInfo.m_Instance, newInfo.m_Name.wide_str(), newInfo.GetDataType()); + newInfo.m_Instance, newInfo.m_Name, newInfo.GetDataType()); newInfo.m_Property = theExistingProperty; m_IgnorePropertyDeleted = false; } @@ -1342,8 +1560,9 @@ public: return inValue; } - void SetPropertyBaseInfo(SMetaPropertyBase &newInfo, TStrType inName, TStrType inFormalName, - TStrType inDescription, TStrType inUsage, + void SetPropertyBaseInfo(SMetaPropertyBase &newInfo, const QString &inName, + const QString &inFormalName, + const QString &inDescription, const QString &inUsage, CompleteMetaDataType::Enum inDataType, const SValue &inDefaultValue, const TMetaDataData &inMetaData) { @@ -1363,16 +1582,16 @@ public: // For properties, you set the default values separately // This may delete the underlying data model property rebuild it. void SetMetaDataPropertyInfo(Qt3DSDMMetaDataPropertyHandle inPropertyHandle, - TStrType inName, TStrType inFormalName, - TStrType inDescription, TStrType inUsage, + const QString &inName, const QString &inFormalName, + const QString &inDescription, const QString &inUsage, CompleteMetaDataType::Enum inDataType, const SValue &inDefaultValue, - const TMetaDataData &inMetaData, TStrType inGroupName, + const TMetaDataData &inMetaData, const QString &inGroupName, bool inIsHidden, bool inIsAnimatable, bool inIsControllable) override { SMetaDataPropertyInfo *infoPtr = FindProperty(inPropertyHandle); - if (infoPtr == NULL) { + if (infoPtr == nullptr) { QT3DS_ASSERT(false); return; } @@ -1406,7 +1625,7 @@ public: void DestroyMetaDataProperty(Qt3DSDMMetaDataPropertyHandle inProperty) override { SMetaDataPropertyInfo *infoPtr = FindProperty(inProperty); - if (infoPtr == NULL) { + if (infoPtr == nullptr) { QT3DS_ASSERT(false); return; } @@ -1419,9 +1638,9 @@ public: } Qt3DSDMMetaDataPropertyHandle GetMetaDataProperty(Qt3DSDMInstanceHandle inInstance, - TStrType inPropertyName) override + const QString &inPropertyName) override { - return FindItemByName<Qt3DSDMMetaDataPropertyHandle>(inInstance, Intern(inPropertyName), + return FindItemByName<Qt3DSDMMetaDataPropertyHandle>(inInstance, inPropertyName, m_InstanceNameToProperties); } Qt3DSDMMetaDataPropertyHandle GetMetaDataProperty(Qt3DSDMInstanceHandle inInstance, @@ -1435,9 +1654,8 @@ public: GetMetaDataPropertyInfo(Qt3DSDMMetaDataPropertyHandle inProperty) override { SMetaDataPropertyInfo *infoPtr = FindProperty(inProperty); - if (infoPtr == NULL) { + if (infoPtr == nullptr) return Empty(); - } return *infoPtr; } @@ -1448,17 +1666,17 @@ public: m_Properties, outProperties); } virtual Qt3DSDMMetaDataPropertyHandle - GetSpecificMetaDataProperty(Qt3DSDMInstanceHandle inInstance, TStrType inPropertyName) + GetSpecificMetaDataProperty(Qt3DSDMInstanceHandle inInstance, const QString &inPropertyName) { TInstancePropertyNamePropertyMap::iterator theFind = m_InstanceNameToProperties.find( - make_pair(inInstance, m_StringTable.RegisterStr(inPropertyName.wide_str()))); + make_pair(inInstance, inPropertyName)); if (theFind != m_InstanceNameToProperties.end()) return theFind->second; return 0; } virtual Qt3DSDMMetaDataPropertyHandle GetOrCreateSpecificMetaDataProperty(Qt3DSDMInstanceHandle inInstance, - TStrType inPropertyName) override + const QString &inPropertyName) override { Qt3DSDMMetaDataPropertyHandle theProp( GetSpecificMetaDataProperty(inInstance, inPropertyName)); @@ -1475,14 +1693,14 @@ public: outProperties.insert(outProperties.end(), find->second.begin(), find->second.end()); } - TCharStr GetFormalName(Qt3DSDMInstanceHandle inInstance, + QString GetFormalName(Qt3DSDMInstanceHandle inInstance, Qt3DSDMPropertyHandle inProperty) override { Qt3DSDMMetaDataPropertyHandle propHandle(GetMetaDataProperty(inInstance, inProperty)); SMetaDataPropertyInfo *infoPtr = FindProperty(propHandle); if (infoPtr) return infoPtr->m_FormalName; - return TCharStr(); + return {}; } AdditionalMetaDataType::Value GetAdditionalMetaDataType( Qt3DSDMInstanceHandle inInstance, Qt3DSDMPropertyHandle inProperty) override @@ -1560,7 +1778,7 @@ public: NVConstDataRef<SPropertyFilterInfo> inFilters) override { SMetaDataPropertyInfo *infoPtr = FindProperty(inProperty); - if (infoPtr == NULL) { + if (infoPtr == nullptr) { QT3DS_ASSERT(false); return; } @@ -1599,11 +1817,12 @@ public: m_InstanceToEvents); } - void SetEventInfo(Qt3DSDMEventHandle inEventHandle, TStrType inName, - TStrType inFormalName, TStrType inCategory, TStrType inDescription) override + void SetEventInfo(Qt3DSDMEventHandle inEventHandle, const QString &inName, + const QString &inFormalName, const QString &inCategory, + const QString &inDescription) override { SEvent *infoPtr = FindEvent(inEventHandle); - if (infoPtr == NULL) { + if (infoPtr == nullptr) { QT3DS_ASSERT(false); return; } @@ -1631,18 +1850,18 @@ public: outEvents); } - Qt3DSDMEventHandle FindEvent(Qt3DSDMInstanceHandle inInstance, TStrType inName) override + Qt3DSDMEventHandle FindEvent(Qt3DSDMInstanceHandle inInstance, const QString &inName) override { - return FindItemByName<Qt3DSDMEventHandle>(inInstance, Intern(inName), + return FindItemByName<Qt3DSDMEventHandle>(inInstance, inName, m_InstanceNameToEvents); } Option<SEventInfo> GetEventInfo(Qt3DSDMEventHandle inEventHandle) override { SEvent *infoPtr = FindEvent(inEventHandle); - if (infoPtr == NULL) { + if (infoPtr == nullptr) return Empty(); - } + SEventInfo retval; retval.m_Name = infoPtr->m_Name; retval.m_FormalName = infoPtr->m_FormalName; @@ -1654,7 +1873,7 @@ public: bool IsCustomEvent(Qt3DSDMEventHandle inEventHandle) override { SEvent *infoPtr = FindEvent(inEventHandle); - if (infoPtr != NULL) + if (infoPtr != nullptr) return IsCustomInstance(infoPtr->m_Instance); return false; } @@ -1667,10 +1886,10 @@ public: } Qt3DSDMEventHandle GetOrCreateSpecificEvent(Qt3DSDMInstanceHandle inInstance, - TStrType inName) override + const QString &inName) override { TInstanceEventNameEventMap::iterator theFind( - m_InstanceNameToEvents.find(make_pair(inInstance, Intern(inName)))); + m_InstanceNameToEvents.find(make_pair(inInstance, (inName)))); if (theFind != m_InstanceNameToEvents.end()) return theFind->second; return CreateMetaDataEvent(inInstance); @@ -1685,12 +1904,12 @@ public: m_Handlers, m_InstanceToHandlers); } - void SetHandlerInfo(Qt3DSDMHandlerHandle inHandle, TStrType inName, - TStrType inFormalName, TStrType inCategoryName, - TStrType inDescription) override + void SetHandlerInfo(Qt3DSDMHandlerHandle inHandle, const QString &inName, + const QString &inFormalName, const QString &inCategoryName, + const QString &inDescription) override { SHandler *infoPtr = FindHandler(inHandle); - if (infoPtr == NULL) { + if (infoPtr == nullptr) { QT3DS_ASSERT(false); return; } @@ -1707,7 +1926,7 @@ public: void DestroyHandler(Qt3DSDMHandlerHandle inHandlerHandle) override { SHandler *infoPtr(FindHandler(inHandlerHandle)); - if (infoPtr == NULL) { + if (infoPtr == nullptr) { QT3DS_ASSERT(false); return; } @@ -1720,16 +1939,16 @@ public: } Qt3DSDMHandlerHandle FindHandlerByName(Qt3DSDMInstanceHandle inInstance, - TStrType inName) override + const QString &inName) override { - return FindItemByName<Qt3DSDMHandlerHandle>(inInstance, Intern(inName), + return FindItemByName<Qt3DSDMHandlerHandle>(inInstance, inName, m_InstanceNameToHandlers); } Option<SHandlerInfo> GetHandlerInfo(Qt3DSDMHandlerHandle inHandlerHandle) override { SHandler *infoPtr = FindHandler(inHandlerHandle); - if (infoPtr == NULL) + if (infoPtr == nullptr) return Empty(); SHandlerInfo retval; @@ -1750,7 +1969,7 @@ public: bool IsCustomHandler(Qt3DSDMHandlerHandle inHandle) override { SHandler *infoPtr = FindHandler(inHandle); - if (infoPtr != NULL) + if (infoPtr != nullptr) return IsCustomInstance(infoPtr->m_Instance); return false; } @@ -1764,10 +1983,10 @@ public: } Qt3DSDMHandlerHandle GetOrCreateSpecificHandler(Qt3DSDMInstanceHandle inInstance, - TStrType inName) override + const QString &inName) override { TInstanceHandlerNameHandlerMap::iterator theFind = - m_InstanceNameToHandlers.find(make_pair(inInstance, Intern(inName))); + m_InstanceNameToHandlers.find(make_pair(inInstance, inName)); if (theFind != m_InstanceNameToHandlers.end()) return theFind->second; return CreateHandler(inInstance); @@ -1780,7 +1999,7 @@ public: const SMetaDataHandlerArgumentInfo &inArgHandle, QT3DSU32 inIdx) { SHandler *infoPtr = FindHandler(inHandler); - if (infoPtr == NULL) { + if (infoPtr == nullptr) { QT3DS_ASSERT(false); return; } @@ -1789,8 +2008,8 @@ public: struct ArgNameEqual { - const TCharStr &m_Name; - ArgNameEqual(const TCharStr &nm) + const QString &m_Name; + ArgNameEqual(const QString &nm) : m_Name(nm) { } @@ -1804,7 +2023,7 @@ public: const SMetaDataHandlerArgumentInfo &inArgHandle) { SHandler *infoPtr = FindHandler(inHandler); - if (infoPtr == NULL) { + if (infoPtr == nullptr) { QT3DS_ASSERT(false); return; } @@ -1852,7 +2071,7 @@ public: QT3DSU32 AddHandlerArgument(Qt3DSDMHandlerHandle inHandler) override { SHandler *infoPtr = FindHandler(inHandler); - if (infoPtr == NULL) { + if (infoPtr == nullptr) { QT3DS_ASSERT(false); return 0; } @@ -1872,7 +2091,7 @@ public: const SMetaDataHandlerArgumentInfo &inInfo) { SMetaDataHandlerArgumentInfo *infoPtr(FindHandlerArg(inHandler, inIdx)); - if (infoPtr == NULL) { + if (infoPtr == nullptr) { QT3DS_ASSERT(false); return; } @@ -1902,24 +2121,24 @@ public: void Undo() override { m_Impl.DoSetHandlerArgument(m_Handler, m_Idx, m_OldValue); } }; - void SetHandlerArgumentInfo(THandlerHandle inHandler, QT3DSU32 inIdx, TStrType inName, - TStrType inFormalName, TStrType inDescription, + void SetHandlerArgumentInfo(THandlerHandle inHandler, QT3DSU32 inIdx, const QString &inName, + const QString &inFormalName, const QString &inDescription, CompleteMetaDataType::Enum inDataType, const SValue &inDefaultValue, const TMetaDataData &inMetaData, HandlerArgumentType::Value inArgType) override { SMetaDataHandlerArgumentInfo *infoPtr(FindHandlerArg(inHandler, inIdx)); - if (infoPtr == NULL) { + if (infoPtr == nullptr) { QT3DS_ASSERT(false); return; } SMetaDataHandlerArgumentInfo &newInfo(*infoPtr); SMetaDataHandlerArgumentInfo oldInfo(newInfo); - SetPropertyBaseInfo(newInfo, inName, inFormalName, inDescription, L"", inDataType, + SetPropertyBaseInfo(newInfo, inName, inFormalName, inDescription, QString(), inDataType, inDefaultValue, inMetaData); newInfo.m_ArgType = inArgType; - if (m_Consumer != NULL) + if (m_Consumer != nullptr) m_Consumer->OnTransaction(make_shared<SetHandlerArgumentInfoTrans>( __FILE__, __LINE__, ref(*this), inHandler, inIdx, newInfo, oldInfo)); @@ -1929,11 +2148,11 @@ public: { SHandler *ownerPtr = FindHandler(inHandler); SMetaDataHandlerArgumentInfo *infoPtr(FindHandlerArg(inHandler, inIdx)); - if (infoPtr == NULL) { + if (infoPtr == nullptr) { QT3DS_ASSERT(false); return; } - if (ownerPtr == NULL) { + if (ownerPtr == nullptr) { QT3DS_ASSERT(false); return; } @@ -1949,12 +2168,12 @@ public: } Option<SMetaDataHandlerArgumentInfo> FindHandlerArgumentByName(THandlerHandle inHandler, - TStrType inName) override + const QString & inName) override { SHandler *ownerPtr = FindHandler(inHandler); - if (ownerPtr == NULL) { + if (ownerPtr == nullptr) return Empty(); - } + for (size_t idx = 0, end = ownerPtr->m_Arguments.size(); idx < end; ++idx) { if (ownerPtr->m_Arguments[idx].m_Name == inName) return ownerPtr->m_Arguments[idx]; @@ -1966,9 +2185,9 @@ public: vector<SMetaDataHandlerArgumentInfo> &outArguments) override { SHandler *ownerPtr = FindHandler(inHandler); - if (ownerPtr == NULL) { + if (ownerPtr == nullptr) return; - } + outArguments.insert(outArguments.end(), ownerPtr->m_Arguments.begin(), ownerPtr->m_Arguments.end()); } @@ -1977,41 +2196,34 @@ public: GetHandlerArgumentInfo(Qt3DSDMHandlerHandle inHandle, QT3DSU32 inIdx) override { SMetaDataHandlerArgumentInfo *infoPtr(FindHandlerArg(inHandle, inIdx)); - if (infoPtr == NULL) { + if (infoPtr == nullptr) return Empty(); - } + return *infoPtr; } QT3DSU32 GetNumHandlerArguments(Qt3DSDMHandlerHandle inHandler) override { SHandler *ownerPtr = FindHandler(inHandler); - if (ownerPtr == NULL) { + if (ownerPtr == nullptr) return 0; - } + return (QT3DSU32)ownerPtr->m_Arguments.size(); } //////////////////////////////////////////////////////////////////////////////////// // References - void AddReference(Qt3DSDMInstanceHandle inInstance, TStrType inRefString) override + void AddReference(Qt3DSDMInstanceHandle inInstance, const QString &inRefString) override { // trim whitespace from the beginning and the end of the string - TCharStr::size_type startPos = inRefString.find_first_not_of(L"\n\r\t "); - TCharStr::size_type endPos = inRefString.find_last_not_of(L"\n\r\t "); - const wchar_t *theStr = NULL; - if (startPos != TCharStr::npos) { - TStrType temp = inRefString.substr(startPos, endPos - startPos + 1); - theStr = Intern(temp); - } else - theStr = Intern(inRefString); + QString trimmed = inRefString.trimmed(); - QT3DSU32 idx = AddItemToInstanceList(inInstance, theStr, m_InstanceToReferences); + QT3DSU32 idx = AddQHashItemToInstanceList(inInstance, trimmed, m_InstanceToReferences); if (m_Consumer) { m_Consumer->OnTransaction( - std::make_shared<InstanceListTransaction<TInstanceStringListMap, - const wchar_t *>>( - __FILE__, __LINE__, inInstance, theStr, + std::make_shared<InstanceListQHashTransaction<TInstanceStringListMap, + const QString &>>( + __FILE__, __LINE__, inInstance, trimmed, std::ref(m_InstanceToReferences), idx, true)); } @@ -2024,8 +2236,8 @@ public: if (find == m_InstanceToReferences.end()) return; - CreateHashMapEraseTransaction(__FILE__, __LINE__, m_Consumer, - make_pair(find->first, find->second), m_InstanceToReferences); + CreateQHashEraseTransaction(__FILE__, __LINE__, m_Consumer, + make_pair(inInstance, *find), m_InstanceToReferences); m_InstanceToReferences.erase(find); } @@ -2037,16 +2249,16 @@ public: { } - size_t operator()(const TCharStr &inHandle) + size_t operator()(const QString &inHandle) { - return reinterpret_cast<size_t>(m_Impl.Intern(inHandle)); + return size_t(qHash(inHandle)); } }; - void GetReferences(Qt3DSDMInstanceHandle inInstance, vector<TCharStr> &outReferences) override + void GetReferences(Qt3DSDMInstanceHandle inInstance, vector<QString> &outReferences) override { - DoGetHandleList(inInstance, m_InstanceToReferences, outReferences, - InternSizeTOpType(*this)); + DoGetQHashHandleList(inInstance, m_InstanceToReferences, outReferences, + InternSizeTOpType(*this)); } //////////////////////////////////////////////////////////////////////////////////// @@ -2071,13 +2283,13 @@ public: TInstanceStrMap::iterator find = m_InstancesToCanonicalType.find(inInstance); if (find != m_InstancesToCanonicalType.end()) { - TCharPtr theName(find->second); - m_CanonicalTypeToInstances.erase(theName); - m_InstancesToCanonicalType.erase(inInstance); - CreateHashMapEraseTransaction(__FILE__, __LINE__, m_Consumer, + QString theName(*find); + m_CanonicalTypeToInstances.erase(m_CanonicalTypeToInstances.find(theName)); + m_InstancesToCanonicalType.erase(m_InstancesToCanonicalType.find(inInstance)); + CreateQHashEraseTransaction(__FILE__, __LINE__, m_Consumer, make_pair(theName, inInstance), m_CanonicalTypeToInstances); - CreateHashMapEraseTransaction(__FILE__, __LINE__, m_Consumer, + CreateQHashEraseTransaction(__FILE__, __LINE__, m_Consumer, make_pair(inInstance, theName), m_InstancesToCanonicalType); } @@ -2093,8 +2305,19 @@ public: unordered_set<TInstanceHandle, hash<int>> &outInstances) { for (typename THashType::const_iterator iter = inHash.begin(), end = inHash.end(); - iter != end; ++iter) + iter != end; ++iter) { outInstances.insert(iter->first); + } + } + + template <typename THashType> + void AddInstancesFromQHash(THashType &inHash, + unordered_set<TInstanceHandle, hash<int>> &outInstances) + { + for (typename THashType::const_iterator iter = inHash.begin(), end = inHash.end(); + iter != end; ++iter) { + outInstances.insert(iter.key()); + } } void SerializeMetaDataData(IDOMWriter &inWriter, TMetaDataData &inItem, @@ -2103,17 +2326,17 @@ public: if (!inItem.empty()) { if (inType == AdditionalMetaDataType::Range) { SMetaDataRange theRange(get<SMetaDataRange>(inItem)); - inWriter.Att(L"min", theRange.m_Min); - inWriter.Att(L"max", theRange.m_Max); + inWriter.Att(QStringLiteral("min"), theRange.m_Min); + inWriter.Att(QStringLiteral("max"), theRange.m_Max); } else if (inType == AdditionalMetaDataType::StringList) { const TMetaDataStringList &theList(get<TMetaDataStringList>(inItem)); - TCharStr theBuffer; + QString theBuffer; for (uint32_t idx = 0, end = theList.size(); idx < end; ++idx) { if (idx) - theBuffer.append(L":"); - theBuffer.append(theList[idx]); + theBuffer += QLatin1Char(':'); + theBuffer += QString::fromWCharArray(theList[idx].wide_str()); } - inWriter.Att(L"list", theBuffer.wide_str()); + inWriter.Att(QStringLiteral("list"), theBuffer); } } } @@ -2140,11 +2363,8 @@ public: const wchar_t *inName = L"default") { const char8_t *theDefaultValue; - qt3ds::foundation::ConvertUTF( - reinterpret_cast<const qt3ds::foundation::TWCharEASTLConverter::TCharType *>( - inName), 0, - m_ConvertStr); - if (inReader.UnregisteredAtt(m_ConvertStr.c_str(), theDefaultValue)) { + QString name(QString::fromWCharArray(inName)); + if (inReader.UnregisteredAtt(qPrintable(name), theDefaultValue)) { m_TempBuffer.clear(); // We have to write a temporary value because the parsing of floats, // in order to be efficient, is destructive. @@ -2178,37 +2398,35 @@ public: ioType = CompleteMetaDataType::FloatRange; } else { TMetaDataStringList theList; - TCharStr theItems; - if (inReader.Att(L"list", theItems)) { - for (TCharStr::size_type theIter = theItems.find_first_of(L":,"); - theIter != theItems.npos; theIter = theItems.find_first_of(L":,")) { - theList.push_back(theItems.substr(0, theIter)); - theItems = theItems.substr(theIter + 1); - } - theList.push_back(theItems); + QString theItems; + if (inReader.Att(QStringLiteral("list"), theItems)) { + const QStringList items = theItems.split(QLatin1Char(':')); + for (const auto &item : qAsConst(items)) + theList.push_back(qUtf16Printable(item)); ioItem = theList; if (ioType != CompleteMetaDataType::StringListOrInt) ioType = CompleteMetaDataType::StringList; } } } - void EnsureCategory(IDOMWriter &, const TCharStr &, const TCharStr &) {} - void EnsureCategory(IDOMReader &, TCharStr &inCategory, const TCharStr &inObjectName) + void EnsureCategory(IDOMWriter &, const QString &, const QString &) {} + void EnsureCategory(IDOMReader &, QString &inCategory, const QString &inObjectName) { Qt3DSDMCategoryHandle theCategory = FindCategoryByName(inCategory); if (theCategory.Valid() == false) { - if (inObjectName.empty()) { + if (inObjectName.isEmpty()) { QT3DS_ASSERT(false); } else { - if (inCategory.empty()) + if (inCategory.isEmpty()) inCategory = inObjectName; pair<Qt3DSDMCategoryHandle, bool> theGetOrCreateResult( GetOrCreateCategory(inCategory)); if (theGetOrCreateResult.second == true) { - SetCategoryInfo(theGetOrCreateResult.first, L"Objects-Behavior-Normal.png", - L"Objects-Behavior-Normal.png", inCategory); + SetCategoryInfo(theGetOrCreateResult.first, + QStringLiteral("Objects-Behavior-Normal.png"), + QStringLiteral("Objects-Behavior-Normal.png"), inCategory); } } } @@ -2216,16 +2434,16 @@ public: void SerializePropertyBase(IDOMWriter &inArchive, SMetaPropertyBase &inItem) { - inArchive.Att(L"name", inItem.m_Name); + inArchive.Att(QStringLiteral("name"), inItem.m_Name); if (inItem.m_FormalName != inItem.m_Name) - inArchive.Att(L"formalName", inItem.m_FormalName); + inArchive.Att(QStringLiteral("formalName"), inItem.m_FormalName); if (inItem.m_Description != inItem.m_Name) - inArchive.Att(L"description", inItem.m_Description); + inArchive.Att(QStringLiteral("description"), inItem.m_Description); if (inItem.m_CompleteType != CompleteMetaDataType::Float && inItem.m_CompleteType != CompleteMetaDataType::FloatRange && inItem.m_CompleteType != CompleteMetaDataType::LongRange && inItem.m_CompleteType != CompleteMetaDataType::StringList) { - inArchive.Att(L"type", inItem.m_CompleteType); + inArchive.Att(QStringLiteral("type"), inItem.m_CompleteType); } // Ensure that all types work @@ -2242,16 +2460,16 @@ public: void SerializePropertyBase(IDOMReader &inArchive, SMetaPropertyBase &inItem) { - inArchive.Att(L"name", inItem.m_Name); - inArchive.Att(L"formalName", inItem.m_FormalName); - inArchive.Att(L"usage", inItem.m_Usage); - inArchive.Att(L"description", inItem.m_Description); - inArchive.Att(L"type", inItem.m_CompleteType); + inArchive.Att(QStringLiteral("name"), inItem.m_Name); + inArchive.Att(QStringLiteral("formalName"), inItem.m_FormalName); + inArchive.Att(QStringLiteral("usage"), inItem.m_Usage); + inArchive.Att(QStringLiteral("description"), inItem.m_Description); + inArchive.Att(QStringLiteral("type"), inItem.m_CompleteType); // Setup reasonable defaults in the case where the users are specifying little information // in the file format - if (inItem.m_FormalName.empty()) + if (inItem.m_FormalName.isEmpty()) inItem.m_FormalName = inItem.m_Name; - if (inItem.m_Description.empty()) + if (inItem.m_Description.isEmpty()) inItem.m_Description = inItem.m_Name; // Ensure that users can use a float type and make minimal decisions @@ -2265,17 +2483,17 @@ public: void FinalizeCategory(IDOMReader &, SCategoryInfo &inCategory) { - if (inCategory.m_Description.empty()) + if (inCategory.m_Description.isEmpty()) inCategory.m_Description = inCategory.m_Name; } template <typename TArchiveType> void SerializeItem(TArchiveType &inArchive, SCategoryInfo &inItem) { - inArchive.Att(L"name", inItem.m_Name); - inArchive.Att(L"description", inItem.m_Description); - inArchive.Att(L"icon", inItem.m_Icon); - inArchive.Att(L"highlightIcon", inItem.m_HighlightIcon); + inArchive.Att(QStringLiteral("name"), inItem.m_Name); + inArchive.Att(QStringLiteral("description"), inItem.m_Description); + inArchive.Att(QStringLiteral("icon"), inItem.m_Icon); + inArchive.Att(QStringLiteral("highlightIcon"), inItem.m_HighlightIcon); FinalizeCategory(inArchive, inItem); } @@ -2285,11 +2503,11 @@ public: { SerializePropertyBase(inArchive, inItem); if (inItem.m_IsHidden == true) - inArchive.Att("hidden", inItem.m_IsHidden); + inArchive.Att(QStringLiteral("hidden"), inItem.m_IsHidden); if (inItem.m_Animatable == false) - inArchive.Att("animatable", inItem.m_Animatable); + inArchive.Att(QStringLiteral("animatable"), inItem.m_Animatable); if (inItem.m_Controllable == true) - inArchive.Att("controllable", inItem.m_Controllable); + inArchive.Att(QStringLiteral("controllable"), inItem.m_Controllable); NVConstDataRef<SPropertyFilterInfo> theInfos = GetMetaDataPropertyFilters(inHandle); for (QT3DSU32 idx = 0, end = theInfos.size(); idx < end; ++idx) { const SPropertyFilterInfo &theInfo(theInfos[idx]); @@ -2303,7 +2521,7 @@ public: theFilterName = L"ShowIfEqual"; IDOMWriter::Scope filterScope(inArchive, theFilterName); - inArchive.Att(L"property", thePropertyInfo.m_Name); + inArchive.Att(QStringLiteral("property"), thePropertyInfo.m_Name); SerializeDataModelValue(inArchive, theInfo.m_Value, thePropertyInfo.m_Type, L"value"); } } @@ -2314,10 +2532,10 @@ public: QT3DS_ASSERT(inHandle.Valid()); SerializePropertyBase(inArchive, inItem); - inArchive.Att("hidden", inItem.m_IsHidden); - inArchive.Att("animatable", inItem.m_Animatable); - inArchive.Att("controllable", inItem.m_Controllable); - inArchive.Att(L"category", inItem.m_GroupName); + inArchive.Att(QStringLiteral("hidden"), inItem.m_IsHidden); + inArchive.Att(QStringLiteral("animatable"), inItem.m_Animatable); + inArchive.Att(QStringLiteral("controllable"), inItem.m_Controllable); + inArchive.Att(QStringLiteral("category"), inItem.m_GroupName); } void ReadChildren(IDOMReader &inArchive, SMetaDataPropertyInfo &inItem, @@ -2328,9 +2546,9 @@ public: for (bool success = inArchive.MoveToFirstChild(); success; success = inArchive.MoveToNextSibling()) { - if (AreEqual(inArchive.GetElementName(), L"ShowIfEqual")) { - TCharStr theName; - inArchive.Att(L"property", theName); + if (inArchive.GetElementName() == QLatin1String("ShowIfEqual")) { + QString theName; + inArchive.Att(QStringLiteral("property"), theName); Qt3DSDMPropertyHandle theProperty = m_DataCore->GetAggregateInstancePropertyByName(inItem.m_Instance, theName); if (theProperty.Valid() == false) { @@ -2344,9 +2562,9 @@ public: theInfo.m_FilterProperty = theProperty; SerializeDataModelValue(inArchive, theInfo.m_Value, thePropDef.m_Type, L"value"); theFilters.push_back(theInfo); - } else if (AreEqual(inArchive.GetElementName(), L"HideIfEqual")) { - TCharStr theName; - inArchive.Att(L"property", theName); + } else if (inArchive.GetElementName() == QLatin1String("HideIfEqual")) { + QString theName; + inArchive.Att(QStringLiteral("property"), theName); Qt3DSDMPropertyHandle theProperty = m_DataCore->GetAggregateInstancePropertyByName(inItem.m_Instance, theName); if (theProperty.Valid() == false) { @@ -2374,21 +2592,21 @@ public: void EnsureEventHandlerBase(IDOMReader &, SEventAndHandlerBase &inItem) { - if (inItem.m_FormalName.empty()) + if (inItem.m_FormalName.isEmpty()) inItem.m_FormalName = inItem.m_Name; - if (inItem.m_Description.empty()) + if (inItem.m_Description.isEmpty()) inItem.m_Description = inItem.m_Name; } void SerializeItem(IDOMWriter &inArchive, SEvent &inItem, Qt3DSDMEventHandle &) { - inArchive.Att(L"name", inItem.m_Name); + inArchive.Att(QStringLiteral("name"), inItem.m_Name); if (inItem.m_Name != inItem.m_FormalName) - inArchive.Att(L"formalName", inItem.m_FormalName); - if (inItem.m_Category != L"Default") - inArchive.Att(L"category", inItem.m_Category); + inArchive.Att(QStringLiteral("formalName"), inItem.m_FormalName); + if (inItem.m_Category != QLatin1String("Default")) + inArchive.Att(QStringLiteral("category"), inItem.m_Category); if (inItem.m_Description != inItem.m_Name) - inArchive.Att(L"description", inItem.m_Description); + inArchive.Att(QStringLiteral("description"), inItem.m_Description); EnsureCategory(inArchive, inItem.m_Category, m_ObjectName); EnsureEventHandlerBase(inArchive, inItem); @@ -2396,11 +2614,11 @@ public: void SerializeItem(IDOMReader &inArchive, SEvent &inItem, Qt3DSDMEventHandle &) { - inArchive.Att(L"name", inItem.m_Name); - inArchive.Att(L"formalName", inItem.m_FormalName); - inArchive.Att(L"category", inItem.m_Category); + inArchive.Att(QStringLiteral("name"), inItem.m_Name); + inArchive.Att(QStringLiteral("formalName"), inItem.m_FormalName); + inArchive.Att(QStringLiteral("category"), inItem.m_Category); EnsureCategory(inArchive, inItem.m_Category, m_ObjectName); - inArchive.Att(L"description", inItem.m_Description); + inArchive.Att(QStringLiteral("description"), inItem.m_Description); EnsureEventHandlerBase(inArchive, inItem); } @@ -2408,20 +2626,20 @@ public: { SerializePropertyBase(inArchive, inArgument); if (inArgument.m_ArgType != HandlerArgumentType::None) - inArchive.Att(L"argumentType", inArgument.m_ArgType); + inArchive.Att(QStringLiteral("argumentType"), inArgument.m_ArgType); } void SerializeHandlerArgument(IDOMReader &inArchive, SMetaDataHandlerArgumentInfo &inArgument) { SerializePropertyBase(inArchive, inArgument); - inArchive.Att(L"argumentType", inArgument.m_ArgType); + inArchive.Att(QStringLiteral("argumentType"), inArgument.m_ArgType); } void SerializeHandlerArguments(IDOMWriter &inWriter, SHandler &inItem, Qt3DSDMHandlerHandle &) { for (size_t idx = 0, end = inItem.m_Arguments.size(); idx < end; ++idx) { SMetaDataHandlerArgumentInfo &theArg(inItem.m_Arguments[idx]); - IDOMWriter::Scope __argScope(inWriter, L"Argument"); + IDOMWriter::Scope __argScope(inWriter, QStringLiteral("Argument")); SerializeHandlerArgument(inWriter, theArg); } } @@ -2442,23 +2660,23 @@ public: void SerializeHandlerItem(IDOMWriter &inArchive, SHandler &inItem) { - inArchive.Att(L"name", inItem.m_Name); + inArchive.Att(QStringLiteral("name"), inItem.m_Name); if (inItem.m_FormalName != inItem.m_Name) - inArchive.Att(L"formalName", inItem.m_FormalName); - if (inItem.m_Category != L"Default") - inArchive.Att(L"category", inItem.m_Category); + inArchive.Att(QStringLiteral("formalName"), inItem.m_FormalName); + if (inItem.m_Category != QLatin1String("Default")) + inArchive.Att(QStringLiteral("category"), inItem.m_Category); if (inItem.m_Description != inItem.m_Name) - inArchive.Att(L"description", inItem.m_Description); + inArchive.Att(QStringLiteral("description"), inItem.m_Description); EnsureEventHandlerBase(inArchive, inItem); } void SerializeHandlerItem(IDOMReader &inArchive, SHandler &inItem) { - inArchive.Att(L"name", inItem.m_Name); - inArchive.Att(L"formalName", inItem.m_FormalName); - inArchive.Att(L"category", inItem.m_Category); + inArchive.Att(QStringLiteral("name"), inItem.m_Name); + inArchive.Att(QStringLiteral("formalName"), inItem.m_FormalName); + inArchive.Att(QStringLiteral("category"), inItem.m_Category); EnsureCategory(inArchive, inItem.m_Category, m_ObjectName); - inArchive.Att(L"description", inItem.m_Description); + inArchive.Att(QStringLiteral("description"), inItem.m_Description); EnsureEventHandlerBase(inArchive, inItem); } @@ -2496,14 +2714,14 @@ public: void CreateInstanceGroupInfo(SMetaDataPropertyInfo &inProperty) { - if (!inProperty.m_GroupName.empty()) { - const wchar_t *theGroupName = Intern(inProperty.m_GroupName); + if (!inProperty.m_GroupName.isEmpty()) { + QString theGroupName = inProperty.m_GroupName; bool found = false; pair<typename TInstanceGroupMap::iterator, bool> inserter = - m_InstanceGroupMap.insert(make_pair(inProperty.m_Instance, vector<TCharPtr>())); - vector<TCharPtr> &itemList = inserter.first->second; + m_InstanceGroupMap.insert(make_pair(inProperty.m_Instance, vector<QString>())); + vector<QString> &itemList = inserter.first->second; for (size_t idx = 0, end = itemList.size(); idx < end; ++idx) { - TCharStr curListName = itemList[idx]; + QString curListName = itemList[idx]; if (curListName == theGroupName) { found = true; break; @@ -2547,7 +2765,7 @@ public: inMap.insert(make_pair(theHandle, theInfo)); this->AddItemToInstanceList(inInstanceHandle, theHandle, inListMap); inNameMap.insert( - make_pair(make_pair(inInstanceHandle, Intern(theInfo.m_Name)), theHandle)); + make_pair(make_pair(inInstanceHandle, theInfo.m_Name), theHandle)); ReadChildren(inArchive, theInfo, theHandle); } } @@ -2558,7 +2776,7 @@ public: TInstanceStringListMap::iterator iter = inMap.find(inInstance); if (iter == inMap.end()) return; - const vector<TCharPtr> &theValueList(iter->second); + const vector<QString> &theValueList(*iter); for (size_t idx = 0, end = theValueList.size(); idx < end; ++idx) { IDOMWriter::Scope __elemScope(inArchive, inElementName); inArchive.Value(theValueList[idx]); @@ -2573,7 +2791,7 @@ public: success = inArchive.MoveToNextSibling(inElementName)) { const wchar_t *theValue; if (inArchive.RegisteredValue(theValue)) - AddItemToInstanceList(inInstance, theValue, inMap); + AddQHashItemToInstanceList(inInstance, QString::fromWCharArray(theValue), inMap); } } @@ -2592,21 +2810,21 @@ public: { for (TCategoryMap::iterator iter = m_Categories.begin(), end = m_Categories.end(); iter != end; ++iter) { - IDOMWriter::Scope __writerScope(inWriter, L"Category"); + IDOMWriter::Scope __writerScope(inWriter, QStringLiteral("Category")); SerializeItem(inWriter, iter->second); } } void SerializeCategories(IDOMReader &inReader) { IDOMReader::Scope __readerScope(inReader); - for (bool success = inReader.MoveToFirstChild(L"Category"); success; - success = inReader.MoveToNextSibling(L"Category")) { + for (bool success = inReader.MoveToFirstChild(QStringLiteral("Category")); success; + success = inReader.MoveToNextSibling(QStringLiteral("Category"))) { SCategoryInfo theInfo; SerializeItem(inReader, theInfo); TCategoryHandle newHandle(GetNextId()); theInfo.m_Canonical = true; m_Categories.insert(make_pair(newHandle, theInfo)); - m_NameToCategories.insert(make_pair(Intern(theInfo.m_Name), newHandle)); + m_NameToCategories.insert(theInfo.m_Name, newHandle); } } @@ -2627,7 +2845,7 @@ public: return false; if (rhsIter == m_Map.end()) return true; - return wcscmp(lhsIter->second, rhsIter->second) < 0; + return lhsIter->compare(*rhsIter) < 0; } }; @@ -2641,7 +2859,7 @@ public: AddInstancesFromHash(m_InstanceToProperties, theInstanceList); AddInstancesFromHash(m_InstanceToEvents, theInstanceList); AddInstancesFromHash(m_InstanceToHandlers, theInstanceList); - AddInstancesFromHash(m_InstanceToReferences, theInstanceList); + AddInstancesFromQHash(m_InstanceToReferences, theInstanceList); vector<TInstanceHandle> theInstances; theInstances.reserve(theInstanceList.size()); @@ -2652,9 +2870,9 @@ public: end = theInstances.end(); iter != end; ++iter) { TInstanceHandle instHandle = *iter; - Option<TCharStr> theType(GetTypeForCanonicalInstance(*iter)); + Option<QString> theType(GetTypeForCanonicalInstance(*iter)); if (theType.hasValue()) { - IDOMWriter::Scope __instanceElem(inWriter, theType->wide_str()); + IDOMWriter::Scope __instanceElem(inWriter, theType); SerializeInstance(inWriter, *iter); } } @@ -2666,18 +2884,17 @@ public: { if (!inReader.Att("NextId", m_NextId)) m_NextId = 1; - m_ObjectName = L""; + m_ObjectName.clear(); SerializeCategories(inReader); IDOMReader::Scope __instanceGatherScope(inReader); for (bool success = inReader.MoveToFirstChild(); success; success = inReader.MoveToNextSibling()) { - const wchar_t *elemName = inReader.GetElementName(); + QString elemName = inReader.GetElementName(); TStrInstanceMap::iterator find = m_CanonicalTypeToInstances.find(elemName); - if (find == m_CanonicalTypeToInstances.end()) { + if (find == m_CanonicalTypeToInstances.end()) continue; - } - SerializeInstance(inReader, find->second); + SerializeInstance(inReader, *find); } } @@ -2701,10 +2918,10 @@ public: // This needs to be undoable so we have to do this through a slightly different // system than we did before. void LoadInstance(IDOMReader &inReader, Qt3DSDMInstanceHandle inInstance, - const TCharStr &inObjectName, + const QString &inObjectName, std::vector<SMetaDataLoadWarning> &outWarnings) override { - const wchar_t *theAtt; + QString theAtt; vector<Qt3DSDMMetaDataPropertyHandle> theProperties; vector<Qt3DSDMEventHandle> theEvents; vector<Qt3DSDMHandlerHandle> theHandlers; @@ -2712,15 +2929,15 @@ public: m_ObjectName = inObjectName; for (bool success = inReader.MoveToFirstChild(); success; success = inReader.MoveToNextSibling()) { - if (AreEqual(inReader.GetElementName(), L"Category")) { + if (inReader.GetElementName() == QLatin1String("Category")) { SCategoryInfo theInfo; SerializeItem(inReader, theInfo); Qt3DSDMCategoryHandle theCategoryInfo(GetOrCreateCategory(theInfo.m_Name).first); SetCategoryInfo(theCategoryInfo, theInfo.m_Icon, theInfo.m_HighlightIcon, theInfo.m_Description); - } else if (AreEqual(inReader.GetElementName(), L"Property")) { + } else if (inReader.GetElementName() == QLatin1String("Property")) { SMetaDataPropertyInfo theInfo(inInstance); - if (inReader.Att(L"name", theAtt)) { + if (inReader.Att(QStringLiteral("name"), theAtt)) { Qt3DSDMMetaDataPropertyHandle theProperty( GetOrCreateSpecificMetaDataProperty(inInstance, theAtt)); SerializeItem(inReader, theInfo, theProperty); @@ -2737,9 +2954,9 @@ public: outWarnings.push_back( SMetaDataLoadWarning(MetaDataLoadWarningType::InvalidProperty, MetaDataLoadWarningMessage::MissingName)); - } else if (AreEqual(inReader.GetElementName(), L"Event")) { + } else if (inReader.GetElementName() == QLatin1String("Event")) { SEvent theInfo(inInstance); - if (inReader.Att(L"name", theAtt)) { + if (inReader.Att(QStringLiteral("name"), theAtt)) { Qt3DSDMEventHandle theEvent(GetOrCreateSpecificEvent(inInstance, theAtt)); SerializeItem(inReader, theInfo, theEvent); SetEventInfo(theEvent, theInfo.m_Name, theInfo.m_FormalName, theInfo.m_Category, @@ -2749,8 +2966,8 @@ public: outWarnings.push_back( SMetaDataLoadWarning(MetaDataLoadWarningType::InvalidEvent, MetaDataLoadWarningMessage::MissingName)); - } else if (AreEqual(inReader.GetElementName(), L"Handler")) { - if (inReader.Att(L"name", theAtt)) { + } else if (inReader.GetElementName() == QLatin1String("Handler")) { + if (inReader.Att(QStringLiteral("name"), theAtt)) { Qt3DSDMHandlerHandle theHandler(GetOrCreateSpecificHandler(inInstance, theAtt)); SHandler theInfo(inInstance); SerializeHandlerItem(inReader, theInfo); @@ -2779,8 +2996,8 @@ public: outWarnings.push_back( SMetaDataLoadWarning(MetaDataLoadWarningType::InvalidHandler, MetaDataLoadWarningMessage::MissingName)); - } else if (AreEqual(inReader.GetElementName(), L"Reference")) { - const wchar_t *theValue; + } else if (inReader.GetElementName() == QLatin1String("Reference")) { + QString theValue; if (inReader.Value(theValue)) AddReference(inInstance, theValue); } else { @@ -2802,19 +3019,8 @@ public: SerializeInstance(inWriter, inInstance); } - // Helper to convert char to wchar_t - eastl::basic_string<qt3ds::foundation::TWCharEASTLConverter::TCharType> m_Buf; - const wchar_t *ConvertChar(const char *inName) - { - if (inName && *inName) { - qt3ds::foundation::ConvertUTF(inName, 0, m_Buf); - return reinterpret_cast<const wchar_t *>(m_Buf.c_str()); - } - return NULL; - } - - void LoadEffectInstance(const char *inShaderFile, Qt3DSDMInstanceHandle inInstance, - const TCharStr &inObjectName, + void LoadEffectInstance(const QString &inShaderFile, Qt3DSDMInstanceHandle inInstance, + const QString &inObjectName, std::vector<SMetaDataLoadWarning> &outWarnings, QFile &inStream) override { @@ -2827,48 +3033,48 @@ public: } } - bool IsEffectInstanceRegistered(const char *inName) override + bool IsEffectInstanceRegistered(const QString &inName) override { - return m_EffectMap.find(Intern(inName)) != m_EffectMap.end(); + return m_EffectMap.find(inName) != m_EffectMap.end(); } inline qt3ds::render::NVRenderTextureFormats::Enum - ConvertTypeAndFormatToTextureFormat(const char8_t *inType, const char8_t *inFormat) + ConvertTypeAndFormatToTextureFormat(const QString &inType, const QString &inFormat) { qt3ds::render::NVRenderTextureFormats::Enum retval = qt3ds::render::NVRenderTextureFormats::RGBA8; - if (AreEqual(inFormat, "source")) + if (inFormat == QLatin1String("source")) retval = qt3ds::render::NVRenderTextureFormats::Unknown; - else if (AreEqual(inFormat, "depth24stencil8")) + else if (inFormat == QLatin1String("depth24stencil8")) retval = qt3ds::render::NVRenderTextureFormats::Depth24Stencil8; else { - if (AreEqual(inType, "ubyte")) { - if (AreEqual(inFormat, "rgb")) + if (inType == QLatin1String("ubyte")) { + if (inFormat == QLatin1String("rgb")) retval = qt3ds::render::NVRenderTextureFormats::RGB8; - else if (AreEqual(inFormat, "rgba")) + else if (inFormat == QLatin1String("rgba")) retval = qt3ds::render::NVRenderTextureFormats::RGBA8; - else if (AreEqual(inFormat, "alpha")) + else if (inFormat == QLatin1String("alpha")) retval = qt3ds::render::NVRenderTextureFormats::Alpha8; - else if (AreEqual(inFormat, "lum")) + else if (inFormat == QLatin1String("lum")) retval = qt3ds::render::NVRenderTextureFormats::Luminance8; - else if (AreEqual(inFormat, "lum_alpha")) + else if (inFormat == QLatin1String("lum_alpha")) retval = qt3ds::render::NVRenderTextureFormats::LuminanceAlpha8; - else if (AreEqual(inFormat, "rg")) + else if (inFormat == QLatin1String("rg")) retval = qt3ds::render::NVRenderTextureFormats::RG8; - } else if (AreEqual(inType, "ushort")) { - if (AreEqual(inFormat, "rgb")) + } else if (inType == QLatin1String("ushort")) { + if (inFormat == QLatin1String("rgb")) retval = qt3ds::render::NVRenderTextureFormats::RGB565; - else if (AreEqual(inFormat, "rgba")) + else if (inFormat == QLatin1String("rgba")) retval = qt3ds::render::NVRenderTextureFormats::RGBA5551; - } else if (AreEqual(inType, "fp16")) { - if (AreEqual(inFormat, "rgba")) + } else if (inType == QLatin1String("fp16")) { + if (inFormat == QLatin1String("rgba")) retval = qt3ds::render::NVRenderTextureFormats::RGBA16F; - else if (AreEqual(inFormat, "rg")) + else if (inFormat == QLatin1String("rg")) retval = qt3ds::render::NVRenderTextureFormats::RG16F; - } else if (AreEqual(inType, "fp32")) { - if (AreEqual(inFormat, "rgba")) + } else if (inType == QLatin1String("fp32")) { + if (inFormat == QLatin1String("rgba")) retval = qt3ds::render::NVRenderTextureFormats::RGBA32F; - else if (AreEqual(inFormat, "rg")) + else if (inFormat == QLatin1String("rg")) retval = qt3ds::render::NVRenderTextureFormats::RG32F; } else { QT3DS_ASSERT(false); @@ -2880,11 +3086,11 @@ public: } static inline qt3ds::render::NVRenderTextureMagnifyingOp::Enum - ConvertFilterToMagOp(const char8_t *inFilter) + ConvertFilterToMagOp(const QString &inFilter) { - if (AreEqual(inFilter, "linear")) + if (inFilter == QLatin1String("linear")) return qt3ds::render::NVRenderTextureMagnifyingOp::Linear; - if (IsTrivial(inFilter) || AreEqual(inFilter, "nearest")) + if (inFilter.isEmpty() || inFilter == QLatin1String("nearest")) return qt3ds::render::NVRenderTextureMagnifyingOp::Nearest; else { QT3DS_ASSERT(false); @@ -2895,20 +3101,20 @@ public: } static inline qt3ds::render::NVRenderTextureMinifyingOp::Enum - ConvertFilterToMinOp(const char8_t *inFilter) + ConvertFilterToMinOp(const QString &inFilter) { // we make the decision based on the texture usage - if (AreEqual(inFilter, "linear")) + if (inFilter == QLatin1String("linear")) return qt3ds::render::NVRenderTextureMinifyingOp::Linear; - if (AreEqual(inFilter, "nearest")) + if (inFilter == QLatin1String("nearest")) return qt3ds::render::NVRenderTextureMinifyingOp::Nearest; - if (AreEqual(inFilter, "linearMipmapLinear")) + if (inFilter == QLatin1String("linearMipmapLinear")) return qt3ds::render::NVRenderTextureMinifyingOp::LinearMipmapLinear; - if (AreEqual(inFilter, "nearestMipmapNearest")) + if (inFilter == QLatin1String("nearestMipmapNearest")) return qt3ds::render::NVRenderTextureMinifyingOp::NearestMipmapNearest; - if (AreEqual(inFilter, "nearestMipmapLinear")) + if (inFilter == QLatin1String("nearestMipmapLinear")) return qt3ds::render::NVRenderTextureMinifyingOp::NearestMipmapLinear; - if (AreEqual(inFilter, "linearMipmapNearest")) + if (inFilter == QLatin1String("linearMipmapNearest")) return qt3ds::render::NVRenderTextureMinifyingOp::LinearMipmapNearest; else { QT3DS_ASSERT(false); @@ -2919,11 +3125,11 @@ public: } static inline qt3ds::render::NVRenderTextureCoordOp::Enum - ConvertTextureCoordOp(const char8_t *inWrap) + ConvertTextureCoordOp(const QString &inWrap) { - if (IsTrivial(inWrap) || AreEqual(inWrap, "clamp")) + if (inWrap.isEmpty() || inWrap == QLatin1String("clamp")) return qt3ds::render::NVRenderTextureCoordOp::ClampToEdge; - if (AreEqual(inWrap, "repeat")) + if (inWrap == QLatin1String("repeat")) return qt3ds::render::NVRenderTextureCoordOp::Repeat; else { QT3DS_ASSERT(false); @@ -2934,26 +3140,26 @@ public: } static inline qt3ds::render::NVRenderTextureTypeValue::Enum - ConvertTextureType(const char8_t *inTexType) + ConvertTextureType(const QString &inTexType) { // this usually comes from a MDL description file - if (IsTrivial(inTexType)) + if (inTexType.isEmpty()) return qt3ds::render::NVRenderTextureTypeValue::Unknown; - if (AreEqual(inTexType, "environment")) + if (inTexType == QLatin1String("environment")) return qt3ds::render::NVRenderTextureTypeValue::Environment; - if (AreEqual(inTexType, "diffuse")) + if (inTexType == QLatin1String("diffuse")) return qt3ds::render::NVRenderTextureTypeValue::Diffuse; - if (AreEqual(inTexType, "specular")) + if (inTexType == QLatin1String("specular")) return qt3ds::render::NVRenderTextureTypeValue::Specular; - if (AreEqual(inTexType, "bump")) + if (inTexType == QLatin1String("bump")) return qt3ds::render::NVRenderTextureTypeValue::Bump; - if (AreEqual(inTexType, "displacement")) + if (inTexType == QLatin1String("displacement")) return qt3ds::render::NVRenderTextureTypeValue::Displace; - if (AreEqual(inTexType, "shadow")) + if (inTexType == QLatin1String("shadow")) return qt3ds::render::NVRenderTextureTypeValue::LightmapShadow; - if (AreEqual(inTexType, "emissive")) + if (inTexType == QLatin1String("emissive")) return qt3ds::render::NVRenderTextureTypeValue::Emissive; - if (AreEqual(inTexType, "emissive_mask")) + if (inTexType == QLatin1String("emissive_mask")) return qt3ds::render::NVRenderTextureTypeValue::Emissive2; else { return qt3ds::render::NVRenderTextureTypeValue::Unknown; @@ -2961,13 +3167,13 @@ public: } static inline qt3ds::render::NVRenderSrcBlendFunc::Enum - ConvertToSrcBlendFunc(const char8_t *inFilter) + ConvertToSrcBlendFunc(const QString &inFilter) { - if (AreEqual(inFilter, "SrcAlpha")) + if (inFilter == QLatin1String("SrcAlpha")) return qt3ds::render::NVRenderSrcBlendFunc::SrcAlpha; - if (AreEqual(inFilter, "OneMinusSrcAlpha")) + if (inFilter == QLatin1String("OneMinusSrcAlpha")) return qt3ds::render::NVRenderSrcBlendFunc::OneMinusSrcAlpha; - if (AreEqual(inFilter, "One")) + if (inFilter == QLatin1String("One")) return qt3ds::render::NVRenderSrcBlendFunc::One; else { QT3DS_ASSERT(false); @@ -2978,13 +3184,13 @@ public: } static inline qt3ds::render::NVRenderDstBlendFunc::Enum - ConvertToDstBlendFunc(const char8_t *inFilter) + ConvertToDstBlendFunc(const QString &inFilter) { - if (AreEqual(inFilter, "SrcAlpha")) + if (inFilter == QLatin1String("SrcAlpha")) return qt3ds::render::NVRenderDstBlendFunc::SrcAlpha; - if (AreEqual(inFilter, "OneMinusSrcAlpha")) + if (inFilter == QLatin1String("OneMinusSrcAlpha")) return qt3ds::render::NVRenderDstBlendFunc::OneMinusSrcAlpha; - if (AreEqual(inFilter, "One")) + if (inFilter == QLatin1String("One")) return qt3ds::render::NVRenderDstBlendFunc::One; else { QT3DS_ASSERT(false); @@ -2994,9 +3200,9 @@ public: } } - static inline qt3ds::render::NVRenderState::Enum ConvertRenderState(const char8_t *inState) + static inline qt3ds::render::NVRenderState::Enum ConvertRenderState(const QString &inState) { - if (AreEqual(inState, "Stencil")) + if (inState == QLatin1String("Stencil")) return qt3ds::render::NVRenderState::StencilTest; else { QT3DS_ASSERT(false); @@ -3007,13 +3213,13 @@ public: } static inline qt3ds::render::NVRenderImageAccessType::Enum - ConvertToImageAccessType(const char8_t *inAccess) + ConvertToImageAccessType(const QString &inAccess) { - if (AreEqual(inAccess, "read")) + if (inAccess == QLatin1String("read")) return qt3ds::render::NVRenderImageAccessType::Read; - if (AreEqual(inAccess, "write")) + if (inAccess == QLatin1String("write")) return qt3ds::render::NVRenderImageAccessType::Write; - if (AreEqual(inAccess, "readwrite")) + if (inAccess == QLatin1String("readwrite")) return qt3ds::render::NVRenderImageAccessType::ReadWrite; else QT3DS_ASSERT(false); @@ -3021,13 +3227,13 @@ public: return qt3ds::render::NVRenderImageAccessType::ReadWrite; } - static inline size_t GetTypeSize(const char8_t *inType) + static inline size_t GetTypeSize(const QString &inType) { - if (AreEqual(inType, "uint")) + if (inType == QLatin1String("uint")) return sizeof(QT3DSU32); - else if (AreEqual(inType, "int")) + else if (inType == QLatin1String("int")) return sizeof(QT3DSI32); - else if (AreEqual(inType, "uvec4")) + else if (inType == QLatin1String("uvec4")) return sizeof(QT3DSU32) * 4; else QT3DS_ASSERT(false); @@ -3036,11 +3242,11 @@ public: } inline qt3ds::render::NVRenderBufferBindValues::Enum - ConvertFormatToBufferBindFlags(const char8_t *inFormat) + ConvertFormatToBufferBindFlags(const QString &inFormat) { - if (AreEqual(inFormat, "storage")) + if (inFormat == QLatin1String("storage")) return qt3ds::render::NVRenderBufferBindValues::Storage; - else if (AreEqual(inFormat, "indirect")) + else if (inFormat == QLatin1String("indirect")) return qt3ds::render::NVRenderBufferBindValues::Draw_Indirect; else QT3DS_ASSERT(false); @@ -3048,27 +3254,26 @@ public: return qt3ds::render::NVRenderBufferBindValues::Unknown; } - static inline void AppendShaderUniform(const char8_t *type, const char8_t *name, - eastl::string &shaderPrefix) + static inline void AppendShaderUniform(const QString &type, const QString &name, + QString &shaderPrefix) { - shaderPrefix.append("uniform "); - shaderPrefix.append(type); - shaderPrefix.append(" "); - shaderPrefix.append(name); - shaderPrefix.append(";\n"); + shaderPrefix += QLatin1String("uniform ") + type + QLatin1Char(' ') + + name + QLatin1String(";\n"); } static inline void AppendShaderCode( - const char8_t *inCode, Qt3DSDMStr &ioStr, - eastl::basic_string<qt3ds::foundation::TWCharEASTLConverter::TCharType> - &inConvertBuffer) + const char8_t *inCode, QString &ioStr) { - qt3ds::foundation::ConvertUTF(inCode, 0, inConvertBuffer); - ioStr.append(inConvertBuffer); + ioStr += QString::fromLatin1(inCode); + } + static inline void AppendShaderCode( + const QString &inCode, QString &ioStr) + { + ioStr += inCode; } void HideEffectProperty(Qt3DSDMInstanceHandle inInstance, const char8_t *inParamName) { Qt3DSDMMetaDataPropertyHandle theProp = - GetSpecificMetaDataProperty(inInstance, Intern(inParamName)); + GetSpecificMetaDataProperty(inInstance, inParamName); if (theProp.Valid()) { SMetaDataPropertyInfo theInfo = GetMetaDataPropertyInfo(theProp); SetMetaDataPropertyInfo(theProp, theInfo.m_Name, theInfo.m_FormalName, @@ -3079,26 +3284,23 @@ public: } } - static inline void GetShaderName(const TCharStr &inObjectName, - const char8_t *inShaderSpecificName, - eastl::string &outShaderName) + static inline void GetShaderName(const QString &inObjectName, + const QString &inShaderSpecificName, + QString &outShaderName) { - outShaderName.clear(); - qt3ds::foundation::ConvertUTF(inObjectName.c_str(), 0, outShaderName); - outShaderName.append(" - "); - outShaderName.append(inShaderSpecificName); + outShaderName = QStringLiteral("%1 - %2").arg(inObjectName).arg(inShaderSpecificName); } void LoadDynamicObjectProperties(IDOMReader &inStream, SMetaDataDynamicObjectImpl &ioObject, - Qt3DSDMInstanceHandle inInstance, const TCharStr &inObjectName, + Qt3DSDMInstanceHandle inInstance, const QString &inObjectName, std::vector<SMetaDataLoadWarning> &outWarnings, - eastl::string &shaderPrefix) + QString &shaderPrefix) { using namespace qt3ds::render::dynamic; ioObject.m_Properties.clear(); ioObject.ClearEnumValueNames(); IDOMReader::Scope __readerScope(inStream); - if (inStream.MoveToFirstChild("MetaData")) { + if (inStream.MoveToFirstChild(QStringLiteral("MetaData"))) { { IDOMReader::Scope __readerScope(inStream); LoadInstance(inStream, inInstance, inObjectName, outWarnings); @@ -3107,52 +3309,59 @@ public: vector<Qt3DSDMMetaDataPropertyHandle> theProperties; GetSpecificMetaDataProperties(inInstance, theProperties); size_t propIdx = 0, propEnd = theProperties.size(); - for (bool success = inStream.MoveToFirstChild("Property"); success && propIdx < propEnd; - success = inStream.MoveToNextSibling("Property"), ++propIdx) { - ioObject.m_Properties.push_back(); + for (bool success = inStream.MoveToFirstChild(QStringLiteral("Property")); + success && propIdx < propEnd; + success = inStream.MoveToNextSibling(QStringLiteral("Property")), ++propIdx) { + ioObject.m_Properties.push_back(SPropertyDefinition()); SPropertyDefinition &theNewDefinition = ioObject.m_Properties.back(); SMetaDataPropertyInfo theInfo(GetMetaDataPropertyInfo(theProperties[propIdx])); - theNewDefinition.m_Name = - m_StringTable.GetRenderStringTable().RegisterStr(theInfo.m_Name.c_str()); - const char8_t *xmlName; - inStream.Att("name", xmlName); - if (AreEqual(xmlName, theNewDefinition.m_Name.c_str())) { + theNewDefinition.m_Name = theInfo.m_Name; + QString name; + inStream.Att(QStringLiteral("name"), name); + if (name == theNewDefinition.m_Name) { switch (theInfo.GetDataType()) { case DataModelDataType::Bool: theNewDefinition.m_DataType = qt3ds::render::NVRenderShaderDataTypes::QT3DSRenderBool; - AppendShaderUniform("bool", theNewDefinition.m_Name.c_str(), shaderPrefix); + AppendShaderUniform(QStringLiteral("bool"), theNewDefinition.m_Name, + shaderPrefix); break; case DataModelDataType::Long: theNewDefinition.m_DataType = qt3ds::render::NVRenderShaderDataTypes::QT3DSI32; - AppendShaderUniform("int", theNewDefinition.m_Name.c_str(), shaderPrefix); + AppendShaderUniform(QStringLiteral("int"), theNewDefinition.m_Name, + shaderPrefix); break; case DataModelDataType::Float2: theNewDefinition.m_DataType = qt3ds::render::NVRenderShaderDataTypes::QT3DSVec2; - AppendShaderUniform("vec2", theNewDefinition.m_Name.c_str(), shaderPrefix); + AppendShaderUniform(QStringLiteral("vec2"), theNewDefinition.m_Name, + shaderPrefix); break; case DataModelDataType::Float3: theNewDefinition.m_DataType = qt3ds::render::NVRenderShaderDataTypes::QT3DSVec3; - AppendShaderUniform("vec3", theNewDefinition.m_Name.c_str(), shaderPrefix); + AppendShaderUniform(QStringLiteral("vec3"), theNewDefinition.m_Name, + shaderPrefix); break; case DataModelDataType::String: if (theInfo.m_CompleteType == CompleteMetaDataType::Texture) { theNewDefinition.m_DataType = qt3ds::render::NVRenderShaderDataTypes::NVRenderTexture2DPtr; - const char8_t *filter = "linear", *minFilter = "linear", - *clamp = "clamp", *usage = "", *path = ""; - if (inStream.Att("filter", filter)) + QString filter = QStringLiteral("linear"); + QString minFilter = QStringLiteral("linear"); + QString clamp = QStringLiteral("clamp"); + QString usage; + QString path; + if (inStream.Att(QStringLiteral("filter"), filter)) theNewDefinition.m_MagFilterOp = ConvertFilterToMagOp(filter); - if (inStream.Att("minfilter", minFilter)) + if (inStream.Att(QStringLiteral("minfilter"), minFilter)) theNewDefinition.m_MinFilterOp = ConvertFilterToMinOp(minFilter); - if (inStream.Att("clamp", clamp)) + if (inStream.Att(QStringLiteral("clamp"), clamp)) theNewDefinition.m_CoordOp = ConvertTextureCoordOp(clamp); - if (inStream.Att("usage", usage)) + if (inStream.Att(QStringLiteral("usage"), usage)) theNewDefinition.m_TexUsageType = ConvertTextureType(usage); - if (inStream.Att("default", path)) { + if (inStream.Att(QStringLiteral("default"), path)) { TDataStrPtr theDataStr( theInfo.m_DefaultValue.getData<TDataStrPtr>()); theNewDefinition.m_ImagePath = @@ -3163,79 +3372,81 @@ public: // Output macro so we can change the set of variables used for this // independent of the // meta data system. - shaderPrefix.append("SNAPPER_SAMPLER2D("); - shaderPrefix.append(theNewDefinition.m_Name.c_str()); - shaderPrefix.append(", "); - shaderPrefix.append(theNewDefinition.m_Name.c_str()); - shaderPrefix.append(", "); + shaderPrefix.append(QLatin1String("SNAPPER_SAMPLER2D(")); + shaderPrefix.append(theNewDefinition.m_Name); + shaderPrefix.append(QLatin1String(", ")); + shaderPrefix.append(theNewDefinition.m_Name); + shaderPrefix.append(QLatin1String(", ")); shaderPrefix.append(filter); - shaderPrefix.append(", "); + shaderPrefix.append(QLatin1String(", ")); shaderPrefix.append(clamp); - shaderPrefix.append(", "); - shaderPrefix.append("false )\n"); + shaderPrefix.append(QLatin1String(", ")); + shaderPrefix.append(QLatin1String("false )\n")); } else if (theInfo.m_CompleteType == CompleteMetaDataType::StringList) { theNewDefinition.m_DataType = qt3ds::render::NVRenderShaderDataTypes::QT3DSI32; const TMetaDataStringList &theList = qt3dsdm::get<TMetaDataStringList>(theInfo.m_MetaDataData); ioObject.m_EnumValueNames.push_back( - new eastl::vector<qt3ds::foundation::CRegisteredString>()); - eastl::vector<qt3ds::foundation::CRegisteredString> &theBack = - *ioObject.m_EnumValueNames.back(); + new QStringList()); + QStringList &theBack = *ioObject.m_EnumValueNames.back(); for (QT3DSU32 idx = 0, end = (QT3DSU32)theList.size(); idx < end; ++idx) - theBack.push_back(m_StringTable.GetRenderStringTable().RegisterStr( - theList[idx].c_str())); - theNewDefinition.m_EnumValueNames = VecToCRef(theBack); + theBack.push_back(QString::fromWCharArray(theList[idx].wide_str())); + theNewDefinition.m_EnumValueNames = theBack; theNewDefinition.m_IsEnumProperty = true; - AppendShaderUniform("int", theNewDefinition.m_Name.c_str(), + AppendShaderUniform(QStringLiteral("int"), theNewDefinition.m_Name, shaderPrefix); } else if (theInfo.m_CompleteType == CompleteMetaDataType::Image2D) { theNewDefinition.m_DataType = qt3ds::render::NVRenderShaderDataTypes::NVRenderImage2DPtr; - const char8_t *format = "", *binding = "", *access = "readonly"; - shaderPrefix.append("layout("); - inStream.Att("format", format); + QString format; + QString binding; + QString access = QStringLiteral("readonly"); + shaderPrefix.append(QLatin1String("layout(")); + inStream.Att(QStringLiteral("format"), format); shaderPrefix.append(format); - if (inStream.Att("binding", binding)) { - shaderPrefix.append(", binding = "); + if (inStream.Att(QStringLiteral("binding"), binding)) { + shaderPrefix.append(QLatin1String(", binding = ")); shaderPrefix.append(binding); } - shaderPrefix.append(") "); + shaderPrefix.append(QLatin1String(") ")); // if we have format layout we cannot set an additional access qualifier - if (inStream.Att("access", access) && !AreEqual(format, "")) + if (inStream.Att(QStringLiteral("access"), access) && !format.isEmpty()) shaderPrefix.append(access); - shaderPrefix.append(" uniform image2D "); - shaderPrefix.append(theNewDefinition.m_Name.c_str()); - shaderPrefix.append(";\n"); + shaderPrefix.append(QLatin1String(" uniform image2D ")); + shaderPrefix.append(theNewDefinition.m_Name); + shaderPrefix.append(QLatin1String(";\n")); } else if (theInfo.m_CompleteType == CompleteMetaDataType::Buffer) { theNewDefinition.m_DataType = qt3ds::render::NVRenderShaderDataTypes::NVRenderDataBufferPtr; - const char8_t *align = "std140", *usage = "storage", *binding = "", - *format = "float"; - shaderPrefix.append("layout("); - - inStream.Att("format", format); - inStream.Att("usage", usage); - if (AreEqual(usage, "storage")) { - inStream.Att("align", align); + QString align = QStringLiteral("std140"); + QString usage = QStringLiteral("storage"); + QString binding; + QString format = QStringLiteral("float"); + shaderPrefix.append(QLatin1String("layout(")); + + inStream.Att(QStringLiteral("format"), format); + inStream.Att(QStringLiteral("usage"), usage); + if (usage == QLatin1String("storage")) { + inStream.Att(QStringLiteral("align"), align); shaderPrefix.append(align); - if (inStream.Att("binding", binding)) { - shaderPrefix.append(", binding = "); + if (inStream.Att(QStringLiteral("binding"), binding)) { + shaderPrefix.append(QLatin1String(", binding = ")); shaderPrefix.append(binding); } - shaderPrefix.append(") "); + shaderPrefix.append(QLatin1String(") ")); - shaderPrefix.append("buffer "); - shaderPrefix.append(theNewDefinition.m_Name.c_str()); - shaderPrefix.append("\n{ \n"); + shaderPrefix.append(QLatin1String("buffer ")); + shaderPrefix.append(theNewDefinition.m_Name); + shaderPrefix.append(QLatin1String("\n{ \n")); shaderPrefix.append(format); - shaderPrefix.append(" "); - shaderPrefix.append(theNewDefinition.m_Name.c_str()); - shaderPrefix.append("_data[]; \n};\n"); + shaderPrefix.append(QLatin1String(" ")); + shaderPrefix.append(theNewDefinition.m_Name); + shaderPrefix.append(QLatin1String("_data[]; \n};\n")); } else { // currently we only handle storage counters QT3DS_ASSERT(false); @@ -3247,7 +3458,8 @@ public: // Fallthrough intentional case DataModelDataType::Float: theNewDefinition.m_DataType = qt3ds::render::NVRenderShaderDataTypes::QT3DSF32; - AppendShaderUniform("float", theNewDefinition.m_Name.c_str(), shaderPrefix); + AppendShaderUniform(QStringLiteral("float"), theNewDefinition.m_Name, + shaderPrefix); break; } } else { @@ -3261,7 +3473,7 @@ public: } void LoadDynamicObjectShaders(IDOMReader &inStream, SMetaDataDynamicObjectImpl &ioObject, - eastl::string &shaderPrefix, const TCharStr &inObjectName) + QString &shaderPrefix, const QString &inObjectName) { eastl::string theShaderNameStr; eastl::string theShaderTypeStr; @@ -3283,30 +3495,29 @@ public: for (bool success = inStream.MoveToFirstChild(); success; success = inStream.MoveToNextSibling()) { IDOMReader::Scope __shaderScope(inStream); - const char8_t *elemName = inStream.GetNarrowElementName(); + const QString elemName = inStream.GetElementName(); // If this is neither a compute shader nor a normal shader, go on and ignore // element. - if (!(AreEqual(elemName, "Shader") || AreEqual(elemName, "ComputeShader"))) + if (!(elemName == QLatin1String("Shader") + || elemName == QLatin1String("ComputeShader"))) { continue; + } - ioObject.m_Shaders.push_back(); + ioObject.m_Shaders.push_back(SMetaDataShader()); SMetaDataShader &theShader = ioObject.m_Shaders.back(); - qt3ds::foundation::ConvertUTF(theShaderTypeStr.c_str(), theShaderTypeStr.size(), - theShader.m_Type); - qt3ds::foundation::ConvertUTF(theShaderVersionStr.c_str(), - theShaderVersionStr.size(), theShader.m_Version); + theShader.m_Type = QString::fromLatin1(theShaderTypeStr.c_str()); + theShader.m_Version = QString::fromLatin1(theShaderVersionStr.c_str()); + const char8_t *theName = ""; char8_t theITOABuffer[64] = { 0 }; if (!inStream.Att("name", theName)) { sprintf(theITOABuffer, "%d", (int)ioObject.m_Shaders.size() - 1); theName = theITOABuffer; } - GetShaderName(inObjectName, theName, theShaderNameStr); - qt3ds::foundation::ConvertUTF(theShaderNameStr.c_str(), theShaderNameStr.size(), - theShader.m_Name); + GetShaderName(inObjectName, theName, theShader.m_Name); - if (AreEqual(elemName, "Shader")) { + if (elemName == QLatin1String("Shader")) { const char8_t *shaderShared = ""; inStream.ChildValue("Shared", shaderShared); const char8_t *vertexCode = ""; @@ -3320,31 +3531,28 @@ public: const char8_t *geomCode = ""; inStream.ChildValue("GeometryShader", geomCode); - AppendShaderCode(shaderPrefix.c_str(), theShader.m_Code, theConvertBuffer); - AppendShaderCode(globalShared, theShader.m_Code, theConvertBuffer); - AppendShaderCode(shaderShared, theShader.m_Code, theConvertBuffer); - AppendShaderCode("\n#ifdef VERTEX_SHADER\n", theShader.m_Code, - theConvertBuffer); - AppendShaderCode(globalVertexShared, theShader.m_Code, theConvertBuffer); - AppendShaderCode(vertexCode, theShader.m_Code, theConvertBuffer); - AppendShaderCode("\n#endif\n", theShader.m_Code, theConvertBuffer); + AppendShaderCode(shaderPrefix, theShader.m_Code); + AppendShaderCode(globalShared, theShader.m_Code); + AppendShaderCode(shaderShared, theShader.m_Code); + AppendShaderCode("\n#ifdef VERTEX_SHADER\n", theShader.m_Code); + AppendShaderCode(globalVertexShared, theShader.m_Code); + AppendShaderCode(vertexCode, theShader.m_Code); + AppendShaderCode("\n#endif\n", theShader.m_Code); if (!IsTrivial(geomCode)) { - AppendShaderCode("\n#ifdef USER_GEOMETRY_SHADER\n", theShader.m_Code, - theConvertBuffer); - AppendShaderCode(geomCode, theShader.m_Code, theConvertBuffer); - AppendShaderCode("\n#endif\n", theShader.m_Code, theConvertBuffer); + AppendShaderCode("\n#ifdef USER_GEOMETRY_SHADER\n", theShader.m_Code); + AppendShaderCode(geomCode, theShader.m_Code); + AppendShaderCode("\n#endif\n", theShader.m_Code); theShader.m_HasGeomShader = true; } - AppendShaderCode("\n#ifdef FRAGMENT_SHADER\n", theShader.m_Code, - theConvertBuffer); - AppendShaderCode(globalFragmentShared, theShader.m_Code, theConvertBuffer); - AppendShaderCode(fragmentCode, theShader.m_Code, theConvertBuffer); - AppendShaderCode("\n#endif\n", theShader.m_Code, theConvertBuffer); - } else if (AreEqual(elemName, "ComputeShader")) { + AppendShaderCode("\n#ifdef FRAGMENT_SHADER\n", theShader.m_Code); + AppendShaderCode(globalFragmentShared, theShader.m_Code); + AppendShaderCode(fragmentCode, theShader.m_Code); + AppendShaderCode("\n#endif\n", theShader.m_Code); + } else if (elemName == QLatin1String("ComputeShader")) { const char8_t *shaderCode = ""; inStream.Value(shaderCode); theShader.m_IsComputeShader = true; - AppendShaderCode(shaderCode, theShader.m_Code, theConvertBuffer); + AppendShaderCode(shaderCode, theShader.m_Code); } } } @@ -3429,13 +3637,13 @@ public: // Reloads an effect if one is already loaded so we can replace the existing effect definition void LoadEffectXML(IDOMReader &inStream, Qt3DSDMInstanceHandle inInstance, - const TCharStr &inObjectName, + const QString &inObjectName, std::vector<SMetaDataLoadWarning> &outWarnings, - const TCharStr &inSourcePath) override + const QString &inSourcePath) override { using namespace qt3ds::render::dynamic; - std::pair<TEffectMap::iterator, bool> theInserter = - m_EffectMap.insert(std::make_pair(Intern(inObjectName), SMetaDataEffectImpl())); + TEffectMap::iterator theInserter = + m_EffectMap.insert(inObjectName, SMetaDataEffectImpl()); /*if ( inStream.MoveToFirstChild( "Effect" ) == false ) { outWarnings.push_back( SMetaDataLoadWarning( MetaDataLoadWarningType::Unknown, @@ -3443,9 +3651,9 @@ public: missing top level Effect tag" ) ); return; }*/ - eastl::string shaderPrefix = "#include \"effect.glsllib\"\n"; + QString shaderPrefix = "#include \"effect.glsllib\"\n"; - SMetaDataEffectImpl &theEffect = theInserter.first->second; + SMetaDataEffectImpl &theEffect = *theInserter; m_ObjectName = inObjectName; theEffect.m_Name = inObjectName; theEffect.m_SourcePath = inSourcePath; @@ -3454,14 +3662,14 @@ public: shaderPrefix); theEffect.m_Shaders.clear(); LoadDynamicObjectShaders(inStream, theEffect, shaderPrefix, inObjectName); - eastl::string theShaderNameStr; + QString theShaderNameStr; { IDOMReader::Scope __readerScope(inStream); if (inStream.MoveToFirstChild("Passes")) { for (bool success = inStream.MoveToFirstChild(); success; success = inStream.MoveToNextSibling()) { IDOMReader::Scope __passScope(inStream); - if (AreEqual("Pass", inStream.GetNarrowElementName())) { + if (QLatin1String("Pass") == inStream.GetElementName()) { bool drawIndirect = false; const char8_t *shader = "", *input = "[source]", *output = "[dest]", *outputFormat = "rgba"; @@ -3477,26 +3685,25 @@ public: else theEffect.m_EffectCommands.push_back( new SBindBuffer( - m_StringTable.GetRenderStringTable().RegisterStr(output), + output, false)); GetShaderName(inObjectName, shader, theShaderNameStr); theEffect.m_EffectCommands.push_back( - new SBindShader(m_StringTable.GetRenderStringTable().RegisterStr( - theShaderNameStr.c_str()))); + new SBindShader(theShaderNameStr)); theEffect.m_EffectCommands.push_back(new SApplyInstanceValue()); if (AreEqual(input, "[source]") || IsTrivial(input)) theEffect.m_EffectCommands.push_back( new SApplyBufferValue( - m_StringTable.GetRenderStringTable().RegisterStr(""), - m_StringTable.GetRenderStringTable().RegisterStr(""))); + (""), + (""))); else theEffect.m_EffectCommands.push_back( new SApplyBufferValue( - m_StringTable.GetRenderStringTable().RegisterStr(input), - m_StringTable.GetRenderStringTable().RegisterStr(""))); + (input), + (""))); for (bool bufParam = inStream.MoveToFirstChild(); bufParam; bufParam = inStream.MoveToNextSibling()) { - if (AreEqual("BufferInput", inStream.GetNarrowElementName())) { + if (QLatin1String("BufferInput") == inStream.GetElementName()) { const char8_t *param = ""; const char8_t *value = ""; inStream.Att("param", param); @@ -3505,20 +3712,17 @@ public: value = ""; theEffect.m_EffectCommands.push_back( new SApplyBufferValue( - m_StringTable.GetRenderStringTable().RegisterStr( - value), - m_StringTable.GetRenderStringTable().RegisterStr( - param))); + value, + param)); HideEffectProperty(inInstance, param); - } else if (AreEqual("DepthInput", inStream.GetNarrowElementName())) { + } else if (QLatin1String("DepthInput") == inStream.GetElementName()) { const char8_t *param = ""; inStream.Att("param", param); theEffect.m_EffectCommands.push_back( new SApplyDepthValue( - m_StringTable.GetRenderStringTable().RegisterStr( - param))); + param)); HideEffectProperty(inInstance, param); - } else if (AreEqual("ImageInput", inStream.GetNarrowElementName())) { + } else if (QLatin1String("ImageInput") == inStream.GetElementName()) { bool useAsTexture = false; bool needSync = false; const char8_t *param = ""; @@ -3538,13 +3742,11 @@ public: theEffect.m_EffectCommands.push_back( new SApplyImageValue( - m_StringTable.GetRenderStringTable().RegisterStr( - value), - m_StringTable.GetRenderStringTable().RegisterStr( - param), useAsTexture, needSync)); + value, + param, useAsTexture, needSync)); HideEffectProperty(inInstance, param); - } else if (AreEqual("DataBufferInput", - inStream.GetNarrowElementName())) { + } else if (QLatin1String("DataBufferInput") == + inStream.GetElementName()) { const char8_t *param = ""; const char8_t *usage = ""; inStream.Att("param", param); @@ -3558,62 +3760,51 @@ public: theEffect.m_EffectCommands.push_back( new SApplyDataBufferValue( - m_StringTable.GetRenderStringTable().RegisterStr( - param), bufType)); + param, bufType)); HideEffectProperty(inInstance, param); - } else if (AreEqual("SetParam", inStream.GetNarrowElementName())) { + } else if (QLatin1String("SetParam") == inStream.GetElementName()) { const char8_t *name = ""; inStream.Att("name", name); const char8_t *value = ""; inStream.Att("value", value); // find the param and the type. - qt3ds::foundation::CRegisteredString propName = - m_StringTable.GetRenderStringTable().RegisterStr(name); - qt3ds::render::dynamic::SPropertyDefinition *theDefinition = NULL; + QString propName = QString::fromLatin1(name); + qt3ds::render::dynamic::SPropertyDefinition *theDefinition = nullptr; for (uint32_t propIdx = 0, propEnd = theEffect.m_Properties.size(); - propIdx < propEnd && theDefinition == NULL; ++propIdx) { + propIdx < propEnd && theDefinition == nullptr; ++propIdx) { if (theEffect.m_Properties[propIdx].m_Name == propName) theDefinition = &theEffect.m_Properties[propIdx]; } - if (theDefinition != NULL) { + if (theDefinition != nullptr) { // Hack it for now because the shader datatypes don't have a // built in sizeof operator. - QT3DSU32 valueSize = 4; + qt3ds::render::NVRenderShaderDataTypes::Enum theDataType = theDefinition->m_DataType; - size_t allocSize = sizeof(SApplyValue) + valueSize; - QT3DSU8 *theCommandData = (QT3DSU8 *)malloc(allocSize); - QT3DSU8 *theValueData = theCommandData + sizeof(SApplyValue); - new (theCommandData) SApplyValue(propName, theDataType); - SApplyValue *theCommand = - reinterpret_cast<SApplyValue *>(theCommandData); + SApplyValue *theCommand = new SApplyValue(propName, theDataType); + switch (theDataType) { - case qt3ds::render::NVRenderShaderDataTypes::QT3DSRenderBool: { - bool &target = *reinterpret_cast<bool *>(theValueData); - qt3ds::foundation::StringConversion<bool>().StrTo(value, - target); - } break; - case qt3ds::render::NVRenderShaderDataTypes::QT3DSI32: { - QT3DSI32 &target = *reinterpret_cast<QT3DSI32 *>( - theValueData); - qt3ds::foundation::StringConversion<QT3DSI32>().StrTo( - value, target); - } break; + case qt3ds::render::NVRenderShaderDataTypes::QT3DSF32: + theCommand->m_Value + = QVariant::fromValue(QString::fromLatin1(value) + .toFloat()); + break; + case qt3ds::render::NVRenderShaderDataTypes::QT3DSI32: + theCommand->m_Value + = QVariant::fromValue(QString::fromLatin1(value) + .toLong()); + break; + case qt3ds::render::NVRenderShaderDataTypes::QT3DSRenderBool: + theCommand->m_Value + = QVariant::fromValue(QString::fromLatin1(value) + == QLatin1String("True")); + break; default: - QT3DS_ASSERT(false); - // Fallthrough intentional - case qt3ds::render::NVRenderShaderDataTypes::QT3DSF32: { - QT3DSF32 &target = *reinterpret_cast<QT3DSF32 *>( - theValueData); - qt3ds::foundation::StringConversion<QT3DSF32>().StrTo( - value, target); - } break; + break; } - theCommand->m_Value = NVDataRef<QT3DSU8>(theValueData, - valueSize); theEffect.m_EffectCommands.push_back(theCommand); } - } else if (AreEqual("Blending", inStream.GetNarrowElementName())) { + } else if (QLatin1String("Blending") == inStream.GetElementName()) { const char8_t *theSrcBlendFuncStr = "", *theDestBlendFuncStr = ""; inStream.Att("source", theSrcBlendFuncStr); inStream.Att("dest", theDestBlendFuncStr); @@ -3626,7 +3817,7 @@ public: // this will setup blending theEffect.m_EffectCommands.push_back( new SApplyBlending(theSrcBlendFunc, theDstBlendFuc)); - } else if (AreEqual("RenderState", inStream.GetNarrowElementName())) { + } else if (QLatin1String("RenderState") == inStream.GetElementName()) { const char8_t *name = ""; inStream.Att("name", name); const char8_t *value = ""; @@ -3641,7 +3832,7 @@ public: // this will setup blending theEffect.m_EffectCommands.push_back( new SApplyRenderState(theState, theStateEnable)); - } else if (AreEqual("DepthStencil", inStream.GetNarrowElementName())) { + } else if (QLatin1String("DepthStencil") == inStream.GetElementName()) { const char8_t *bufferName = ""; inStream.Att("buffer", bufferName); QT3DSU32 stencilvalue = 0; @@ -3672,8 +3863,7 @@ public: ParseDepthStencilFlags(flags); theEffect.m_EffectCommands.push_back( new SDepthStencil( - m_StringTable.GetRenderStringTable().RegisterStr( - bufferName), flagValues, stencilFailOperation, + bufferName, flagValues, stencilFailOperation, depthPass, depthFail, stencilFunction, stencilvalue, mask)); } else { @@ -3681,13 +3871,13 @@ public: } } theEffect.m_EffectCommands.push_back(new SRender(drawIndirect)); - } else if (AreEqual("Buffer", inStream.GetNarrowElementName()) - || AreEqual("Image", inStream.GetNarrowElementName())) { + } else if (QLatin1String("Buffer") == inStream.GetElementName() + || QLatin1String("Image") == inStream.GetElementName()) { SAllocateBufferFlags theFlags; const char8_t *theLifetimeStr = "", *theType = "", *theFormat = "", *theFilter = "", *theWrap = "", *theName = ""; QT3DSF32 theSize = 1.0f; - bool isImage = AreEqual("Image", inStream.GetNarrowElementName()); + bool isImage = (QLatin1String("Image") == inStream.GetElementName()); inStream.Att("name", theName); inStream.Att("lifetime", theLifetimeStr); inStream.Att("type", theType); @@ -3721,17 +3911,15 @@ public: theEffect.m_EffectCommands.push_back( new SAllocateImage( - m_StringTable.GetRenderStringTable().RegisterStr( - theName), theTexFormat, theMagOp, theCoordOp, + theName, theTexFormat, theMagOp, theCoordOp, theSize, theFlags, theAccess)); } else { theEffect.m_EffectCommands.push_back( new SAllocateBuffer( - m_StringTable.GetRenderStringTable().RegisterStr( - theName), theTexFormat, theMagOp, theCoordOp, + theName, theTexFormat, theMagOp, theCoordOp, theSize, theFlags)); } - } else if (AreEqual("DataBuffer", inStream.GetNarrowElementName())) { + } else if (QLatin1String("DataBuffer") == inStream.GetElementName()) { SAllocateBufferFlags theFlags; const char8_t *theLifetimeStr = "", *theType = "", *theWrapName = "", *theWrapType = "", *theFormat = "", *theName = ""; @@ -3765,10 +3953,9 @@ public: } else { theEffect.m_EffectCommands.push_back( new SAllocateDataBuffer( - m_StringTable.GetRenderStringTable().RegisterStr( - theName), bufType, - m_StringTable.GetRenderStringTable().RegisterStr( - theWrapName), wrapBufType, theSize, theFlags)); + + theName, bufType, + theWrapName, wrapBufType, theSize, theFlags)); } } else { QT3DS_ASSERT(false); // Unrecognized effect passes member. @@ -3780,8 +3967,7 @@ public: // Create the minimal set of commands that we could run the first shader with. theEffect.m_EffectCommands.push_back(new SBindTarget()); theEffect.m_EffectCommands.push_back( - new SBindShader(m_StringTable.GetRenderStringTable().RegisterStr( - theEffect.m_Shaders[0].m_Name.c_str()))); + new SBindShader(theEffect.m_Shaders[0].m_Name)); theEffect.m_EffectCommands.push_back(new SApplyInstanceValue()); theEffect.m_EffectCommands.push_back(new SRender(false)); } @@ -3789,41 +3975,40 @@ public: } } - bool LoadEffectXMLFromSourcePath(const char *inSourcePath, + bool LoadEffectXMLFromSourcePath(const QString &inSourcePath, Qt3DSDMInstanceHandle inInstance, - const TCharStr &inObjectName, + const QString &inObjectName, std::vector<SMetaDataLoadWarning> &outWarnings, QFile &inStream) override { std::shared_ptr<IDOMFactory> theFactory( IDOMFactory::CreateDOMFactory(m_DataCore->GetStringTablePtr())); - qt3dsdm::SDOMElement *theElem = CDOMSerializer::Read(*theFactory, inStream, NULL); - if (theElem != NULL) { + qt3dsdm::SDOMElement *theElem = CDOMSerializer::Read(*theFactory, inStream, nullptr); + if (theElem != nullptr) { std::shared_ptr<IDOMReader> theReader( IDOMReader::CreateDOMReader(*theElem, m_DataCore->GetStringTablePtr(), theFactory)); LoadEffectXML(*theReader, inInstance, inObjectName, outWarnings, - TCharStr(Intern(inSourcePath))); + inSourcePath); return true; } return false; } - Option<SMetaDataEffect> GetEffectBySourcePath(const char *inSourcePath) override + Option<SMetaDataEffect> GetEffectBySourcePath(const QString &inSourcePath) override { QDir sourcePath = QDir::cleanPath(QString(inSourcePath)); for (TEffectMap::iterator iter = m_EffectMap.begin(), end = m_EffectMap.end(); iter != end; ++iter) { - QDir effectPath = QDir::cleanPath(QString::fromWCharArray( - iter->second.m_SourcePath.wide_str())); + QDir effectPath = QDir::cleanPath(iter->m_SourcePath); if (effectPath == sourcePath) - return iter->second.ToEffect(); + return iter->ToEffect(); } return Empty(); } - void LoadMaterialInstance(const char *inShaderFile, Qt3DSDMInstanceHandle inInstance, - const TCharStr &inName, + void LoadMaterialInstance(const QString &inShaderFile, Qt3DSDMInstanceHandle inInstance, + const QString &inName, std::vector<SMetaDataLoadWarning> &outWarnings, QFile &inStream) override { @@ -3836,20 +4021,20 @@ public: } } - bool IsMaterialClassRegistered(const char *inName) override + bool IsMaterialClassRegistered(const QString &inName) override { - return m_CustomMaterials.find(Intern(inName)) != m_CustomMaterials.end(); + return m_CustomMaterials.find(inName) != m_CustomMaterials.end(); } void LoadMaterialClassXML(IDOMReader &inStream, Qt3DSDMInstanceHandle inInstance, - const TCharStr &inObjectName, + const QString &inObjectName, std::vector<SMetaDataLoadWarning> &outWarnings, - const TCharStr &inSourcePath) override + const QString &inSourcePath) override { using namespace qt3ds::render::dynamic; - std::pair<TCustomMaterialMap::iterator, bool> theInserter = m_CustomMaterials.insert( - std::make_pair(Intern(inObjectName), SMetaDataCustomMaterialImpl())); + TCustomMaterialMap::iterator theInserter = m_CustomMaterials.insert( + inObjectName, SMetaDataCustomMaterialImpl()); /*if ( inStream.MoveToFirstChild( "Effect" ) == false ) { outWarnings.push_back( SMetaDataLoadWarning( MetaDataLoadWarningType::Unknown, @@ -3857,9 +4042,9 @@ public: missing top level Effect tag" ) ); return; }*/ - eastl::string shaderPrefix = "#include \"customMaterial.glsllib\"\n"; + QString shaderPrefix = QStringLiteral("#include \"customMaterial.glsllib\"\n"); - SMetaDataCustomMaterialImpl &theMaterial = theInserter.first->second; + SMetaDataCustomMaterialImpl &theMaterial = *theInserter; m_ObjectName = inObjectName; theMaterial.m_Name = inObjectName; theMaterial.m_SourcePath = inSourcePath; @@ -3868,71 +4053,71 @@ public: theMaterial.m_AlwaysDirty = false; theMaterial.m_ShaderKey = 0; theMaterial.m_LayerCount = 0; - inStream.Att("always-dirty", theMaterial.m_AlwaysDirty); + inStream.Att(QStringLiteral("always-dirty"), theMaterial.m_AlwaysDirty); LoadDynamicObjectProperties(inStream, theMaterial, inInstance, inObjectName, outWarnings, shaderPrefix); LoadDynamicObjectShaders(inStream, theMaterial, shaderPrefix, inObjectName); // currently single pass shader only if (theMaterial.m_Shaders.size()) { - eastl::string theShaderNameStr; + QString theShaderNameStr; // in Passes we store additional render commands IDOMReader::Scope __readerScope(inStream); - if (inStream.MoveToFirstChild("Passes")) { + if (inStream.MoveToFirstChild(QStringLiteral("Passes"))) { for (bool success = inStream.MoveToFirstChild(); success; success = inStream.MoveToNextSibling()) { IDOMReader::Scope __passScope(inStream); - if (AreEqual("Pass", inStream.GetNarrowElementName())) { + if (QLatin1String("Pass") == inStream.GetElementName()) { const char8_t *typeStr; if (!inStream.UnregisteredAtt("type", typeStr)) typeStr = "render"; if (AreEqual(typeStr, "render")) { - const char8_t *shader = "", *input = "[source]", *output = "[dest]", - *outputFormat = "rgba", *clear = ""; + QString shader; + QString input = QStringLiteral("[source]"); + QString output = QStringLiteral("[dest]"); + QString outputFormat = QStringLiteral("rgba"); + QString clear; bool needsClear = false; - inStream.Att("shader", shader); - inStream.Att("input", input); - inStream.Att("output", output); + inStream.Att(QStringLiteral("shader"), shader); + inStream.Att(QStringLiteral("input"), input); + inStream.Att(QStringLiteral("output"), output); // for multi pass materials - inStream.Att("clear", clear); - if (AreEqual("true", clear)) + inStream.Att(QStringLiteral("clear"), clear); + if (QLatin1String("true") == clear) needsClear = true; GetShaderName(inObjectName, shader, theShaderNameStr); // this is only for the final output of the effect - inStream.Att("format", outputFormat); + inStream.Att(QStringLiteral("format"), outputFormat); qt3ds::render::NVRenderTextureFormats::Enum theOutputFormat = - ConvertTypeAndFormatToTextureFormat("ubyte", outputFormat); + ConvertTypeAndFormatToTextureFormat(QStringLiteral("ubyte"), + outputFormat); - if (AreEqual(output, "[dest]") || IsTrivial(output)) { + if (output == QLatin1String("[dest]") || output.isEmpty()) { theMaterial.m_CustomerMaterialCommands.push_back( new SBindTarget(theOutputFormat)); } else { theMaterial.m_CustomerMaterialCommands.push_back( new SBindBuffer( - m_StringTable.GetRenderStringTable().RegisterStr( - output), needsClear)); + output, needsClear)); } // add shader to command stream - qt3ds::render::CRegisteredString theShaderName; + QString theShaderName; if (!IsTrivial(shader)) { for (QT3DSU32 idx = 0, end = theMaterial.m_Shaders.size(); - idx < end && theShaderName.IsValid() == false; ++idx) { - qt3ds::render::CRegisteredString thePossibleNameStr = - m_StringTable.GetRenderStringTable().RegisterStr( - theMaterial.m_Shaders[idx].m_Name.c_str()); - if (AreEqual(thePossibleNameStr.c_str(), - theShaderNameStr.c_str())) + idx < end && theShaderName.isNull() == true; ++idx) { + QString thePossibleNameStr = + theMaterial.m_Shaders[idx].m_Name; + if (thePossibleNameStr == theShaderNameStr) theShaderName = thePossibleNameStr; } } - if (theShaderName.IsValid() == false - && theMaterial.m_Shaders.empty() == false) - theShaderName = m_StringTable.GetRenderStringTable().RegisterStr( - theMaterial.m_Shaders[0].m_Name.c_str()); - if (theShaderName.IsValid()) { + if (theShaderName.isEmpty() == true + && theMaterial.m_Shaders.isEmpty() == false) + theShaderName = theMaterial.m_Shaders[0].m_Name; + if (!theShaderName.isEmpty()) { theMaterial.m_CustomerMaterialCommands.push_back( new SBindShader(theShaderName)); // this is a place holder for our input values to the shader @@ -3941,7 +4126,7 @@ public: for (bool bufParam = inStream.MoveToFirstChild(); bufParam; bufParam = inStream.MoveToNextSibling()) { - if (AreEqual("BufferBlit", inStream.GetNarrowElementName())) { + if (QLatin1String("BufferBlit") == inStream.GetElementName()) { const char8_t *value = ""; const char8_t *dest = ""; const char8_t *source = ""; @@ -3954,17 +4139,15 @@ public: theMaterial.m_CustomerMaterialCommands.push_back( new SApplyBlitFramebuffer( - m_StringTable.GetRenderStringTable().RegisterStr( - source), - m_StringTable.GetRenderStringTable().RegisterStr( - dest))); + source, + dest)); // note need a better way to pass information from MDL to // our input // We use buffer blits to simulate glass refraction theMaterial.m_HasRefraction = true; - } else if (AreEqual("BufferInput", - inStream.GetNarrowElementName())) { + } else if (QLatin1String("BufferInput") == + inStream.GetElementName()) { const char8_t *param = ""; const char8_t *value = ""; inStream.Att("param", param); @@ -3973,13 +4156,11 @@ public: value = ""; theMaterial.m_CustomerMaterialCommands.push_back( new SApplyBufferValue( - m_StringTable.GetRenderStringTable().RegisterStr( - value), - m_StringTable.GetRenderStringTable().RegisterStr( - param))); + value, + param)); HideEffectProperty(inInstance, param); - } else if (AreEqual("Blending", - inStream.GetNarrowElementName())) { + } else if (QLatin1String("Blending") == + inStream.GetElementName()) { const char8_t *theSrcBlendFuncStr = "", *theDestBlendFuncStr = ""; inStream.Att("source", theSrcBlendFuncStr); @@ -3996,8 +4177,8 @@ public: theDstBlendFuc)); // if we have blending we have transparency theMaterial.m_HasTransparency = true; - } else if (AreEqual("RenderState", - inStream.GetNarrowElementName())) { + } else if (QLatin1String("RenderState") == + inStream.GetElementName()) { // UdoL Todo: add this one } } @@ -4006,15 +4187,15 @@ public: // pass. theMaterial.m_CustomerMaterialCommands.push_back(new SRender(false)); } - } else if (AreEqual("ShaderKey", inStream.GetNarrowElementName())) { + } else if (QLatin1String("ShaderKey") == inStream.GetElementName()) { QT3DSU32 theValue = 0; inStream.Att("value", theValue); theMaterial.m_ShaderKey = theValue; - } else if (AreEqual("LayerKey", inStream.GetNarrowElementName())) { + } else if (QLatin1String("LayerKey") == inStream.GetElementName()) { QT3DSU32 theValue = 0; inStream.Att("count", theValue); theMaterial.m_LayerCount = theValue; - } else if (AreEqual("Buffer", inStream.GetNarrowElementName())) { + } else if (QLatin1String("Buffer") == inStream.GetElementName()) { SAllocateBufferFlags theFlags; const char8_t *theLifetimeStr = "", *theType = "", *theFormat = "", *theFilter = "", *theWrap = "", *theName = ""; @@ -4046,8 +4227,7 @@ public: } else { theMaterial.m_CustomerMaterialCommands.push_back( new SAllocateBuffer( - m_StringTable.GetRenderStringTable().RegisterStr( - theName), theTexFormat, theMagOp, theCoordOp, + theName, theTexFormat, theMagOp, theCoordOp, theSize, theFlags)); } } @@ -4058,8 +4238,7 @@ public: // add minimal set // add shader to command stream theMaterial.m_CustomerMaterialCommands.push_back( - new SBindShader(m_StringTable.GetRenderStringTable().RegisterStr( - theMaterial.m_Shaders[0].m_Name.c_str()))); + new SBindShader(theMaterial.m_Shaders[0].m_Name)); // this is a place holder for our input values to the shader theMaterial.m_CustomerMaterialCommands.push_back(new SApplyInstanceValue()); // add the render command as last thing @@ -4068,34 +4247,34 @@ public: } } - bool LoadMaterialClassFromSourcePath(const char *inSourcePath, + bool LoadMaterialClassFromSourcePath(const QString &inSourcePath, Qt3DSDMInstanceHandle inInstance, - const TCharStr &inObjectName, + const QString &inObjectName, std::vector<SMetaDataLoadWarning> &outWarnings, QFile &inStream) override { std::shared_ptr<IDOMFactory> theFactory( IDOMFactory::CreateDOMFactory(m_DataCore->GetStringTablePtr())); - qt3dsdm::SDOMElement *theElem = CDOMSerializer::Read(*theFactory, inStream, NULL); - if (theElem != NULL) { + qt3dsdm::SDOMElement *theElem = CDOMSerializer::Read(*theFactory, inStream, nullptr); + if (theElem != nullptr) { std::shared_ptr<IDOMReader> theReader( IDOMReader::CreateDOMReader(*theElem, m_DataCore->GetStringTablePtr(), theFactory)); LoadMaterialClassXML(*theReader, inInstance, inObjectName, outWarnings, - TCharStr(Intern(inSourcePath))); + inSourcePath); return true; } return false; } - Option<SMetaDataCustomMaterial> GetMaterialBySourcePath(const char *inSourcePath) override + Option<SMetaDataCustomMaterial> GetMaterialBySourcePath(const QString &inSourcePath) override { - TCharStr theSourcePath(Intern(inSourcePath)); + QString theSourcePath(inSourcePath); for (TCustomMaterialMap::iterator iter = m_CustomMaterials.begin(), end = m_CustomMaterials.end(); iter != end; ++iter) { - if (iter->second.m_SourcePath == theSourcePath) - return iter->second.ToMaterial(); + if (iter->m_SourcePath == theSourcePath) + return iter->ToMaterial(); } return Empty(); } @@ -4105,29 +4284,39 @@ public: void SetConsumer(TTransactionConsumerPtr inConsumer) override { m_Consumer = inConsumer; } //////////////////////////////////////////////////////////////////////////////////// +#ifndef QT3DSDM_META_DATA_NO_SIGNALS +#define QT3DSDM_SIGNAL_OVERRIDE override +#else +#define QT3DSDM_SIGNAL_OVERRIDE +#endif // Signals virtual TSignalConnectionPtr ConnectInternalCategoryDestroyed(function<void(Qt3DSDMCategoryHandle)> inCallback) + QT3DSDM_SIGNAL_OVERRIDE { return CONNECT(&SNewMetaDataImpl::internalCategoryDestroyed); } virtual TSignalConnectionPtr - ConnectInternalPropertyDestroyed(function<void(Qt3DSDMMetaDataPropertyHandle)> inCallback) + ConnectInternalPropertyDestroyed( + function<void(Qt3DSDMMetaDataPropertyHandle)> inCallback) QT3DSDM_SIGNAL_OVERRIDE { return CONNECT(&SNewMetaDataImpl::internalMetaDataPropertyDestroyed); } virtual TSignalConnectionPtr ConnectInternalEventDestroyed(function<void(Qt3DSDMEventHandle)> inCallback) + QT3DSDM_SIGNAL_OVERRIDE { return CONNECT(&SNewMetaDataImpl::internalEventDestroyed); } virtual TSignalConnectionPtr ConnectInternalHandlerDestroyed(function<void(Qt3DSDMHandlerHandle)> inCallback) + QT3DSDM_SIGNAL_OVERRIDE { return CONNECT(&SNewMetaDataImpl::internalHandlerDestroyed); } virtual TSignalConnectionPtr - ConnectInternalHandlerArgDestroyed(function<void(Qt3DSDMHandlerHandle, QT3DSU32)> inCallback) + ConnectInternalHandlerArgDestroyed( + function<void(Qt3DSDMHandlerHandle, QT3DSU32)> inCallback) QT3DSDM_SIGNAL_OVERRIDE { return CONNECT(&SNewMetaDataImpl::internalHandlerArgDestroyed); } diff --git a/src/Authoring/QT3DSDM/Systems/Qt3DSDMMetaData.h b/src/Authoring/QT3DSDM/Systems/Qt3DSDMMetaData.h index be202710..1e41f771 100644 --- a/src/Authoring/QT3DSDM/Systems/Qt3DSDMMetaData.h +++ b/src/Authoring/QT3DSDM/Systems/Qt3DSDMMetaData.h @@ -82,10 +82,10 @@ struct SMetaDataLoadWarning { MetaDataLoadWarningType::Enum m_Type; MetaDataLoadWarningMessage::Enum m_Message; - TCharStr m_ExtraInfo; + QString m_ExtraInfo; SMetaDataLoadWarning(MetaDataLoadWarningType::Enum inType, - MetaDataLoadWarningMessage::Enum inMessage, TCharStr inInfo = TCharStr()) + MetaDataLoadWarningMessage::Enum inMessage, const QString &inInfo = {}) : m_Type(inType) , m_Message(inMessage) , m_ExtraInfo(inInfo) @@ -118,7 +118,6 @@ class IMetaData protected: virtual ~IMetaData() {} public: - typedef const TCharStr &TStrType; //////////////////////////////////////////////////////////////////////////////////// // Sharing some utility objects @@ -133,20 +132,21 @@ public: // If this object is canonical, then we expect this mapping setup before loading the // canonical data, and we will use a type lookup instead of a direct handle lookup // when loading canonical information. - virtual void SetInstanceAsCanonical(Qt3DSDMInstanceHandle inInstance, TStrType inTypename) = 0; + virtual void SetInstanceAsCanonical(Qt3DSDMInstanceHandle inInstance, + const QString &inTypename) = 0; - virtual Qt3DSDMInstanceHandle GetCanonicalInstanceForType(TStrType inTypename) = 0; + virtual Qt3DSDMInstanceHandle GetCanonicalInstanceForType(const QString &inTypename) = 0; // If this instance wasn't registered as canonical, then we return empty. - virtual Option<TCharStr> GetTypeForCanonicalInstance(Qt3DSDMInstanceHandle inInstance) = 0; + virtual Option<QString> GetTypeForCanonicalInstance(Qt3DSDMInstanceHandle inInstance) = 0; // Gets the type for this instance via derivation - virtual Option<TCharStr> GetTypeForInstance(Qt3DSDMInstanceHandle inInstance) = 0; + virtual Option<QString> GetTypeForInstance(Qt3DSDMInstanceHandle inInstance) = 0; // Get group count for instance virtual QT3DSU32 GetGroupCountForInstance(Qt3DSDMInstanceHandle inInstance) = 0; // Get all group names virtual QT3DSU32 GetGroupNamesForInstance(Qt3DSDMInstanceHandle inInstance, - std::vector<TCharStr> &outNames) = 0; + std::vector<QString> &outNames) = 0; // Get group count for instance - virtual Option<TCharStr> GetGroupFilterNameForInstance(Qt3DSDMInstanceHandle inInstance, + virtual Option<QString> GetGroupFilterNameForInstance(Qt3DSDMInstanceHandle inInstance, long inIndex) = 0; //////////////////////////////////////////////////////////////////////////////////// @@ -154,17 +154,17 @@ public: // Categories appear in the UI to divide up large lists of events, actions, and properties. // Returns <handle,true> if a category was created // else returns <handle,false> - virtual pair<Qt3DSDMCategoryHandle, bool> GetOrCreateCategory(TStrType inName) = 0; + virtual pair<Qt3DSDMCategoryHandle, bool> GetOrCreateCategory(const QString &inName) = 0; - virtual void SetCategoryInfo(Qt3DSDMCategoryHandle inCategory, TStrType inIcon, - TStrType inHighlight, TStrType inDescription) = 0; + virtual void SetCategoryInfo(Qt3DSDMCategoryHandle inCategory, const QString &inIcon, + const QString &inHighlight, const QString &inDescription) = 0; virtual void DestroyCategory(Qt3DSDMCategoryHandle inCategory) = 0; virtual Option<SCategoryInfo> GetCategoryInfo(Qt3DSDMCategoryHandle inCategory) = 0; - virtual Qt3DSDMCategoryHandle FindCategoryByName(TStrType inName) = 0; + virtual Qt3DSDMCategoryHandle FindCategoryByName(const QString &inName) = 0; virtual void GetCategories(vector<Qt3DSDMCategoryHandle> &outCategories) = 0; - virtual Option<SCategoryInfo> GetEventCategory(TStrType inName) = 0; - virtual Option<SCategoryInfo> GetHandlerCategory(TStrType inName) = 0; + virtual Option<SCategoryInfo> GetEventCategory(const QString &inName) = 0; + virtual Option<SCategoryInfo> GetHandlerCategory(const QString &inName) = 0; //////////////////////////////////////////////////////////////////////////////////// // Properties @@ -178,11 +178,12 @@ public: // For properties, you set the default values separately // This may delete the underlying data model property rebuild it. virtual void SetMetaDataPropertyInfo(Qt3DSDMMetaDataPropertyHandle inPropertyHandle, - TStrType inName, TStrType inFormalName, - TStrType inDescription, TStrType inUsage, + const QString &inName, const QString &inFormalName, + const QString &inDescription, const QString &inUsage, CompleteMetaDataType::Enum inDataType, const SValue &inDefaultValue, - const TMetaDataData &inMetaData, TStrType inGroupName, + const TMetaDataData &inMetaData, + const QString &inGroupName, bool inIsHidden = false, bool inIsAnimatable = false, bool inIsControllable = false) = 0; @@ -193,7 +194,7 @@ public: virtual void DestroyMetaDataProperty(Qt3DSDMMetaDataPropertyHandle inProperty) = 0; virtual Qt3DSDMMetaDataPropertyHandle GetMetaDataProperty(Qt3DSDMInstanceHandle inInstance, - TStrType inPropertyName) = 0; + const QString &inPropertyName) = 0; virtual Qt3DSDMMetaDataPropertyHandle GetMetaDataProperty(Qt3DSDMInstanceHandle inInstance, Qt3DSDMPropertyHandle inProperty) = 0; virtual Option<SMetaDataPropertyInfo> @@ -205,12 +206,12 @@ public: // Get the meta data properties defined on *only* this object, don't search parents virtual Qt3DSDMMetaDataPropertyHandle GetOrCreateSpecificMetaDataProperty(Qt3DSDMInstanceHandle inInstance, - TStrType inPropertyName) = 0; + const QString &inPropertyName) = 0; virtual void GetSpecificMetaDataProperties(Qt3DSDMInstanceHandle inInstance, vector<Qt3DSDMMetaDataPropertyHandle> &outProperties) = 0; - virtual TCharStr GetFormalName(Qt3DSDMInstanceHandle inInstance, + virtual QString GetFormalName(Qt3DSDMInstanceHandle inInstance, Qt3DSDMPropertyHandle inProperty) = 0; virtual AdditionalMetaDataType::Value GetAdditionalMetaDataType(Qt3DSDMInstanceHandle inInstance, Qt3DSDMPropertyHandle inProperty) = 0; @@ -233,14 +234,15 @@ public: // CreateMetaDataEvent was original named CreateEvent but this collides with // the microsoft macro CreateEvent which expands to CreateEventA or CreateEventW virtual Qt3DSDMEventHandle CreateMetaDataEvent(Qt3DSDMInstanceHandle inInstance) = 0; - virtual void SetEventInfo(Qt3DSDMEventHandle inEventHandle, TStrType inName, - TStrType inFormalName, TStrType inCategory, - TStrType inDescription) = 0; + virtual void SetEventInfo(Qt3DSDMEventHandle inEventHandle, const QString &inName, + const QString &inFormalName, const QString &inCategory, + const QString &inDescription) = 0; virtual void DestroyEvent(Qt3DSDMEventHandle inEventHandle) = 0; virtual void GetEvents(Qt3DSDMInstanceHandle inInstance, TEventHandleList &outEvents) = 0; - virtual Qt3DSDMEventHandle FindEvent(Qt3DSDMInstanceHandle inInstance, TStrType inName) = 0; + virtual Qt3DSDMEventHandle FindEvent(Qt3DSDMInstanceHandle inInstance, + const QString &inName) = 0; virtual Option<SEventInfo> GetEventInfo(Qt3DSDMEventHandle inEventHandle) = 0; virtual bool IsCustomEvent(Qt3DSDMEventHandle inEventHandle) = 0; @@ -248,18 +250,18 @@ public: virtual void GetSpecificEvents(Qt3DSDMInstanceHandle inInstance, TEventHandleList &outEvents) = 0; virtual Qt3DSDMEventHandle GetOrCreateSpecificEvent(Qt3DSDMInstanceHandle inInstance, - TStrType inName) = 0; + const QString &inName) = 0; //////////////////////////////////////////////////////////////////////////////////// // Handlers virtual Qt3DSDMHandlerHandle CreateHandler(Qt3DSDMInstanceHandle inInstance) = 0; - virtual void SetHandlerInfo(Qt3DSDMHandlerHandle inHandle, TStrType inName, - TStrType inFormalName, TStrType inCategory, - TStrType inDescription) = 0; + virtual void SetHandlerInfo(Qt3DSDMHandlerHandle inHandle, const QString &inName, + const QString &inFormalName, const QString &inCategory, + const QString &inDescription) = 0; virtual void DestroyHandler(Qt3DSDMHandlerHandle inHandlerHandle) = 0; virtual Qt3DSDMHandlerHandle FindHandlerByName(Qt3DSDMInstanceHandle inInstance, - TStrType inName) = 0; + const QString &inName) = 0; virtual Option<SHandlerInfo> GetHandlerInfo(Qt3DSDMHandlerHandle inHandlerHandle) = 0; virtual void GetHandlers(Qt3DSDMInstanceHandle inInstance, THandlerHandleList &outHandlers) = 0; virtual bool IsCustomHandler(Qt3DSDMHandlerHandle inEventHandle) = 0; @@ -267,21 +269,23 @@ public: virtual void GetSpecificHandlers(Qt3DSDMInstanceHandle inInstance, THandlerHandleList &outHandlers) = 0; virtual Qt3DSDMHandlerHandle GetOrCreateSpecificHandler(Qt3DSDMInstanceHandle inInstance, - TStrType inName) = 0; + const QString &inName) = 0; //////////////////////////////////////////////////////////////////////////////////// // Handler Arguments virtual QT3DSU32 AddHandlerArgument(Qt3DSDMHandlerHandle inHandler) = 0; virtual void - SetHandlerArgumentInfo(Qt3DSDMHandlerHandle inHandler, QT3DSU32 inArgIndex, TStrType inName, - TStrType inFormalName, TStrType inDescription, + SetHandlerArgumentInfo(Qt3DSDMHandlerHandle inHandler, QT3DSU32 inArgIndex, + const QString &inName, + const QString &inFormalName, const QString &inDescription, CompleteMetaDataType::Enum inDataType, const SValue &inDefaultValue, - const TMetaDataData &inMetaData, HandlerArgumentType::Value inArgType) = 0; + const TMetaDataData &inMetaData, + HandlerArgumentType::Value inArgType) = 0; virtual void DestroyHandlerArgument(Qt3DSDMHandlerHandle inHandler, QT3DSU32 inArgIndex) = 0; virtual Option<SMetaDataHandlerArgumentInfo> - FindHandlerArgumentByName(Qt3DSDMHandlerHandle inHandler, TStrType inName) = 0; + FindHandlerArgumentByName(Qt3DSDMHandlerHandle inHandler, const QString &inName) = 0; virtual void GetHandlerArguments(Qt3DSDMHandlerHandle inHandler, vector<SMetaDataHandlerArgumentInfo> &outArguments) = 0; virtual Option<SMetaDataHandlerArgumentInfo> @@ -291,13 +295,13 @@ public: //////////////////////////////////////////////////////////////////////////////////// // References // Duplicate references are removed from this instance - virtual void AddReference(Qt3DSDMInstanceHandle inInstance, TStrType inRefString) = 0; + virtual void AddReference(Qt3DSDMInstanceHandle inInstance, const QString &inRefString) = 0; virtual void DestroyReferences(Qt3DSDMInstanceHandle inInstance) = 0; // Does the recursive gather from all the parents. Duplicate references are removed from the // final list. virtual void GetReferences(Qt3DSDMInstanceHandle inInstance, - std::vector<TCharStr> &outReferences) = 0; + std::vector<QString> &outReferences) = 0; //////////////////////////////////////////////////////////////////////////////////// // Instance-global functions @@ -322,46 +326,47 @@ public: // Load meta data and apply it to just this instance virtual void LoadInstance(IDOMReader &inReader, Qt3DSDMInstanceHandle inInstance, - const TCharStr &inName, + const QString &inName, std::vector<SMetaDataLoadWarning> &outWarnings) = 0; // Save just this instances meta data out to the writer virtual void SaveInstance(IDOMWriter &inWriter, Qt3DSDMInstanceHandle inInstance) = 0; // Load effect meta data from file and apply it to just this instance - virtual void LoadEffectInstance(const char *inShaderFile, Qt3DSDMInstanceHandle inInstance, - const TCharStr &inName, + virtual void LoadEffectInstance(const QString &inShaderFile, Qt3DSDMInstanceHandle inInstance, + const QString &inName, std::vector<SMetaDataLoadWarning> &outWarnings, QFile &inStream) = 0; - virtual bool IsEffectInstanceRegistered(const char *inName) = 0; + virtual bool IsEffectInstanceRegistered(const QString &inName) = 0; virtual void LoadEffectXML(IDOMReader &inStream, Qt3DSDMInstanceHandle inInstance, - const TCharStr &inObjectName, + const QString &inObjectName, std::vector<SMetaDataLoadWarning> &outWarnings, - const TCharStr &inSourcePath) = 0; - virtual bool LoadEffectXMLFromSourcePath(const char *inSourcePath, + const QString &inSourcePath) = 0; + virtual bool LoadEffectXMLFromSourcePath(const QString &inSourcePath, Qt3DSDMInstanceHandle inInstance, - const TCharStr &inObjectName, + const QString &inObjectName, std::vector<SMetaDataLoadWarning> &outWarnings, QFile &inStream) = 0; - virtual Option<SMetaDataEffect> GetEffectBySourcePath(const char *inName) = 0; + virtual Option<SMetaDataEffect> GetEffectBySourcePath(const QString &inName) = 0; - virtual void LoadMaterialInstance(const char *inShaderFile, + virtual void LoadMaterialInstance(const QString &inShaderFile, Qt3DSDMInstanceHandle inInstance, - const TCharStr &inName, + const QString &inName, std::vector<SMetaDataLoadWarning> &outWarnings, QFile &inStream) = 0; - virtual bool IsMaterialClassRegistered(const char *inName) = 0; + virtual bool IsMaterialClassRegistered(const QString &inName) = 0; virtual void LoadMaterialClassXML(IDOMReader &inStream, Qt3DSDMInstanceHandle inInstance, - const TCharStr &inObjectName, + const QString &inObjectName, std::vector<SMetaDataLoadWarning> &outWarnings, - const TCharStr &inSourcePath) = 0; - virtual bool LoadMaterialClassFromSourcePath(const char *inSourcePath, + const QString &inSourcePath) = 0; + virtual bool LoadMaterialClassFromSourcePath(const QString &inSourcePath, Qt3DSDMInstanceHandle inInstance, - const TCharStr &inObjectName, + const QString &inObjectName, std::vector<SMetaDataLoadWarning> &outWarnings, QFile &inStream) = 0; - virtual Option<SMetaDataCustomMaterial> GetMaterialBySourcePath(const char *inSourcePath) = 0; + virtual Option<SMetaDataCustomMaterial> GetMaterialBySourcePath( + const QString &inSourcePath) = 0; //////////////////////////////////////////////////////////////////////////////////// // Undo/Redo diff --git a/src/Authoring/QT3DSDM/Systems/Qt3DSDMMetaDataTypes.h b/src/Authoring/QT3DSDM/Systems/Qt3DSDMMetaDataTypes.h index ead6c4ff..cb512fe9 100644 --- a/src/Authoring/QT3DSDM/Systems/Qt3DSDMMetaDataTypes.h +++ b/src/Authoring/QT3DSDM/Systems/Qt3DSDMMetaDataTypes.h @@ -28,6 +28,7 @@ ****************************************************************************/ #pragma once #include "Qt3DSDMMetaDataValue.h" +#include "render/Qt3DSRenderDynamicObjectSystemCommands.h" namespace qt3ds { namespace render { @@ -119,10 +120,10 @@ inline AdditionalMetaDataType::Value GetMetaDataValueType(const TMetaDataData &i // and handler arguments. struct SMetaPropertyBase { - TCharStr m_Name; - TCharStr m_FormalName; - TCharStr m_Usage; - TCharStr m_Description; + QString m_Name; + QString m_FormalName; + QString m_Usage; + QString m_Description; CompleteMetaDataType::Enum m_CompleteType; TMetaDataData m_MetaDataData; SValue m_DefaultValue; @@ -157,7 +158,7 @@ struct SMetaDataPropertyInfo : SMetaPropertyBase bool m_IsHidden; // Is this property visible in the UI bool m_Animatable; // Is this property visible in the UI - TCharStr m_GroupName; // Name of the group this property belongs to or "default" + QString m_GroupName; // Name of the group this property belongs to or "default" SMetaDataPropertyInfo(Qt3DSDMInstanceHandle inInstance) : m_Instance(inInstance) @@ -198,17 +199,17 @@ struct SMetaDataHandlerArgumentInfo : SMetaPropertyBase struct SCategoryInfo { - TCharStr m_Name; - TCharStr m_Description; - TCharStr m_Icon; - TCharStr m_HighlightIcon; + QString m_Name; + QString m_Description; + QString m_Icon; + QString m_HighlightIcon; bool m_Canonical; SCategoryInfo() : m_Canonical(false) { } - SCategoryInfo(TCharStr inName) + SCategoryInfo(const QString &inName) : m_Name(inName) , m_Canonical(false) { @@ -223,18 +224,18 @@ struct SEventInfo || m_Category != inEvent.m_Category || m_Description != inEvent.m_Description); } - TCharStr m_Name; - TCharStr m_FormalName; - TCharStr m_Category; - TCharStr m_Description; + QString m_Name; + QString m_FormalName; + QString m_Category; + QString m_Description; }; struct SHandlerInfo { - TCharStr m_Name; - TCharStr m_FormalName; - TCharStr m_Category; - TCharStr m_Description; + QString m_Name; + QString m_FormalName; + QString m_Category; + QString m_Description; bool operator!=(const SHandlerInfo &inHandler) const { @@ -271,12 +272,12 @@ struct SPropertyFilterInfo }; struct SMetaDataShader { - TCharStr m_Name; - TCharStr m_Type; ///< shader type (GLSL or HLSL) - TCharStr m_Version; ///< shader version (e.g. 330 vor GLSL) + QString m_Name; + QString m_Type; ///< shader type (GLSL or HLSL) + QString m_Version; ///< shader version (e.g. 330 vor GLSL) // Code contains both the vertex and fragment portions separated by #define's. //#define VERTEX_SHADER, #define FRAGMENT_SHADER - TCharStr m_Code; + QString m_Code; bool m_HasGeomShader; bool m_IsComputeShader; SMetaDataShader() @@ -284,8 +285,8 @@ struct SMetaDataShader , m_IsComputeShader(false) { } - SMetaDataShader(const TCharStr &inName, const TCharStr &inType, const TCharStr &inVersion, - const TCharStr &inCode, bool hasGeom, bool isCompute) + SMetaDataShader(const QString &inName, const QString &inType, const QString &inVersion, + const QString &inCode, bool hasGeom, bool isCompute) : m_Name(inName) , m_Type(inType) , m_Version(inVersion) @@ -298,13 +299,13 @@ struct SMetaDataShader struct SMetaDataDynamicObject { - TCharStr m_Name; - qt3ds::foundation::NVConstDataRef<SMetaDataShader> m_Shaders; - qt3ds::foundation::NVConstDataRef<qt3ds::render::dynamic::SPropertyDefinition> m_Properties; + QString m_Name; + QVector<SMetaDataShader> m_Shaders; + QVector<qt3ds::render::dynamic::SPropertyDefinition> m_Properties; SMetaDataDynamicObject() {} SMetaDataDynamicObject( - const TCharStr &inName, qt3ds::foundation::NVConstDataRef<SMetaDataShader> inShaders, - qt3ds::foundation::NVConstDataRef<qt3ds::render::dynamic::SPropertyDefinition> inProperties) + const QString &inName, const QVector<SMetaDataShader> &inShaders, + const QVector<qt3ds::render::dynamic::SPropertyDefinition> &inProperties) : m_Name(inName) , m_Shaders(inShaders) , m_Properties(inProperties) @@ -314,12 +315,12 @@ struct SMetaDataDynamicObject struct SMetaDataEffect : public SMetaDataDynamicObject { - qt3ds::foundation::NVConstDataRef<qt3ds::render::dynamic::SCommand *> m_EffectCommands; + QVector<qt3ds::render::dynamic::SCommand *> m_EffectCommands; SMetaDataEffect() {} SMetaDataEffect( - const TCharStr &inName, qt3ds::foundation::NVConstDataRef<SMetaDataShader> inShaders, - qt3ds::foundation::NVConstDataRef<qt3ds::render::dynamic::SPropertyDefinition> inProperties, - qt3ds::foundation::NVConstDataRef<qt3ds::render::dynamic::SCommand *> inEffectCommands) + const QString &inName, const QVector<SMetaDataShader> &inShaders, + const QVector<qt3ds::render::dynamic::SPropertyDefinition> &inProperties, + const QVector<qt3ds::render::dynamic::SCommand *> &inEffectCommands) : SMetaDataDynamicObject(inName, inShaders, inProperties) , m_EffectCommands(inEffectCommands) { @@ -328,7 +329,7 @@ struct SMetaDataEffect : public SMetaDataDynamicObject struct SMetaDataCustomMaterial : public SMetaDataDynamicObject { - qt3ds::foundation::NVConstDataRef<qt3ds::render::dynamic::SCommand *> m_CustomMaterialCommands; + QVector<qt3ds::render::dynamic::SCommand *> m_CustomMaterialCommands; bool m_HasTransparency; bool m_HasRefraction; bool m_AlwaysDirty; @@ -336,9 +337,9 @@ struct SMetaDataCustomMaterial : public SMetaDataDynamicObject unsigned int m_LayerCount; SMetaDataCustomMaterial() {} SMetaDataCustomMaterial( - const TCharStr &inName, qt3ds::foundation::NVConstDataRef<SMetaDataShader> inShaders, - qt3ds::foundation::NVConstDataRef<qt3ds::render::dynamic::SPropertyDefinition> inProperties, - qt3ds::foundation::NVConstDataRef<qt3ds::render::dynamic::SCommand *> inCustomMaterialCommands, + const QString &inName, const QVector<SMetaDataShader> &inShaders, + const QVector<qt3ds::render::dynamic::SPropertyDefinition> &inProperties, + const QVector<qt3ds::render::dynamic::SCommand *> &inCustomMaterialCommands, bool inHasTransparency, bool inHasRefraction, bool inIsAlwaysDirty, unsigned int inShaderKey, unsigned int inLayerCount) : SMetaDataDynamicObject(inName, inShaders, inProperties) diff --git a/src/Authoring/QT3DSDM/Systems/Qt3DSDMPropertyDefinition.h b/src/Authoring/QT3DSDM/Systems/Qt3DSDMPropertyDefinition.h index d324b539..0a5d2854 100644 --- a/src/Authoring/QT3DSDM/Systems/Qt3DSDMPropertyDefinition.h +++ b/src/Authoring/QT3DSDM/Systems/Qt3DSDMPropertyDefinition.h @@ -36,7 +36,7 @@ namespace qt3dsdm { struct Qt3DSDMPropertyDefinition { - TCharStr m_Name; + QString m_Name; Qt3DSDMInstanceHandle m_Instance; DataModelDataType::Value m_Type; @@ -44,7 +44,7 @@ struct Qt3DSDMPropertyDefinition : m_Type(DataModelDataType::None) { } - Qt3DSDMPropertyDefinition(Qt3DSDMInstanceHandle inInstanceHandle, TCharPtr inName, + Qt3DSDMPropertyDefinition(Qt3DSDMInstanceHandle inInstanceHandle, const QString &inName, DataModelDataType::Value inType) : m_Name(inName) , m_Instance(inInstanceHandle) diff --git a/src/Authoring/QT3DSDM/Systems/Qt3DSDMSignals.h b/src/Authoring/QT3DSDM/Systems/Qt3DSDMSignals.h index 57b96591..9fda2d46 100644 --- a/src/Authoring/QT3DSDM/Systems/Qt3DSDMSignals.h +++ b/src/Authoring/QT3DSDM/Systems/Qt3DSDMSignals.h @@ -103,9 +103,9 @@ public: const std::function<void(Qt3DSDMInstanceHandle, Qt3DSDMInstanceHandle)> &inCallback) = 0; virtual TSignalConnectionPtr ConnectPropertyAdded(const std::function<void(Qt3DSDMInstanceHandle, Qt3DSDMPropertyHandle, - TCharPtr, DataModelDataType::Value)> &inCallback) = 0; + const QString &, DataModelDataType::Value)> &inCallback) = 0; virtual TSignalConnectionPtr ConnectPropertyRemoved( - const std::function<void(Qt3DSDMInstanceHandle, Qt3DSDMPropertyHandle, TCharPtr, + const std::function<void(Qt3DSDMInstanceHandle, Qt3DSDMPropertyHandle, const QString &, DataModelDataType::Value)> &inCallback) = 0; }; @@ -120,10 +120,10 @@ public: virtual void SignalInstanceParentRemoved(Qt3DSDMInstanceHandle inInstance, Qt3DSDMInstanceHandle inParent) = 0; virtual void SignalPropertyAdded(Qt3DSDMInstanceHandle inInstance, - Qt3DSDMPropertyHandle inProperty, TCharPtr inName, + Qt3DSDMPropertyHandle inProperty, const QString &inName, DataModelDataType::Value inDataType) = 0; virtual void SignalPropertyRemoved(Qt3DSDMInstanceHandle inInstance, - Qt3DSDMPropertyHandle inProperty, TCharPtr inName, + Qt3DSDMPropertyHandle inProperty, const QString &inName, DataModelDataType::Value inDataType) = 0; }; @@ -253,16 +253,16 @@ public: virtual TSignalConnectionPtr ConnectTargetObjectSet( const std::function<void(Qt3DSDMActionHandle, SObjectRefType &)> &inCallback) = 0; virtual TSignalConnectionPtr ConnectEventSet( - const std::function<void(Qt3DSDMActionHandle, const wstring &)> &inCallback) = 0; + const std::function<void(Qt3DSDMActionHandle, const QString &)> &inCallback) = 0; virtual TSignalConnectionPtr ConnectHandlerSet( - const std::function<void(Qt3DSDMActionHandle, const wstring &)> &inCallback) = 0; + const std::function<void(Qt3DSDMActionHandle, const QString &)> &inCallback) = 0; virtual TSignalConnectionPtr ConnectHandlerArgumentAdded( - const std::function<void(Qt3DSDMActionHandle, Qt3DSDMHandlerArgHandle, const TCharStr &, - HandlerArgumentType::Value, DataModelDataType::Value)> &inCallback) = 0; + const std::function<void(Qt3DSDMActionHandle, Qt3DSDMHandlerArgHandle, const QString &, + HandlerArgumentType::Value, DataModelDataType::Value)> &inCallback) = 0; virtual TSignalConnectionPtr ConnectHandlerArgumentRemoved( - const std::function<void(Qt3DSDMActionHandle, Qt3DSDMHandlerArgHandle, const TCharStr &, - HandlerArgumentType::Value, DataModelDataType::Value)> &inCallback) = 0; + const std::function<void(Qt3DSDMActionHandle, Qt3DSDMHandlerArgHandle, const QString &, + HandlerArgumentType::Value, DataModelDataType::Value)> &inCallback) = 0; virtual TSignalConnectionPtr ConnectHandlerArgumentValueSet( const std::function<void(Qt3DSDMHandlerArgHandle, const SValue &)> &inCallback) = 0; }; @@ -274,16 +274,18 @@ public: SObjectRefType &inTriggerObject) = 0; virtual void SendTargetObjectSet(Qt3DSDMActionHandle inAction, SObjectRefType &inTargetObject) = 0; - virtual void SendEventSet(Qt3DSDMActionHandle inAction, const wstring &inEventHandle) = 0; - virtual void SendHandlerSet(Qt3DSDMActionHandle inAction, const wstring &inActionName) = 0; + virtual void SendEventSet(Qt3DSDMActionHandle inAction, const QString &inEventHandle) = 0; + virtual void SendHandlerSet(Qt3DSDMActionHandle inAction, const QString &inActionName) = 0; virtual void SendHandlerArgumentAdded(Qt3DSDMActionHandle inAction, Qt3DSDMHandlerArgHandle inHandlerArgument, - const TCharStr &inName, HandlerArgumentType::Value inArgType, + const QString &inName, + HandlerArgumentType::Value inArgType, DataModelDataType::Value inValueType) = 0; virtual void SendHandlerArgumentRemoved(Qt3DSDMActionHandle inAction, Qt3DSDMHandlerArgHandle inHandlerArgument, - const TCharStr &inName, HandlerArgumentType::Value inArgType, + const QString &inName, + HandlerArgumentType::Value inArgType, DataModelDataType::Value inValueType) = 0; virtual void SendHandlerArgumentValueSet(Qt3DSDMHandlerArgHandle inHandlerArgument, const SValue &inValue) = 0; @@ -341,7 +343,7 @@ public: const std::function<void(Qt3DSDMHandlerParamHandle)> &inCallback) = 0; virtual TSignalConnectionPtr ConnectCustomReferencesModified( - const std::function<void(Qt3DSDMInstanceHandle, const TCharStr &)> &inCallback) = 0; + const std::function<void(Qt3DSDMInstanceHandle, const QString &)> &inCallback) = 0; }; class ICustomPropCoreSignalSender : public ISignalItem @@ -372,7 +374,7 @@ public: virtual void SendCustomHandlerParamModified(Qt3DSDMHandlerParamHandle inParameter) = 0; virtual void SendCustomReferencesModified(Qt3DSDMInstanceHandle inOwner, - const TCharStr &inString) = 0; + const QString &inString) = 0; }; class ISlideSystemSignalProvider : public ISignalItem @@ -513,7 +515,7 @@ public: virtual TSignalConnectionPtr ConnectCustomHandlerParamModified( const std::function<void(Qt3DSDMHandlerParamHandle)> &inCallback) = 0; virtual TSignalConnectionPtr ConnectCustomReferencesModified( - const std::function<void(Qt3DSDMInstanceHandle, const TCharStr &)> &inCallback) = 0; + const std::function<void(Qt3DSDMInstanceHandle, const QString &)> &inCallback) = 0; virtual TSignalConnectionPtr ConnectControlledToggled( const std::function<void(Qt3DSDMInstanceHandle, Qt3DSDMPropertyHandle)> &inCallback) = 0; }; @@ -585,7 +587,7 @@ public: Qt3DSDMHandlerHandle inHandler) = 0; virtual void SendCustomHandlerParamModified(Qt3DSDMHandlerParamHandle inParameter) = 0; virtual void SendCustomReferencesModified(Qt3DSDMInstanceHandle inOwner, - const TCharStr &inString) = 0; + const QString &inString) = 0; virtual void SendControlledToggled(Qt3DSDMInstanceHandle inInstance, Qt3DSDMPropertyHandle inProperty) = 0; }; diff --git a/src/Authoring/QT3DSDM/Systems/Qt3DSDMValue.h b/src/Authoring/QT3DSDM/Systems/Qt3DSDMValue.h index 1e6870ee..cc610e90 100644 --- a/src/Authoring/QT3DSDM/Systems/Qt3DSDMValue.h +++ b/src/Authoring/QT3DSDM/Systems/Qt3DSDMValue.h @@ -299,7 +299,7 @@ inline QColor get<QColor>(const SValue &inType) template <> inline QString get<QString>(const qt3dsdm::SValue &inType) { - return QString::fromWCharArray(qt3dsdm::get<qt3dsdm::TDataStrPtr>(inType)->GetData()); + return qt3dsdm::get<qt3dsdm::TDataStrPtr>(inType)->toQString(); } template <> diff --git a/src/Authoring/QT3DSDM/Systems/Qt3DSDMWStrOpsImpl.h b/src/Authoring/QT3DSDM/Systems/Qt3DSDMWStrOpsImpl.h index bbc3b8d4..94948146 100644 --- a/src/Authoring/QT3DSDM/Systems/Qt3DSDMWStrOpsImpl.h +++ b/src/Authoring/QT3DSDM/Systems/Qt3DSDMWStrOpsImpl.h @@ -611,6 +611,30 @@ struct WCharTReader else outBuffer = NVConstDataRef<TDataType>(); } + template <typename TDataType> + void ReadBuffer(QVector<TDataType> &outBuffer) + { + m_Buffer.clear(); + m_StartPtr = FindNextNonWhitespace(m_StartPtr); + while (m_StartPtr && *m_StartPtr) { + char8_t *nextPtr = FindNextWhitespace(m_StartPtr); + if (nextPtr && *nextPtr) + *nextPtr = 0; + else + nextPtr = NULL; + TDataType temp; + WStrOps<TDataType>().StrTo(m_StartPtr, temp); + m_Buffer.write(temp); + m_StartPtr = nextPtr; + if (m_StartPtr) + m_StartPtr = FindNextNonWhitespace(m_StartPtr + 1); + } + QT3DSU32 numItems = m_Buffer.size() / sizeof(TDataType); + if (numItems) { + outBuffer.resize(numItems); + memcpy(outBuffer.data(), m_Buffer.begin(), numItems * sizeof(TDataType)); + } + } }; template <> @@ -679,6 +703,30 @@ struct WStrOps<EAnimationType> return 0; } } + QT3DSU32 ToStr(EAnimationType value, NVDataRef<char8_t> buffer) + { + const char8_t *animType = NULL; + switch (value) { + case EAnimationTypeLinear: + animType = "Linear"; + break; + case EAnimationTypeBezier: + animType = "Bezier"; + break; + case EAnimationTypeEaseInOut: + animType = "EaseInOut"; + break; + default: + QT3DS_ASSERT(false); + break; + } + if (animType != NULL) + return snprintf(buffer.begin(), buffer.size(), "%s", animType); + else { + QT3DS_ASSERT(false); + return 0; + } + } bool StrTo(const wchar_t *buffer, EAnimationType &item) { if (AreEqual(L"Linear", buffer)) { @@ -702,14 +750,18 @@ template <> struct WStrOps<CompleteMetaDataType::Enum> { QT3DSU32 ToStr(CompleteMetaDataType::Enum item, NVDataRef<wchar_t> buffer); + QT3DSU32 ToStr(CompleteMetaDataType::Enum item, NVDataRef<char8_t> buffer); bool StrTo(const wchar_t *buffer, CompleteMetaDataType::Enum &item); + bool StrTo(const char8_t *buffer, CompleteMetaDataType::Enum &item); }; template <> struct WStrOps<HandlerArgumentType::Value> { QT3DSU32 ToStr(HandlerArgumentType::Value item, NVDataRef<wchar_t> buffer); + QT3DSU32 ToStr(HandlerArgumentType::Value item, NVDataRef<char8_t> buffer); bool StrTo(const wchar_t *buffer, HandlerArgumentType::Value &item); + bool StrTo(const char8_t *buffer, HandlerArgumentType::Value &item); }; #ifndef __clang__ diff --git a/src/Authoring/QT3DSDM/Systems/Qt3DSDMXML.cpp b/src/Authoring/QT3DSDM/Systems/Qt3DSDMXML.cpp index b1cb9235..1abb22ac 100644 --- a/src/Authoring/QT3DSDM/Systems/Qt3DSDMXML.cpp +++ b/src/Authoring/QT3DSDM/Systems/Qt3DSDMXML.cpp @@ -60,749 +60,725 @@ using qt3ds::foundation::Pool; namespace qt3dsdm { -// All names are string table values so we can do straight -// pointer comparisons on them, we don't have the compare their -// values. -struct SDOMAttribute -{ - TXMLCharPtr m_Name; - TXMLCharPtr m_Value; - SDOMAttribute *m_NextAttribute; - - SDOMAttribute(TXMLCharPtr nm, TXMLCharPtr val) - : m_Name(nm) - , m_Value(val) - , m_NextAttribute(NULL) - { - } -}; +SDOMAttribute::SDOMAttribute(TXMLCharPtr nm, TXMLCharPtr val) + : m_Name(nm) + , m_Value(val) + , m_NextAttribute(NULL) +{ +} -struct SDOMElement -{ - TXMLCharPtr m_Name; - SDOMAttribute *m_FirstAttribute; - SDOMAttribute *m_LastAttribute; - SDOMElement *m_Parent; - SDOMElement *m_FirstChild; - SDOMElement *m_LastChild; - SDOMElement *m_NextSibling; - TXMLCharPtr m_Value; - - SDOMElement(TXMLCharPtr nm) - : m_Name(nm) - , m_FirstAttribute(nullptr) - , m_LastAttribute(nullptr) - , m_Parent(nullptr) - , m_FirstChild(nullptr) - , m_LastChild(nullptr) - , m_NextSibling(nullptr) - , m_Value("") - { - } +SDOMElement::SDOMElement(TXMLCharPtr nm) + : m_Name(nm) + , m_FirstAttribute(nullptr) + , m_LastAttribute(nullptr) + , m_Parent(nullptr) + , m_FirstChild(nullptr) + , m_LastChild(nullptr) + , m_NextSibling(nullptr) + , m_Value("") +{ +} - void AddAttribute(SDOMAttribute &att) - { - if (m_LastAttribute) { - m_LastAttribute->m_NextAttribute = &att; - m_LastAttribute = &att; - } else { - QT3DS_ASSERT(m_FirstAttribute == NULL); - m_FirstAttribute = m_LastAttribute = &att; - } - } - // Used to ensure duplicate attributes can't happen - void SetAttributeValue(TXMLCharPtr inName, TXMLCharPtr inValue, IDOMFactory &inFactory, - const SDOMFlags &inFlags) - { - inName = inFactory.GetStringTable()->RegisterStr(inName); - SDOMAttribute *att = FindAttribute(inName, inFlags); - if (att) { - att->m_Value = inFactory.RegisterValue(inValue); - } else { - AddAttribute(*inFactory.NextAttribute(inName, inValue)); - } +void SDOMElement::AddAttribute(SDOMAttribute &att) +{ + if (m_LastAttribute) { + m_LastAttribute->m_NextAttribute = &att; + m_LastAttribute = &att; + } else { + QT3DS_ASSERT(m_FirstAttribute == NULL); + m_FirstAttribute = m_LastAttribute = &att; } - void SetAttributeValue(TWideXMLCharPtr inName, TWideXMLCharPtr inValue, IDOMFactory &inFactory, - const SDOMFlags &inFlags) - { - TXMLCharPtr theName = inFactory.GetStringTable()->GetNarrowStr(inName); - SDOMAttribute *att = FindAttribute(theName, inFlags); - if (att) { - att->m_Value = inFactory.RegisterValue(inValue); - } else { - AddAttribute( - *inFactory.NextAttribute(inFactory.GetStringTable()->GetWideStr(inName), inValue)); - } +} +// Used to ensure duplicate attributes can't happen +void SDOMElement::SetAttributeValue(TXMLCharPtr inName, TXMLCharPtr inValue, IDOMFactory &inFactory, + const SDOMFlags &inFlags) +{ + inName = inFactory.GetStringTable()->RegisterStr(inName); + SDOMAttribute *att = FindAttribute(inName, inFlags); + if (att) { + att->m_Value = inFactory.RegisterValue(inValue); + } else { + AddAttribute(*inFactory.NextAttribute(inName, inValue)); } - const SDOMAttribute *FindAttribute(TXMLCharPtr nm, const SDOMFlags &inFlags) const - { - return const_cast<SDOMElement *>(this)->FindAttribute(nm, inFlags); +} +void SDOMElement::SetAttributeValue(TWideXMLCharPtr inName, TWideXMLCharPtr inValue, + IDOMFactory &inFactory, const SDOMFlags &inFlags) +{ + TXMLCharPtr theName = inFactory.GetStringTable()->GetNarrowStr(inName); + SDOMAttribute *att = FindAttribute(theName, inFlags); + if (att) { + att->m_Value = inFactory.RegisterValue(inValue); + } else { + AddAttribute( + *inFactory.NextAttribute(inFactory.GetStringTable()->GetWideStr(inName), inValue)); } - SDOMAttribute *FindAttribute(TXMLCharPtr nm, const SDOMFlags &inFlags) - { - for (SDOMAttribute *att = m_FirstAttribute; att != NULL; att = att->m_NextAttribute) { - if (att->m_Name == nm) - return att; - else if (inFlags.CaselessAttributes() && AreEqualCaseless(nm, att->m_Name)) - return att; - } - return NULL; +} +const SDOMAttribute *SDOMElement::FindAttribute(TXMLCharPtr nm, const SDOMFlags &inFlags) const +{ + return const_cast<SDOMElement *>(this)->FindAttribute(nm, inFlags); +} +SDOMAttribute *SDOMElement::FindAttribute(TXMLCharPtr nm, const SDOMFlags &inFlags) +{ + for (SDOMAttribute *att = m_FirstAttribute; att != NULL; att = att->m_NextAttribute) { + if (att->m_Name == nm) + return att; + else if (inFlags.CaselessAttributes() && AreEqualCaseless(nm, att->m_Name)) + return att; } - void RemoveAttribute(TXMLCharPtr nm, const SDOMFlags &inFlags) - { - SDOMAttribute *preatt = m_FirstAttribute; - for (SDOMAttribute *att = m_FirstAttribute; att != NULL; - preatt = att, att = att->m_NextAttribute) { - if (att->m_Name == nm - || (inFlags.CaselessAttributes() && AreEqualCaseless(nm, att->m_Name))) { - if (att == m_FirstAttribute) { - m_FirstAttribute = att->m_NextAttribute; - } else { - preatt->m_NextAttribute = att->m_NextAttribute; - if (att == m_LastAttribute) - m_LastAttribute = preatt; - } - - att->m_NextAttribute = NULL; + return NULL; +} +void SDOMElement::RemoveAttribute(TXMLCharPtr nm, const SDOMFlags &inFlags) +{ + SDOMAttribute *preatt = m_FirstAttribute; + for (SDOMAttribute *att = m_FirstAttribute; att != NULL; + preatt = att, att = att->m_NextAttribute) { + if (att->m_Name == nm + || (inFlags.CaselessAttributes() && AreEqualCaseless(nm, att->m_Name))) { + if (att == m_FirstAttribute) { + m_FirstAttribute = att->m_NextAttribute; + } else { + preatt->m_NextAttribute = att->m_NextAttribute; + if (att == m_LastAttribute) + m_LastAttribute = preatt; } + + att->m_NextAttribute = NULL; } } - TXMLCharPtr GetAttributeValue(TXMLCharPtr nm, SDOMFlags &inFlags) const - { - const SDOMAttribute *att = FindAttribute(nm, inFlags); - if (att) - return att->m_Value; - return NULL; +} +TXMLCharPtr SDOMElement::GetAttributeValue(TXMLCharPtr nm, SDOMFlags &inFlags) const +{ + const SDOMAttribute *att = FindAttribute(nm, inFlags); + if (att) + return att->m_Value; + return NULL; +} +void SDOMElement::AddChild(SDOMElement &elem) +{ + elem.m_Parent = this; + if (m_LastChild) { + m_LastChild->m_NextSibling = &elem; + m_LastChild = &elem; + } else { + QT3DS_ASSERT(m_FirstChild == NULL); + m_FirstChild = m_LastChild = &elem; } - void AddChild(SDOMElement &elem) - { - elem.m_Parent = this; - if (m_LastChild) { - m_LastChild->m_NextSibling = &elem; - m_LastChild = &elem; - } else { - QT3DS_ASSERT(m_FirstChild == NULL); - m_FirstChild = m_LastChild = &elem; - } +} +SDOMElement *SDOMElement::FindPreviousChild(SDOMElement &elem) +{ + if (&elem == m_FirstChild) + return NULL; + // Find the previous sibling. + SDOMElement *theChild = m_FirstChild; + // Empty loop intentional + for (; theChild && theChild->m_NextSibling != &elem; theChild = theChild->m_NextSibling) { } - SDOMElement *FindPreviousChild(SDOMElement &elem) - { - if (&elem == m_FirstChild) - return NULL; - // Find the previous sibling. - SDOMElement *theChild = m_FirstChild; - // Empty loop intentional - for (; theChild && theChild->m_NextSibling != &elem; theChild = theChild->m_NextSibling) { - } - return theChild; + return theChild; +} +void SDOMElement::RemoveChild(SDOMElement &elem) +{ + if (elem.m_Parent != this) { + QT3DS_ASSERT(false); + return; } - void RemoveChild(SDOMElement &elem) - { - if (elem.m_Parent != this) { - QT3DS_ASSERT(false); - return; - } - elem.m_Parent = NULL; - if (&elem == m_FirstChild) { - m_FirstChild = elem.m_NextSibling; - } else { - SDOMElement *theChild(FindPreviousChild(elem)); - QT3DS_ASSERT(theChild); - if (theChild) { - theChild->m_NextSibling = elem.m_NextSibling; - if (&elem == m_LastChild) - m_LastChild = theChild; - } + elem.m_Parent = NULL; + if (&elem == m_FirstChild) { + m_FirstChild = elem.m_NextSibling; + } else { + SDOMElement *theChild(FindPreviousChild(elem)); + QT3DS_ASSERT(theChild); + if (theChild) { + theChild->m_NextSibling = elem.m_NextSibling; + if (&elem == m_LastChild) + m_LastChild = theChild; } - elem.m_NextSibling = NULL; } + elem.m_NextSibling = NULL; +} - void ReplaceChild(SDOMElement &inChild, SDOMElement &inReplacement) - { - inChild.m_Parent = NULL; - if (&inChild == m_FirstChild) - m_FirstChild = &inReplacement; - else { - SDOMElement *theChild(FindPreviousChild(inChild)); - QT3DS_ASSERT(theChild); - if (theChild) { - theChild->m_NextSibling = &inReplacement; - if (&inChild == m_LastChild) - m_LastChild = &inReplacement; - } +void SDOMElement::ReplaceChild(SDOMElement &inChild, SDOMElement &inReplacement) +{ + inChild.m_Parent = NULL; + if (&inChild == m_FirstChild) + m_FirstChild = &inReplacement; + else { + SDOMElement *theChild(FindPreviousChild(inChild)); + QT3DS_ASSERT(theChild); + if (theChild) { + theChild->m_NextSibling = &inReplacement; + if (&inChild == m_LastChild) + m_LastChild = &inReplacement; } - inReplacement.m_NextSibling = inChild.m_NextSibling; - inReplacement.m_Parent = this; - inChild.m_NextSibling = NULL; } + inReplacement.m_NextSibling = inChild.m_NextSibling; + inReplacement.m_Parent = this; + inChild.m_NextSibling = NULL; +} - void InsertChildBefore(SDOMElement &elem, SDOMElement &theSibling) - { - // Ensure elem isn't in the graph. - QT3DS_ASSERT(elem.m_Parent == NULL); - QT3DS_ASSERT(elem.m_NextSibling == NULL); - elem.m_Parent = this; - if (&theSibling == m_FirstChild) - m_FirstChild = &elem; - else { - SDOMElement *thePrevious = FindPreviousChild(theSibling); - QT3DS_ASSERT(thePrevious); - if (thePrevious) - thePrevious->m_NextSibling = &elem; - } - - elem.m_NextSibling = &theSibling; - } - QT3DSU32 GetNumChildren(TXMLCharPtr inChildName, const SDOMFlags &inFlags) const - { - QT3DSU32 idx = 0; - for (SDOMElement *elem = m_FirstChild; elem != NULL; elem = elem->m_NextSibling) { - if (elem->m_Name == inChildName) - ++idx; - else if (inFlags.CaselessElements() && AreEqualCaseless(inChildName, elem->m_Name)) - ++idx; - } - return idx; - } - QT3DSU32 GetNumChildren() const - { - QT3DSU32 idx = 0; - for (SDOMElement *elem = m_FirstChild; elem != NULL; elem = elem->m_NextSibling) +void SDOMElement::InsertChildBefore(SDOMElement &elem, SDOMElement &theSibling) +{ + // Ensure elem isn't in the graph. + QT3DS_ASSERT(elem.m_Parent == NULL); + QT3DS_ASSERT(elem.m_NextSibling == NULL); + elem.m_Parent = this; + if (&theSibling == m_FirstChild) + m_FirstChild = &elem; + else { + SDOMElement *thePrevious = FindPreviousChild(theSibling); + QT3DS_ASSERT(thePrevious); + if (thePrevious) + thePrevious->m_NextSibling = &elem; + } + + elem.m_NextSibling = &theSibling; +} +QT3DSU32 SDOMElement::GetNumChildren(TXMLCharPtr inChildName, const SDOMFlags &inFlags) const +{ + QT3DSU32 idx = 0; + for (SDOMElement *elem = m_FirstChild; elem != NULL; elem = elem->m_NextSibling) { + if (elem->m_Name == inChildName) + ++idx; + else if (inFlags.CaselessElements() && AreEqualCaseless(inChildName, elem->m_Name)) ++idx; - return idx; } - SDOMElement *FindChildByName(TXMLCharPtr nm, const SDOMFlags &inFlags) const - { - for (SDOMElement *elem = m_FirstChild; elem != NULL; elem = elem->m_NextSibling) { - if (elem->m_Name == nm) - return elem; - else if (inFlags.CaselessElements() && AreEqualCaseless(nm, elem->m_Name)) - return elem; - } - return NULL; + return idx; +} +QT3DSU32 SDOMElement::GetNumChildren() const +{ + QT3DSU32 idx = 0; + for (SDOMElement *elem = m_FirstChild; elem != NULL; elem = elem->m_NextSibling) + ++idx; + return idx; +} +SDOMElement *SDOMElement::FindChildByName(TXMLCharPtr nm, const SDOMFlags &inFlags) const +{ + for (SDOMElement *elem = m_FirstChild; elem != NULL; elem = elem->m_NextSibling) { + if (elem->m_Name == nm) + return elem; + else if (inFlags.CaselessElements() && AreEqualCaseless(nm, elem->m_Name)) + return elem; } - SDOMElement *FindNextSiblingByName(TXMLCharPtr nm, const SDOMFlags &inFlags) const - { - for (SDOMElement *elem = m_NextSibling; elem != NULL; elem = elem->m_NextSibling) { - if (elem->m_Name == nm) - return elem; - else if (inFlags.CaselessElements() && AreEqualCaseless(nm, elem->m_Name)) - return elem; - } - return NULL; + return NULL; +} +SDOMElement *SDOMElement::FindNextSiblingByName(TXMLCharPtr nm, const SDOMFlags &inFlags) const +{ + for (SDOMElement *elem = m_NextSibling; elem != NULL; elem = elem->m_NextSibling) { + if (elem->m_Name == nm) + return elem; + else if (inFlags.CaselessElements() && AreEqualCaseless(nm, elem->m_Name)) + return elem; } -}; + return NULL; +} + } -namespace { const QT3DSU16 g_BOMMarker = (QT3DSU16)0xFEFF; -struct SElemPointer : eastl::pair<SDOMElement *, SDOMAttribute *> +SElemPointer::SElemPointer(SDOMElement *elem) + : std::pair<SDOMElement *, SDOMAttribute *>(elem, NULL) { - SElemPointer(SDOMElement *elem = NULL) - : eastl::pair<SDOMElement *, SDOMAttribute *>(elem, NULL) - { - } - SElemPointer &operator=(SDOMElement *elem) - { - first = elem; - second = NULL; - return *this; - } - SElemPointer &operator=(SDOMAttribute *att) - { - second = att; - return *this; - } - SElemPointer &operator=(const eastl::pair<SDOMElement *, SDOMAttribute *> &other) - { - eastl::pair<SDOMElement *, SDOMAttribute *>::operator=(other); - return *this; - } - operator SDOMElement *() const { return first; } - SDOMElement *operator->() const { return first; } -}; +} +SElemPointer &SElemPointer::operator=(SDOMElement *elem) +{ + first = elem; + second = NULL; + return *this; +} +SElemPointer &SElemPointer::operator=(SDOMAttribute *att) +{ + second = att; + return *this; +} +SElemPointer &SElemPointer::operator=(const std::pair<SDOMElement *, SDOMAttribute *> &other) +{ + std::pair<SDOMElement *, SDOMAttribute *>::operator=(other); + return *this; +} +SElemPointer::operator SDOMElement *() const { return first; } +SDOMElement *SElemPointer::operator->() const { return first; } + // Some DOM parsing operations are destructive. If you need // them to not be destructive, then we need to modify // the reader. Specifically parsing lists of floats, due // to a bug in strtod, is destructive. -struct SDOMReader : public IDOMReader -{ - SElemPointer m_TopElement; - eastl::vector<eastl::pair<SDOMElement *, SDOMAttribute *>> m_ScopeStack; - std::shared_ptr<IDOMFactory> m_Factory; - SDOMFlags m_Flags; - eastl::basic_string<TWCharEASTLConverter::TCharType> m_TempBuffer; - - SDOMReader(SDOMElement &te, std::shared_ptr<qt3dsdm::IStringTable> s, - std::shared_ptr<IDOMFactory> inFactory = std::shared_ptr<IDOMFactory>()) - : IDOMReader(s) - , m_TopElement(&te) - , m_Factory(inFactory) - { - } - - SDOMElement *Current() const { return m_TopElement.first; } - void SetDOMFlags(SDOMFlags inFlags) override { m_Flags = inFlags; } - SDOMFlags GetDOMFlags() const override { return m_Flags; } - - void PushScope() override { m_ScopeStack.push_back(m_TopElement); } - void PopScope() override - { - if (m_ScopeStack.size()) { - m_TopElement = m_ScopeStack.back(); - m_ScopeStack.pop_back(); - } else - m_TopElement = eastl::pair<SDOMElement *, SDOMAttribute *>(NULL, NULL); - } - void *GetScope() override { return m_TopElement.first; } +SDOMReader::SDOMReader(SDOMElement &te, std::shared_ptr<qt3dsdm::IStringTable> s, + std::shared_ptr<IDOMFactory> inFactory) + : IDOMReader(s) + , m_TopElement(&te) + , m_Factory(inFactory) +{ +} - void SetScope(void *inScope) override - { - m_TopElement = - eastl::make_pair(reinterpret_cast<SDOMElement *>(inScope), (SDOMAttribute *)NULL); - } +SDOMElement *SDOMReader::Current() const { return m_TopElement.first; } +void SDOMReader::SetDOMFlags(SDOMFlags inFlags) { m_Flags = inFlags; } +SDOMFlags SDOMReader::GetDOMFlags() const { return m_Flags; } - TWideXMLCharPtr GetElementName() const override - { - return m_StringTable->GetWideStr(GetNarrowElementName()); +void SDOMReader::PushScope() { m_ScopeStack.push_back(m_TopElement); } +void SDOMReader::PopScope() { + if (m_ScopeStack.size()) { + m_TopElement = m_ScopeStack.back(); + m_ScopeStack.pop_back(); + } else { + m_TopElement = std::pair<SDOMElement *, SDOMAttribute *>(NULL, NULL); } +} - TXMLCharPtr GetNarrowElementName() const override - { - if (!Current()) { - QT3DS_ASSERT(false); - return NULL; - } - return Current()->m_Name; - } +void *SDOMReader::GetScope() { return m_TopElement.first; } - bool UnregisteredAtt(TWideXMLCharPtr name, TWideXMLCharPtr &outValue) override - { - outValue = L""; - SDOMElement *current(Current()); - if (current) { - TXMLCharPtr theValue = - current->GetAttributeValue(m_StringTable->GetNarrowStr(name), m_Flags); - if (theValue && *theValue) { - ConvertUTF(theValue, 0, m_TempBuffer); - outValue = reinterpret_cast<const wchar_t *>(m_TempBuffer.c_str()); - return true; - } - } else { - QT3DS_ASSERT(false); - } - return false; - } +void SDOMReader::SetScope(void *inScope) { + m_TopElement = + std::make_pair(reinterpret_cast<SDOMElement *>(inScope), (SDOMAttribute *)NULL); +} - bool UnregisteredAtt(TXMLCharPtr name, TXMLCharPtr &outValue) override - { - outValue = ""; - SDOMElement *current(Current()); - if (current) { - outValue = current->GetAttributeValue(m_StringTable->GetNarrowStr(name), m_Flags); - if (outValue) - return true; - } else { - QT3DS_ASSERT(false); - } - return false; +QString SDOMReader::GetElementName() const { + if (!Current()) { + QT3DS_ASSERT(false); + return NULL; } + return QString::fromLatin1(Current()->m_Name); +} - bool Att(TWideXMLCharPtr name, TWideXMLCharPtr &outValue) override - { - if (UnregisteredAtt(name, outValue)) { - outValue = m_StringTable->RegisterStr(outValue); +bool SDOMReader::UnregisteredAtt(TWideXMLCharPtr name, TWideXMLCharPtr &outValue) { + outValue = L""; + SDOMElement *current(Current()); + if (current) { + TXMLCharPtr theValue = + current->GetAttributeValue(m_StringTable->GetNarrowStr(name), m_Flags); + if (theValue && *theValue) { + ConvertUTF(theValue, 0, m_TempBuffer); + outValue = reinterpret_cast<const wchar_t *>(m_TempBuffer.c_str()); return true; } - return false; + } else { + QT3DS_ASSERT(false); } - bool Att(TXMLCharPtr name, TXMLCharPtr &outValue) override - { - if (UnregisteredAtt(name, outValue)) { - outValue = m_StringTable->RegisterStr(outValue); + return false; +} + +bool SDOMReader::UnregisteredAtt(TXMLCharPtr name, TXMLCharPtr &outValue) { + outValue = ""; + SDOMElement *current(Current()); + if (current) { + outValue = current->GetAttributeValue(m_StringTable->GetNarrowStr(name), m_Flags); + if (outValue) return true; - } - return false; + } else { + QT3DS_ASSERT(false); } + return false; +} - QT3DSU32 CountChildren() override - { - SDOMElement *elem = Current(); - if (elem == NULL) { - QT3DS_ASSERT(false); - return 0; - } - return elem->GetNumChildren(); +bool SDOMReader::Att(TWideXMLCharPtr name, TWideXMLCharPtr &outValue) { + if (UnregisteredAtt(name, outValue)) { + outValue = m_StringTable->RegisterStr(outValue); + return true; } - - QT3DSU32 CountChildren(TWideXMLCharPtr childName) override - { - return CountChildren(m_StringTable->GetNarrowStr(childName)); + return false; +} +bool SDOMReader::Att(TXMLCharPtr name, TXMLCharPtr &outValue) { + if (UnregisteredAtt(name, outValue)) { + outValue = m_StringTable->RegisterStr(outValue); + return true; } + return false; +} - QT3DSU32 CountChildren(TXMLCharPtr childName) override - { - SDOMElement *elem = Current(); - if (elem == NULL) { - QT3DS_ASSERT(false); - return 0; - } - return elem->GetNumChildren(m_StringTable->GetNarrowStr(childName), m_Flags); +QT3DSU32 SDOMReader::CountChildren() +{ + SDOMElement *elem = Current(); + if (elem == NULL) { + QT3DS_ASSERT(false); + return 0; } + return elem->GetNumChildren(); +} - eastl::pair<TWideXMLCharPtr, TWideXMLCharPtr> - ToWide(const eastl::pair<TXMLCharPtr, TXMLCharPtr> &att) - { - return eastl::make_pair(m_StringTable->GetWideStr(att.first), - m_StringTable->GetWideStr(att.second)); - } - eastl::pair<TWideXMLCharPtr, TWideXMLCharPtr> CurrentAtt() - { - return ToWide(CurrentAttNarrow()); - } +QT3DSU32 SDOMReader::CountChildren(TWideXMLCharPtr childName) +{ + return CountChildren(m_StringTable->GetNarrowStr(childName)); +} - eastl::pair<TXMLCharPtr, TXMLCharPtr> CurrentAttNarrow() - { - if (m_TopElement.second) - return eastl::make_pair(m_TopElement.second->m_Name, m_TopElement.second->m_Value); - return eastl::make_pair("", ""); - } - eastl::pair<TXMLCharPtr, TXMLCharPtr> GetNarrowFirstAttribute() override - { - if (m_TopElement.first == NULL) { - QT3DS_ASSERT(false); - eastl::make_pair("", ""); - } - m_TopElement.second = m_TopElement.first->m_FirstAttribute; - return CurrentAttNarrow(); +QT3DSU32 SDOMReader::CountChildren(TXMLCharPtr childName) +{ + SDOMElement *elem = Current(); + if (elem == NULL) { + QT3DS_ASSERT(false); + return 0; } + return elem->GetNumChildren(m_StringTable->GetNarrowStr(childName), m_Flags); +} - eastl::pair<TWideXMLCharPtr, TWideXMLCharPtr> GetFirstAttribute() override - { - return ToWide(GetNarrowFirstAttribute()); - } - eastl::pair<TXMLCharPtr, TXMLCharPtr> GetNarrowNextAttribute() override - { - if (m_TopElement.second) - m_TopElement.second = m_TopElement.second->m_NextAttribute; - return CurrentAttNarrow(); +std::pair<QString, QString> SDOMReader::CurrentAttNarrow() +{ + if (m_TopElement.second) { + return std::make_pair(QString::fromLatin1(m_TopElement.second->m_Name), + QString::fromLatin1(m_TopElement.second->m_Value)); } + return std::make_pair(QString(), QString()); +} - eastl::pair<TWideXMLCharPtr, TWideXMLCharPtr> GetNextAttribute() override - { - return ToWide(GetNarrowNextAttribute()); - } +std::pair<QString, QString> SDOMReader::GetNextAttribute() +{ + if (m_TopElement.second) + m_TopElement.second = m_TopElement.second->m_NextAttribute; + return CurrentAttNarrow(); +} - bool MoveToFirstChild() override - { - SDOMElement *elem = Current(); - if (elem == NULL) { - QT3DS_ASSERT(false); - return false; - } - if (elem->m_FirstChild) { - m_TopElement = elem->m_FirstChild; - return true; - } - return false; +std::pair<QString, QString> SDOMReader::GetFirstAttribute() +{ + if (m_TopElement.first == NULL) { + QT3DS_ASSERT(false); + std::make_pair(QString(), QString()); } - bool MoveToFirstChild(TXMLCharPtr childName) override - { - SDOMElement *elem = Current(); - if (elem == NULL) { - QT3DS_ASSERT(false); - return false; - } - SDOMElement *child = elem->FindChildByName(m_StringTable->RegisterStr(childName), m_Flags); - if (child != NULL) { - m_TopElement = child; - return true; - } + m_TopElement.second = m_TopElement.first->m_FirstAttribute; + return CurrentAttNarrow(); +} + +bool SDOMReader::MoveToFirstChild() +{ + SDOMElement *elem = Current(); + if (elem == NULL) { + QT3DS_ASSERT(false); return false; } - - bool MoveToFirstChild(TWideXMLCharPtr childName) override - { - return MoveToFirstChild(m_StringTable->GetNarrowStr(childName)); + if (elem->m_FirstChild) { + m_TopElement = elem->m_FirstChild; + return true; } + return false; +} - bool MoveToNextSibling() override - { - SDOMElement *elem = Current(); - if (elem == NULL) { - QT3DS_ASSERT(false); - return false; - } - if (elem->m_NextSibling) { - m_TopElement = elem->m_NextSibling; - return true; - } +bool SDOMReader::MoveToFirstChild(TXMLCharPtr childName) +{ + SDOMElement *elem = Current(); + if (elem == NULL) { + QT3DS_ASSERT(false); return false; } - bool MoveToNextSibling(TXMLCharPtr childName) override - { - SDOMElement *elem = Current(); - if (elem == NULL) { - QT3DS_ASSERT(false); - return false; - } - SDOMElement *nextSibling = - elem->FindNextSiblingByName(m_StringTable->RegisterStr(childName), m_Flags); - if (nextSibling) { - m_TopElement = nextSibling; - return true; - } + SDOMElement *child = elem->FindChildByName(m_StringTable->RegisterStr(childName), m_Flags); + if (child != NULL) { + m_TopElement = child; + return true; + } + return false; +} + +bool SDOMReader::MoveToFirstChild(TWideXMLCharPtr childName) +{ + return MoveToFirstChild(m_StringTable->GetNarrowStr(childName)); +} + +bool SDOMReader::MoveToNextSibling() +{ + SDOMElement *elem = Current(); + if (elem == NULL) { + QT3DS_ASSERT(false); return false; } - bool MoveToNextSibling(TWideXMLCharPtr childName) override - { - return MoveToNextSibling(m_StringTable->GetNarrowStr(childName)); + if (elem->m_NextSibling) { + m_TopElement = elem->m_NextSibling; + return true; } - // Leave element means go to its parent. - void Leave() override - { - if (m_TopElement) - m_TopElement = m_TopElement->m_Parent; + return false; +} - QT3DS_ASSERT(m_TopElement); +bool SDOMReader::MoveToNextSibling(TXMLCharPtr childName) +{ + SDOMElement *elem = Current(); + if (elem == NULL) { + QT3DS_ASSERT(false); + return false; } - bool Value(TXMLCharPtr &outValue) override - { - SDOMElement *current(Current()); - if (!current) { - QT3DS_ASSERT(false); - return false; - } - outValue = current->m_Value; + SDOMElement *nextSibling + = elem->FindNextSiblingByName(m_StringTable->RegisterStr(childName), m_Flags); + if (nextSibling) { + m_TopElement = nextSibling; return true; } + return false; +} - bool Value(TWideXMLCharPtr &outValue) override - { - outValue = L""; - TXMLCharPtr theValue; - if (Value(theValue)) { - ConvertUTF(theValue, 0, m_TempBuffer); - outValue = reinterpret_cast<const wchar_t *>(m_TempBuffer.c_str()); - return true; - } +bool SDOMReader::MoveToNextSibling(TWideXMLCharPtr childName) +{ + return MoveToNextSibling(m_StringTable->GetNarrowStr(childName)); +} + +bool SDOMReader::MoveToNextSibling(const QString &childName) +{ + return MoveToNextSibling(qPrintable(childName)); +} + +bool SDOMReader::MoveToFirstChild(const QString &childName) +{ + return MoveToFirstChild(qPrintable(childName)); +} + +// Leave element means go to its parent. +void SDOMReader::Leave() +{ + if (m_TopElement) + m_TopElement = m_TopElement->m_Parent; + + QT3DS_ASSERT(m_TopElement); +} +bool SDOMReader::Value(TXMLCharPtr &outValue) +{ + SDOMElement *current(Current()); + if (!current) { + QT3DS_ASSERT(false); return false; } + outValue = current->m_Value; + return true; +} - SDOMElement *GetTopElement() override - { - SDOMElement *current(Current()); - while (current && current->m_Parent) - current = current->m_Parent; - return current; +bool SDOMReader::Value(TWideXMLCharPtr &outValue) +{ + outValue = L""; + TXMLCharPtr theValue; + if (Value(theValue)) { + ConvertUTF(theValue, 0, m_TempBuffer); + outValue = reinterpret_cast<const wchar_t *>(m_TempBuffer.c_str()); + return true; } + return false; +} - virtual std::shared_ptr<IDOMFactory> GetFactory() { return m_Factory; } -}; +bool SDOMReader::Value(QString &outValue) +{ + outValue = ""; + TXMLCharPtr theValue; + if (Value(theValue)) { + outValue = QString::fromLatin1(theValue); + return true; + } + return false; +} -struct SDOMWriter : public IDOMWriter, public SDOMReader +SDOMElement *SDOMReader::GetTopElement() const { - std::shared_ptr<IDOMFactory> m_FactoryPtr; - IDOMFactory &m_Factory; + SDOMElement *current(Current()); + while (current && current->m_Parent) + current = current->m_Parent; + return current; +} - SDOMWriter(std::shared_ptr<IDOMFactory> inDOMFactory, - std::shared_ptr<qt3dsdm::IStringTable> inStringTable, SDOMElement &inTopElem) - : m_FactoryPtr(inDOMFactory) - , m_Factory(*inDOMFactory) - , SDOMReader(inTopElem, inStringTable) - { - } - void SetDOMFlags(SDOMFlags inFlags) override { m_Flags = inFlags; } - SDOMFlags GetDOMFlags() const override { return m_Flags; } +std::shared_ptr<IDOMFactory> SDOMReader::GetFactory() const +{ + return m_Factory; +} - void Begin(TXMLCharPtr inElemName) override - { - if (!m_TopElement) { - QT3DS_ASSERT(false); - return; - } - SDOMElement *current(Current()); - SDOMElement *newElement(m_Factory.NextElement(inElemName)); - current->AddChild(*newElement); - m_TopElement = newElement; - } +SDOMWriter::SDOMWriter(std::shared_ptr<IDOMFactory> inDOMFactory, + std::shared_ptr<qt3dsdm::IStringTable> inStringTable, SDOMElement &inTopElem) + : m_FactoryPtr(inDOMFactory) + , m_Factory(*inDOMFactory) + , SDOMReader(inTopElem, inStringTable) +{ +} +void SDOMWriter::SetDOMFlags(SDOMFlags inFlags) { m_Flags = inFlags; } +SDOMFlags SDOMWriter::GetDOMFlags() const { return m_Flags; } - void Begin(TWideXMLCharPtr inElemName) override - { - Begin(m_FactoryPtr->GetStringTable()->GetNarrowStr(inElemName)); +void SDOMWriter::Begin(TXMLCharPtr inElemName) +{ + if (!m_TopElement) { + QT3DS_ASSERT(false); + return; } + SDOMElement *current(Current()); + SDOMElement *newElement(m_Factory.NextElement(inElemName)); + current->AddChild(*newElement); + m_TopElement = newElement; +} - void Att(TXMLCharPtr name, TXMLCharPtr value) override - { - if (!m_TopElement) { - QT3DS_ASSERT(false); - return; - } - m_TopElement->SetAttributeValue(name, value, m_Factory, m_Flags); +void SDOMWriter::Begin(TWideXMLCharPtr inElemName) +{ + Begin(m_FactoryPtr->GetStringTable()->GetNarrowStr(inElemName)); +} + +void SDOMWriter::Begin(const QString &inElemName) +{ + Begin(qPrintable(inElemName)); +} + +void SDOMWriter::Att(TXMLCharPtr name, TXMLCharPtr value) +{ + if (!m_TopElement) { + QT3DS_ASSERT(false); + return; } - // Attributes. They may be sorted just before write - void Att(TWideXMLCharPtr name, TWideXMLCharPtr value) override - { - if (!m_TopElement) { - QT3DS_ASSERT(false); - return; - } - m_TopElement->SetAttributeValue(name, value, m_Factory, m_Flags); + m_TopElement->SetAttributeValue(name, value, m_Factory, m_Flags); +} +// Attributes. They may be sorted just before write +void SDOMWriter::Att(TWideXMLCharPtr name, TWideXMLCharPtr value) +{ + if (!m_TopElement) { + QT3DS_ASSERT(false); + return; } + m_TopElement->SetAttributeValue(name, value, m_Factory, m_Flags); +} - void Value(TWideXMLCharPtr value) override - { - if (!m_TopElement) { - QT3DS_ASSERT(false); - return; - } - if (value == NULL) - value = L""; - size_t len = wcslen(value); - m_Factory.AppendStrBuf(value, (QT3DSU32)len); - m_TopElement->m_Value = m_Factory.FinalizeStrBuf(); +void SDOMWriter::Value(TWideXMLCharPtr value) +{ + if (!m_TopElement) { + QT3DS_ASSERT(false); + return; } - void Value(TXMLCharPtr value) override - { - if (!m_TopElement) { - QT3DS_ASSERT(false); - return; - } - if (value == NULL) - value = ""; - size_t len = strlen(value); - m_Factory.AppendStrBuf(value, (QT3DSU32)len); - m_TopElement->m_Value = m_Factory.FinalizeStrBuf(); + if (value == NULL) + value = L""; + size_t len = wcslen(value); + m_Factory.AppendStrBuf(value, (QT3DSU32)len); + m_TopElement->m_Value = m_Factory.FinalizeStrBuf(); +} +void SDOMWriter::Value(TXMLCharPtr value) +{ + if (!m_TopElement) { + QT3DS_ASSERT(false); + return; } + if (value == NULL) + value = ""; + size_t len = strlen(value); + m_Factory.AppendStrBuf(value, (QT3DSU32)len); + m_TopElement->m_Value = m_Factory.FinalizeStrBuf(); +} - void End() override - { - if (!m_TopElement) { - QT3DS_ASSERT(false); - return; - } - Leave(); +void SDOMWriter::Value(const QString &value) +{ + Value(qUtf16Printable(value)); +} + +void SDOMWriter::End() +{ + if (!m_TopElement) { + QT3DS_ASSERT(false); + return; } - void RemoveCurrent() override - { - SDOMElement *current(Current()); - if (!current) { - QT3DS_ASSERT(false); - return; - } - if (current->m_Parent) { - m_TopElement = current->m_Parent; - m_TopElement->RemoveChild(*current); - } + Leave(); +} +void SDOMWriter::RemoveCurrent() +{ + SDOMElement *current(Current()); + if (!current) { + QT3DS_ASSERT(false); + return; } - void ReplaceCurrent(SDOMElement &inElement) override - { - SDOMElement *current(Current()); - if (!current) { - QT3DS_ASSERT(false); - return; - } - if (current->m_Parent) { - current->m_Parent->ReplaceChild(*current, inElement); - m_TopElement = &inElement; - } else { - m_TopElement = &inElement; - inElement.m_Parent = NULL; - inElement.m_NextSibling = NULL; - } + if (current->m_Parent) { + m_TopElement = current->m_Parent; + m_TopElement->RemoveChild(*current); } - void AppendChildren(SDOMElement &inElement) override - { - SDOMElement *current(Current()); - if (!current) { - QT3DS_ASSERT(false); - return; - } - SDOMElement *theChild = inElement.m_FirstChild; - inElement.m_FirstChild = inElement.m_LastChild = NULL; - while (theChild) { - SDOMElement *theCurrentChild = theChild; - theChild = theChild->m_NextSibling; - - theCurrentChild->m_Parent = NULL; - theCurrentChild->m_NextSibling = NULL; - current->AddChild(*theCurrentChild); - } +} +void SDOMWriter::ReplaceCurrent(SDOMElement &inElement) +{ + SDOMElement *current(Current()); + if (!current) { + QT3DS_ASSERT(false); + return; } - void RemoveAttribute(TXMLCharPtr inItem) override - { - SDOMElement *current(Current()); - if (!current) { - QT3DS_ASSERT(false); - return; - } - current->RemoveAttribute(m_StringTable->RegisterStr(inItem), m_Flags); + if (current->m_Parent) { + current->m_Parent->ReplaceChild(*current, inElement); + m_TopElement = &inElement; + } else { + m_TopElement = &inElement; + inElement.m_Parent = NULL; + inElement.m_NextSibling = NULL; } - void RemoveAttribute(TWideXMLCharPtr inItem) override - { - RemoveAttribute(m_StringTable->GetNarrowStr(inItem)); +} +void SDOMWriter::AppendChildren(SDOMElement &inElement) +{ + SDOMElement *current(Current()); + if (!current) { + QT3DS_ASSERT(false); + return; } + SDOMElement *theChild = inElement.m_FirstChild; + inElement.m_FirstChild = inElement.m_LastChild = NULL; + while (theChild) { + SDOMElement *theCurrentChild = theChild; + theChild = theChild->m_NextSibling; - void MoveBefore(TXMLCharPtr inItem, TXMLCharPtr inSibling) override - { - SDOMElement *current(Current()); - if (!current) { - QT3DS_ASSERT(false); - return; - } - - SDOMElement *theItem = - current->FindChildByName(m_StringTable->RegisterStr(inItem), m_Flags); - SDOMElement *theSibling = - current->FindChildByName(m_StringTable->RegisterStr(inSibling), m_Flags); - QT3DS_ASSERT(theItem && theSibling); - if (theItem && theSibling) { - current->RemoveChild(*theItem); - current->InsertChildBefore(*theItem, *theSibling); - } + theCurrentChild->m_Parent = NULL; + theCurrentChild->m_NextSibling = NULL; + current->AddChild(*theCurrentChild); + } +} +void SDOMWriter::RemoveAttribute(TXMLCharPtr inItem) +{ + SDOMElement *current(Current()); + if (!current) { + QT3DS_ASSERT(false); + return; } + current->RemoveAttribute(m_StringTable->RegisterStr(inItem), m_Flags); +} +void SDOMWriter::RemoveAttribute(TWideXMLCharPtr inItem) +{ + RemoveAttribute(m_StringTable->GetNarrowStr(inItem)); +} - void MoveBefore(TWideXMLCharPtr inItem, TWideXMLCharPtr inSibling) override - { - MoveBefore(m_StringTable->GetNarrowStr(inItem), m_StringTable->GetNarrowStr(inSibling)); +void SDOMWriter::MoveBefore(TXMLCharPtr inItem, TXMLCharPtr inSibling) +{ + SDOMElement *current(Current()); + if (!current) { + QT3DS_ASSERT(false); + return; } - // If current has no parent, then we are at the top - // of the tree and we should return 0. Or if there is no - // current. - // If there is one parent, we should return 1. - QT3DSU32 GetTabs() override - { - QT3DSU32 retval = 0; - SDOMElement *current(Current()); - do { - if (current) - current = current->m_Parent; - if (current) - ++retval; - } while (current); - return retval; + SDOMElement *theItem = current->FindChildByName(m_StringTable->RegisterStr(inItem), m_Flags); + SDOMElement *theSibling + = current->FindChildByName(m_StringTable->RegisterStr(inSibling), m_Flags); + QT3DS_ASSERT(theItem && theSibling); + if (theItem && theSibling) { + current->RemoveChild(*theItem); + current->InsertChildBefore(*theItem, *theSibling); } +} + +void SDOMWriter::MoveBefore(TWideXMLCharPtr inItem, TWideXMLCharPtr inSibling) +{ + MoveBefore(m_StringTable->GetNarrowStr(inItem), m_StringTable->GetNarrowStr(inSibling)); +} - SDOMElement *GetTopElement() override { return SDOMReader::GetTopElement(); } +// If current has no parent, then we are at the top +// of the tree and we should return 0. Or if there is no +// current. +// If there is one parent, we should return 1. +QT3DSU32 SDOMWriter::GetTabs() +{ + QT3DSU32 retval = 0; + SDOMElement *current(Current()); + do { + if (current) + current = current->m_Parent; + if (current) + ++retval; + } while (current); + return retval; +} + +SDOMElement *SDOMWriter::GetTopElement() const +{ + return SDOMReader::GetTopElement(); +} + +std::shared_ptr<IDOMFactory> SDOMWriter::GetFactory() const +{ + return m_FactoryPtr; +} - std::shared_ptr<IDOMFactory> GetFactory() override { return m_FactoryPtr; } -}; struct SimpleXmlWriter { QIODevice &m_file; - eastl::vector<eastl::pair<TXMLCharPtr, bool>> m_OpenElements; + std::vector<std::pair<TXMLCharPtr, bool>> m_OpenElements; bool m_ElementOpen; wchar_t m_PrintBuf[256]; QT3DSU32 m_Tabs; - eastl::basic_string<char8_t> m_ConvertBuf; - eastl::basic_string<TWCharEASTLConverter::TCharType> m_WideBuffer; QTextStream m_stream; SimpleXmlWriter(QIODevice &stream, QT3DSU32 inTabs = 0) @@ -852,7 +828,7 @@ struct SimpleXmlWriter Tabs(); Write('<'); Write(name); - m_OpenElements.push_back(eastl::pair<TXMLCharPtr, bool>(name, false)); + m_OpenElements.push_back(std::pair<TXMLCharPtr, bool>(name, false)); m_ElementOpen = true; } TWideXMLCharPtr ToStr(char8_t val) @@ -962,7 +938,7 @@ struct SimpleXmlWriter void End(bool newlineAfterClose = true) { QT3DS_ASSERT(m_OpenElements.size()); - eastl::pair<TXMLCharPtr, bool> topElem = m_OpenElements.back(); + std::pair<TXMLCharPtr, bool> topElem = m_OpenElements.back(); m_OpenElements.pop_back(); if (m_ElementOpen) Write(" />"); @@ -981,7 +957,6 @@ struct SimpleXmlWriter struct DOMParser { - typedef eastl::basic_string<TWCharEASTLConverter::TCharType> TStrType; IDOMFactory &m_Factory; SDOMElement *m_TopElement; SDOMElement *m_FirstElement; @@ -1183,7 +1158,6 @@ public: std::shared_ptr<qt3dsdm::IStringTable> GetStringTable() override { return m_StringTable; } }; -} bool IDOMReader::Value(DataModelDataType::Value type, SValue &outValue) { @@ -1205,13 +1179,13 @@ IDOMReader::CreateDOMReader(SDOMElement &inRootElement, inFactory); } -eastl::pair<std::shared_ptr<IDOMWriter>, std::shared_ptr<IDOMReader>> +std::pair<std::shared_ptr<IDOMWriter>, std::shared_ptr<IDOMReader>> IDOMWriter::CreateDOMWriter(std::shared_ptr<IDOMFactory> inFactory, SDOMElement &inRootElement, std::shared_ptr<qt3dsdm::IStringTable> inStringTable) { std::shared_ptr<SDOMWriter> writer(std::make_shared<SDOMWriter>( inFactory, std::ref(inStringTable), std::ref(inRootElement))); - return eastl::make_pair(writer, writer); + return std::make_pair(writer, writer); } TXMLCharPtr IDOMFactory::RegisterValue(TWideXMLCharPtr inValue) diff --git a/src/Authoring/QT3DSDM/Systems/Qt3DSDMXML.h b/src/Authoring/QT3DSDM/Systems/Qt3DSDMXML.h index c62e287b..b2ba637d 100644 --- a/src/Authoring/QT3DSDM/Systems/Qt3DSDMXML.h +++ b/src/Authoring/QT3DSDM/Systems/Qt3DSDMXML.h @@ -167,30 +167,30 @@ public: // Return an attribute whose value *is* registered with the string table. virtual bool Att(TWideXMLCharPtr name, TWideXMLCharPtr &outValue) = 0; virtual bool Att(TXMLCharPtr name, TXMLCharPtr &outValue) = 0; - virtual eastl::pair<TWideXMLCharPtr, TWideXMLCharPtr> GetFirstAttribute() = 0; - virtual eastl::pair<TWideXMLCharPtr, TWideXMLCharPtr> GetNextAttribute() = 0; - virtual eastl::pair<TXMLCharPtr, TXMLCharPtr> GetNarrowFirstAttribute() = 0; - virtual eastl::pair<TXMLCharPtr, TXMLCharPtr> GetNarrowNextAttribute() = 0; + virtual std::pair<QString, QString> GetFirstAttribute() = 0; + virtual std::pair<QString, QString> GetNextAttribute() = 0; virtual QT3DSU32 CountChildren() = 0; virtual QT3DSU32 CountChildren(TWideXMLCharPtr childName) = 0; virtual QT3DSU32 CountChildren(TXMLCharPtr childName) = 0; virtual bool MoveToFirstChild(TWideXMLCharPtr childName) = 0; virtual bool MoveToFirstChild(TXMLCharPtr childName) = 0; + virtual bool MoveToFirstChild(const QString &childName) = 0; virtual bool MoveToFirstChild() = 0; virtual bool MoveToNextSibling(TWideXMLCharPtr siblingName) = 0; virtual bool MoveToNextSibling(TXMLCharPtr siblingName) = 0; + virtual bool MoveToNextSibling(const QString &childName) = 0; virtual bool MoveToNextSibling() = 0; // Leave element means go to its parent. virtual void Leave() = 0; - virtual TWideXMLCharPtr GetElementName() const = 0; - virtual TXMLCharPtr GetNarrowElementName() const = 0; + virtual QString GetElementName() const = 0; // Value is the concatentated text node values inside the element virtual bool Value(TWideXMLCharPtr &outValue) = 0; virtual bool Value(TXMLCharPtr &outValue) = 0; + virtual bool Value(QString &outValue) = 0; // Get the element this reader was created with - virtual SDOMElement *GetTopElement() = 0; + virtual SDOMElement *GetTopElement() const = 0; bool Att(TWideXMLCharPtr name, TXMLWideStr &outValue) { @@ -212,6 +212,26 @@ public: return false; } + bool Att(TWideXMLCharPtr name, QString &outValue) + { + TWideXMLCharPtr temp; + if (UnregisteredAtt(name, temp)) { + outValue = QString::fromWCharArray(temp); + return true; + } + return false; + } + + bool Att(const QString &name, QString &outValue) + { + TWideXMLCharPtr temp; + if (UnregisteredAtt(qUtf16Printable(name), temp)) { + outValue = QString::fromWCharArray(temp); + return true; + } + return false; + } + // Helpers to help make the parsing a bit easier. template <typename TDataType> bool Att(TWideXMLCharPtr name, TDataType &outValue) @@ -235,6 +255,17 @@ public: return false; } } + template <typename TDataType> + bool Att(const QString &name, TDataType &outValue) + { + TXMLCharPtr temp; + if (UnregisteredAtt(qPrintable(name), temp)) { + WStrOps<TDataType>().StrTo(temp, outValue); + return true; + } else { + return false; + } + } bool ChildValue(TXMLCharPtr name, TXMLCharPtr &value) { @@ -256,6 +287,16 @@ public: return false; } + bool ChildValue(const QString &name, QString &value) + { + if (MoveToFirstChild(name)) { + Value(value); + Leave(); + return true; + } + return false; + } + bool RegisteredChildValue(TWideXMLCharPtr name, TWideXMLCharPtr &value) { if (MoveToFirstChild(name)) { @@ -322,9 +363,15 @@ public: void Serialize(const wchar_t *elemName, TSerializer &serializer) { IDOMReader::Scope __theScope(*this); - if (MoveToFirstChild(elemName)) { + if (MoveToFirstChild(elemName)) + serializer.Serialize(*this); + } + template <typename TSerializer> + void Serialize(const QString &elemName, TSerializer &serializer) + { + IDOMReader::Scope __theScope(*this); + if (MoveToFirstChild(elemName)) serializer.Serialize(*this); - } } // Optionally hold on to the factory to keep our elements in memory as long as we are. static std::shared_ptr<IDOMReader> @@ -355,6 +402,11 @@ public: { m_Writer.Begin(inElemName); } + Scope(IDOMWriter &writer, const QString &inElemName) + : m_Writer(writer) + { + m_Writer.Begin(inElemName); + } ~Scope() { m_Writer.End(); } }; @@ -368,11 +420,13 @@ public: // and Values <b>onetwothree</b> virtual void Begin(TWideXMLCharPtr inElemName) = 0; virtual void Begin(TXMLCharPtr inElemName) = 0; + virtual void Begin(const QString &inElemName) = 0; // Attributes. They may be sorted just before write virtual void Att(TWideXMLCharPtr name, TWideXMLCharPtr value) = 0; virtual void Att(TXMLCharPtr name, TXMLCharPtr value) = 0; virtual void Value(TWideXMLCharPtr value) = 0; virtual void Value(TXMLCharPtr value) = 0; + virtual void Value(const QString &value) = 0; virtual void End() = 0; virtual void RemoveCurrent() = 0; virtual void ReplaceCurrent(SDOMElement &inElement) = 0; @@ -383,8 +437,8 @@ public: // Get the number of tabs required to line up the next line // with the opening of the previous line virtual QT3DSU32 GetTabs() = 0; - virtual SDOMElement *GetTopElement() = 0; - virtual std::shared_ptr<IDOMFactory> GetFactory() = 0; + virtual SDOMElement *GetTopElement() const = 0; + virtual std::shared_ptr<IDOMFactory> GetFactory() const = 0; // Move this item before this sibling. Function does not rearrange the // tree in any major way and will not work if inItem and inSibling aren't // siblings. @@ -405,6 +459,13 @@ public: End(); } + virtual void ChildValue(const QString &name, const QString &value) + { + Begin(name); + Value(value); + End(); + } + TWideXMLCharPtr ToStr(wchar_t val) { m_PrintBuf[0] = val; @@ -437,6 +498,14 @@ public: } void Att(TXMLCharPtr name, const TXMLStr &inValue) { return Att(name, inValue.c_str()); } + void Att(TWideXMLCharPtr name, const QString &inValue) + { + return Att(name, qUtf16Printable(inValue)); + } + void Att(const QString &name, const QString &inValue) + { + return Att(qUtf16Printable(name), qUtf16Printable(inValue)); + } template <typename TData> void Att(TWideXMLCharPtr name, TData value) @@ -450,6 +519,12 @@ public: Att(name, ToNarrowStr(value)); } + template <typename TData> + void Att(const QString &name, TData value) + { + Att(qPrintable(name), ToNarrowStr(value)); + } + template <typename TSerializer> void Serialize(const wchar_t *elemName, TSerializer &serializer) { @@ -473,11 +548,11 @@ public: // Note that the default method of creating a writer also creates a reader; they can // both manipulation the DOM hierarch. - static eastl::pair<std::shared_ptr<IDOMWriter>, std::shared_ptr<IDOMReader>> + static std::pair<std::shared_ptr<IDOMWriter>, std::shared_ptr<IDOMReader>> CreateDOMWriter(std::shared_ptr<IDOMFactory> inFactory, SDOMElement &inRootElement, std::shared_ptr<IStringTable> inStringTable); - static eastl::pair<std::shared_ptr<IDOMWriter>, std::shared_ptr<IDOMReader>> + static std::pair<std::shared_ptr<IDOMWriter>, std::shared_ptr<IDOMReader>> CreateDOMWriter(const wchar_t *inTopElemName, std::shared_ptr<IStringTable> inStringTable) { std::shared_ptr<IDOMFactory> theFactory(IDOMFactory::CreateDOMFactory(inStringTable)); @@ -502,5 +577,139 @@ public: static SDOMElement *Read(IDOMFactory &inFactory, QIODevice &inStream, CXmlErrorHandler *inErrorHandler = NULL); }; + +struct SDOMAttribute +{ + TXMLCharPtr m_Name; + TXMLCharPtr m_Value; + SDOMAttribute *m_NextAttribute; + + SDOMAttribute(TXMLCharPtr nm, TXMLCharPtr val); +}; + +struct SDOMElement +{ + TXMLCharPtr m_Name; + SDOMAttribute *m_FirstAttribute; + SDOMAttribute *m_LastAttribute; + SDOMElement *m_Parent; + SDOMElement *m_FirstChild; + SDOMElement *m_LastChild; + SDOMElement *m_NextSibling; + TXMLCharPtr m_Value; + + SDOMElement(TXMLCharPtr nm); + + void AddAttribute(SDOMAttribute &att); + // Used to ensure duplicate attributes can't happen + void SetAttributeValue(TXMLCharPtr inName, TXMLCharPtr inValue, IDOMFactory &inFactory, + const SDOMFlags &inFlags); + void SetAttributeValue(TWideXMLCharPtr inName, TWideXMLCharPtr inValue, IDOMFactory &inFactory, + const SDOMFlags &inFlags); + const SDOMAttribute *FindAttribute(TXMLCharPtr nm, const SDOMFlags &inFlags) const; + SDOMAttribute *FindAttribute(TXMLCharPtr nm, const SDOMFlags &inFlags); + void RemoveAttribute(TXMLCharPtr nm, const SDOMFlags &inFlags); + TXMLCharPtr GetAttributeValue(TXMLCharPtr nm, SDOMFlags &inFlags) const; + void AddChild(SDOMElement &elem); + SDOMElement *FindPreviousChild(SDOMElement &elem); + void RemoveChild(SDOMElement &elem); + + void ReplaceChild(SDOMElement &inChild, SDOMElement &inReplacement); + + void InsertChildBefore(SDOMElement &elem, SDOMElement &theSibling); + QT3DSU32 GetNumChildren(TXMLCharPtr inChildName, const SDOMFlags &inFlags) const; + QT3DSU32 GetNumChildren() const; + SDOMElement *FindChildByName(TXMLCharPtr nm, const SDOMFlags &inFlags) const; + SDOMElement *FindNextSiblingByName(TXMLCharPtr nm, const SDOMFlags &inFlags) const; +}; + +struct SElemPointer : std::pair<SDOMElement *, SDOMAttribute *> +{ + SElemPointer(SDOMElement *elem = NULL); + SElemPointer &operator=(SDOMElement *elem); + SElemPointer &operator=(SDOMAttribute *att); + SElemPointer &operator=(const std::pair<SDOMElement *, SDOMAttribute *> &other); + operator SDOMElement *() const; + SDOMElement *operator->() const; +}; + +#include "foundation/StrConvertUTF.h" + +struct SDOMReader : public IDOMReader +{ + SElemPointer m_TopElement; + std::vector<std::pair<SDOMElement *, SDOMAttribute *>> m_ScopeStack; + std::shared_ptr<IDOMFactory> m_Factory; + SDOMFlags m_Flags; + eastl::basic_string<qt3ds::foundation::TWCharEASTLConverter::TCharType> m_TempBuffer; + + SDOMReader(SDOMElement &te, std::shared_ptr<qt3dsdm::IStringTable> s, + std::shared_ptr<IDOMFactory> inFactory = std::shared_ptr<IDOMFactory>()); + SDOMElement *Current() const; + void SetDOMFlags(SDOMFlags inFlags) override; + SDOMFlags GetDOMFlags() const override; + void PushScope() override; + void PopScope() override; + void *GetScope() override; + void SetScope(void *inScope) override; + QString GetElementName() const override; + bool UnregisteredAtt(TWideXMLCharPtr name, TWideXMLCharPtr &outValue) override; + bool UnregisteredAtt(TXMLCharPtr name, TXMLCharPtr &outValue) override; + bool Att(TWideXMLCharPtr name, TWideXMLCharPtr &outValue) override; + bool Att(TXMLCharPtr name, TXMLCharPtr &outValue) override; + QT3DSU32 CountChildren() override; + QT3DSU32 CountChildren(TWideXMLCharPtr childName) override; + QT3DSU32 CountChildren(TXMLCharPtr childName) override; + std::pair<QString, QString> CurrentAttNarrow(); + std::pair<QString, QString> GetNextAttribute() override; + std::pair<QString, QString> GetFirstAttribute() override; + bool MoveToFirstChild() override; + bool MoveToFirstChild(TXMLCharPtr childName) override; + bool MoveToFirstChild(TWideXMLCharPtr childName) override; + bool MoveToNextSibling() override; + bool MoveToNextSibling(TXMLCharPtr childName) override; + bool MoveToNextSibling(TWideXMLCharPtr childName) override; + bool MoveToNextSibling(const QString &childName) override; + bool MoveToFirstChild(const QString &childName) override; + // Leave element means go to its parent. + void Leave() override; + bool Value(TXMLCharPtr &outValue) override; + bool Value(TWideXMLCharPtr &outValue) override; + bool Value(QString &outValue) override; + SDOMElement *GetTopElement() const override; + virtual std::shared_ptr<IDOMFactory> GetFactory() const; +}; + + +struct SDOMWriter : public IDOMWriter, public SDOMReader +{ + std::shared_ptr<IDOMFactory> m_FactoryPtr; + IDOMFactory &m_Factory; + + SDOMWriter(std::shared_ptr<IDOMFactory> inDOMFactory, + std::shared_ptr<qt3dsdm::IStringTable> inStringTable, SDOMElement &inTopElem); + void SetDOMFlags(SDOMFlags inFlags) override; + SDOMFlags GetDOMFlags() const override; + void Begin(TXMLCharPtr inElemName) override; + void Begin(TWideXMLCharPtr inElemName) override; + void Begin(const QString &inElemName) override; + void Att(TXMLCharPtr name, TXMLCharPtr value) override; + void Att(TWideXMLCharPtr name, TWideXMLCharPtr value) override; + void Value(TWideXMLCharPtr value) override; + void Value(TXMLCharPtr value) override; + void Value(const QString &value) override; + void End() override; + void RemoveCurrent() override; + void ReplaceCurrent(SDOMElement &inElement) override; + void AppendChildren(SDOMElement &inElement) override; + void RemoveAttribute(TXMLCharPtr inItem) override; + void RemoveAttribute(TWideXMLCharPtr inItem) override; + void MoveBefore(TXMLCharPtr inItem, TXMLCharPtr inSibling) override; + void MoveBefore(TWideXMLCharPtr inItem, TWideXMLCharPtr inSibling) override; + QT3DSU32 GetTabs() override; + SDOMElement *GetTopElement() const override; + std::shared_ptr<IDOMFactory> GetFactory() const override; +}; + } #endif diff --git a/src/Authoring/QT3DSDM/Systems/SignalsImpl.cpp b/src/Authoring/QT3DSDM/Systems/SignalsImpl.cpp index 6f42516b..ce3d1505 100644 --- a/src/Authoring/QT3DSDM/Systems/SignalsImpl.cpp +++ b/src/Authoring/QT3DSDM/Systems/SignalsImpl.cpp @@ -96,9 +96,9 @@ Q_SIGNALS: void instanceDeleted(Qt3DSDMInstanceHandle handle); void instanceDerived(Qt3DSDMInstanceHandle handle, Qt3DSDMInstanceHandle handle2); void instanceParentRemoved(Qt3DSDMInstanceHandle handle, Qt3DSDMInstanceHandle handle2); - void propertyAdded(Qt3DSDMInstanceHandle, Qt3DSDMPropertyHandle, TCharPtr, + void propertyAdded(Qt3DSDMInstanceHandle, Qt3DSDMPropertyHandle, const QString &, DataModelDataType::Value); - void propertyRemoved(Qt3DSDMInstanceHandle, Qt3DSDMPropertyHandle, TCharPtr, + void propertyRemoved(Qt3DSDMInstanceHandle, Qt3DSDMPropertyHandle, const QString &, DataModelDataType::Value); public: @@ -134,13 +134,13 @@ public: } virtual TSignalConnectionPtr ConnectPropertyAdded(const std::function<void(Qt3DSDMInstanceHandle, Qt3DSDMPropertyHandle, - TCharPtr, DataModelDataType::Value)> &inCallback) override + const QString &, DataModelDataType::Value)> &inCallback) override { return CONNECT_QT(QObject::connect(this, &CDataCoreSignaller::propertyAdded, inCallback)); } virtual TSignalConnectionPtr ConnectPropertyRemoved(const std::function<void(Qt3DSDMInstanceHandle, Qt3DSDMPropertyHandle, - TCharPtr, DataModelDataType::Value)> &inCallback) override + const QString &, DataModelDataType::Value)> &inCallback) override { return CONNECT_QT(QObject::connect(this, &CDataCoreSignaller::propertyRemoved, inCallback)); @@ -174,14 +174,14 @@ public: Q_EMIT instanceParentRemoved(inInstance, inParent); } void SignalPropertyAdded(Qt3DSDMInstanceHandle inInstance, - Qt3DSDMPropertyHandle inProperty, TCharPtr inName, + Qt3DSDMPropertyHandle inProperty, const QString &inName, DataModelDataType::Value inDataType) override { CHECK_SIGNALS_ENABLED(); Q_EMIT propertyAdded(inInstance, inProperty, inName, inDataType); } void SignalPropertyRemoved(Qt3DSDMInstanceHandle inInstance, - Qt3DSDMPropertyHandle inProperty, TCharPtr inName, + Qt3DSDMPropertyHandle inProperty, const QString &inName, DataModelDataType::Value inDataType) override { CHECK_SIGNALS_ENABLED(); @@ -546,12 +546,12 @@ class CActionCoreSignaller : public QObject, public IActionCoreSignalProvider, Q_SIGNALS: void triggerObjectSet(Qt3DSDMActionHandle, SObjectRefType &); void targetObjectSet(Qt3DSDMActionHandle, SObjectRefType &); - void eventHandleSet(Qt3DSDMActionHandle, const wstring &); - void handlerHandleSet(Qt3DSDMActionHandle, const wstring &); + void eventHandleSet(Qt3DSDMActionHandle, const QString &); + void handlerHandleSet(Qt3DSDMActionHandle, const QString &); - void handlerArgumentAdded(Qt3DSDMActionHandle, Qt3DSDMHandlerArgHandle, const TCharStr &, + void handlerArgumentAdded(Qt3DSDMActionHandle, Qt3DSDMHandlerArgHandle, const QString &, HandlerArgumentType::Value, DataModelDataType::Value); - void handlerArgumentRemoved(Qt3DSDMActionHandle, Qt3DSDMHandlerArgHandle, const TCharStr &, + void handlerArgumentRemoved(Qt3DSDMActionHandle, Qt3DSDMHandlerArgHandle, const QString &, HandlerArgumentType::Value, DataModelDataType::Value); void handlerArgumentValueSet(Qt3DSDMHandlerArgHandle, const SValue &); @@ -567,25 +567,29 @@ public: return CONNECT_SIGNAL_QT(&CActionCoreSignaller::targetObjectSet); } virtual TSignalConnectionPtr - ConnectEventSet(const std::function<void(Qt3DSDMActionHandle, const wstring &)> &inCallback) override + ConnectEventSet(const std::function<void(Qt3DSDMActionHandle, const QString &)> + &inCallback) override { return CONNECT_SIGNAL_QT(&CActionCoreSignaller::eventHandleSet); } virtual TSignalConnectionPtr - ConnectHandlerSet(const std::function<void(Qt3DSDMActionHandle, const wstring &)> &inCallback) override + ConnectHandlerSet(const std::function<void(Qt3DSDMActionHandle, const QString &)> + &inCallback) override { return CONNECT_SIGNAL_QT(&CActionCoreSignaller::handlerHandleSet); } TSignalConnectionPtr ConnectHandlerArgumentAdded( - const std::function<void(Qt3DSDMActionHandle, Qt3DSDMHandlerArgHandle, const TCharStr &, - HandlerArgumentType::Value, DataModelDataType::Value)> &inCallback) override + const std::function<void(Qt3DSDMActionHandle, Qt3DSDMHandlerArgHandle, const QString &, + HandlerArgumentType::Value, DataModelDataType::Value)> + &inCallback) override { return CONNECT_SIGNAL_QT(&CActionCoreSignaller::handlerArgumentAdded); } TSignalConnectionPtr ConnectHandlerArgumentRemoved( - const std::function<void(Qt3DSDMActionHandle, Qt3DSDMHandlerArgHandle, const TCharStr &, - HandlerArgumentType::Value, DataModelDataType::Value)> &inCallback) override + const std::function<void(Qt3DSDMActionHandle, Qt3DSDMHandlerArgHandle, const QString &, + HandlerArgumentType::Value, DataModelDataType::Value)> + &inCallback) override { return CONNECT_SIGNAL_QT(&CActionCoreSignaller::handlerArgumentRemoved); } @@ -605,35 +609,37 @@ public: CHECK_SIGNALS_ENABLED(); Q_EMIT targetObjectSet(inAction, inTargetObject); } - void SendEventSet(Qt3DSDMActionHandle inAction, const wstring &inEventHandle) override + void SendEventSet(Qt3DSDMActionHandle inAction, const QString &inEventHandle) override { CHECK_SIGNALS_ENABLED(); Q_EMIT eventHandleSet(inAction, inEventHandle); } - void SendHandlerSet(Qt3DSDMActionHandle inAction, const wstring &inHandlerHandle) override + void SendHandlerSet(Qt3DSDMActionHandle inAction, const QString &inHandlerHandle) override { CHECK_SIGNALS_ENABLED(); Q_EMIT handlerHandleSet(inAction, inHandlerHandle); } void SendHandlerArgumentAdded(Qt3DSDMActionHandle inAction, - Qt3DSDMHandlerArgHandle inHandlerArgument, - const TCharStr &inName, HandlerArgumentType::Value inArgType, - DataModelDataType::Value inValueType) override + Qt3DSDMHandlerArgHandle inHandlerArgument, + const QString &inName, + HandlerArgumentType::Value inArgType, + DataModelDataType::Value inValueType) override { CHECK_SIGNALS_ENABLED(); Q_EMIT handlerArgumentAdded(inAction, inHandlerArgument, inName, inArgType, inValueType); } void SendHandlerArgumentRemoved(Qt3DSDMActionHandle inAction, - Qt3DSDMHandlerArgHandle inHandlerArgument, - const TCharStr &inName, HandlerArgumentType::Value inArgType, - DataModelDataType::Value inValueType) override + Qt3DSDMHandlerArgHandle inHandlerArgument, + const QString &inName, + HandlerArgumentType::Value inArgType, + DataModelDataType::Value inValueType) override { CHECK_SIGNALS_ENABLED(); Q_EMIT handlerArgumentRemoved(inAction, inHandlerArgument, inName, inArgType, inValueType); } void SendHandlerArgumentValueSet(Qt3DSDMHandlerArgHandle inHandlerArgument, - const SValue &inValue) override + const SValue &inValue) override { CHECK_SIGNALS_ENABLED(); Q_EMIT handlerArgumentValueSet(inHandlerArgument, inValue); @@ -889,7 +895,7 @@ Q_SIGNALS: void customHandlerParamCreated(Qt3DSDMHandlerParamHandle, Qt3DSDMHandlerHandle); void customHandlerParamDeleted(Qt3DSDMHandlerParamHandle, Qt3DSDMHandlerHandle); void customHandlerParamModified(Qt3DSDMHandlerParamHandle); - void customReferencesModified(Qt3DSDMInstanceHandle, const TCharStr &); + void customReferencesModified(Qt3DSDMInstanceHandle, const QString &); public: TSignalConnectionPtr ConnectCustomPropertyCreated( @@ -953,7 +959,7 @@ public: return CONNECT_SIGNAL_QT(&CCustomPropCoreSignaller::customHandlerParamModified); } TSignalConnectionPtr ConnectCustomReferencesModified( - const std::function<void(Qt3DSDMInstanceHandle, const TCharStr &)> &inCallback) override + const std::function<void(Qt3DSDMInstanceHandle, const QString &)> &inCallback) override { return CONNECT_SIGNAL_QT(&CCustomPropCoreSignaller::customReferencesModified); } @@ -1025,7 +1031,7 @@ public: Q_EMIT customHandlerParamModified(inParameter); } void SendCustomReferencesModified(Qt3DSDMInstanceHandle inOwner, - const TCharStr &inString) override + const QString &inString) override { CHECK_SIGNALS_ENABLED(); Q_EMIT customReferencesModified(inOwner, inString); @@ -1084,7 +1090,7 @@ Q_SIGNALS: void customHandlerParamCreated(Qt3DSDMHandlerParamHandle, Qt3DSDMHandlerHandle); void customHandlerParamDeleted(Qt3DSDMHandlerParamHandle, Qt3DSDMHandlerHandle); void customHandlerParamModified(Qt3DSDMHandlerParamHandle); - void customReferencesModified(Qt3DSDMInstanceHandle, const TCharStr &); + void customReferencesModified(Qt3DSDMInstanceHandle, const QString &); private: ISlideSystemSignalProvider *m_SlideSystemSignalProvider; @@ -1303,7 +1309,7 @@ public: return CONNECT_SIGNAL_QT(&CStudioFullSystemSignaller::customHandlerParamModified); } TSignalConnectionPtr ConnectCustomReferencesModified( - const std::function<void(Qt3DSDMInstanceHandle, const TCharStr &)> &inCallback) override + const std::function<void(Qt3DSDMInstanceHandle, const QString &)> &inCallback) override { return CONNECT_SIGNAL_QT(&CStudioFullSystemSignaller::customReferencesModified); } @@ -1540,7 +1546,7 @@ public: Q_EMIT customHandlerParamModified(inParameter); } void SendCustomReferencesModified(Qt3DSDMInstanceHandle inOwner, - const TCharStr &inString) override + const QString &inString) override { CHECK_SIGNALS_ENABLED(); Q_EMIT customReferencesModified(inOwner, inString); diff --git a/src/Authoring/QT3DSDM/Systems/StandardExtensions.h b/src/Authoring/QT3DSDM/Systems/StandardExtensions.h index a9946002..02633072 100644 --- a/src/Authoring/QT3DSDM/Systems/StandardExtensions.h +++ b/src/Authoring/QT3DSDM/Systems/StandardExtensions.h @@ -70,10 +70,17 @@ inline void for_each_item(TCountFunc inCountFunc, TItemByIndexFunc inItemByIndex template <typename TContainerType, typename TItemType> inline void insert_unique(TContainerType &inContainer, const TItemType &inItem) { - if (find(inContainer.begin(), inContainer.end(), inItem) == inContainer.end()) + if (std::find(inContainer.begin(), inContainer.end(), inItem) == inContainer.end()) inContainer.insert(inContainer.end(), inItem); } +template <typename TContainerType, typename TItemType> +inline void insert_unique_qt(TContainerType &inContainer, const TItemType &inItem) +{ + if (std::find(inContainer.begin(), inContainer.end(), inItem) == inContainer.end()) + inContainer.push_back(inItem); +} + template <typename TContainerType, typename TItemType, typename TPred> inline void insert_unique_if(TContainerType &inContainer, const TItemType &inItem, TPred inPred) { diff --git a/src/Authoring/QT3DSDM/Systems/StudioCoreSystem.cpp b/src/Authoring/QT3DSDM/Systems/StudioCoreSystem.cpp index f9f0e2c8..c1821f0b 100644 --- a/src/Authoring/QT3DSDM/Systems/StudioCoreSystem.cpp +++ b/src/Authoring/QT3DSDM/Systems/StudioCoreSystem.cpp @@ -365,7 +365,7 @@ std::shared_ptr<IActionCore> CStudioCoreSystem::GetTransactionlessActionCore() } inline bool InstanceSpecificNameMatches(Qt3DSDMInstanceHandle inInstance, - Qt3DSDMPropertyHandle inProperty, const TCharStr &inName, + Qt3DSDMPropertyHandle inProperty, const QString &inName, const CSimpleDataCore &inData) { TPropertyHandleList theProperties; @@ -373,13 +373,13 @@ inline bool InstanceSpecificNameMatches(Qt3DSDMInstanceHandle inInstance, SValue theValue; if (exists(theProperties, std::bind(equal_to<int>(), inProperty, std::placeholders::_1)) && inData.GetSpecificInstancePropertyValue(inInstance, inProperty, theValue)) { - return inName == get<TDataStrPtr>(theValue)->GetData(); + return inName == get<TDataStrPtr>(theValue)->toQString(); } return false; } Qt3DSDMInstanceHandle CStudioCoreSystem::FindInstanceByName(Qt3DSDMPropertyHandle inNameProperty, - const TCharStr &inName) const + const QString &inName) const { TInstanceHandleList theInstances; m_DataCore->GetInstances(theInstances); diff --git a/src/Authoring/QT3DSDM/Systems/StudioCoreSystem.h b/src/Authoring/QT3DSDM/Systems/StudioCoreSystem.h index 18f1dad6..eb558437 100644 --- a/src/Authoring/QT3DSDM/Systems/StudioCoreSystem.h +++ b/src/Authoring/QT3DSDM/Systems/StudioCoreSystem.h @@ -83,7 +83,7 @@ public: std::shared_ptr<ICustomPropCore> GetTransactionlessCustomPropCore(); Qt3DSDMInstanceHandle FindInstanceByName(Qt3DSDMPropertyHandle inNameProperty, - const TCharStr &inName) const; + const QString &inName) const; void SetConsumer(TTransactionConsumerPtr inConsumer) override; }; diff --git a/src/Authoring/QT3DSDM/Systems/StudioFullSystem.cpp b/src/Authoring/QT3DSDM/Systems/StudioFullSystem.cpp index c98f8a81..000e2879 100644 --- a/src/Authoring/QT3DSDM/Systems/StudioFullSystem.cpp +++ b/src/Authoring/QT3DSDM/Systems/StudioFullSystem.cpp @@ -623,7 +623,7 @@ bool CStudioFullSystem::GetCanonicalInstancePropertyValue(Qt3DSDMInstanceHandle } Qt3DSDMInstanceHandle CStudioFullSystem::FindInstanceByName(Qt3DSDMPropertyHandle inNameProperty, - const TCharStr &inName) const + const QString &inName) const { return m_CoreSystem->FindInstanceByName(inNameProperty, inName); } diff --git a/src/Authoring/QT3DSDM/Systems/StudioFullSystem.h b/src/Authoring/QT3DSDM/Systems/StudioFullSystem.h index 9411e783..e5167d64 100644 --- a/src/Authoring/QT3DSDM/Systems/StudioFullSystem.h +++ b/src/Authoring/QT3DSDM/Systems/StudioFullSystem.h @@ -145,7 +145,7 @@ public: bool GetCanonicalInstancePropertyValue(Qt3DSDMInstanceHandle inInstance, Qt3DSDMPropertyHandle inProperty, SValue &outValue) const; Qt3DSDMInstanceHandle FindInstanceByName(Qt3DSDMPropertyHandle inNameProperty, - const TCharStr &inName) const; + const QString &inName) const; void SetConsumer(TTransactionConsumerPtr inConsumer) override; TTransactionConsumerPtr GetConsumer() { return m_Consumer; } diff --git a/src/Authoring/QT3DSDM/Systems/StudioPropertySystem.cpp b/src/Authoring/QT3DSDM/Systems/StudioPropertySystem.cpp index 09f0159a..e97f21ff 100644 --- a/src/Authoring/QT3DSDM/Systems/StudioPropertySystem.cpp +++ b/src/Authoring/QT3DSDM/Systems/StudioPropertySystem.cpp @@ -55,19 +55,19 @@ DataModelDataType::Value CStudioPropertySystem::GetDataType(Qt3DSDMPropertyHandl return DataModelDataType::None; } -TCharStr CStudioPropertySystem::GetName(Qt3DSDMPropertyHandle inProperty) const +QString CStudioPropertySystem::GetName(Qt3DSDMPropertyHandle inProperty) const { if (m_DataCore->IsProperty(inProperty)) return m_DataCore->GetProperty(inProperty).m_Name; - return TCharStr(); + return {}; } -TCharStr CStudioPropertySystem::GetFormalName(Qt3DSDMInstanceHandle inInstance, +QString CStudioPropertySystem::GetFormalName(Qt3DSDMInstanceHandle inInstance, Qt3DSDMPropertyHandle inProperty) const { if (inInstance.Valid() && inProperty.Valid()) return m_MetaData->GetFormalName(inInstance, inProperty); - return TCharStr(); + return {}; } AdditionalMetaDataType::Value @@ -93,7 +93,7 @@ Qt3DSDMInstanceHandle CStudioPropertySystem::GetPropertyOwner(Qt3DSDMPropertyHan Qt3DSDMPropertyHandle CStudioPropertySystem::GetAggregateInstancePropertyByName(Qt3DSDMInstanceHandle inInstance, - const TCharStr &inStr) const + const QString &inStr) const { return m_DataCore->GetAggregateInstancePropertyByName(inInstance, inStr); } @@ -188,8 +188,8 @@ bool CStudioPropertySystem::IsInstanceOrDerivedFrom(Qt3DSDMInstanceHandle inInst } Qt3DSDMPropertyHandle CStudioPropertySystem::AddProperty(Qt3DSDMInstanceHandle inInstance, - TCharPtr inName, - DataModelDataType::Value inPropType) + const QString &inName, + DataModelDataType::Value inPropType) { return m_DataCore->AddProperty(inInstance, inName, inPropType); } diff --git a/src/Authoring/QT3DSDM/Systems/StudioPropertySystem.h b/src/Authoring/QT3DSDM/Systems/StudioPropertySystem.h index 1fbeaf21..b180778d 100644 --- a/src/Authoring/QT3DSDM/Systems/StudioPropertySystem.h +++ b/src/Authoring/QT3DSDM/Systems/StudioPropertySystem.h @@ -78,27 +78,28 @@ public: } DataModelDataType::Value GetDataType(Qt3DSDMPropertyHandle inProperty) const override; - TCharStr GetName(Qt3DSDMPropertyHandle inProperty) const override; - TCharStr GetFormalName(Qt3DSDMInstanceHandle inInstance, - Qt3DSDMPropertyHandle inProperty) const override; + QString GetName(Qt3DSDMPropertyHandle inProperty) const override; + QString GetFormalName(Qt3DSDMInstanceHandle inInstance, + Qt3DSDMPropertyHandle inProperty) const override; virtual AdditionalMetaDataType::Value GetAdditionalMetaDataType(Qt3DSDMInstanceHandle inInstance, Qt3DSDMPropertyHandle inProperty) const override; TMetaDataData GetAdditionalMetaDataData(Qt3DSDMInstanceHandle inInstance, - Qt3DSDMPropertyHandle inProperty) const override; + Qt3DSDMPropertyHandle inProperty) const override; Qt3DSDMInstanceHandle GetPropertyOwner(Qt3DSDMPropertyHandle inProperty) const override; Qt3DSDMPropertyHandle GetAggregateInstancePropertyByName(Qt3DSDMInstanceHandle inInstance, - const TCharStr &inStr) const override; + const QString &inStr) const override; void GetAggregateInstanceProperties(Qt3DSDMInstanceHandle inInstance, - TPropertyHandleList &outProperties) const override; + TPropertyHandleList &outProperties) const override; bool HasAggregateInstanceProperty(Qt3DSDMInstanceHandle inInstance, - Qt3DSDMPropertyHandle inProperty) const override; + Qt3DSDMPropertyHandle inProperty) const override; bool GetInstancePropertyValue(Qt3DSDMInstanceHandle inInstance, - Qt3DSDMPropertyHandle inProperty, SValue &outValue) const override; + Qt3DSDMPropertyHandle inProperty, + SValue &outValue) const override; void SetInstancePropertyValue(Qt3DSDMInstanceHandle inInstance, - Qt3DSDMPropertyHandle inProperty, const SValue &inValue) override; + Qt3DSDMPropertyHandle inProperty, const SValue &inValue) override; Qt3DSDMInstanceHandle CreateInstance() override; void GetInstances(TInstanceHandleList &outInstances) const override; @@ -106,21 +107,23 @@ public: void DeriveInstance(Qt3DSDMInstanceHandle inInstance, Qt3DSDMInstanceHandle inParent) override; bool IsInstanceOrDerivedFrom(Qt3DSDMInstanceHandle inInstance, - Qt3DSDMInstanceHandle inParent) const override; + Qt3DSDMInstanceHandle inParent) const override; - Qt3DSDMPropertyHandle AddProperty(Qt3DSDMInstanceHandle inInstance, TCharPtr inName, - DataModelDataType::Value inPropType) override; + Qt3DSDMPropertyHandle AddProperty(Qt3DSDMInstanceHandle inInstance, const QString &inName, + DataModelDataType::Value inPropType) override; bool HandleValid(int inHandle) const override; // Get the instance property value from the slide that owns the instance or the data core if the // slide doesn't have the value bool GetCanonicalInstancePropertyValue(Qt3DSDMInstanceHandle inInstance, - Qt3DSDMPropertyHandle inProperty, SValue &outValue) const; + Qt3DSDMPropertyHandle inProperty, + SValue &outValue) const; private: static bool DerivedGuidMatches(qt3dsdm::IDataCore &inDataCore, qt3dsdm::Qt3DSDMInstanceHandle inInstance, - qt3dsdm::Qt3DSDMPropertyHandle inProperty, qt3dsdm::SLong4 inGuid); + qt3dsdm::Qt3DSDMPropertyHandle inProperty, + qt3dsdm::SLong4 inGuid); CStudioPropertySystem(const CStudioPropertySystem&) = delete; CStudioPropertySystem& operator=(const CStudioPropertySystem&) = delete; }; diff --git a/src/Authoring/QT3DSDM/Systems/VectorTransactions.h b/src/Authoring/QT3DSDM/Systems/VectorTransactions.h index ff1fe2e2..4f26032c 100644 --- a/src/Authoring/QT3DSDM/Systems/VectorTransactions.h +++ b/src/Authoring/QT3DSDM/Systems/VectorTransactions.h @@ -100,7 +100,10 @@ struct HashMapAction , m_Value(val) { } - bool Exists() { return m_HashMap.find(m_Value.first) != m_HashMap.end(); } + bool Exists() const + { + return m_HashMap.find(m_Value.first) != m_HashMap.end(); + } void Add() { Q_ASSERT(!Exists()); @@ -113,6 +116,34 @@ struct HashMapAction } }; +template <typename TKeyType, typename TValueType> +struct QHashAction +{ + QHash<TKeyType, TValueType> &m_map; + std::pair<TKeyType, TValueType> m_Value; + + QHashAction(QHash<TKeyType, TValueType> &map, + const std::pair<TKeyType, TValueType> &val) + : m_map(map) + , m_Value(val) + { + } + bool Exists() const + { + return m_map.find(m_Value.first) != m_map.end(); + } + void Add() + { + Q_ASSERT(!Exists()); + m_map.insert(m_Value.first, m_Value.second); + } + void Remove() + { + Q_ASSERT(Exists()); + m_map.erase(m_map.find(m_Value.first)); + } +}; + template <typename TKeyType, typename TValueType, typename THashType> struct HashMapInsertTransaction : public HashMapAction<TKeyType, TValueType, THashType>, public ITransaction, @@ -147,6 +178,40 @@ struct HashMapEraseTransaction : public HashMapAction<TKeyType, TValueType, THas void Undo() override { base::Add(); } }; +template <typename TKeyType, typename TValueType> +struct QHashInsertTransaction : public QHashAction<TKeyType, TValueType>, + public ITransaction, + public IMergeableTransaction<TValueType> +{ + typedef QHashAction<TKeyType, TValueType> base; + QHashInsertTransaction(const char *inFile, int inLine, + QHash<TKeyType, TValueType> &map, + const std::pair<TKeyType, TValueType> &val) + : QHashAction<TKeyType, TValueType>(map, val) + , ITransaction(inFile, inLine) + { + } + void Do() override { base::Add(); } + void Undo() override { base::Remove(); } + void Update(const TValueType &inValue) override { base::m_Value.second = inValue; } +}; + +template <typename TKeyType, typename TValueType> +struct QHashEraseTransaction : public QHashAction<TKeyType, TValueType>, + public ITransaction +{ + typedef QHashAction<TKeyType, TValueType> base; + QHashEraseTransaction(const char *inFile, int inLine, + QHash<TKeyType, TValueType> &map, + const std::pair<TKeyType, TValueType> &val) + : QHashAction<TKeyType, TValueType>(map, val) + , ITransaction(inFile, inLine) + { + } + void Do() override { base::Remove(); } + void Undo() override { base::Add(); } +}; + template <typename TKeyType, typename TValueType, typename THashType> inline std::shared_ptr<IMergeableTransaction<TValueType>> CreateHashMapInsertTransaction(const char *inFile, int inLine, TTransactionConsumerPtr inConsumer, @@ -165,17 +230,48 @@ CreateHashMapInsertTransaction(const char *inFile, int inLine, TTransactionConsu return retval; } +template <typename TKeyType, typename TValueType> +inline std::shared_ptr<IMergeableTransaction<TValueType>> +CreateQHashInsertTransaction(const char *inFile, int inLine, TTransactionConsumerPtr inConsumer, + const std::pair<TKeyType, TValueType> &inItem, + QHash<TKeyType, TValueType> &inItems) +{ + using namespace std; + std::shared_ptr<IMergeableTransaction<TValueType>> retval; + if (inConsumer) { + std::shared_ptr<QHashInsertTransaction<TKeyType, TValueType>> transaction( + std::make_shared<QHashInsertTransaction<TKeyType, TValueType>>( + inFile, inLine, std::ref(inItems), std::cref(inItem))); + retval = static_pointer_cast<IMergeableTransaction<TValueType>>(transaction); + inConsumer->OnTransaction(static_pointer_cast<ITransaction>(transaction)); + } + return retval; +} + template <typename TKeyType, typename TValueType, typename THashType> inline void CreateHashMapEraseTransaction(const char *inFile, int inLine, TTransactionConsumerPtr inConsumer, const std::pair<TKeyType, TValueType> &inItem, std::unordered_map<TKeyType, TValueType, THashType> &inItems) { - using namespace std; - if (inConsumer) + if (inConsumer) { inConsumer->OnTransaction(static_pointer_cast<ITransaction>( std::make_shared<HashMapEraseTransaction<TKeyType, TValueType, THashType>>( inFile, inLine, std::ref(inItems), std::cref(inItem)))); + } +} + +template <typename TKeyType, typename TValueType> +inline void +CreateQHashEraseTransaction(const char *inFile, int inLine, TTransactionConsumerPtr inConsumer, + const std::pair<TKeyType, TValueType> &inItem, + QHash<TKeyType, TValueType> &inItems) +{ + if (inConsumer) { + inConsumer->OnTransaction(static_pointer_cast<ITransaction>( + std::make_shared<QHashEraseTransaction<TKeyType, TValueType>>( + inFile, inLine, std::ref(inItems), std::cref(inItem)))); + } } template <typename TKeyType, typename TValueType, typename THashType> diff --git a/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImport.cpp b/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImport.cpp index b5067299..62fd5da6 100644 --- a/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImport.cpp +++ b/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImport.cpp @@ -39,31 +39,37 @@ using qt3dsdm::IStringTable; -namespace qt3dsdm { -} - using namespace qt3dsimp; -namespace eastl { -template <> -struct hash<AnimationId> +namespace qt3dsimp { + +bool operator<(const AnimationId &a, const AnimationId &o) { - size_t operator()(const AnimationId &id) const - { - return hash<TIMPHandle>()(id.m_Instance) ^ hash<TCharPtr>()(id.m_Property) - ^ hash<QT3DSU32>()(id.m_SubPropIndex); - } -}; + if (a.m_Instance < o.m_Instance) + return true; + if (a.m_Property < o.m_Property) + return true; + if (a.m_SubPropIndex < o.m_SubPropIndex) + return true; + return false; +} -template <> -struct equal_to<AnimationId> +uint qHash(const AnimationId &aid, uint seed) { - bool operator()(const AnimationId &lhs, const AnimationId &rhs) const - { - return lhs.m_Instance == rhs.m_Instance && AreEqual(lhs.m_Property, rhs.m_Property) - && lhs.m_SubPropIndex == rhs.m_SubPropIndex; - } -}; + QtPrivate::QHashCombine hash; + seed = hash(aid.m_Instance, seed); + seed = qHash(aid.m_Property, seed); + seed = hash(aid.m_SubPropIndex, seed); + return seed; +} + +bool operator==(const AnimationId &a, const AnimationId &b) +{ + return a.m_Instance == b.m_Instance + && a.m_Property == b.m_Property + && a.m_SubPropIndex == b.m_SubPropIndex; +} + } using eastl::make_pair; @@ -83,9 +89,9 @@ namespace { template <typename TDataType> struct AddRemoveImpl { - ImportArray<TDataType> m_Existing; - ImportArray<TDataType> m_Added; - ImportArray<TDataType> m_Removed; + QVector<TDataType> m_Existing; + QVector<TDataType> m_Added; + QVector<TDataType> m_Removed; operator AddRemoveData<TDataType>() const { @@ -105,10 +111,10 @@ struct ImportReportImpl // added before children. AddRemoveImpl<InstanceDesc> m_Instances; AddRemoveImpl<ParentChildLink> m_Links; - ImportArray<Pair<InstanceDesc, ComposerObjectTypes::Enum>> m_TypeChanges; - AddRemoveImpl<Pair<TCharPtr, TCharPtr>> m_Images; - AddRemoveImpl<Pair<TCharPtr, TCharPtr>> m_Meshes; - AddRemoveImpl<Pair<TCharPtr, TCharPtr>> m_PathBuffers; + QVector<std::pair<InstanceDesc, ComposerObjectTypes::Enum>> m_TypeChanges; + AddRemoveImpl<std::pair<QString, QString>> m_Images; + AddRemoveImpl<std::pair<QString, QString>> m_Meshes; + AddRemoveImpl<std::pair<QString, QString>> m_PathBuffers; AddRemoveImpl<Animation> m_Animations; operator ImportReport() @@ -130,7 +136,7 @@ struct ImportReportImpl struct InstanceDiffOp { QT3DSU32 NumItems(const Import &src) { return src.GetNumInstances(); } - void GetItems(const Import &src, NVDataRef<InstanceDesc> data) { src.GetInstances(data); } + void GetItems(const Import &src, QVector<InstanceDesc> &data) { src.GetInstances(data); } // ID's *and* types have to match in order to get valid output bool HasItem(const Import &src, const InstanceDesc &data) { @@ -139,15 +145,15 @@ struct InstanceDiffOp } }; -bool FindChild(Option<InstanceDesc> hdlOpt, TCharPtr inCompareNextSibling, - ComposerObjectTypes::Enum childType, NVDataRef<InstanceDesc> children) +bool FindChild(Option<InstanceDesc> hdlOpt, const QString &inCompareNextSibling, + ComposerObjectTypes::Enum childType, const QVector<InstanceDesc> &children) { if (hdlOpt.hasValue() == false) return false; - TCharPtr id = hdlOpt->m_Id; + QString id = hdlOpt->m_Id; QT3DSIMP_FOREACH(idx, children.size()) { - TCharPtr nextSibling = idx + 1 < children.size() ? children[idx + 1].m_Id : L""; + QString nextSibling = ((idx + 1) < children.size()) ? children[idx + 1].m_Id : QString(); // Because we know that the import objects share a single string table, // we know that equal strings will actually be equal via ptr comparison if (children[idx].m_Id == id && children[idx].m_Type == childType @@ -160,11 +166,11 @@ bool FindChild(Option<InstanceDesc> hdlOpt, TCharPtr inCompareNextSibling, struct ImageDiffOp { QT3DSU32 NumItems(const Import &src) { return src.GetNumImages(); } - void GetItems(const Import &src, NVDataRef<Pair<TCharPtr, TCharPtr>> data) + void GetItems(const Import &src, QVector<std::pair<QString, QString>> &data) { src.GetImages(data); } - bool HasItem(const Import &src, const Pair<TCharPtr, TCharPtr> &data) + bool HasItem(const Import &src, const std::pair<QString, QString> &data) { return src.FindImageByRelativePath(data.first).hasValue(); } @@ -173,33 +179,33 @@ struct ImageDiffOp struct MeshDiffOp { QT3DSU32 NumItems(const Import &src) { return src.GetNumMeshes(); } - void GetItems(const Import &src, NVDataRef<Pair<TCharPtr, TCharPtr>> data) + void GetItems(const Import &src, QVector<std::pair<QString, QString>> &data) { src.GetMeshes(data); } - bool HasItem(const Import &src, const Pair<TCharPtr, TCharPtr> &data) + bool HasItem(const Import &src, const std::pair<QString, QString> &data) { return src.HasMesh(data.first); } }; - +#if RUNTIME_SPLIT_TEMPORARILY_REMOVED struct PathBufferDiffOp { QT3DSU32 NumItems(const Import &src) { return src.GetNumPathBuffers(); } - void GetItems(const Import &src, NVDataRef<Pair<TCharPtr, TCharPtr>> data) + void GetItems(const Import &src, QVector<std::pair<QString, QString>> &data) { src.GetPathBuffers(data); } - bool HasItem(const Import &src, const Pair<TCharPtr, TCharPtr> &data) + bool HasItem(const Import &src, const std::pair<QString, QString> &data) { return src.FindPathBufferByRelativePath(data.first).hasValue(); } }; - +#endif struct AnimationDiffOp { QT3DSU32 NumItems(const Import &src) { return src.GetNumAnimations(); } - void GetItems(const Import &src, NVDataRef<Animation> data) { src.GetAnimations(data); } + void GetItems(const Import &src, QVector<Animation> &data) { src.GetAnimations(data); } bool HasItem(const Import &src, const Animation &data) { return src.FindAnimation(data.m_InstanceId, data.m_PropertyName, data.m_SubPropertyIndex) @@ -214,157 +220,133 @@ struct AnimationDiffOp struct MeshEntry { - TCharPtr m_SourceId; - TCharPtr m_FilePath; - TCharPtr m_ReferencePath; // file path plus revision - MeshEntry(TCharPtr inSourceId, CFilePath inPath, QT3DSU32 inRevision, - qt3dsdm::IStringTable &inStringTable) + QString m_SourceId; + QString m_FilePath; + QString m_ReferencePath; // file path plus revision + QT3DSU32 m_revision; + MeshEntry(const QString &inSourceId, const QString &inPath, QT3DSU32 inRevision) : m_SourceId(inSourceId) - , m_FilePath(L"") - , m_ReferencePath(L"") - { - m_FilePath = inStringTable.RegisterStr(inPath.toCString()); - inPath.SetIdentifier(QString::number(inRevision)); - m_ReferencePath = inStringTable.RegisterStr(inPath.toCString()); - } - - MeshEntry(TCharPtr inSourceId, TCharPtr inPath, qt3dsdm::IStringTable &inStringTable) - : m_SourceId(inStringTable.RegisterStr(inSourceId)) - , m_FilePath(inStringTable.RegisterStr(inPath)) - , m_ReferencePath(L"") - { - } -}; - -struct STCharPtrHash -{ -#ifdef _WIN32 - size_t operator()(TCharPtr nm) const + , m_FilePath(inPath) + , m_ReferencePath(inPath) + , m_revision(inRevision) { - StaticAssert<sizeof(wchar_t) == sizeof(char16_t)>::valid_expression(); - return eastl::hash<const char16_t *>()(reinterpret_cast<const char16_t *>(nm)); + m_ReferencePath.append(QString::number(m_revision)); } -#else - size_t operator()(TCharPtr nm) const + MeshEntry(const QString &inSourceId, const QString &inPath) + : m_SourceId(inSourceId) + , m_FilePath(inPath) + , m_revision(0) { - StaticAssert<sizeof(wchar_t) == sizeof(char32_t)>::valid_expression(); - return eastl::hash<const char32_t *>()(reinterpret_cast<const char32_t *>(nm)); } -#endif -}; - -struct STCharPtrEqualTo -{ - bool operator()(TCharPtr lhs, TCharPtr rhs) const { return AreEqual(lhs, rhs); } }; class ImportImpl : public Import { public: - typedef ImportHashMap<TCharPtr, Instance *, STCharPtrHash, STCharPtrEqualTo> TIdToInstanceMap; - typedef ImportHashMap<TCharPtr, TCharPtr, STCharPtrHash, STCharPtrEqualTo> TStrToStrMap; - typedef ImportHashMap<TCharPtr, MeshEntry, STCharPtrHash, STCharPtrEqualTo> TPathToMeshMap; + typedef QHash<QString, Instance *> TIdToInstanceMap; + typedef QHash<QString, QString> TStrToStrMap; + typedef QHash<QString, MeshEntry> TPathToMeshMap; TStringTablePtr m_StringTablePtr; qt3dsdm::IStringTable &m_StringTable; - ImportHashSet<TIMPHandle> m_ValidInstances; - ImportHashSet<TIMPHandle> m_InValidInstances; + QSet<TIMPHandle> m_ValidInstances; + QSet<TIMPHandle> m_InValidInstances; TIdToInstanceMap m_IdToInstMap; // Mapping from original ID to new location TStrToStrMap m_Images; TStrToStrMap m_PathBuffers; // Mapping from mesh name to new location TPathToMeshMap m_Meshes; - ImportHashMap<AnimationId, Animation *> m_Animations; - - CFilePath m_DestDirectory; - CFilePath m_SrcDirectory; - CFilePath m_SrcFile; - CFilePath m_FullSrcDirectory; - CFilePath m_ImageDir; - CFilePath m_MeshDir; - CFilePath m_PathBufferDir; + QHash<AnimationId, Animation *> m_Animations; + + QString m_DestDirectory; + QString m_SrcDirectory; + QString m_SrcFile; + QString m_FullSrcDirectory; + QString m_ImageDir; + QString m_MeshDir; + QString m_PathBufferDir; mutable ImportReportImpl m_ImportReport; - eastl::string m_ConvertStr; - - virtual ~ImportImpl() - { - for (ImportHashSet<TIMPHandle>::iterator iter = m_ValidInstances.begin(), - end = m_ValidInstances.end(); - iter != end; ++iter) - delete fromHdl((*iter)); - for (ImportHashMap<AnimationId, Animation *>::iterator iter = m_Animations.begin(), - end = m_Animations.end(); - iter != end; ++iter) - free(iter->second); + + ~ImportImpl() override + { + for (auto instance : m_ValidInstances) + delete fromHdl(instance); + for (auto animation : m_Animations) + delete animation; m_ValidInstances.clear(); m_Animations.clear(); m_InValidInstances.clear(); } - ImportImpl(TStringTablePtr strTable, const Q3DStudio::CString &srcFile, - const Q3DStudio::CString &destDirectory, const wchar_t *imagesDir = L"", - const wchar_t *meshesDir = L"") + ImportImpl(TStringTablePtr strTable, const QString &srcFile, + const QString &destDirectory, const QString &imagesDir = {}, + const QString &meshesDir = {}) : m_StringTablePtr(strTable) , m_StringTable(*strTable.get()) , m_DestDirectory(destDirectory) { - if (srcFile.Length()) { - m_FullSrcDirectory = CFilePath(srcFile).GetDirectory(); + if (!srcFile.isEmpty()) { + QFileInfo info(srcFile); + m_FullSrcDirectory = info.canonicalPath(); m_SrcFile = CFilePath::GetRelativePathFromBase(destDirectory, srcFile); - m_SrcDirectory = CFilePath(m_SrcFile).GetDirectory(); + m_SrcDirectory = QFileInfo(m_SrcFile).canonicalPath(); } // On load, images and meshes directories will be trivial. - if (!IsTrivial(imagesDir)) { + if (!imagesDir.isEmpty()) { m_ImageDir = imagesDir; - if (m_ImageDir.isRelative()) - m_ImageDir = CFilePath::CombineBaseAndRelative(destDirectory, CString(imagesDir)); + if (QFileInfo(m_ImageDir).isRelative()) + m_ImageDir = CFilePath::CombineBaseAndRelative(destDirectory, imagesDir); } - if (!IsTrivial(meshesDir)) { + if (!meshesDir.isEmpty()) { m_MeshDir = meshesDir; - if (m_MeshDir.isRelative()) - m_MeshDir = CFilePath::CombineBaseAndRelative(destDirectory, CString(meshesDir)); + if (QFileInfo(m_MeshDir).isRelative()) + m_MeshDir = CFilePath::CombineBaseAndRelative(destDirectory, meshesDir); } - m_PathBufferDir = CFilePath::CombineBaseAndRelative(destDirectory, CString(L"paths")); + m_PathBufferDir = CFilePath::CombineBaseAndRelative(destDirectory, QStringLiteral("paths")); } - TCharPtr RegisterStr(TCharPtr str) override { return m_StringTable.RegisterStr(str); } - QString GetSrcFile() const override { return m_SrcFile.toQString(); } - QString GetDestDir() const override { return m_DestDirectory.toQString(); } - QString GetImageDir() const override { return m_ImageDir.toQString(); } - QString GetMeshDir() const override { return m_MeshDir.toQString(); } - QString GetPathBufferDir() const override { return m_PathBufferDir.toQString(); } + QString RegisterStr(TCharPtr str) override { return QString::fromWCharArray(str); } + QString GetSrcFile() const override { return m_SrcFile; } + QString GetDestDir() const override { return m_DestDirectory; } + QString GetImageDir() const override { return m_ImageDir; } + QString GetMeshDir() const override { return m_MeshDir; } +#if RUNTIME_SPLIT_TEMPORARILY_REMOVED + QString GetPathBufferDir() const override { return m_PathBufferDir; } +#endif void Release() override { delete this; } Instance *GetInstance(TIMPHandle inst) const { if (m_ValidInstances.contains(inst)) return fromHdl(inst); - return NULL; + return nullptr; } Instance *GetInstance(TIMPHandle inst) { if (m_ValidInstances.contains(inst)) return fromHdl(inst); - return NULL; + return nullptr; } - Instance *GetInstance(TCharPtr id) + Instance *GetInstance(const QString &id) { - ImportHashMap<TCharPtr, Instance *>::const_iterator entry = m_IdToInstMap.find(id); + QHash<QString, Instance *>::const_iterator entry + = m_IdToInstMap.find(id); if (entry != m_IdToInstMap.end()) - return entry->second; - return NULL; + return *entry; + return nullptr; } - Instance *GetInstance(TCharPtr id) const + Instance *GetInstance(const QString &id) const { - ImportHashMap<TCharPtr, Instance *>::const_iterator entry = m_IdToInstMap.find(id); + QHash<QString, Instance *>::const_iterator entry + = m_IdToInstMap.find(id); if (entry != m_IdToInstMap.end()) - return entry->second; - return NULL; + return *entry; + return nullptr; } Option<InstanceDesc> GetInstanceByHandle(TIMPHandle inst) const override @@ -373,7 +355,7 @@ public: return *fromHdl(inst); return Empty(); } - Option<InstanceDesc> FindInstanceById(TCharPtr inst) const override + Option<InstanceDesc> FindInstanceById(const QString &inst) const override { Instance *retval = GetInstance(inst); if (retval && retval->m_Valid) @@ -381,7 +363,7 @@ public: return Empty(); } - Option<InstanceDesc> FindAnyInstanceById(TCharPtr inst) const override + Option<InstanceDesc> FindAnyInstanceById(const QString &inst) const override { Instance *retval = GetInstance(inst); if (retval) @@ -395,7 +377,7 @@ public: return (QT3DSU32)(m_ValidInstances.size() - m_InValidInstances.size()); } - void AddInstance(Instance *inInstance, NVDataRef<InstanceDesc> &inAdded, QT3DSU32 &addIdx, + void AddInstance(Instance *inInstance, QVector<InstanceDesc> &inAdded, QT3DSU32 &addIdx, QT3DSU32 numItems) const { if (addIdx < numItems) { @@ -409,21 +391,17 @@ public: } } - QT3DSU32 GetInstances(NVDataRef<InstanceDesc> outDescs) const override + QT3DSU32 GetInstances(QVector<InstanceDesc> &outDescs) const override { QT3DS_ASSERT(outDescs.size() >= GetNumInstances()); - QT3DSU32 numItems = qMin(outDescs.size(), GetNumInstances()); + QT3DSU32 numItems = qMin(QT3DSU32(outDescs.size()), GetNumInstances()); QT3DSU32 idx = 0; - ImportHashSet<TIMPHandle> &validInstances( - const_cast<ImportHashSet<TIMPHandle> &>(m_ValidInstances)); - for (ImportHashSet<TIMPHandle>::iterator theIter = validInstances.begin(), - end = validInstances.end(); - theIter != end; ++theIter) { - if (m_InValidInstances.contains(*theIter)) + for (auto instance : qAsConst(m_ValidInstances)) { + if (m_InValidInstances.contains(instance)) continue; - Instance *theInstance = GetInstance(*theIter); + Instance *theInstance = GetInstance(instance); if (theInstance->m_Parent == 0) AddInstance(theInstance, outDescs, idx, numItems); } @@ -433,40 +411,40 @@ public: QT3DSU32 GetNumProperties(TIMPHandle instance) const override { Instance *inst = GetInstance(instance); - if (inst == NULL) { + if (inst == nullptr) { QT3DS_ASSERT(false); return 0; } return (QT3DSU32)inst->m_PropertyValues.size(); } - QT3DSU32 GetProperties(TIMPHandle instance, NVDataRef<PropertyValue> outBuffer) const override + QT3DSU32 GetProperties(TIMPHandle instance, QVector<PropertyValue> &outBuffer) const override { Instance *inst = GetInstance(instance); - if (inst == NULL) { + if (inst == nullptr) { QT3DS_ASSERT(false); return 0; } - QT3DSU32 numItems = qMin((QT3DSU32)outBuffer.size(), (QT3DSU32)inst->m_PropertyValues.size()); + QT3DSU32 numItems = qMin(QT3DSU32(outBuffer.size()), + QT3DSU32(inst->m_PropertyValues.size())); QT3DSU32 idx = 0; - for (ImportHashMap<ComposerPropertyNames::Enum, SInternValue>::iterator - iter = inst->m_PropertyValues.begin(), - end = inst->m_PropertyValues.end(); - iter != end && idx < numItems; ++iter, ++idx) - outBuffer[idx] = PropertyValue(iter->first, iter->second); + for (auto iter = inst->m_PropertyValues.begin(), end = inst->m_PropertyValues.end(); + iter != end && idx < numItems; ++iter, ++idx) { + outBuffer[idx] = PropertyValue(iter.key(), iter.value()); + } return numItems; } Option<SValue> GetInstancePropertyValue(TIMPHandle instance, - ComposerPropertyNames::Enum val) const override + ComposerPropertyNames::Enum val) const override { Instance *inst = GetInstance(instance); - if (inst == NULL) { + if (inst == nullptr) { QT3DS_ASSERT(false); return Empty(); } - const ImportHashMap<ComposerPropertyNames::Enum, SInternValue>::iterator entry = + const QHash<ComposerPropertyNames::Enum, SInternValue>::iterator entry = inst->m_PropertyValues.find(val); if (entry != inst->m_PropertyValues.end()) - return entry->second.GetValue(); + return entry->GetValue(); return Empty(); } @@ -474,7 +452,7 @@ public: QT3DSU32 GetNumChildren(TIMPHandle instance) const override { Instance *inst = GetInstance(instance); - if (inst == NULL) { + if (inst == nullptr) { QT3DS_ASSERT(false); return 0; } @@ -489,10 +467,10 @@ public: } // Returns valid children in the childBuffer parameter. - QT3DSU32 GetChildren(TIMPHandle instance, NVDataRef<InstanceDesc> childBuffer) const override + QT3DSU32 GetChildren(TIMPHandle instance, QVector<InstanceDesc> &childBuffer) const override { Instance *inst = GetInstance(instance); - if (inst == NULL) { + if (inst == nullptr) { QT3DS_ASSERT(false); return 0; } @@ -513,11 +491,11 @@ public: void MarkInstanceInvalid(TIMPHandle instance) override { Instance *inst = GetInstance(instance); - if (inst == NULL) { + if (inst == nullptr) { QT3DS_ASSERT(false); return; } - if (m_InValidInstances.insert(instance).second) { + if (*m_InValidInstances.insert(instance)) { inst->MarkInvalid(); QT3DSIMP_FOREACH(idx, (QT3DSU32)inst->m_Children.size()) { @@ -526,20 +504,18 @@ public: MarkInstanceInvalid(toHdl(theInstance)); } std::vector<AnimationId> animationsToErase; - for (ImportHashMap<AnimationId, Animation *>::iterator iter = m_Animations.begin(), - end = m_Animations.end(); - iter != end; ++iter) { - if (iter->first.m_Instance == instance) - animationsToErase.push_back(iter->first); + for (auto iter = m_Animations.begin(), end = m_Animations.end(); iter != end; ++iter) { + if (iter.key().m_Instance == instance) + animationsToErase.push_back(iter.key()); } - for (size_t idx = 0, end = animationsToErase.size(); idx < end; ++idx) - m_Animations.erase(animationsToErase[idx]); + for (auto animation : qAsConst(animationsToErase)) + m_Animations.remove(animation); } } - TIMPHandle CreateInstance(TCharPtr name, ComposerObjectTypes::Enum inType) override + TIMPHandle CreateInstance(const QString &name, ComposerObjectTypes::Enum inType) override { - if (IsTrivial(name) == false) { + if (name.isEmpty() == false) { Option<InstanceDesc> exists = FindInstanceById(name); bool hasValue = exists.hasValue(); if (hasValue) { @@ -547,38 +523,32 @@ public: return exists->m_Handle; } } - name = m_StringTable.RegisterStr(name); InstanceDesc newDesc; newDesc.m_Id = name; newDesc.m_Type = inType; Instance *newInst = new Instance(newDesc); m_ValidInstances.insert(toHdl(newInst)); - m_IdToInstMap.insert(eastl::make_pair(name, newInst)); + m_IdToInstMap.insert(name, newInst); return toHdl(newInst); } - Instance *CopyInstanceHierarchy(Instance &inSource, ImportHashMap<TCharPtr, TCharPtr> &inIdMap) + Instance *CopyInstanceHierarchy(Instance &inSource, QHash<QString, QString> &inIdMap) { - wstring uniqueStem(inSource.m_Id); - wstring instId(uniqueStem); + QString uniqueStem(inSource.m_Id); + QString instId(uniqueStem); int index = 1; do { - wchar_t buf[16]; - WStrOps<QT3DSU32>().ToStr(index, toDataRef(buf, 16)); + instId = QStringLiteral("%1_%2").arg(uniqueStem).arg(index); ++index; - instId.assign(uniqueStem); - instId.append(L"_"); - instId.append(buf); - } while (FindInstanceById(RegisterStr(instId.c_str())).hasValue()); + } while (FindInstanceById(instId).hasValue()); - Instance *retval = - GetInstance(CreateInstance(RegisterStr(instId.c_str()), inSource.m_Type)); - inIdMap.insert(eastl::make_pair(RegisterStr(inSource.m_Id), RegisterStr(retval->m_Id))); + Instance *retval = GetInstance(CreateInstance(instId, inSource.m_Type)); + inIdMap.insert(inSource.m_Id, retval->m_Id); QT3DSIMP_FOREACH(idx, (QT3DSU32)inSource.m_Children.size()) { Instance *oldChild = GetInstance(inSource.m_Children[idx]); - if (oldChild == NULL) { + if (oldChild == nullptr) { QT3DS_ASSERT(false); return retval; } @@ -589,40 +559,36 @@ public: } void CopyInstancePropertiesAndAnimation(Instance &inSource, - ImportHashMap<TCharPtr, TCharPtr> &inIdMap) + QHash<QString, QString> &inIdMap) { - const ImportHashMap<TCharPtr, TCharPtr>::iterator theNewItemId = - inIdMap.find(inSource.m_Id); + const QHash<QString, QString>::iterator theNewItemId = inIdMap.find(inSource.m_Id); if (theNewItemId == inIdMap.end()) { QT3DS_ASSERT(false); return; } - Instance *theCopy = GetInstance(theNewItemId->second); - if (theCopy == NULL) { + Instance *theCopy = GetInstance(*theNewItemId); + if (theCopy == nullptr) { QT3DS_ASSERT(false); return; } - for (ImportHashMap<ComposerPropertyNames::Enum, SInternValue>::iterator - iter = inSource.m_PropertyValues.begin(), - end = inSource.m_PropertyValues.end(); + for (auto iter = inSource.m_PropertyValues.begin(), end = inSource.m_PropertyValues.end(); iter != end; ++iter) { - SInternValue current(iter->second); + SInternValue current(*iter); if (GetValueType(current.GetValue()) == DataModelDataType::StringRef) { const SStringRef &theRef = get<SStringRef>(current.GetValue()); - const ImportHashMap<TCharPtr, TCharPtr>::iterator theNewId = - inIdMap.find(theRef.m_Id); - if (theNewId != inIdMap.end()) + const QHash<QString, QString>::iterator theNewId + = inIdMap.find(QString::fromWCharArray(theRef.m_Id)); + if (theNewId != inIdMap.end()) { current = SInternValue::ISwearThisHasAlreadyBeenInternalized( - SValue(SStringRef(theNewId->second))); + SValue(QVariant::fromValue(*theNewId))); + } } - theCopy->m_PropertyValues.insert(eastl::make_pair(iter->first, current)); + theCopy->m_PropertyValues.insert(iter.key(), current); } - for (ImportHashMap<AnimationId, Animation *>::iterator iter = m_Animations.begin(), - end = m_Animations.end(); - iter != end; ++iter) { - if (iter->first.m_Instance == toHdl(&inSource)) { - const Animation *theSrcAnimation = iter->second; + for (auto iter = m_Animations.begin(), end = m_Animations.end(); iter != end; ++iter) { + if (iter.key().m_Instance == toHdl(&inSource)) { + const Animation *theSrcAnimation = *iter; DoAddAnimation(theCopy->m_Id, theSrcAnimation->m_PropertyName, theSrcAnimation->m_SubPropertyIndex, theSrcAnimation->m_Type, theSrcAnimation->m_Keyframes); @@ -631,7 +597,7 @@ public: QT3DSIMP_FOREACH(idx, (QT3DSU32)inSource.m_Children.size()) { Instance *oldChild = GetInstance(inSource.m_Children[idx]); - if (oldChild == NULL) { + if (oldChild == nullptr) { QT3DS_ASSERT(false); return; } @@ -642,18 +608,18 @@ public: TIMPHandle CopyInstance(TIMPHandle inSource) override { Instance *inst = GetInstance(inSource); - if (inst == NULL) { + if (inst == nullptr) { QT3DS_ASSERT(false); return 0; } // map from old ids to new ids - ImportHashMap<TCharPtr, TCharPtr> idMap; + QHash<QString, QString> idMap; // copy the hierarchy first Instance *retval = CopyInstanceHierarchy(*inst, idMap); Instance *parent = fromHdl(inst->m_Parent); - if (parent != NULL) + if (parent != nullptr) parent->AddChild(retval, inst); // Copy properties and animations @@ -662,10 +628,10 @@ public: return toHdl(retval); } - bool SetInstanceProperties(TIMPHandle instance, NVConstDataRef<PropertyValue> inBuffer) override + bool SetInstanceProperties(TIMPHandle instance, const QVector<PropertyValue> &inBuffer) override { Instance *inst = GetInstance(instance); - if (inst == NULL) { + if (inst == nullptr) { QT3DS_ASSERT(false); return false; } @@ -673,10 +639,10 @@ public: return true; } bool DoSetInstancePropertyValue(TIMPHandle instance, ComposerPropertyNames::Enum pname, - const TImportModelValue &val) override + const TImportModelValue &val) override { Instance *inst = GetInstance(instance); - if (inst == NULL) { + if (inst == nullptr) { QT3DS_ASSERT(false); return false; } @@ -685,7 +651,7 @@ public: } bool DoSetInstancePropertyValue(TIMPHandle inst, ComposerPropertyNames::Enum pname, - TCharPtr val) override + const QString &val) override { return DoSetInstancePropertyValue(inst, pname, std::make_shared<CDataStr>(val)); } @@ -693,11 +659,11 @@ public: { Instance *inst = GetInstance(instance); Instance *child = GetInstance(childHdl); - if (inst == NULL) { + if (inst == nullptr) { QT3DS_ASSERT(false); return false; } - if (child == NULL) { + if (child == nullptr) { QT3DS_ASSERT(false); return false; } @@ -732,90 +698,89 @@ public: } QT3DSU32 GetNumImages() const override { return (QT3DSU32)m_Images.size(); } - QT3DSU32 GetImages(NVDataRef<Pair<TCharPtr, TCharPtr>> imgPaths) const override + QT3DSU32 GetImages(QVector<std::pair<QString, QString>> &imgPaths) const override { QT3DSU32 numItems = qMin((QT3DSU32)imgPaths.size(), (QT3DSU32)m_Images.size()); QT3DS_ASSERT(numItems == m_Images.size()); QT3DSU32 idx = 0; - for (ImportHashMap<TCharPtr, TCharPtr>::const_iterator iter = m_Images.begin(), - end = m_Images.end(); + for (auto iter = m_Images.begin(), end = m_Images.end(); iter != end && idx < numItems; ++iter, ++idx) - imgPaths[idx] = Pair<TCharPtr, TCharPtr>(iter->first, iter->second); + imgPaths[idx] = std::pair<QString, QString>(iter.key(), iter.value()); return numItems; } + bool ensureDirectoryExists(const QString &directory) + { + QDir dir(directory); + dir.mkpath(QStringLiteral(".")); + return dir.exists(); + } // Copies the an appropriate location in our import directory // Returns the path of the added image. This may mangle the name slightly // In case of a conflict. - CharPtrOrError AddImage(TCharPtr _imgPath) override + QStringOrError AddImage(const QString &_imgPath) override { - Option<TCharPtr> added = FindImageByPath(_imgPath); + Option<QString> added = FindImageByPath(_imgPath); if (added.hasValue()) return *added; - if (!m_ImageDir.IsDirectory()) - m_ImageDir.CreateDir(true); - - if (!m_ImageDir.IsDirectory()) - return ImportErrorData(ImportErrorCodes::UnableToCreateDirectory, m_ImageDir.toCString()); + if (!ensureDirectoryExists(m_ImageDir)) + return ImportErrorData(ImportErrorCodes::UnableToCreateDirectory, m_ImageDir); - Q3DStudio::CString imgPath = CFilePath::GetAbsolutePath(CString(_imgPath)); - Q3DStudio::CString srcImgPath = + QString imgPath = QFileInfo(_imgPath).absoluteFilePath(); + QString srcImgPath = CFilePath::GetRelativePathFromBase(m_FullSrcDirectory, imgPath); - Q3DStudio::SFileErrorCodeFileNameAndNumBytes copyResult = - Q3DStudio::SFileTools::FindAndCopyDestFile(m_ImageDir, imgPath); + QString destFile; + bool copyResult = Q3DStudio::SFileTools::FindAndCopyDestFile(QDir(m_ImageDir), imgPath, + destFile); // Get the actual return value relative do our destination directory - Q3DStudio::CString _retval = - CFilePath::GetRelativePathFromBase(m_DestDirectory, copyResult.m_DestFilename); - // Register the string, so we can hand retval back to clients - TCharPtr retval = m_StringTable.RegisterStr(_retval.c_str()); - m_Images.insert(eastl::make_pair(m_StringTable.RegisterStr(srcImgPath.c_str()), retval)); - - if (copyResult.m_Error != Q3DStudio::FileErrorCodes::NoError) { - CharPtrOrError errorValue( - ImportErrorData(FromFileErrorCode(copyResult.m_Error), RegisterStr(imgPath))); + QString retval = CFilePath::GetRelativePathFromBase(m_DestDirectory, destFile); + + m_Images.insert(srcImgPath, retval); + + if (!copyResult) { + QStringOrError errorValue( + ImportErrorData(ImportErrorCodes::ResourceNotWriteable, imgPath)); errorValue.m_Value = retval; return errorValue; } return retval; } - CharPtrOrError AddOrReplaceImage(TCharPtr _imgPath, Option<TCharPtr> dstPath) + QStringOrError AddOrReplaceImage(const QString &_imgPath, Option<QString> dstPath) { if (dstPath.hasValue()) { - if (!m_ImageDir.IsDirectory()) - m_ImageDir.CreateDir(true); - if (!m_ImageDir.IsDirectory()) - return ImportErrorData(ImportErrorCodes::UnableToCreateDirectory, m_ImageDir.toCString()); + if (!ensureDirectoryExists(m_ImageDir)) + return ImportErrorData(ImportErrorCodes::UnableToCreateDirectory, m_ImageDir); + CFilePath fullDestPath = - CFilePath::CombineBaseAndRelative(m_DestDirectory, CString(dstPath.getValue())); + CFilePath::CombineBaseAndRelative(m_DestDirectory, dstPath.getValue()); Q3DStudio::SFileErrorCodeAndNumBytes copyResult = Q3DStudio::SFileTools::Copy( fullDestPath, Q3DStudio::FileOpenFlags(Q3DStudio::FileOpenFlagValues::Truncate | Q3DStudio::FileOpenFlagValues::Open | Q3DStudio::FileOpenFlagValues::Create), - CString(_imgPath)); + _imgPath); // Regardless of if the copy operation succeeds or not, if the destination exists // already // Then we enter it into our dictionary if (fullDestPath.IsFile()) { - CFilePath imgPath = CFilePath::GetAbsolutePath(CString(_imgPath)); - CFilePath srcImgPath = + QString imgPath = QFileInfo(_imgPath).absoluteFilePath(); + QString srcImgPath = CFilePath::GetRelativePathFromBase(m_FullSrcDirectory, imgPath); - m_Images.insert(eastl::make_pair(m_StringTable.RegisterStr(srcImgPath.toCString()), - m_StringTable.RegisterStr(dstPath.getValue()))); + m_Images.insert(srcImgPath, dstPath.getValue()); } - TCharPtr returnPath = dstPath.getValue(); + QString returnPath = dstPath.getValue(); if (copyResult.m_Error != Q3DStudio::FileErrorCodes::NoError) { QT3DS_ASSERT(false); - const wchar_t *extraData = NULL; + QString extraData; ImportErrorCodes::Enum error = FromFileErrorCode(copyResult.m_Error); if (error == ImportErrorCodes::ResourceNotWriteable) extraData = dstPath.getValue(); else if (error == ImportErrorCodes::SourceFileNotReadable) extraData = _imgPath; - CharPtrOrError errorRet(ImportErrorData(error, extraData)); + QStringOrError errorRet(ImportErrorData(error, extraData)); errorRet.m_Value = returnPath; return errorRet; } @@ -823,84 +788,76 @@ public: } return AddImage(_imgPath); } - Option<TCharPtr> FindImageByPath(TCharPtr _imgPath) const override + Option<QString> FindImageByPath(const QString &_imgPath) const override { - Q3DStudio::CString imgPath = CFilePath::GetAbsolutePath(CString(_imgPath)); - Q3DStudio::CString srcImgPath = - CFilePath::GetRelativePathFromBase(m_FullSrcDirectory, imgPath); - return FindImageByRelativePath(srcImgPath.c_str()); + const QString imgPath(QFileInfo(_imgPath).absoluteFilePath()); + const QString srcImgPath(CFilePath::GetRelativePathFromBase(m_FullSrcDirectory, imgPath)); + return FindImageByRelativePath(srcImgPath); } - Option<TCharPtr> FindImageByRelativePath(TCharPtr imgPath) const override + Option<QString> FindImageByRelativePath(const QString &imgPath) const override { - ImportHashMap<TCharPtr, TCharPtr>::const_iterator entry = m_Images.find(imgPath); + QHash<QString, QString>::const_iterator entry = m_Images.find(imgPath); if (entry != m_Images.end()) - return entry->second; + return *entry; return Empty(); } QT3DSU32 GetNumMeshes() const override { return (QT3DSU32)m_Meshes.size(); } - QT3DSU32 GetMeshes(NVDataRef<Pair<TCharPtr, TCharPtr>> bufferPaths) const override + QT3DSU32 GetMeshes(QVector<std::pair<QString, QString>> &bufferPaths) const override { - QT3DSU32 numItems = qMin((QT3DSU32)m_Meshes.size(), bufferPaths.size()); + QT3DSU32 numItems = qMin(m_Meshes.size(), bufferPaths.size()); QT3DS_ASSERT(numItems == m_Meshes.size()); QT3DSU32 idx = 0; - for (ImportHashMap<TCharPtr, MeshEntry>::const_iterator iter = m_Meshes.begin(), - end = m_Meshes.end(); - iter != end && idx < numItems; ++iter, ++idx) - bufferPaths[idx] = Pair<TCharPtr, TCharPtr>(iter->first, iter->second.m_FilePath); + for (auto iter = m_Meshes.begin(), end = m_Meshes.end(); + iter != end && idx < numItems; ++iter, ++idx) { + bufferPaths[idx] = std::make_pair(iter.key(), iter->m_FilePath); + } return numItems; } + // Copies the vertex buffer into the appropriate location, renaming if necessary. - CharPtrOrError AddMesh(const Mesh &meshBuffer, TCharPtr _name) override + QStringOrError AddMesh(const Mesh &meshBuffer, const QString &_name) override { - if (IsTrivial(_name)) { + if (_name.isNull()) { QT3DS_ASSERT(false); - return L""; + return QString(); } - Q3DStudio::CString name = CFilePath::MakeSafeFileStem(_name); + QString name = CFilePath::MakeSafeFileStem(_name); - Option<TCharPtr> meshOpt = FindMeshReferencePathByName(name.c_str()); + Option<QString> meshOpt = FindMeshReferencePathByName(name); if (meshOpt.hasValue()) return *meshOpt; - if (!m_MeshDir.IsDirectory()) - m_MeshDir.CreateDir(true); - if (!m_MeshDir.IsDirectory()) - return ImportErrorData(ImportErrorCodes::UnableToCreateDirectory, m_MeshDir.toCString()); + if (!ensureDirectoryExists(m_MeshDir)) + return ImportErrorData(ImportErrorCodes::UnableToCreateDirectory, m_MeshDir); - Q3DStudio::TFilePtr handf = - Q3DStudio::SFileTools::FindUniqueDestFile(m_MeshDir, name, L"mesh"); -#ifdef RUNTIME_SPLIT_TEMPORARILY_REMOVED - Qt3DSFileToolsSeekableMeshBufIOStream output(handf); + const QString handf = Q3DStudio::SFileTools::FindUniqueDestFile(m_MeshDir, name, + QStringLiteral("mesh")); + QFile output(handf); + output.open(QFile::WriteOnly | QFile::NewOnly); MallocAllocator alloc; QT3DSU32 meshId = meshBuffer.SaveMulti(alloc, output); - CFilePath _retval = CFilePath::GetRelativePathFromBase(m_DestDirectory, handf->m_Path); - MeshEntry newEntry(m_StringTable.RegisterStr(name.c_str()), _retval, meshId, m_StringTable); - m_Meshes.insert(eastl::make_pair(newEntry.m_SourceId, newEntry)); + QString _retval = CFilePath::GetRelativePathFromBase(m_DestDirectory, handf); + MeshEntry newEntry(name, _retval, meshId); + m_Meshes.insert(newEntry.m_SourceId, newEntry); return newEntry.m_ReferencePath; -#endif - return L""; } - CharPtrOrError AddOrReplaceMesh(const Mesh &meshBuffer, TCharPtr name, Option<TCharPtr> srcMesh) + QStringOrError AddOrReplaceMesh(const Mesh &meshBuffer, const QString &name, + Option<QString> srcMesh) { using namespace Q3DStudio; if (srcMesh.hasValue()) { - if (!m_MeshDir.IsDirectory()) - m_MeshDir.CreateDir(true); - if (!m_MeshDir.IsDirectory()) { - return ImportErrorData(ImportErrorCodes::UnableToCreateDirectory, - m_MeshDir.toCString()); - } + if (!ensureDirectoryExists(m_MeshDir)) + return ImportErrorData(ImportErrorCodes::UnableToCreateDirectory, m_MeshDir); - CFilePath meshPath = - CFilePath::CombineBaseAndRelative(m_DestDirectory, CString(srcMesh.getValue())); -#ifdef RUNTIME_SPLIT_TEMPORARILY_REMOVED - meshPath = meshPath.filePath(); - Qt3DSFileToolsSeekableMeshBufIOStream output( - SFile::Wrap(SFile::OpenForWrite(meshPath, FileWriteFlags()), meshPath)); - if (output.IsOpen() == false) { + const QString meshPath + = CFilePath::CombineBaseAndRelative(m_DestDirectory, srcMesh.getValue()); + + QFile output(meshPath); + output.open(QFile::WriteOnly | QFile::Truncate); + if (output.isOpen() == false) { QT3DS_ASSERT(false); return ImportErrorData(ImportErrorCodes::ResourceNotWriteable, srcMesh.getValue()); } @@ -908,58 +865,55 @@ public: MallocAllocator allocator; QT3DSU32 meshId = meshBuffer.SaveMulti(allocator, output); - CFilePath relativePath = CFilePath::GetRelativePathFromBase(m_DestDirectory, meshPath); + QString relativePath = CFilePath::GetRelativePathFromBase(m_DestDirectory, meshPath); - MeshEntry newEntry(m_StringTable.RegisterStr(name), relativePath, meshId, - m_StringTable); - m_Meshes.insert(eastl::make_pair(newEntry.m_SourceId, newEntry)); + MeshEntry newEntry(name, relativePath, meshId); + m_Meshes.insert(newEntry.m_SourceId, newEntry); return newEntry.m_ReferencePath; -#endif - return L""; } return AddMesh(meshBuffer, name); } - bool HasMesh(TCharPtr meshName) const override + bool HasMesh(const QString & meshName) const override { return m_Meshes.find(meshName) != m_Meshes.end(); } - Option<TCharPtr> FindMeshReferencePathByName(TCharPtr meshName) const override + Option<QString> FindMeshReferencePathByName(const QString &meshName) const override { - ImportHashMap<TCharPtr, MeshEntry>::const_iterator entry = m_Meshes.find(meshName); + QHash<QString, MeshEntry>::const_iterator entry = m_Meshes.find(meshName); if (entry != m_Meshes.end()) { - QT3DS_ASSERT(!IsTrivial(entry->second.m_ReferencePath)); - return entry->second.m_ReferencePath; + QT3DS_ASSERT(!entry->m_ReferencePath.isEmpty()); + return entry->m_ReferencePath; } return Empty(); } - Option<TCharPtr> FindMeshFilePathByName(TCharPtr meshName) const override + Option<QString> FindMeshFilePathByName(const QString &meshName) const override { - ImportHashMap<TCharPtr, MeshEntry>::const_iterator entry = m_Meshes.find(meshName); + QHash<QString, MeshEntry>::const_iterator entry = m_Meshes.find(meshName); if (entry != m_Meshes.end()) { - QT3DS_ASSERT(!IsTrivial(entry->second.m_FilePath)); - return entry->second.m_FilePath; + QT3DS_ASSERT(!entry->m_FilePath.isEmpty()); + return entry->m_FilePath; } return Empty(); } - +#if RUNTIME_SPLIT_TEMPORARILY_REMOVED QT3DSU32 GetNumPathBuffers() const override { return (QT3DSU32)m_PathBuffers.size(); } - QT3DSU32 GetPathBuffers(NVDataRef<Pair<TCharPtr, TCharPtr>> pathBufferPaths) const override + QT3DSU32 GetPathBuffers(QVector<std::pair<QString, QString>> &pathBufferPaths) const override { QT3DSU32 numItems = qMin((QT3DSU32)pathBufferPaths.size(), (QT3DSU32)m_PathBuffers.size()); QT3DS_ASSERT(numItems == m_PathBuffers.size()); QT3DSU32 idx = 0; - for (ImportHashMap<TCharPtr, TCharPtr>::const_iterator iter = m_PathBuffers.begin(), + for (ImportHashMap<QString, QString>::const_iterator iter = m_PathBuffers.begin(), end = m_PathBuffers.end(); iter != end && idx < numItems; ++iter, ++idx) - pathBufferPaths[idx] = Pair<TCharPtr, TCharPtr>(iter->first, iter->second); + pathBufferPaths[idx] = std::make_pair(iter->first, iter->second); return numItems; } // Copies the vertex buffer into the appropriate location, renaming if necessary. - CharPtrOrError AddPathBuffer(const SPathBuffer &pathBuffer, TCharPtr _name) override + QStringOrError AddPathBuffer(const SPathBuffer &pathBuffer, const QString &_name) override { if (IsTrivial(_name)) { QT3DS_ASSERT(false); @@ -967,7 +921,7 @@ public: } Q3DStudio::CString name = CFilePath::MakeSafeFileStem(_name); - Option<TCharPtr> pathBufferOpt = FindPathBufferByRelativePath(name.c_str()); + Option<QString> pathBufferOpt = FindPathBufferByRelativePath(name.c_str()); if (pathBufferOpt.hasValue()) return *pathBufferOpt; @@ -984,13 +938,13 @@ public: CFilePath _retval = CFilePath::GetRelativePathFromBase(m_DestDirectory, handf->m_Path); const wchar_t *return_Value = m_StringTable.RegisterStr(_retval.toCString()); m_PathBuffers.insert( - eastl::make_pair(m_StringTable.RegisterStr(name.c_str()), return_Value)); + std::make_pair(m_StringTable.RegisterStr(name.c_str()), return_Value)); #endif return L""; } - CharPtrOrError AddOrReplacePathBuffer(const SPathBuffer &pathBuffer, TCharPtr name, - Option<TCharPtr> srcPathBuffer) + QStringOrError AddOrReplacePathBuffer(const SPathBuffer &pathBuffer, const QString &name, + Option<QString> srcPathBuffer) { using namespace Q3DStudio; if (srcPathBuffer.hasValue()) { @@ -1027,7 +981,7 @@ public: return AddPathBuffer(pathBuffer, name); } - Option<TCharPtr> FindPathBufferByPath(TCharPtr _pathBufferPath) const override + Option<QString> FindPathBufferByPath(const QString &_pathBufferPath) const override { Q3DStudio::CString pathBufferPath = CFilePath::GetAbsolutePath(CString(_pathBufferPath)); Q3DStudio::CString srcpathBufferPath = @@ -1035,33 +989,28 @@ public: return FindPathBufferByRelativePath(srcpathBufferPath.c_str()); } - Option<TCharPtr> FindPathBufferByRelativePath(TCharPtr pathBufferPath) const override + Option<QString> FindPathBufferByRelativePath(const QString &pathBufferPath) const override { - ImportHashMap<TCharPtr, TCharPtr>::const_iterator entry = + ImportHashMap<QString, QString>::const_iterator entry = m_PathBuffers.find(pathBufferPath); if (entry != m_PathBuffers.end()) return entry->second; return Empty(); } - +#endif QT3DSU32 GetNumAnimations() const override { return QT3DSU32(m_Animations.size()); } - QT3DSU32 GetAnimations(NVDataRef<Animation> outBuffers) const override + QT3DSU32 GetAnimations(QVector<Animation> &outBuffers) const override { - QT3DSU32 numItems = qMin(QT3DSU32(m_Animations.size()), outBuffers.size()); - QT3DS_ASSERT(numItems == m_Animations.size()); - QT3DSU32 idx = 0; - for (ImportHashMap<AnimationId, Animation *>::const_iterator iter = m_Animations.begin(), - end = m_Animations.end(); - iter != end && idx < numItems; ++iter, ++idx) - outBuffers[idx] = *iter->second; + QT3DSU32 numItems = qMin(m_Animations.size(), outBuffers.size()); + Q_ASSERT(numItems == m_Animations.size()); + std::copy(m_Animations.begin(), m_Animations.begin() + numItems, outBuffers.begin()); return numItems; } // Data is copied into this object, you can release the anim buffer data after this - void DoAddAnimation(TCharPtr instance, TCharPtr propName, QT3DSU32 subPropIndex, - EAnimationType bufType, NVConstDataRef<QT3DSF32> values) override + void DoAddAnimation(const QString &instance, const QString &propName, QT3DSU32 subPropIndex, + EAnimationType bufType, const QVector<QT3DSF32> &values) override { - propName = m_StringTable.RegisterStr(propName); Option<Animation> buffer(FindAnimation(instance, propName, subPropIndex)); if (buffer.hasValue()) { QT3DS_ASSERT(false); @@ -1072,21 +1021,21 @@ public: if (instOpt.hasValue() == false) return; - m_Animations.insert(eastl::make_pair( + m_Animations.insert( AnimationId(instOpt->m_Handle, propName, subPropIndex), - CreateAnimation(instOpt->m_Id, propName, subPropIndex, bufType, values))); + CreateAnimation(instOpt->m_Id, propName, subPropIndex, bufType, values)); } - Option<Animation> FindAnimation(TCharPtr instId, TCharPtr propName, + Option<Animation> FindAnimation(const QString &instId, const QString &propName, QT3DSU32 subPropIndex) const override { Option<InstanceDesc> instance(FindInstanceById(instId)); if (instance.hasValue() == false) return Empty(); AnimationId id(instance->m_Handle, propName, subPropIndex); - ImportHashMap<AnimationId, Animation *>::const_iterator entry(m_Animations.find(id)); + QHash<AnimationId, Animation *>::const_iterator entry(m_Animations.find(id)); if (entry != m_Animations.end()) - return *entry->second; + return **entry; return Empty(); } @@ -1119,7 +1068,7 @@ public: AddAddedItems(m_ImportReport.m_Meshes, MeshDiffOp()); AddAddedItems(m_ImportReport.m_Animations, AnimationDiffOp()); - ImportArray<InstanceDesc> childList; + QVector<InstanceDesc> childList; QT3DSIMP_FOREACH(idx, m_ImportReport.m_Instances.m_Added.size()) { const InstanceDesc &inst(m_ImportReport.m_Instances.m_Added[idx]); @@ -1128,7 +1077,8 @@ public: GetChildren(inst.m_Handle, childList); QT3DSIMP_FOREACH(child, childList.size()) { - TCharPtr sibling = child + 1 < childList.size() ? childList[child + 1].m_Id : L""; + QString sibling = child + 1 < childList.size() + ? childList[child + 1].m_Id : QString(); m_ImportReport.m_Links.m_Added.push_back( ParentChildLink(inst.m_Id, childList[child].m_Id, sibling)); } @@ -1154,32 +1104,32 @@ public: MemoryBuffer<RawAllocator> &inTempBuf) { Instance *theInstance = GetInstance(inAnimation.m_InstanceId); - if (theInstance == NULL || theInstance->m_Valid == false) + if (theInstance == nullptr || theInstance->m_Valid == false) return; IDOMWriter::Scope __animScope(writer, L"AnimationTrack"); - TCharStr thePropName(inAnimation.m_PropertyName); + QString thePropName(inAnimation.m_PropertyName); SImportComposerTypes theTypes; SImportAsset &theAsset(theTypes.GetImportAssetForType(inType)); - DataModelDataType::Value theType(theAsset.GetPropertyDataType(thePropName.wide_str())); + DataModelDataType::Value theType(theAsset.GetPropertyDataType(thePropName)); std::tuple<bool, size_t> animAndArity = GetDatatypeAnimatableAndArity(theType); if (std::get<0>(animAndArity) == false) { QT3DS_ASSERT(false); return; }; if (std::get<1>(animAndArity) > 1) { - thePropName.append(L"."); + thePropName.append(QLatin1Char('.')); switch (inAnimation.m_SubPropertyIndex) { case 0: - thePropName.append(L"x"); + thePropName.append(QLatin1Char('x')); break; case 1: - thePropName.append(L"y"); + thePropName.append(QLatin1Char('y')); break; case 2: - thePropName.append(L"z"); + thePropName.append(QLatin1Char('z')); break; case 3: - thePropName.append(L"w"); + thePropName.append(QLatin1Char('w')); break; } } @@ -1197,7 +1147,7 @@ public: writer.Value((const wchar_t *)inTempBuf.begin()); } } - void SerializeAnimation(IDOMReader &reader, const wchar_t *inInstanceId, + void SerializeAnimation(IDOMReader &reader, const QString &inInstanceId, MemoryBuffer<RawAllocator> &inTempBuf, MemoryBuffer<RawAllocator> &inAttributeBuffer) { @@ -1231,7 +1181,7 @@ public: break; } } - theAnimation.m_PropertyName = m_StringTable.RegisterStr(theName.wide_str()); + theAnimation.m_PropertyName = QString::fromWCharArray(theName.wide_str()); reader.Att(L"type", theAnimation.m_Type); inAttributeBuffer.clear(); const char8_t *theValue; @@ -1239,15 +1189,15 @@ public: inAttributeBuffer.write(theValue, (QT3DSU32)strlen(theValue) + 1); inAttributeBuffer.write((QT3DSU16)0); WCharTReader theReader((char8_t *)inAttributeBuffer.begin(), inTempBuf, m_StringTable); - NVConstDataRef<float> theData; + QVector<float> theData; theReader.ReadBuffer(theData); Animation *newAnim = CreateAnimation(theAnimation.m_InstanceId, theAnimation.m_PropertyName, theAnimation.m_SubPropertyIndex, theAnimation.m_Type, theData); - m_Animations.insert(eastl::make_pair( + m_Animations.insert( AnimationId(toHdl(GetInstance(theAnimation.m_InstanceId)), theAnimation.m_PropertyName, theAnimation.m_SubPropertyIndex), - newAnim)); + newAnim); } struct PropertyNameSorter { @@ -1259,8 +1209,8 @@ public: return true; if (rhs == ComposerPropertyNames::name) return false; - return wcscmp(ComposerPropertyNames::Convert(lhs), ComposerPropertyNames::Convert(rhs)) - < 0; + return ComposerPropertyNames::Convert(lhs).compare(ComposerPropertyNames::Convert(rhs)) + < 0; } }; @@ -1269,34 +1219,34 @@ public: if (inInstance.m_Valid == false) return; IDOMWriter::Scope __instanceScope(writer, ComposerObjectTypes::Convert(inInstance.m_Type)); - writer.Att(L"id", inInstance.m_Id); + QString id; + writer.Att(QStringLiteral("id"), inInstance.m_Id); // Write properties, then write animations - ImportArray<ComposerPropertyNames::Enum> theNames; - for (ImportHashMap<ComposerPropertyNames::Enum, SInternValue>::iterator + QVector<ComposerPropertyNames::Enum> theNames; + for (QHash<ComposerPropertyNames::Enum, SInternValue>::iterator iter = inInstance.m_PropertyValues.begin(), end = inInstance.m_PropertyValues.end(); iter != end; ++iter) { - theNames.push_back(iter->first); + theNames.push_back(iter.key()); } std::sort(theNames.begin(), theNames.end(), PropertyNameSorter()); - for (QT3DSU32 nameIdx = 0, nameEnd = (QT3DSU32)theNames.size(); nameIdx < nameEnd; ++nameIdx) { - ImportHashMap<ComposerPropertyNames::Enum, SInternValue>::const_iterator iter( + for (QT3DSU32 nameIdx = 0, nameEnd = (QT3DSU32)theNames.size(); + nameIdx < nameEnd; ++nameIdx) { + QHash<ComposerPropertyNames::Enum, SInternValue>::const_iterator iter( inInstance.m_PropertyValues.find(theNames[nameIdx])); inTempBuf.clear(); WCharTWriter bufWriter(inTempBuf); - WStrOps<SValue>().ToBuf(iter->second.GetValue(), bufWriter); + WStrOps<SValue>().ToBuf(iter->GetValue(), bufWriter); if (inTempBuf.size()) { inTempBuf.writeZeros(sizeof(wchar_t)); - writer.Att(ComposerPropertyNames::Convert(iter->first), - (const wchar_t *)inTempBuf.begin()); + writer.Att(ComposerPropertyNames::Convert(iter.key()), + QString::fromWCharArray((const wchar_t *)inTempBuf.begin())); } } - for (ImportHashMap<AnimationId, Animation *>::const_iterator iter = m_Animations.begin(), - end = m_Animations.end(); - iter != end; ++iter) { - if (iter->first.m_Instance == toHdl(&inInstance)) - Serialize(writer, inInstance.m_Type, *iter->second, inTempBuf); + for (auto iter = m_Animations.begin(), end = m_Animations.end(); iter != end; ++iter) { + if (iter.key().m_Instance == toHdl(&inInstance)) + Serialize(writer, inInstance.m_Type, **iter, inTempBuf); } for (QT3DSU32 childIdx = 0, childEnd = (QT3DSU32)inInstance.m_Children.size(); childIdx < childEnd; ++childIdx) { @@ -1313,31 +1263,32 @@ public: SImportComposerTypes theTypes; SImportAsset &theAsset(theTypes.GetImportAssetForType(inInstance.m_Type)); m_ValidInstances.insert(inInstance.m_Handle); - m_IdToInstMap.insert(eastl::make_pair(inInstance.m_Id, &inInstance)); - for (eastl::pair<const char8_t *, const char8_t *> att = reader.GetNarrowFirstAttribute(); - !IsTrivial(att.first); att = reader.GetNarrowNextAttribute()) { - if (AreEqual("id", att.first)) + m_IdToInstMap.insert(inInstance.m_Id, &inInstance); + for (std::pair<QString, QString> att = reader.GetFirstAttribute(); + !IsTrivial(att.first); att = reader.GetNextAttribute()) { + if (QLatin1String("id") == att.first) continue; DataModelDataType::Value thePropertyType = theAsset.GetPropertyDataType(att.first); if (thePropertyType != DataModelDataType::None) { if (thePropertyType == DataModelDataType::Long4) thePropertyType = DataModelDataType::StringRef; inAttributeBuffer.clear(); - inAttributeBuffer.write(att.second, (QT3DSU32)strlen(att.second) + 1); + inAttributeBuffer.write(qPrintable(att.second), + (QT3DSU32)strlen(qPrintable(att.second)) + 1); inAttributeBuffer.write((QT3DSU16)0); WCharTReader theReader((char8_t *)inAttributeBuffer.begin(), inTempBuf, m_StringTable); SValue theValue = WStrOps<SValue>().BufTo(thePropertyType, theReader); inInstance.m_PropertyValues.insert( - eastl::make_pair(ComposerPropertyNames::Convert(att.first), - SInternValue(theValue, m_StringTable))); + ComposerPropertyNames::Convert(att.first), + SInternValue(theValue, m_StringTable)); } } { IDOMReader::Scope animScope(reader); for (bool success = reader.MoveToFirstChild(); success; success = reader.MoveToNextSibling()) { - if (AreEqual(reader.GetElementName(), L"AnimationTrack")) { + if (reader.GetElementName() == QLatin1String("AnimationTrack")) { SerializeAnimation(reader, inInstance.m_Id, inTempBuf, inAttributeBuffer); } else { Instance *newInstance = new Instance(); @@ -1353,8 +1304,8 @@ public: for (TStrToStrMap::iterator iter = inHashMap.begin(), end = inHashMap.end(); iter != end; ++iter) { IDOMWriter::Scope __elemScope(inWriter, inElemName); - inWriter.ChildValue(L"Source", iter->first); - inWriter.ChildValue(L"Dest", iter->second); + inWriter.ChildValue(QStringLiteral("Source"), iter.key()); + inWriter.ChildValue(QStringLiteral("Dest"), *iter); } } @@ -1363,11 +1314,11 @@ public: IDOMReader::Scope itemScope(inReader); for (bool success = inReader.MoveToFirstChild(inElemName); success; success = inReader.MoveToNextSibling(inElemName)) { - const char8_t *source, *dest; - inReader.ChildValue("Source", source); - inReader.ChildValue("Dest", dest); - inHashMap.insert( - eastl::make_pair(m_StringTable.GetWideStr(source), m_StringTable.GetWideStr(dest))); + QString source; + QString dest; + inReader.ChildValue(QStringLiteral("Source"), source); + inReader.ChildValue(QStringLiteral("Dest"), dest); + inHashMap.insert(source, dest); } } @@ -1376,8 +1327,8 @@ public: for (TPathToMeshMap::iterator iter = inHashMap.begin(), end = inHashMap.end(); iter != end; ++iter) { IDOMWriter::Scope __elemScope(inWriter, inElemName); - inWriter.ChildValue(L"Source", iter->first); - inWriter.ChildValue(L"Dest", iter->second.m_FilePath); + inWriter.ChildValue(QStringLiteral("Source"), iter.key()); + inWriter.ChildValue(QStringLiteral("Dest"), iter->m_FilePath); } } @@ -1386,29 +1337,29 @@ public: IDOMReader::Scope itemScope(inReader); for (bool success = inReader.MoveToFirstChild(inElemName); success; success = inReader.MoveToNextSibling(inElemName)) { - const char8_t *source, *dest; - inReader.ChildValue("Source", source); - inReader.ChildValue("Dest", dest); - MeshEntry theEntry(m_StringTable.GetWideStr(source), m_StringTable.GetWideStr(dest), - m_StringTable); - inHashMap.insert(eastl::make_pair(theEntry.m_SourceId, theEntry)); + QString source; + QString dest; + inReader.ChildValue(QStringLiteral("Source"), source); + inReader.ChildValue(QStringLiteral("Dest"), dest); + MeshEntry theEntry(source, dest); + inHashMap.insert(theEntry.m_SourceId, theEntry); } } - QT3DSU32 Save(TCharPtr fname) const override + QT3DSU32 Save(const QString &fname) const override { using namespace Q3DStudio; QT3DSU32 theRevisionId = 1; - CFilePath fullPath = CFilePath::CombineBaseAndRelative(m_DestDirectory, CString(fname)); + QString fullPath = Q3DStudio::CFilePath::CombineBaseAndRelative(m_DestDirectory, fname); std::shared_ptr<IDOMFactory> factory(IDOMFactory::CreateDOMFactory(m_StringTablePtr)); std::shared_ptr<IDOMWriter> theWriter; - SDOMElement *theTopElement = NULL; - bool exists = fullPath.Exists(); + SDOMElement *theTopElement = nullptr; + bool exists = QFileInfo(fullPath).exists(); { if (exists) { - QFile stream(fullPath.toQString()); + QFile stream(fullPath); // OK, ensure we can open this file in append mode. // This is kind of tricky because we need to write the data to the file @@ -1421,11 +1372,11 @@ public: theTopElement = CDOMSerializer::Read(*factory, stream); - if (theTopElement == NULL) { + if (theTopElement == nullptr) { QT3DS_ASSERT(false); return 0; } - eastl::pair<std::shared_ptr<IDOMWriter>, std::shared_ptr<IDOMReader>> + std::pair<std::shared_ptr<IDOMWriter>, std::shared_ptr<IDOMReader>> theDomAccess( IDOMWriter::CreateDOMWriter(factory, *theTopElement, m_StringTablePtr)); theWriter = theDomAccess.first; @@ -1447,12 +1398,12 @@ public: writer.Att(L"Revision", theRevisionId); MemoryBuffer<RawAllocator> tempBuf; - ImportArray<Instance *> rootList; - for (ImportHashMap<TCharPtr, Instance *>::const_iterator iter = m_IdToInstMap.begin(), + QVector<Instance *> rootList; + for (QHash<QString, Instance *>::const_iterator iter = m_IdToInstMap.begin(), end = m_IdToInstMap.end(); iter != end; ++iter) { - if (iter->second->m_Parent == 0) - rootList.push_back(iter->second); + if ((*iter)->m_Parent == 0) + rootList.push_back(*iter); } { IDOMWriter::Scope __graphScope(writer, L"Graph"); @@ -1461,13 +1412,11 @@ public: } { IDOMWriter::Scope __importScope(writer, L"Import"); - CFilePath theDirectory(fullPath.GetDirectory()); - CFilePath theSrcFile = m_SrcFile; - if (theSrcFile.IsAbsolute()) - theSrcFile = CFilePath::GetRelativePathFromBase(theDirectory, m_SrcFile); + QString theSrcFile = m_SrcFile; + if (QFileInfo(theSrcFile).isAbsolute()) + theSrcFile = CFilePath::GetRelativePathFromBase(fullPath, m_SrcFile); - CString src = theSrcFile.toCString(); - writer.Att(L"SrcFile", src.c_str()); + writer.Att(L"SrcFile", theSrcFile); writer.Att(L"ImageDir", L"Images"); writer.Att(L"MeshDir", L"Meshes"); Serialize(writer, L"Image", const_cast<TStrToStrMap &>(m_Images)); @@ -1475,7 +1424,7 @@ public: } } { - QFile stream(fullPath.toQString()); + QFile stream(fullPath); stream.open(QFile::ReadWrite | QFile::Append); stream.seek(0); CDOMSerializer::WriteXMLHeader(stream); @@ -1485,13 +1434,13 @@ public: return theRevisionId; } - bool Load(const Q3DStudio::CString &fname, QT3DSU32 inDocumentId) + bool Load(const QString &fname, QT3DSU32 inDocumentId) { using namespace Q3DStudio; std::shared_ptr<IDOMFactory> factory(IDOMFactory::CreateDOMFactory(m_StringTablePtr)); - SDOMElement *topElement = NULL; + SDOMElement *topElement = nullptr; { - QFile stream(fname.toQString()); + QFile stream(fname); if (stream.open(QFile::ReadOnly) == false) { QT3DS_ASSERT(false); return false; @@ -1500,7 +1449,7 @@ public: topElement = CDOMSerializer::Read(*factory, stream); } - if (topElement == NULL) { + if (topElement == nullptr) { QT3DS_ASSERT(false); return false; } @@ -1526,7 +1475,9 @@ public: return false; } - const wchar_t *srcFile, *imagesDir, *meshDir; + QString srcFile; + QString imagesDir; + QString meshDir; if (fileVersion > Import::GetImportFileVersion()) { QT3DS_ASSERT(false); @@ -1553,12 +1504,14 @@ public: reader.Att(L"MeshDir", meshDir); // We ignore, however, srcpath. // because it may be different. - m_SrcFile = CString(srcFile); - m_SrcDirectory = m_SrcFile.GetDirectory(); + m_SrcFile = srcFile; + m_SrcDirectory = QFileInfo(m_SrcFile).absolutePath(); m_FullSrcDirectory = CFilePath::CombineBaseAndRelative(m_DestDirectory, m_SrcDirectory); - m_ImageDir = CFilePath::CombineBaseAndRelative(m_DestDirectory, CString(imagesDir)); - m_MeshDir = CFilePath::CombineBaseAndRelative(m_DestDirectory, CString(meshDir)); + m_ImageDir = CFilePath::CombineBaseAndRelative(m_DestDirectory, + imagesDir); + m_MeshDir = CFilePath::CombineBaseAndRelative(m_DestDirectory, + meshDir); Serialize(reader, L"Image", m_Images); Serialize(reader, L"Mesh", m_Meshes); } @@ -1575,9 +1528,9 @@ class RefreshImpl : public Import mutable MemoryBuffer<RawAllocator> m_TempBuffer; public: - RefreshImpl(ImportImpl &src, const Q3DStudio::CString &srcDirectory) - : m_Import(src.m_StringTablePtr, srcDirectory, src.m_DestDirectory, src.m_ImageDir.toCString(), - src.m_MeshDir.toCString()) + RefreshImpl(ImportImpl &src, const QString &srcDirectory) + : m_Import(src.m_StringTablePtr, srcDirectory, src.m_DestDirectory, src.m_ImageDir, + src.m_MeshDir) , m_Source(src) { } @@ -1588,29 +1541,29 @@ public: // Implement the import interface... - TCharPtr RegisterStr(TCharPtr str) override { return m_Import.RegisterStr(str); } + QString RegisterStr(TCharPtr str) override { return m_Import.RegisterStr(str); } QString GetSrcFile() const override { return m_Import.GetSrcFile(); } QString GetDestDir() const override { return m_Import.GetDestDir(); } QString GetImageDir() const override { return m_Import.GetImageDir(); } QString GetMeshDir() const override { return m_Import.GetMeshDir(); } - QString GetPathBufferDir() const override { return m_Import.GetPathBufferDir(); } - QT3DSU32 Save(TCharPtr fname) const override { return m_Import.Save(fname); } + //QString GetPathBufferDir() const override { return m_Import.GetPathBufferDir(); } + QT3DSU32 Save(const QString &fname) const override { return m_Import.Save(fname); } // Add a mapping from an named id to a handle Option<InstanceDesc> GetInstanceByHandle(TIMPHandle inst) const override { return m_Import.GetInstanceByHandle(inst); } - Option<InstanceDesc> FindInstanceById(TCharPtr inst) const override + Option<InstanceDesc> FindInstanceById(const QString &inst) const override { return m_Import.FindInstanceById(inst); } - Option<InstanceDesc> FindAnyInstanceById(TCharPtr inst) const override + Option<InstanceDesc> FindAnyInstanceById(const QString &inst) const override { return m_Import.FindAnyInstanceById(inst); } QT3DSU32 GetNumInstances() const override { return m_Import.GetNumInstances(); } - QT3DSU32 GetInstances(NVDataRef<InstanceDesc> outDescs) const override + QT3DSU32 GetInstances(QVector<InstanceDesc> &outDescs) const override { return m_Import.GetInstances(outDescs); } @@ -1618,7 +1571,7 @@ public: { return m_Import.GetNumProperties(instance); } - QT3DSU32 GetProperties(TIMPHandle inst, NVDataRef<PropertyValue> outBuffer) const override + QT3DSU32 GetProperties(TIMPHandle inst, QVector<PropertyValue> &outBuffer) const override { return m_Import.GetProperties(inst, outBuffer); } @@ -1631,13 +1584,13 @@ public: { return m_Import.GetNumChildren(instance); } - QT3DSU32 GetChildren(TIMPHandle instance, NVDataRef<InstanceDesc> childBuffer) const override + QT3DSU32 GetChildren(TIMPHandle instance, QVector<InstanceDesc> &childBuffer) const override { return m_Import.GetChildren(instance, childBuffer); } // Carry user id's across. - TIMPHandle CreateInstance(TCharPtr name, ComposerObjectTypes::Enum inType) override + TIMPHandle CreateInstance(const QString &name, ComposerObjectTypes::Enum inType) override { TIMPHandle retval = m_Import.CreateInstance(name, inType); Option<InstanceDesc> srcInst = m_Source.FindInstanceById(name); @@ -1645,14 +1598,14 @@ public: if (srcInst->m_Type != inType) { Instance *inst = fromHdl(retval); m_ImportReport.m_TypeChanges.push_back( - Pair<InstanceDesc, ComposerObjectTypes::Enum>(*inst, srcInst->m_Type)); + std::pair<InstanceDesc, ComposerObjectTypes::Enum>(*inst, srcInst->m_Type)); } } return retval; } TIMPHandle CopyInstance(TIMPHandle inSource) override { return m_Import.CopyInstance(inSource); } - bool SetInstanceProperties(TIMPHandle inst, NVConstDataRef<PropertyValue> inBuffer) override + bool SetInstanceProperties(TIMPHandle inst, const QVector<PropertyValue> &inBuffer) override { return m_Import.SetInstanceProperties(inst, inBuffer); } @@ -1662,7 +1615,7 @@ public: return m_Import.DoSetInstancePropertyValue(inst, pname, val); } bool DoSetInstancePropertyValue(TIMPHandle inst, ComposerPropertyNames::Enum pname, - TCharPtr val) override + const QString &val) override { return m_Import.DoSetInstancePropertyValue(inst, pname, val); } @@ -1673,108 +1626,101 @@ public: void MarkInstanceInvalid(TIMPHandle inst) override { m_Import.MarkInstanceInvalid(inst); } QT3DSU32 GetNumImages() const override { return m_Import.GetNumImages(); } - QT3DSU32 GetImages(NVDataRef<Pair<TCharPtr, TCharPtr>> imgPaths) const override + QT3DSU32 GetImages(QVector<std::pair<QString, QString>> &imgPaths) const override { return m_Import.GetImages(imgPaths); } // Copies the an appropriate location in our import directory // Returns the path of the added image. This may mangle the name slightly // In case of a conflict. - CharPtrOrError AddImage(TCharPtr _imgPath) override + QStringOrError AddImage(const QString &_imgPath) override { - Option<TCharPtr> added = m_Source.FindImageByPath(_imgPath); + Option<QString> added = m_Source.FindImageByPath(_imgPath); return m_Import.AddOrReplaceImage(_imgPath, added); } - Option<TCharPtr> FindImageByPath(TCharPtr imgPath) const override + Option<QString> FindImageByPath(const QString &imgPath) const override { return m_Import.FindImageByPath(imgPath); } - Option<TCharPtr> FindImageByRelativePath(TCharPtr imgPath) const override + Option<QString> FindImageByRelativePath(const QString &imgPath) const override { return m_Import.FindImageByRelativePath(imgPath); } QT3DSU32 GetNumMeshes() const override { return m_Import.GetNumMeshes(); } - QT3DSU32 GetMeshes(NVDataRef<Pair<TCharPtr, TCharPtr>> bufferPaths) const override + QT3DSU32 GetMeshes(QVector<std::pair<QString, QString>> &bufferPaths) const override { return m_Import.GetMeshes(bufferPaths); } // Copies the vertex buffer into the appropriate location, renaming if necessary. // Mesh name is used to write out a reasonable buffer *and* on refresh to know // if a buffer is changed/updated or not - CharPtrOrError AddMesh(const Mesh &meshBuffer, TCharPtr meshName) override + QStringOrError AddMesh(const Mesh &meshBuffer, const QString &meshName) override { - Q3DStudio::CString safeName = CFilePath::MakeSafeFileStem(meshName); + const QString &safeName = CFilePath::MakeSafeFileStem(meshName); return m_Import.AddOrReplaceMesh(meshBuffer, meshName, - m_Source.FindMeshFilePathByName(safeName.c_str())); + m_Source.FindMeshFilePathByName(safeName)); } - bool HasMesh(TCharPtr meshName) const override { return m_Import.HasMesh(meshName); } + bool HasMesh(const QString & meshName) const override { return m_Import.HasMesh(meshName); } - Option<TCharPtr> FindMeshReferencePathByName(TCharPtr meshName) const override + Option<QString> FindMeshReferencePathByName(const QString &meshName) const override { return m_Import.FindMeshReferencePathByName(meshName); } - Option<TCharPtr> FindMeshFilePathByName(TCharPtr meshName) const override + Option<QString> FindMeshFilePathByName(const QString &meshName) const override { return m_Import.FindMeshFilePathByName(meshName); } - +#if RUNTIME_SPLIT_TEMPORARILY_REMOVED QT3DSU32 GetNumPathBuffers() const override { return m_Import.GetNumPathBuffers(); } - QT3DSU32 GetPathBuffers(NVDataRef<Pair<TCharPtr, TCharPtr>> pathBufferPaths) const override + QT3DSU32 GetPathBuffers(QVector<std::pair<QString, QString>> pathBufferPaths) const override { return m_Import.GetPathBuffers(pathBufferPaths); } // Copies the an appropriate location in our import directory // Returns the path of the added PathBuffer. This may mangle the name slightly // In case of a conflict. - CharPtrOrError AddPathBuffer(const SPathBuffer &pathBuffer, TCharPtr pathName) override + QStringOrError AddPathBuffer(const SPathBuffer &pathBuffer, QString pathName) override { - Option<TCharPtr> added = m_Source.FindPathBufferByPath(pathName); + Option<QString> added = m_Source.FindPathBufferByPath(pathName); return m_Import.AddOrReplacePathBuffer(pathBuffer, pathName, added); } - Option<TCharPtr> FindPathBufferByPath(TCharPtr pathBufferPath) const override + Option<QString> FindPathBufferByPath(QString pathBufferPath) const override { return m_Import.FindPathBufferByPath(pathBufferPath); } - Option<TCharPtr> FindPathBufferByRelativePath(TCharPtr pathBufferPath) const override + Option<QString> FindPathBufferByRelativePath(QString pathBufferPath) const override { return m_Import.FindPathBufferByRelativePath(pathBufferPath); } - +#endif QT3DSU32 GetNumAnimations() const override { return m_Import.GetNumAnimations(); } - QT3DSU32 GetAnimations(NVDataRef<Animation> outBuffers) const override + QT3DSU32 GetAnimations(QVector<Animation> &outBuffers) const override { return m_Import.GetAnimations(outBuffers); } // Data is copied into this object, you can release the anim buffer data after this - void DoAddAnimation(TCharPtr instance, TCharPtr propName, QT3DSU32 subPropIndex, - EAnimationType type, NVConstDataRef<QT3DSF32> values) override + void DoAddAnimation(const QString &instance, const QString &propName, QT3DSU32 subPropIndex, + EAnimationType type, const QVector<QT3DSF32> &values) override { m_Import.DoAddAnimation(instance, propName, subPropIndex, type, values); } - Option<Animation> FindAnimation(TCharPtr instance, TCharPtr propName, + Option<Animation> FindAnimation(const QString &instance, const QString &propName, QT3DSU32 subPropIndex) const override { return m_Import.FindAnimation(instance, propName, subPropIndex); } - template <typename TDataType> - NVDataRef<TDataType> TempAlloc(QT3DSU32 numItems) const - { - m_TempBuffer.reserve(numItems * sizeof(TDataType)); - return toDataRef((TDataType *)m_TempBuffer.begin(), numItems); - } - template <typename TDataType, typename TDiffOp> void CompileItemReport(AddRemoveImpl<TDataType> &result, TDiffOp op) const { QT3DSU32 numItems = op.NumItems(m_Import); - NVDataRef<TDataType> tempData(TempAlloc<TDataType>(numItems)); + QVector<TDataType> tempData(numItems); op.GetItems(m_Import, tempData); QT3DSIMP_FOREACH(idx, numItems) { @@ -1785,7 +1731,7 @@ public: result.m_Added.push_back(newDesc); } numItems = op.NumItems(m_Source); - tempData = TempAlloc<TDataType>(numItems); + tempData.resize(numItems); op.GetItems(m_Source, tempData); QT3DSIMP_FOREACH(idx, numItems) { @@ -1795,6 +1741,14 @@ public: } } + QVector<InstanceDesc> toVector(const InstanceDesc *data, QT3DSU32 count) + { + QVector<InstanceDesc> ret(count); + for (int i = 0; i < count; ++i) + ret[i] = data[i]; + return ret; + } + ImportReport CompileReport() const override { m_ImportReport.clear(); @@ -1802,7 +1756,9 @@ public: CompileItemReport(m_ImportReport.m_Instances, InstanceDiffOp()); CompileItemReport(m_ImportReport.m_Images, ImageDiffOp()); CompileItemReport(m_ImportReport.m_Meshes, MeshDiffOp()); +#if RUNTIME_SPLIT_TEMPORARILY_REMOVED CompileItemReport(m_ImportReport.m_PathBuffers, PathBufferDiffOp()); +#endif CompileItemReport(m_ImportReport.m_Animations, AnimationDiffOp()); // OK, prepare parent child links @@ -1811,29 +1767,29 @@ public: { const InstanceDesc &oldDesc(m_ImportReport.m_Instances.m_Removed[idx]); QT3DSU32 numChildren = m_Source.GetNumChildren(oldDesc.m_Handle); - NVDataRef<InstanceDesc> tempData(TempAlloc<InstanceDesc>(numChildren)); + QVector<InstanceDesc> tempData(numChildren); m_Source.GetChildren(oldDesc.m_Handle, tempData); QT3DSIMP_FOREACH(chld, numChildren) m_ImportReport.m_Links.m_Removed.push_back( - ParentChildLink(oldDesc.m_Id, tempData[chld].m_Id, L"")); + ParentChildLink(oldDesc.m_Id, tempData[chld].m_Id, QString())); } QT3DSIMP_FOREACH(idx, m_ImportReport.m_Instances.m_Added.size()) { const InstanceDesc &newDesc(m_ImportReport.m_Instances.m_Added[idx]); QT3DSU32 numChildren = GetNumChildren(newDesc.m_Handle); - NVDataRef<InstanceDesc> tempData(TempAlloc<InstanceDesc>(numChildren)); + QVector<InstanceDesc> tempData(numChildren); m_Import.GetChildren(newDesc.m_Handle, tempData); QT3DSIMP_FOREACH(chldIdx, numChildren) { // Run through children in reverse order // so that we know the sibling pointer is good. QT3DSU32 chld = numChildren - chldIdx - 1; - TCharPtr child = tempData[chld].m_Id; + QString child = tempData[chld].m_Id; // If the chlid existed in the original, then it also needs to be added here. // Because that means the a new object was added and an original object was // re-attached. if (m_Source.FindInstanceById(child).hasValue()) { - TCharPtr sibling = chld + 1 < numChildren ? tempData[chld + 1].m_Id : L""; + QString sibling = chld + 1 < numChildren ? tempData[chld + 1].m_Id : QString(); m_ImportReport.m_Links.m_Added.push_back( ParentChildLink(newDesc.m_Id, child, sibling)); } @@ -1845,10 +1801,8 @@ public: const InstanceDesc &oldDesc(m_Source.FindInstanceById(newDesc.m_Id)); QT3DSU32 numNewChildren(GetNumChildren(newDesc.m_Handle)); QT3DSU32 numOldChildren(m_Source.GetNumChildren(oldDesc.m_Handle)); - NVDataRef<InstanceDesc> tempData( - TempAlloc<InstanceDesc>(numNewChildren + numOldChildren)); - NVDataRef<InstanceDesc> newChildren(tempData.begin(), numNewChildren); - NVDataRef<InstanceDesc> oldChildren(tempData.begin() + numNewChildren, numOldChildren); + QVector<InstanceDesc> newChildren(numNewChildren); + QVector<InstanceDesc> oldChildren(numOldChildren); m_Import.GetChildren(newDesc.m_Handle, newChildren); m_Source.GetChildren(oldDesc.m_Handle, oldChildren); QT3DSIMP_FOREACH(childIdx, numNewChildren) @@ -1857,7 +1811,8 @@ public: // This is necessary for addChild. QT3DSU32 child = numNewChildren - childIdx - 1; const InstanceDesc &childDesc = newChildren[child]; - TCharPtr sibling = child + 1 < numNewChildren ? newChildren[child + 1].m_Id : L""; + QString sibling = child + 1 < numNewChildren + ? newChildren[child + 1].m_Id : QString(); ParentChildLink link(newDesc.m_Id, childDesc.m_Id, sibling); if (FindChild(m_Source.FindInstanceById(childDesc.m_Id), sibling, childDesc.m_Type, oldChildren)) @@ -1868,13 +1823,13 @@ public: QT3DSIMP_FOREACH(child, oldChildren.size()) { const InstanceDesc &childDesc = oldChildren[child]; - TCharPtr sibling = - child + 1 < oldChildren.size() ? oldChildren[child + 1].m_Id : L""; + QString sibling = + child + 1 < oldChildren.size() ? oldChildren[child + 1].m_Id : QString(); if (FindChild(m_Import.FindInstanceById(childDesc.m_Id), sibling, childDesc.m_Type, newChildren) == false) m_ImportReport.m_Links.m_Removed.push_back( - ParentChildLink(oldDesc.m_Id, childDesc.m_Id, L"")); + ParentChildLink(oldDesc.m_Id, childDesc.m_Id, QString())); } } m_Import.FinalizeReport(); @@ -1889,60 +1844,55 @@ public: ImportPtrOrError Import::Create(const QString &_srcPath, const QString &_destDir) { -#ifdef RUNTIME_SPLIT_TEMPORARILY_REMOVED - CFilePath srcPath(CFilePath::GetAbsolutePath(_srcPath)); - CFilePath destDir(CFilePath::GetAbsolutePath(_destDir)); + QString srcPath(QFileInfo(_srcPath).absoluteFilePath()); + QString destDir(QFileInfo(_destDir).absoluteFilePath()); - if (!srcPath.IsFile()) - return ImportErrorData(ImportErrorCodes::SourceFileDoesNotExist, srcPath.toCString()); + if (!QFileInfo(_srcPath).isFile()) + return ImportErrorData(ImportErrorCodes::SourceFileDoesNotExist, srcPath); - if (!destDir.CreateDir(true)) - return ImportErrorData(ImportErrorCodes::UnableToCreateDirectory, destDir.toCString()); + if (!CFilePath::CreateDir(destDir, true)) + return ImportErrorData(ImportErrorCodes::UnableToCreateDirectory, destDir); TStringTablePtr strTable = qt3dsdm::IStringTable::CreateStringTable(); - return new ImportImpl(strTable, srcPath, destDir, L"maps", L"meshes"); -#endif - return ImportErrorData(); + return new ImportImpl(strTable, srcPath, destDir, QStringLiteral("maps"), + QStringLiteral("meshes")); } ImportPtrOrError Import::Load(const QString &pathToFile, QT3DSU32 inImportVersion) { -#ifdef RUNTIME_SPLIT_TEMPORARILY_REMOVED - CFilePath fullFilePath(CFilePath::GetAbsolutePath(pathToFile)); - CFilePath destDir(fullFilePath.GetDirectory()); + QFileInfo info(pathToFile); + QString fullFilePath(info.absoluteFilePath()); + QString destDir(info.canonicalPath()); - if (fullFilePath.IsFile() == false) - return ImportErrorData(ImportErrorCodes::SourceFileNotReadable, fullFilePath.toCString()); + if (info.isFile() == false) + return ImportErrorData(ImportErrorCodes::SourceFileNotReadable, fullFilePath); TStringTablePtr strTable = qt3dsdm::IStringTable::CreateStringTable(); - ImportImpl *impl = new ImportImpl(strTable, Q3DStudio::CString(), destDir); + ImportImpl *impl = new ImportImpl(strTable, QString(), destDir); bool success = impl->Load(fullFilePath, inImportVersion); QT3DS_ASSERT(success); if (success == false) { impl->Release(); - return ImportErrorData(ImportErrorCodes::SourceFileNotReadable, fullFilePath.toCString()); + return ImportErrorData(ImportErrorCodes::SourceFileNotReadable, fullFilePath); } return impl; -#endif - return ImportErrorData(); } -ImportPtrOrError Import::CreateForRefresh(Import &original, TCharPtr _srcPath) +ImportPtrOrError Import::CreateForRefresh(Import &original, const QString &_srcPath) { - CFilePath srcPath(CFilePath::GetAbsolutePath(_srcPath)); + QFileInfo srcPath(_srcPath); - if (!srcPath.IsFile()) { + if (!srcPath.isFile()) { original.Release(); - return ImportErrorData(ImportErrorCodes::SourceFileDoesNotExist, srcPath.toCString()); + return ImportErrorData(ImportErrorCodes::SourceFileDoesNotExist, _srcPath); } - RefreshImpl *refresh(new RefreshImpl(static_cast<ImportImpl &>(original), srcPath)); + RefreshImpl *refresh(new RefreshImpl(static_cast<ImportImpl &>(original), _srcPath)); return &refresh->GetImportInterface(); } QT3DSU32 Import::GetHighestImportRevision(const QString &pathToFile) { -#ifdef RUNTIME_SPLIT_TEMPORARILY_REMOVED using std::shared_ptr; CFilePath fullFilePath(CFilePath::GetAbsolutePath(pathToFile)); QFile stream(fullFilePath.toQString()); @@ -1956,7 +1906,7 @@ QT3DSU32 Import::GetHighestImportRevision(const QString &pathToFile) std::shared_ptr<IDOMFactory> theFactory = IDOMFactory::CreateDOMFactory(theStringTable); SDOMElement *theTopElement = CDOMSerializer::Read(*theFactory, stream); - if (theTopElement == NULL) { + if (theTopElement == nullptr) { QT3DS_ASSERT(false); return 0; } @@ -1964,6 +1914,4 @@ QT3DSU32 Import::GetHighestImportRevision(const QString &pathToFile) std::shared_ptr<IDOMReader> theReader = IDOMReader::CreateDOMReader(*theTopElement, theStringTable); return ImportImpl::FindHighestRevisionInDocument(*theReader); -#endif - return 0; } diff --git a/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImport.h b/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImport.h index 53d4d456..a845904e 100644 --- a/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImport.h +++ b/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImport.h @@ -42,13 +42,12 @@ typedef QT3DSU64 TIMPHandle; struct InstanceDesc { - TCharPtr m_Id; + QString m_Id; TIMPHandle m_Parent; TIMPHandle m_Handle; ComposerObjectTypes::Enum m_Type; InstanceDesc() - : m_Id(NULL) - , m_Parent(0) + : m_Parent(0) , m_Handle(0) , m_Type(ComposerObjectTypes::Unknown) { @@ -57,13 +56,13 @@ struct InstanceDesc struct Animation { - TCharPtr m_InstanceId; - TCharPtr m_PropertyName; + QString m_InstanceId; + QString m_PropertyName; QT3DSU32 m_SubPropertyIndex; EAnimationType m_Type; - NVConstDataRef<QT3DSF32> m_Keyframes; - Animation(TCharPtr iid, TCharPtr pname, QT3DSU32 subPropIndex, EAnimationType bufType, - NVConstDataRef<QT3DSF32> keyframes) + QVector<QT3DSF32> m_Keyframes; + Animation(const QString &iid, const QString &pname, QT3DSU32 subPropIndex, + EAnimationType bufType, const QVector<QT3DSF32> &keyframes) : m_InstanceId(iid) , m_PropertyName(pname) , m_SubPropertyIndex(subPropIndex) @@ -72,12 +71,23 @@ struct Animation { } Animation() - : m_InstanceId(L"") - , m_PropertyName(L"") - , m_SubPropertyIndex(0) + : m_SubPropertyIndex(0) , m_Type(EAnimationTypeNone) { } + Animation(const Animation &a) + : m_InstanceId(a.m_InstanceId) + , m_PropertyName(a.m_PropertyName) + , m_SubPropertyIndex(a.m_SubPropertyIndex) + , m_Type(a.m_Type) + , m_Keyframes(a.m_Keyframes) + { + } + Animation &operator=(const Animation *o) + { + *this = Animation(*o); + return *this; + } }; struct AddRemoveInfo @@ -101,11 +111,11 @@ struct AddRemoveInfo struct ParentChildLink { - TCharPtr m_Parent; - TCharPtr m_Child; - TCharPtr m_NextSibling; + QString m_Parent; + QString m_Child; + QString m_NextSibling; - ParentChildLink(TCharPtr p, TCharPtr c, TCharPtr ns) + ParentChildLink(const QString &p, const QString &c, const QString &ns) : m_Parent(p) , m_Child(c) , m_NextSibling(ns) @@ -114,8 +124,6 @@ struct ParentChildLink ParentChildLink() {} bool operator<(const ParentChildLink &other) const { - // This works because at this point id's are in the string table - // so equal strings are pointed to by the same pointer. return m_Parent < other.m_Parent; } }; @@ -123,12 +131,12 @@ struct ParentChildLink template <typename TDataType> struct AddRemoveData { - NVConstDataRef<TDataType> m_Existing; - NVConstDataRef<TDataType> m_Added; - NVConstDataRef<TDataType> m_Removed; + QVector<TDataType> m_Existing; + QVector<TDataType> m_Added; + QVector<TDataType> m_Removed; AddRemoveData() {} - AddRemoveData(NVConstDataRef<TDataType> exist, NVConstDataRef<TDataType> add, - NVConstDataRef<TDataType> rem) + AddRemoveData(const QVector<TDataType> &exist, const QVector<TDataType> &add, + const QVector<TDataType> &rem) : m_Existing(exist) , m_Added(add) , m_Removed(rem) @@ -155,16 +163,16 @@ struct ImportReport // to a different mesh instance). AddRemoveData<ParentChildLink> m_Links; - AddRemoveData<Pair<TCharPtr, TCharPtr>> m_Images; - AddRemoveData<Pair<TCharPtr, TCharPtr>> m_Meshes; - AddRemoveData<Pair<TCharPtr, TCharPtr>> m_PathBuffers; + AddRemoveData<std::pair<QString, QString>> m_Images; + AddRemoveData<std::pair<QString, QString>> m_Meshes; + AddRemoveData<std::pair<QString, QString>> m_PathBuffers; AddRemoveData<Animation> m_Animations; ImportReport() {} ImportReport(AddRemoveData<InstanceDesc> instances, AddRemoveData<ParentChildLink> links, - AddRemoveData<Pair<TCharPtr, TCharPtr>> imageBuffers, - AddRemoveData<Pair<TCharPtr, TCharPtr>> meshes, - AddRemoveData<Pair<TCharPtr, TCharPtr>> pathBuffers, + AddRemoveData<std::pair<QString, QString>> imageBuffers, + AddRemoveData<std::pair<QString, QString>> meshes, + AddRemoveData<std::pair<QString, QString>> pathBuffers, AddRemoveData<Animation> animBuffers) : m_Instances(instances) , m_Links(links) @@ -212,7 +220,7 @@ struct DatatypeOrError }; class Import; typedef DatatypeOrError<Import *> ImportPtrOrError; -typedef DatatypeOrError<TCharPtr> CharPtrOrError; +typedef DatatypeOrError<QString> QStringOrError; template <typename TDataType> struct SImportConverter @@ -245,7 +253,7 @@ public: // Cache this string in the string table and return // a representation that will be around until this import object // is destroyed. - virtual TCharPtr RegisterStr(TCharPtr data) = 0; + virtual QString RegisterStr(TCharPtr data) = 0; // Returns the source directory relative to the dest directory // or the full path if it is on a different drive virtual QString GetSrcFile() const = 0; @@ -256,32 +264,32 @@ public: // Returns the full path of the mesh directory virtual QString GetMeshDir() const = 0; // Returns the full path to the path buffer directory - virtual QString GetPathBufferDir() const = 0; + //virtual QString GetPathBufferDir() const = 0; virtual void Release() = 0; // returns false if fname couldn't be opened for write // Fname is appended to the directory this object was created with. // This is necessary in order to keep relative paths valid within // the import file. Returns an ID that uniquely identifies this import // object within the final document. - virtual QT3DSU32 Save(TCharPtr fname) const = 0; + virtual QT3DSU32 Save(const QString &fname) const = 0; // Add a mapping from an named id to a handle virtual Option<InstanceDesc> GetInstanceByHandle(TIMPHandle inst) const = 0; - virtual Option<InstanceDesc> FindInstanceById(TCharPtr inst) const = 0; - virtual Option<InstanceDesc> FindAnyInstanceById(TCharPtr inst) const = 0; + virtual Option<InstanceDesc> FindInstanceById(const QString &inst) const = 0; + virtual Option<InstanceDesc> FindAnyInstanceById(const QString &inst) const = 0; virtual QT3DSU32 GetNumInstances() const = 0; - virtual QT3DSU32 GetInstances(NVDataRef<InstanceDesc> outDescs) const = 0; + virtual QT3DSU32 GetInstances(QVector<InstanceDesc> &outDescs) const = 0; virtual QT3DSU32 GetNumProperties(TIMPHandle instance) const = 0; - virtual QT3DSU32 GetProperties(TIMPHandle inst, NVDataRef<PropertyValue> outBuffer) const = 0; + virtual QT3DSU32 GetProperties(TIMPHandle inst, QVector<PropertyValue> &outBuffer) const = 0; virtual Option<SValue> GetInstancePropertyValue(TIMPHandle inst, ComposerPropertyNames::Enum val) const = 0; virtual QT3DSU32 GetNumChildren(TIMPHandle instance) const = 0; - virtual QT3DSU32 GetChildren(TIMPHandle instance, NVDataRef<InstanceDesc> childBuffer) const = 0; + virtual QT3DSU32 GetChildren(TIMPHandle instance, QVector<InstanceDesc> &childBuffer) const = 0; // Invalid instances will not be saved out to the import file and should be ignored // in the import report. virtual void MarkInstanceInvalid(TIMPHandle inst) = 0; - virtual TIMPHandle CreateInstance(TCharPtr id, ComposerObjectTypes::Enum inType) = 0; + virtual TIMPHandle CreateInstance(const QString &id, ComposerObjectTypes::Enum inType) = 0; // The new instance ends up attached to the same parent // and just after inSource in the parent's children lists. // This performs a deep copy and fixes up references if they occur in the @@ -290,7 +298,7 @@ public: // Returns true if inst exists, false otherwise. - virtual bool SetInstanceProperties(TIMPHandle inst, NVConstDataRef<PropertyValue> inBuffer) = 0; + virtual bool SetInstanceProperties(TIMPHandle inst, const QVector<PropertyValue> &inBuffer) = 0; template <typename TPropertyType, typename TDataType> void SetInstancePropertyValue(TIMPHandle inst, @@ -301,11 +309,19 @@ public: SImportConverter<TPropertyType>().Convert(val)); } + template <typename TPropertyType> + void SetInstancePropertyValue(TIMPHandle inst, + const SImportPropertyDefinition<TPropertyType> &inProperty, + const QString &val) + { + DoSetInstancePropertyValue(inst, inProperty.m_Name, val); + } + virtual bool AddChild(TIMPHandle inst, TIMPHandle child) = 0; virtual QT3DSU32 GetNumImages() const = 0; // Returns imgOriginalPath,imgDestPath pair - virtual QT3DSU32 GetImages(NVDataRef<Pair<TCharPtr, TCharPtr>> imgPaths) const = 0; + virtual QT3DSU32 GetImages(QVector<std::pair<QString, QString>> &imgPaths) const = 0; // Copies the an appropriate location in our import directory // Returns the path of the added image. This may mangle the name slightly // In case of a conflict. @@ -316,15 +332,15 @@ public: // This path is relative to the current working directory when this object was created // or absolute. // Returns a relative path, from dest directory, where the image was saved out to. - virtual CharPtrOrError AddImage(TCharPtr imgPath) = 0; + virtual QStringOrError AddImage(const QString &imgPath) = 0; // Assuming this image path is relative to the current working directory, find the image - virtual Option<TCharPtr> FindImageByPath(TCharPtr imgPath) const = 0; + virtual Option<QString> FindImageByPath(const QString &imgPath) const = 0; // Assuming this path is relative to the import source document, find the image. - virtual Option<TCharPtr> FindImageByRelativePath(TCharPtr imgPath) const = 0; + virtual Option<QString> FindImageByRelativePath(const QString &imgPath) const = 0; virtual QT3DSU32 GetNumMeshes() const = 0; // Returns meshName,meshDestPath pair - virtual QT3DSU32 GetMeshes(NVDataRef<Pair<TCharPtr, TCharPtr>> bufferPaths) const = 0; + virtual QT3DSU32 GetMeshes(QVector<std::pair<QString, QString>> &bufferPaths) const = 0; // Copies the vertex buffer into the appropriate location, renaming if necessary. // Mesh name is used to write out a reasonable buffer *and* on refresh to know @@ -335,29 +351,30 @@ public: // be stuck with a half-updated dataset. // Returns a relative path, from the mesh directory, where the mesh was saved out // to. - virtual CharPtrOrError AddMesh(const Mesh &meshBuffer, TCharPtr meshName) = 0; - virtual bool HasMesh(TCharPtr meshName) const = 0; + virtual QStringOrError AddMesh(const Mesh &meshBuffer, const QString &meshName) = 0; + virtual bool HasMesh(const QString &meshName) const = 0; // Return the mesh path with the current version number - virtual Option<TCharPtr> FindMeshReferencePathByName(TCharPtr meshName) const = 0; - virtual Option<TCharPtr> FindMeshFilePathByName(TCharPtr meshName) const = 0; - + virtual Option<QString> FindMeshReferencePathByName(const QString &meshName) const = 0; + virtual Option<QString> FindMeshFilePathByName(const QString &meshName) const = 0; +#if RUNTIME_SPLIT_TEMPORARILY_REMOVED virtual QT3DSU32 GetNumPathBuffers() const = 0; // Returns imgOriginalPath,imgDestPath pair - virtual QT3DSU32 GetPathBuffers(NVDataRef<Pair<TCharPtr, TCharPtr>> pathBufferPaths) const = 0; - virtual CharPtrOrError AddPathBuffer(const SPathBuffer &pathBuffer, TCharPtr pathName) = 0; + virtual QT3DSU32 GetPathBuffers(QVector<std::pair<QString, QString>> pathBufferPaths) const = 0; + virtual QStringOrError AddPathBuffer(const SPathBuffer &pathBuffer, QString pathName) = 0; // Assuming this Path path is relative to the current working directory, find the Path - virtual Option<TCharPtr> FindPathBufferByPath(TCharPtr pathBufferPath) const = 0; + virtual Option<QString> FindPathBufferByPath(QString pathBufferPath) const = 0; // Assuming this path is relative to the import source document, find the Path. - virtual Option<TCharPtr> FindPathBufferByRelativePath(TCharPtr pathBufferPath) const = 0; - + virtual Option<QString> FindPathBufferByRelativePath(QString pathBufferPath) const = 0; +#endif virtual QT3DSU32 GetNumAnimations() const = 0; - virtual QT3DSU32 GetAnimations(NVDataRef<Animation> outBuffers) const = 0; + virtual QT3DSU32 GetAnimations(QVector<Animation> &outBuffers) const = 0; // Data is copied into this object, you can release the anim buffer data after this - virtual Option<Animation> FindAnimation(TCharPtr instance, TCharPtr propName, + virtual Option<Animation> FindAnimation(const QString &instance, const QString &propName, QT3DSU32 subPropIndex) const = 0; template <typename TDataType> - void AddAnimation(TCharPtr instance, const SImportPropertyDefinition<TDataType> &inProperty, - QT3DSU32 subPropIndex, EAnimationType type, NVConstDataRef<QT3DSF32> values) + void AddAnimation(const QString &instance, + const SImportPropertyDefinition<TDataType> &inProperty, + QT3DSU32 subPropIndex, EAnimationType type,const QVector<QT3DSF32> &values) { std::tuple<bool, size_t> isAnimatableAndArity( GetDatatypeAnimatableAndArity(TypeToDataType<TDataType>())); @@ -379,12 +396,13 @@ public: protected: // Careful with this. If the property value contains heap memory // Then this may crash if you are coming from a dll. - virtual void DoAddAnimation(TCharPtr instance, TCharPtr propName, QT3DSU32 subPropIndex, - EAnimationType type, NVConstDataRef<QT3DSF32> values) = 0; + virtual void DoAddAnimation(const QString &instance, const QString &propName, + QT3DSU32 subPropIndex, + EAnimationType type, const QVector<QT3DSF32> &values) = 0; virtual bool DoSetInstancePropertyValue(TIMPHandle inst, ComposerPropertyNames::Enum pname, const TImportModelValue &val) = 0; virtual bool DoSetInstancePropertyValue(TIMPHandle inst, ComposerPropertyNames::Enum pname, - TCharPtr val) = 0; + const QString &val) = 0; public: // Create blank import object @@ -409,7 +427,7 @@ public: // We use relative paths throughout the system so that image src paths are relative // to the src document directory and such, so we can still import sanely. // Dest directory is set to where original's dest directory was set to. - static ImportPtrOrError CreateForRefresh(Import &original, TCharPtr srcFile); + static ImportPtrOrError CreateForRefresh(Import &original, const QString &srcFile); // Return the highest import version in a given document. Returns zero upon // failure, else an integer that is valid for load. diff --git a/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImportComposerTypes.cpp b/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImportComposerTypes.cpp index 5012f36f..1c6d9f30 100644 --- a/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImportComposerTypes.cpp +++ b/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImportComposerTypes.cpp @@ -32,7 +32,7 @@ using namespace qt3dsimp; #define HANDLE_COMPOSER_PROPERTY_NO_DEFAULT(name, memberName, dtype) \ - if (AreEqual(inPropertyName, L"" #name)) \ + if (inPropertyName == QLatin1String(#name)) \ return TypeToDataType<dtype>(); #define HANDLE_COMPOSER_PROPERTY(name, memberName, dtype, defaultValue) \ @@ -41,7 +41,7 @@ using namespace qt3dsimp; #define HANDLE_COMPOSER_PROPERTY_DUPLICATE(name, memberName, dtype, defaultValue) \ HANDLE_COMPOSER_PROPERTY(name, memberName, dtype, defaultValue) -DataModelDataType::Value SImportAsset::GetPropertyDataType(const wchar_t *inPropertyName) +DataModelDataType::Value SImportAsset::GetPropertyDataType(const QString &inPropertyName) { ITERATE_COMPOSER_NAMED_PROPERTIES ITERATE_COMPOSER_ASSET_PROPERTIES @@ -50,43 +50,43 @@ DataModelDataType::Value SImportAsset::GetPropertyDataType(const wchar_t *inProp return DataModelDataType::None; } -DataModelDataType::Value SImportNode::GetPropertyDataType(const wchar_t *inPropertyName) +DataModelDataType::Value SImportNode::GetPropertyDataType(const QString &inPropertyName) { ITERATE_COMPOSER_NODE_PROPERTIES return SImportAsset::GetPropertyDataType(inPropertyName); } -DataModelDataType::Value SImportModel::GetPropertyDataType(const wchar_t *inPropertyName) +DataModelDataType::Value SImportModel::GetPropertyDataType(const QString &inPropertyName) { ITERATE_COMPOSER_MODEL_PROPERTIES return SImportNode::GetPropertyDataType(inPropertyName); } -DataModelDataType::Value SImportMaterial::GetPropertyDataType(const wchar_t *inPropertyName) +DataModelDataType::Value SImportMaterial::GetPropertyDataType(const QString &inPropertyName) { ITERATE_COMPOSER_MATERIAL_PROPERTIES return SImportAsset::GetPropertyDataType(inPropertyName); } -DataModelDataType::Value SImportImage::GetPropertyDataType(const wchar_t *inPropertyName) +DataModelDataType::Value SImportImage::GetPropertyDataType(const QString &inPropertyName) { ITERATE_COMPOSER_IMAGE_PROPERTIES return SImportAsset::GetPropertyDataType(inPropertyName); } -DataModelDataType::Value SImportPath::GetPropertyDataType(const wchar_t *inPropertyName) +DataModelDataType::Value SImportPath::GetPropertyDataType(const QString &inPropertyName) { ITERATE_COMPOSER_PATH_PROPERTIES return SImportNode::GetPropertyDataType(inPropertyName); } -DataModelDataType::Value SImportSubPath::GetPropertyDataType(const wchar_t *inPropertyName) +DataModelDataType::Value SImportSubPath::GetPropertyDataType(const QString &inPropertyName) { ITERATE_COMPOSER_PATH_SUBPATH_PROPERTIES return SImportAsset::GetPropertyDataType(inPropertyName); } -DataModelDataType::Value SImportPathAnchorPoint::GetPropertyDataType(const wchar_t *inPropertyName) +DataModelDataType::Value SImportPathAnchorPoint::GetPropertyDataType(const QString &inPropertyName) { ITERATE_COMPOSER_PATH_ANCHOR_POINT_PROPERTIES return SImportAsset::GetPropertyDataType(inPropertyName); @@ -106,57 +106,6 @@ DataModelDataType::Value SImportPathAnchorPoint::GetPropertyDataType(const wchar #define HANDLE_COMPOSER_PROPERTY_DUPLICATE(name, memberName, dtype, defaultValue) \ HANDLE_COMPOSER_PROPERTY(name, memberName, dtype, defaultValue) -DataModelDataType::Value SImportAsset::GetPropertyDataType(const char8_t *inPropertyName) -{ - ITERATE_COMPOSER_NAMED_PROPERTIES - ITERATE_COMPOSER_ASSET_PROPERTIES - - QT3DS_ASSERT(false); - return DataModelDataType::None; -} - -DataModelDataType::Value SImportNode::GetPropertyDataType(const char8_t *inPropertyName) -{ - ITERATE_COMPOSER_NODE_PROPERTIES - return SImportAsset::GetPropertyDataType(inPropertyName); -} - -DataModelDataType::Value SImportModel::GetPropertyDataType(const char8_t *inPropertyName) -{ - ITERATE_COMPOSER_MODEL_PROPERTIES - return SImportNode::GetPropertyDataType(inPropertyName); -} - -DataModelDataType::Value SImportMaterial::GetPropertyDataType(const char8_t *inPropertyName) -{ - ITERATE_COMPOSER_MATERIAL_PROPERTIES - return SImportAsset::GetPropertyDataType(inPropertyName); -} - -DataModelDataType::Value SImportImage::GetPropertyDataType(const char8_t *inPropertyName) -{ - ITERATE_COMPOSER_IMAGE_PROPERTIES - return SImportAsset::GetPropertyDataType(inPropertyName); -} - -DataModelDataType::Value SImportPath::GetPropertyDataType(const char8_t *inPropertyName) -{ - ITERATE_COMPOSER_PATH_PROPERTIES - return SImportNode::GetPropertyDataType(inPropertyName); -} - -DataModelDataType::Value SImportSubPath::GetPropertyDataType(const char8_t *inPropertyName) -{ - ITERATE_COMPOSER_PATH_SUBPATH_PROPERTIES - return SImportAsset::GetPropertyDataType(inPropertyName); -} - -DataModelDataType::Value SImportPathAnchorPoint::GetPropertyDataType(const char8_t *inPropertyName) -{ - ITERATE_COMPOSER_PATH_ANCHOR_POINT_PROPERTIES - return SImportAsset::GetPropertyDataType(inPropertyName); -} - #undef HANDLE_COMPOSER_PROPERTY_NO_DEFAULT #undef HANDLE_COMPOSER_PROPERTY #undef HANDLE_COMPOSER_PROPERTY_DUPLICATE diff --git a/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImportComposerTypes.h b/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImportComposerTypes.h index 8cb805a3..52b4024c 100644 --- a/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImportComposerTypes.h +++ b/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImportComposerTypes.h @@ -69,17 +69,15 @@ struct SImportAsset { ITERATE_COMPOSER_NAMED_PROPERTIES ITERATE_COMPOSER_ASSET_PROPERTIES - virtual DataModelDataType::Value GetPropertyDataType(const wchar_t *inPropertyName); - virtual DataModelDataType::Value GetPropertyDataType(const char8_t *inPropertyName); + virtual DataModelDataType::Value GetPropertyDataType(const QString &inPropertyName); virtual ComposerObjectTypes::Enum GetObjectType() { return ComposerObjectTypes::Asset; } - const wchar_t *GetObjectName() { return ComposerObjectTypes::Convert(GetObjectType()); } + QString GetObjectName() { return ComposerObjectTypes::Convert(GetObjectType()); } }; struct SImportNode : public SImportAsset { ITERATE_COMPOSER_NODE_PROPERTIES - DataModelDataType::Value GetPropertyDataType(const wchar_t *inPropertyName) override; - DataModelDataType::Value GetPropertyDataType(const char8_t *inPropertyName) override; + DataModelDataType::Value GetPropertyDataType(const QString &inPropertyName) override; ComposerObjectTypes::Enum GetObjectType() override { return ComposerObjectTypes::Node; } }; @@ -91,48 +89,42 @@ struct SImportGroup : public SImportNode struct SImportModel : public SImportNode { ITERATE_COMPOSER_MODEL_PROPERTIES - DataModelDataType::Value GetPropertyDataType(const wchar_t *inPropertyName) override; - DataModelDataType::Value GetPropertyDataType(const char8_t *inPropertyName) override; + DataModelDataType::Value GetPropertyDataType(const QString &inPropertyName) override; ComposerObjectTypes::Enum GetObjectType() override { return ComposerObjectTypes::Model; } }; struct SImportMaterial : public SImportAsset { ITERATE_COMPOSER_MATERIAL_PROPERTIES - DataModelDataType::Value GetPropertyDataType(const wchar_t *inPropertyName) override; - DataModelDataType::Value GetPropertyDataType(const char8_t *inPropertyName) override; + DataModelDataType::Value GetPropertyDataType(const QString &inPropertyName) override; ComposerObjectTypes::Enum GetObjectType() override { return ComposerObjectTypes::Material; } }; struct SImportImage : public SImportAsset { ITERATE_COMPOSER_IMAGE_PROPERTIES - DataModelDataType::Value GetPropertyDataType(const wchar_t *inPropertyName) override; - DataModelDataType::Value GetPropertyDataType(const char8_t *inPropertyName) override; + DataModelDataType::Value GetPropertyDataType(const QString &inPropertyName) override; ComposerObjectTypes::Enum GetObjectType() override { return ComposerObjectTypes::Image; } }; struct SImportPath : public SImportNode { ITERATE_COMPOSER_PATH_PROPERTIES - DataModelDataType::Value GetPropertyDataType(const wchar_t *inPropertyName) override; - DataModelDataType::Value GetPropertyDataType(const char8_t *inPropertyName) override; + DataModelDataType::Value GetPropertyDataType(const QString &inPropertyName) override; ComposerObjectTypes::Enum GetObjectType() override { return ComposerObjectTypes::Path; } }; struct SImportSubPath : public SImportAsset { ITERATE_COMPOSER_PATH_SUBPATH_PROPERTIES - DataModelDataType::Value GetPropertyDataType(const wchar_t *inPropertyName) override; - DataModelDataType::Value GetPropertyDataType(const char8_t *inPropertyName) override; + DataModelDataType::Value GetPropertyDataType(const QString &inPropertyName) override; ComposerObjectTypes::Enum GetObjectType() override { return ComposerObjectTypes::SubPath; } }; struct SImportPathAnchorPoint : public SImportAsset { ITERATE_COMPOSER_PATH_ANCHOR_POINT_PROPERTIES - DataModelDataType::Value GetPropertyDataType(const wchar_t *inPropertyName) override; - DataModelDataType::Value GetPropertyDataType(const char8_t *inPropertyName) override; + DataModelDataType::Value GetPropertyDataType(const QString &inPropertyName) override; ComposerObjectTypes::Enum GetObjectType() override { return ComposerObjectTypes::PathAnchorPoint; diff --git a/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImportContainers.h b/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImportContainers.h index 2f2a72ee..eaf09492 100644 --- a/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImportContainers.h +++ b/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImportContainers.h @@ -41,41 +41,6 @@ namespace qt3dsimp { #define QT3DSIMP_FOREACH(idxnm, val) \ for (QT3DSU32 idxnm = 0, __numItems = (QT3DSU32)val; idxnm < __numItems; ++idxnm) -template <typename TKey, typename TValue, typename THash = eastl::hash<TKey>, - typename TPredicate = eastl::equal_to<TKey>> -struct ImportHashMap : public eastl::hash_map<TKey, TValue, THash, TPredicate> -{ - using base_type = eastl::hash_map<TKey, TValue, THash, TPredicate>; - - ImportHashMap() {} - - - - bool contains(const TKey &key) const { return find(key) != base_type::end(); } -}; -template <typename TKey> -struct ImportHashSet : public eastl::hash_set<TKey, eastl::hash<TKey>, eastl::equal_to<TKey>> -{ - using base_type = eastl::hash_set<TKey, eastl::hash<TKey>, eastl::equal_to<TKey>>; - ImportHashSet() {} - bool contains(const TKey &key) const { return base_type::find(key) != base_type::end(); } -}; -template <typename TValue> -struct ImportArray : public eastl::vector<TValue> -{ - using base_type = eastl::vector<TValue>; - - ImportArray() {} - operator NVConstDataRef<TValue>() const - { - return NVConstDataRef<TValue>(base_type::data(), (QT3DSU32) base_type::size()); - } - - operator NVDataRef<TValue>() { - return NVDataRef<TValue>(base_type::data(), (QT3DSU32) base_type::size()); - } -}; - inline NVConstDataRef<wchar_t> toRef(const wchar_t *data, QT3DSU32 len = 0) { if (IsTrivial(data)) diff --git a/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImportImpl.h b/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImportImpl.h index 53643650..f2810a8b 100644 --- a/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImportImpl.h +++ b/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImportImpl.h @@ -59,8 +59,8 @@ inline Instance *fromHdl(TIMPHandle hdl) struct Instance : public InstanceDesc { - ImportHashMap<ComposerPropertyNames::Enum, SInternValue> m_PropertyValues; - eastl::vector<TCharPtr> m_Children; + QHash<ComposerPropertyNames::Enum, SInternValue> m_PropertyValues; + QStringList m_Children; bool m_Valid; public: @@ -79,7 +79,8 @@ public: { m_PropertyValues[name] = val; } - void SetPropertyValues(NVConstDataRef<PropertyValue> values, qt3dsdm::IStringTable &inStringTable) + void SetPropertyValues(const QVector<PropertyValue> &values, + qt3dsdm::IStringTable &inStringTable) { m_PropertyValues.clear(); QT3DSIMP_FOREACH(idx, values.size()) @@ -113,7 +114,7 @@ public: } QT3DS_ASSERT(child->m_Parent == 0); child->m_Parent = toHdl(this); - eastl::vector<TCharPtr>::iterator theIter = + QStringList::iterator theIter = std::find(m_Children.begin(), m_Children.end(), inInsertAfter->m_Id); if (theIter != m_Children.end()) ++theIter; @@ -125,9 +126,9 @@ public: struct AnimationId { TIMPHandle m_Instance; - TCharPtr m_Property; + QString m_Property; QT3DSU32 m_SubPropIndex; - AnimationId(TIMPHandle inst, TCharPtr p, QT3DSU32 spi) + AnimationId(TIMPHandle inst, const QString &p, QT3DSU32 spi) : m_Instance(inst) , m_Property(p) , m_SubPropIndex(spi) @@ -135,23 +136,21 @@ struct AnimationId } AnimationId() : m_Instance(0) - , m_Property(0) , m_SubPropIndex(0) { } + AnimationId(const AnimationId &o) + : m_Instance(o.m_Instance) + , m_Property(o.m_Property) + , m_SubPropIndex(o.m_SubPropIndex) + { + } }; -inline Animation *CreateAnimation(TCharPtr instance, TCharPtr propName, QT3DSU32 spi, - EAnimationType bufType, NVConstDataRef<QT3DSF32> values) +inline Animation *CreateAnimation(const QString &instance, const QString &propName, QT3DSU32 spi, + EAnimationType bufType, const QVector<QT3DSF32> &values) { - QT3DSU32 animBufSize = sizeof(Animation); - QT3DSU32 valueSize = values.size() * sizeof(QT3DSF32); - QT3DSU8 *memBuf = (QT3DSU8 *)malloc(animBufSize + valueSize); - QT3DSF32 *framePtr = (QT3DSF32 *)(memBuf + animBufSize); - memCopy(framePtr, values.begin(), valueSize); - values = toConstDataRef(framePtr, values.size()); - Animation *newBuf = new (memBuf) Animation(instance, propName, spi, bufType, values); - return newBuf; + return new Animation(instance, propName, spi, bufType, values); } } diff --git a/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImportLibPrecompile.h b/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImportLibPrecompile.h index 34da79d0..4acb2d64 100644 --- a/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImportLibPrecompile.h +++ b/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImportLibPrecompile.h @@ -43,7 +43,6 @@ #include <fstream> #include "Qt3DSDMDataTypes.h" #include "foundation/Qt3DSIntrinsics.h" -#include "foundation/Qt3DSBasicTemplates.h" namespace qt3dsimp { using namespace qt3ds; diff --git a/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImportMeshBuilder.cpp b/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImportMeshBuilder.cpp index 976fc29b..9906c0ed 100644 --- a/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImportMeshBuilder.cpp +++ b/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImportMeshBuilder.cpp @@ -54,7 +54,7 @@ NVConstDataRef<TDataType> toRefBuf(QT3DSU8 *bufData, QT3DSU32 off, QT3DSU32 size struct DynamicVBuf { QT3DSU32 m_Stride; - ImportArray<NVRenderVertexBufferEntry> m_VertexBufferEntries; + QVector<NVRenderVertexBufferEntry> m_VertexBufferEntries; MemoryBuffer<RawAllocator> m_VertexData; void clear() @@ -104,13 +104,13 @@ class MeshBuilderImpl : public MeshBuilder { DynamicVBuf m_VertexBuffer; DynamicIndexBuf m_IndexBuffer; - ImportArray<Joint> m_Joints; - ImportArray<SubsetDesc> m_MeshSubsetDescs; + QVector<Joint> m_Joints; + QVector<SubsetDesc> m_MeshSubsetDescs; NVRenderDrawMode::Enum m_DrawMode; NVRenderWinding::Enum m_Winding; MemoryBuffer<RawAllocator> m_RemappedVertexData; MemoryBuffer<RawAllocator> m_NewIndexBuffer; - ImportArray<QT3DSU8> m_MeshBuffer; + QVector<QT3DSU8> m_MeshBuffer; public: MeshBuilderImpl() { Reset(); } @@ -303,8 +303,8 @@ public: // did we find some duplicates? if (matDuplicates) { - ImportArray<SubsetDesc> newMeshSubsetDescs; - ImportArray<SubsetDesc>::iterator theIter; + QVector<SubsetDesc> newMeshSubsetDescs; + QVector<SubsetDesc>::iterator theIter; QString curMatName; m_NewIndexBuffer.clear(); @@ -312,7 +312,7 @@ public: ++theIter) { bool bProcessed = false; - for (ImportArray<SubsetDesc>::iterator iter = newMeshSubsetDescs.begin(); + for (QVector<SubsetDesc>::iterator iter = newMeshSubsetDescs.begin(); iter != newMeshSubsetDescs.end(); ++iter) { if (theIter->m_Name == iter->m_Name) { bProcessed = true; diff --git a/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImportPerformImport.cpp b/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImportPerformImport.cpp index 4b716a9b..00ae8cb8 100644 --- a/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImportPerformImport.cpp +++ b/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImportPerformImport.cpp @@ -52,8 +52,8 @@ struct ScopedReleaser }; void DoUpdateInstances(Import &import, IComposerEditor &composer, - NVConstDataRef<InstanceDesc> instances, - ImportArray<PropertyValue> &properties) + const QVector<InstanceDesc> &instances, + QVector<PropertyValue> &properties) { QT3DSIMP_FOREACH(idx, instances.size()) { @@ -73,11 +73,12 @@ void DoUpdateInstances(Import &import, IComposerEditor &composer, } } -SImportResult::SImportResult(const Q3DStudio::CFilePath &inFilePath, QT3DSU32 inFileVersion) +SImportResult::SImportResult(const QString &inFilePath, QT3DSU32 inFileVersion) : m_Error(ImportErrorCodes::NoError) , m_FilePath(inFilePath) + , m_fileVersion(inFileVersion) { - m_FilePath.SetIdentifier(QString::number(inFileVersion)); + } /** @@ -115,11 +116,11 @@ void CPerformImport::DoImportToComposer(Import &import, IComposerEditor &compose QT3DSIMP_FOREACH(idx, report.m_Instances.m_Added.size()) { const InstanceDesc &desc(report.m_Instances.m_Added[idx]); - if (AreEqual(desc.m_Id, L"__import__root__")) + if (desc.m_Id == QLatin1String("__import__root__")) composer.CreateRootInstance(desc.m_Id, desc.m_Type); else { Option<InstanceDesc> parent(import.GetInstanceByHandle(desc.m_Parent)); - TImportId parentId = L""; + TImportId parentId; if (parent.hasValue()) parentId = parent->m_Id; if (desc.m_Type != ComposerObjectTypes::Material) @@ -129,7 +130,7 @@ void CPerformImport::DoImportToComposer(Import &import, IComposerEditor &compose } } - ImportArray<PropertyValue> properties; + QVector<PropertyValue> properties; DoUpdateInstances(import, composer, report.m_Instances.m_Added, properties); DoUpdateInstances(import, composer, report.m_Instances.m_Existing, properties); @@ -167,110 +168,99 @@ void CPerformImport::DoImportToComposer(Import &import, IComposerEditor &compose SImportResult CPerformImport::RefreshToComposer(ITranslator &translator, IComposerEditor &inComposer, Import &inOriginalImport, - const Q3DStudio::CFilePath &ioImportFile) + const QString &ioImportFile) { ScopedReleaser<Import> __originalScope(inOriginalImport); ScopedReleaser<ITranslator> __translatorScope(translator); - const CFilePath &importDestFile(ioImportFile); + const QFileInfo &importDestFile(ioImportFile); - if (importDestFile.IsFile() && importDestFile.GetFileFlags().CanWrite() == false) + if (importDestFile.isFile() && importDestFile.isWritable() == false) return ImportErrorCodes::ResourceNotWriteable; - __originalScope.dtype = NULL; + __originalScope.dtype = nullptr; ImportPtrOrError importPtr = - Import::CreateForRefresh(inOriginalImport, translator.GetSourceFile().toStdWString().c_str()); - if (importPtr.m_Value == NULL) + Import::CreateForRefresh(inOriginalImport, translator.GetSourceFile()); + if (importPtr.m_Value == nullptr) return importPtr.m_ErrorData.m_Error; ScopedReleaser<Import> __importScope(*importPtr.m_Value); if (translator.PerformTranslation(*importPtr.m_Value)) { DoImportToComposer(*importPtr.m_Value, inComposer); - Q3DStudio::CString fname = Q3DStudio::CFilePath(importDestFile).GetFileName(); - QT3DSU32 importId = importPtr.m_Value->Save(fname.c_str()); - return SImportResult(importDestFile, importId); + QT3DSU32 importId = importPtr.m_Value->Save(importDestFile.fileName()); + return SImportResult(importDestFile.absoluteFilePath(), importId); } return ImportErrorCodes::TranslationToImportFailed; } SImportResult CPerformImport::RefreshToComposer(ITranslator &translator, IComposerEditor &composer, - const CFilePath &ioImportFile) + const QString &ioImportFile) { -#ifdef RUNTIME_SPLIT_TEMPORARILY_REMOVED - ImportPtrOrError originalPtr = Import::Load(ioImportFile.toCString()); - if (originalPtr.m_Value == NULL) + ImportPtrOrError originalPtr = Import::Load(ioImportFile); + if (originalPtr.m_Value == nullptr) return originalPtr.m_ErrorData.m_Error; return RefreshToComposer(translator, composer, *originalPtr.m_Value, ioImportFile); -#endif - return SImportResult(ImportErrorCodes::SourceFileNotReadable); } SImportResult CPerformImport::ImportToComposer(ITranslator &translator, IComposerEditor &composer, - const Q3DStudio::CFilePath &inImportFile) + const QString &inImportFile) { -#ifdef RUNTIME_SPLIT_TEMPORARILY_REMOVED ScopedReleaser<ITranslator> __translatorScope(translator); - const CFilePath &importDestFile(inImportFile); - if (importDestFile.IsFile() && importDestFile.GetFileFlags().CanWrite() == false) + const QFileInfo &importDestFile(inImportFile); + if (importDestFile.isFile() && importDestFile.isWritable() == false) return ImportErrorCodes::ResourceNotWriteable; ImportPtrOrError importPtr = - Import::Create(translator.GetSourceFile().toStdWString().c_str(), importDestFile.GetDirectory().toCString()); - if (importPtr.m_Value == NULL) + Import::Create(translator.GetSourceFile(), importDestFile.absolutePath()); + if (importPtr.m_Value == nullptr) return importPtr.m_ErrorData.m_Error; ScopedReleaser<Import> __importScope(*importPtr.m_Value); if (translator.PerformTranslation(*importPtr.m_Value)) { DoImportToComposer(*importPtr.m_Value, composer); - Q3DStudio::CString fname = importDestFile.GetFileName(); - QT3DSU32 importId = importPtr.m_Value->Save(fname.c_str()); - return SImportResult(importDestFile, importId); + QString fname = importDestFile.fileName(); + QT3DSU32 importId = importPtr.m_Value->Save(fname); + return SImportResult(importDestFile.absoluteFilePath(), importId); } -#endif return ImportErrorCodes::TranslationToImportFailed; } SImportResult CPerformImport::ImportToComposerFromImportFile(IComposerEditor &composer, - const Q3DStudio::CFilePath &inImportFile) + const QString &inImportFile) { -#ifdef RUNTIME_SPLIT_TEMPORARILY_REMOVED - const CFilePath &importDestFile(inImportFile); - if (importDestFile.IsFile() == false) + const QFileInfo &importDestFile(inImportFile); + if (importDestFile.isFile() == false) return ImportErrorCodes::SourceFileDoesNotExist; - QT3DSU32 fileId = Import::GetHighestImportRevision(inImportFile.toCString()); + QT3DSU32 fileId = Import::GetHighestImportRevision(inImportFile); if (fileId == 0) return ImportErrorCodes::SourceFileNotReadable; - ImportPtrOrError importPtr = Import::Load(importDestFile.toCString(), fileId); - if (importPtr.m_Value == NULL) + ImportPtrOrError importPtr = Import::Load(inImportFile, fileId); + if (importPtr.m_Value == nullptr) return importPtr.m_ErrorData.m_Error; ScopedReleaser<Import> __importScope(*importPtr.m_Value); DoImportToComposer(*importPtr.m_Value, composer); return SImportResult(inImportFile, fileId); -#endif - return ImportErrorCodes::SourceFileNotReadable; } SImportResult CPerformImport::TranslateToImportFile(ITranslator &translator, - const Q3DStudio::CFilePath &inImportFile) + const QString &inImportFile) { -#ifdef RUNTIME_SPLIT_TEMPORARILY_REMOVED ScopedReleaser<ITranslator> __translatorScope(translator); - const CFilePath &importDestFile(inImportFile); - if (importDestFile.IsFile() && importDestFile.GetFileFlags().CanWrite() == false) + const QFileInfo &importDestFile(inImportFile); + if (importDestFile.isFile() && importDestFile.isWritable() == false) return ImportErrorCodes::ResourceNotWriteable; ImportPtrOrError importPtr = - Import::Create(translator.GetSourceFile().toStdWString().c_str(), importDestFile.GetDirectory().toCString()); - if (importPtr.m_Value == NULL) + Import::Create(translator.GetSourceFile(), importDestFile.absolutePath()); + if (importPtr.m_Value == nullptr) return importPtr.m_ErrorData.m_Error; ScopedReleaser<Import> __importScope(*importPtr.m_Value); if (translator.PerformTranslation(*importPtr.m_Value)) { - Q3DStudio::CString fname = importDestFile.GetFileName(); - QT3DSU32 importId = importPtr.m_Value->Save(fname.c_str()); + QString fname = importDestFile.fileName(); + QT3DSU32 importId = importPtr.m_Value->Save(fname); return SImportResult(inImportFile, importId); } -#endif return ImportErrorCodes::TranslationToImportFailed; } diff --git a/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImportPerformImport.h b/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImportPerformImport.h index 1c0fda7e..22398340 100644 --- a/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImportPerformImport.h +++ b/src/Authoring/QT3DSIMP/Qt3DSImportLib/Qt3DSImportPerformImport.h @@ -52,28 +52,29 @@ using namespace qt3dsdm; struct ParentChildLink; struct PropertyValue; class Import; -class InstanceDesc; +struct InstanceDesc; struct ImportErrorData { ImportErrorCodes::Enum m_Error; - const wchar_t *m_ExtraInfo; - explicit ImportErrorData(ImportErrorCodes::Enum err, TCharPtr extraInfo) + QString m_ExtraInfo; + explicit ImportErrorData(ImportErrorCodes::Enum err, const QString &extraInfo) : m_Error(err) , m_ExtraInfo(extraInfo) { } ImportErrorData() : m_Error(ImportErrorCodes::NoError) - , m_ExtraInfo(L"") { } void PrintErrorString(wchar_t *buffer, QT3DSU32 bufLen) { - if (m_Error != ImportErrorCodes::NoError) + if (m_Error != ImportErrorCodes::NoError) { + QByteArray data(m_ExtraInfo.toLocal8Bit()); swprintf(buffer, bufLen, ImportErrorCodes::GetEnglishFormatString(m_Error), - m_ExtraInfo); + data.data()); + } else swprintf(buffer, bufLen, L"No error"); } @@ -97,7 +98,7 @@ struct PropertyValue } }; -typedef const wchar_t *TImportId; +typedef QString TImportId; /** * Interface to allow abstract UIComposer details (doc, slides, etc) @@ -142,11 +143,11 @@ public: // they may be out of order so if the child already has this parent relationship you need // to check the order and ensure that is also (somewhat) correct. virtual void AddChild(TImportId parent, TImportId child, TImportId nextSibling) = 0; - virtual void RemoveAnimation(TImportId hdl, const wchar_t *propName, long propSubIndex) = 0; - virtual void UpdateAnimation(TImportId hdl, const wchar_t *propName, long propSubIndex, + virtual void RemoveAnimation(TImportId hdl, const QString &propName, long propSubIndex) = 0; + virtual void UpdateAnimation(TImportId hdl, const QString &propName, long propSubIndex, EAnimationType animType, const float *animData, QT3DSU32 numFloats) = 0; - virtual void AddAnimation(TImportId hdl, const wchar_t *propName, long propSubIndex, + virtual void AddAnimation(TImportId hdl, const QString &propName, long propSubIndex, EAnimationType animType, const float *animData, QT3DSU32 numFloats) = 0; virtual void EndImport() = 0; @@ -174,13 +175,14 @@ struct SImportResult ImportErrorCodes::Enum m_Error; // The file path will probably contain a version number at the end of the // string, so you need to be aware of this. - Q3DStudio::CFilePath m_FilePath; + QString m_FilePath; + QT3DSU32 m_fileVersion; SImportResult(ImportErrorCodes::Enum inError) : m_Error(inError) { } - SImportResult(const Q3DStudio::CFilePath &inFilePath, QT3DSU32 inFileVersion); + SImportResult(const QString &inFilePath, QT3DSU32 inFileVersion); }; // The file path @@ -205,7 +207,7 @@ public: */ static SImportResult RefreshToComposer(ITranslator &translator, IComposerEditor &inComposers, Import &inOriginalFile, - const Q3DStudio::CFilePath &ioImportFile); + const QString &ioImportFile); /** * Exception safe! translator and importer are always released!! @@ -220,7 +222,7 @@ public: * that was imported. */ static SImportResult RefreshToComposer(ITranslator &translator, IComposerEditor &inComposers, - const Q3DStudio::CFilePath &ioImportFile); + const QString &ioImportFile); /** * Exception safe! translator and importer are always released!! * 1. Create blank importer @@ -232,7 +234,7 @@ public: * If the import file exists, a new import version will be written to the file. */ static SImportResult ImportToComposer(ITranslator &translator, IComposerEditor &composer, - const Q3DStudio::CFilePath &inImportFile); + const QString &inImportFile); /** * Load the dest file, and import the objects into composer. @@ -241,7 +243,7 @@ public: * The import file must exist. */ static SImportResult ImportToComposerFromImportFile(IComposerEditor &composer, - const Q3DStudio::CFilePath &inImportFile); + const QString &inImportFile); /** * Translate an outside file type to an import file but don't import that file. If thei mport @@ -249,7 +251,7 @@ public: * version is written to the import file. */ static SImportResult TranslateToImportFile(ITranslator &translator, - const Q3DStudio::CFilePath &inImportFile); + const QString &inImportFile); static void DoImportToComposer(Import &import, IComposerEditor &composer); }; diff --git a/src/Authoring/QT3DSIMP/Qt3DSImportSGTranslation/Qt3DSImportSceneGraphTranslation.cpp b/src/Authoring/QT3DSIMP/Qt3DSImportSGTranslation/Qt3DSImportSceneGraphTranslation.cpp index dc8e1a80..11eab904 100644 --- a/src/Authoring/QT3DSIMP/Qt3DSImportSGTranslation/Qt3DSImportSceneGraphTranslation.cpp +++ b/src/Authoring/QT3DSIMP/Qt3DSImportSGTranslation/Qt3DSImportSceneGraphTranslation.cpp @@ -82,8 +82,8 @@ struct SGKeyframe struct SGAnimationApplier { virtual ~SGAnimationApplier() {} - virtual void Apply(Import &inImport, const wchar_t *inInstanceId, QT3DSU32 subPropIndex, - EAnimationType inAnimType, NVConstDataRef<float> inData) = 0; + virtual void Apply(Import &inImport, const QString &inInstanceId, QT3DSU32 subPropIndex, + EAnimationType inAnimType, const QVector<float> &inData) = 0; }; template <typename TDataType> @@ -94,8 +94,8 @@ struct SSpecificSGAnimationApplier : public SGAnimationApplier : m_Property(inProp) { } - void Apply(Import &inImport, const wchar_t *inInstanceId, QT3DSU32 subPropIndex, - EAnimationType inAnimType, NVConstDataRef<float> inData) override + void Apply(Import &inImport, const QString &inInstanceId, QT3DSU32 subPropIndex, + EAnimationType inAnimType, const QVector<float> &inData) override { inImport.AddAnimation(inInstanceId, m_Property, subPropIndex, inAnimType, inData); } @@ -103,8 +103,8 @@ struct SSpecificSGAnimationApplier : public SGAnimationApplier struct SGAnimation { - std::function<void(Import &, QT3DSU32, ImportArray<SGKeyframe> &)> m_AnimationApplier; - ImportArray<SGKeyframe> m_Keyframes; + std::function<void(Import &, QT3DSU32, QVector<SGKeyframe> &)> m_AnimationApplier; + QVector<SGKeyframe> m_Keyframes; QT3DSU32 m_SubPropIndex; std::shared_ptr<SGAnimationApplier> m_Applier; @@ -365,11 +365,11 @@ class SGTrans : public ISceneGraphTranslation, public SImportComposerTypes { // uses relationship, not owns. Import &m_Import; - ImportArray<TIMPHandle> m_InstanceStack; - ImportHashMap<TIMPHandle, MeshBuilder *> m_Helpers; - ImportHashSet<TIMPHandle> m_DuplicateMaterials; - ImportArray<SGAnimation> m_Animations; - ImportHashSet<TIMPHandle> m_Invalids; + QVector<TIMPHandle> m_InstanceStack; + QHash<TIMPHandle, MeshBuilder *> m_Helpers; + QSet<TIMPHandle> m_DuplicateMaterials; + QVector<SGAnimation> m_Animations; + QSet<TIMPHandle> m_Invalids; ISGTranslationLog &m_Log; MemoryBuffer<RawAllocator> m_TempBuffer; EAuthoringToolType m_AuthoringToolType; @@ -391,10 +391,8 @@ public: } virtual ~SGTrans() { - for (ImportHashMap<TIMPHandle, MeshBuilder *>::iterator iter = m_Helpers.begin(), - end = m_Helpers.end(); - iter != end; ++iter) - iter->second->Release(); + for (auto helper : qAsConst(m_Helpers)) + helper->Release(); } template <typename TDataType> @@ -419,30 +417,27 @@ public: TCharPtr ToImport(const wchar_t *data) { return data; } - template <typename TNameType> - void InternalPushObject(const TNameType *inName, ComposerObjectTypes::Enum inType) + void InternalPushObject(const QString &inName, ComposerObjectTypes::Enum inType) { if (m_InstanceStack.size() == 0) { MarkInvalid(); return; } - TCharPtr name(ToImport(inName)); + QString name(inName); - if (name == NULL || *name == 0) + if (name.isEmpty()) name = ComposerObjectTypes::Convert(inType); - Q3DStudio::CFilePath objectName = Q3DStudio::CFilePath(name); - Q3DStudio::CString normName = objectName.toCString(); - name = normName; + name = QFileInfo(name).filePath(); - TCharPtr nameStem = name; + QString nameStem = name; if (m_Import.FindInstanceById(name).hasValue()) { - wchar_t nameBuf[1024]; + QString tempName; int idx = 1; do { - swprintf(nameBuf, 1024, L"%ls_%04d", nameStem, idx); + tempName = QStringLiteral("%1_%2").arg(nameStem).arg(idx, 4, 10, QLatin1Char('0')); ++idx; - name = nameBuf; + name = tempName; } while (m_Import.FindAnyInstanceById(name) .hasValue()); // don't use any instance which was already used valid or not } @@ -510,16 +505,17 @@ public: { TIMPHandle model = PopObject(); if (model) { - TCharPtr modelId = m_Import.GetInstanceByHandle(model)->m_Id; - ImportHashMap<TIMPHandle, MeshBuilder *>::const_iterator entry = m_Helpers.find(model); + QString modelId = m_Import.GetInstanceByHandle(model)->m_Id; + QHash<TIMPHandle, MeshBuilder *>::const_iterator entry = m_Helpers.find(model); if (entry != m_Helpers.end()) { - entry->second->ConnectSubMeshes(); - entry->second->OptimizeMesh(); - Mesh &mesh = entry->second->GetMesh(); - CharPtrOrError meshData = m_Import.AddMesh(mesh, modelId); - if (meshData.m_Value && *meshData.m_Value) + (*entry)->ConnectSubMeshes(); + (*entry)->OptimizeMesh(); + Mesh &mesh = (*entry)->GetMesh(); + QStringOrError meshData = m_Import.AddMesh(mesh, modelId); + if (!meshData.m_Value.isEmpty()) { m_Import.SetInstancePropertyValue(model, m_Asset.m_SourcePath, meshData.m_Value); + } if (meshData.m_Error) m_Log.OnWarning(ESceneGraphWarningCode_LockedDestFile, meshData.m_Value); } @@ -530,7 +526,7 @@ public: // mark as not duplicated material m_isDuplicatedMaterial = false; // find if there exists already an instance of this material - TCharPtr name(ToImport(inName)); + QString name(QString::fromLatin1(inName)); Option<InstanceDesc> inst = m_Import.FindInstanceById(name); if (inst.hasValue()) { @@ -577,59 +573,56 @@ public: } void PushTexture(const char * /*inName*/, const char *inSourcePath, long inMapType) override { - TCharPtr source = m_Import.RegisterStr(ToImport(inSourcePath)); + QString source = QString::fromLatin1(inSourcePath); // Ignore paths such as: // /d:/something if (source[2] == ':') { if (source[0] == '\\' || source[0] == '/') - ++source; + source = source.right(source.length() - 1); } - CharPtrOrError result = m_Import.AddImage(source); - TCharPtr dest = result.m_Value; - TCharPtr imgPath = NULL; - wchar_t pathBuf[1024]; + QStringOrError result = m_Import.AddImage(source); + QString dest = result.m_Value; + QString imgPath; if (result.m_Error) { + QString errorStr; ESceneGraphWarningCode code = ESceneGraphWarningCode_Generic; - const wchar_t *errorStr = source; if (result.m_ErrorData.m_Error == ImportErrorCodes::SourceFileNotReadable) code = ESceneGraphWarningCode_MissingSourceFile; else if (result.m_ErrorData.m_Error == ImportErrorCodes::ResourceNotWriteable) { code = ESceneGraphWarningCode_LockedDestFile; - errorStr = m_Import.RegisterStr(dest); + errorStr = dest; } m_Log.OnWarning(code, errorStr); } - if (result.m_Value != NULL && *result.m_Value) + if (!result.m_Value.isNull()) imgPath = result.m_Value; - else { - swprintf(pathBuf, 1024, L"%hs/missing.png", - m_Import.GetImageDir().toStdString().c_str()); - imgPath = pathBuf; - } + else + imgPath = QStringLiteral("%1/missing.png").arg(m_Import.GetImageDir()); + // We want to name the texture after the material id concatenated with the map type. // This ensures that we carry texture settings across for materials because the material // id doesn't change. TIMPHandle theMaterial = m_InstanceStack.back(); - std::wstring theId(m_Import.GetInstanceByHandle(theMaterial)->m_Id); - theId.append(L"_"); + QString theId(m_Import.GetInstanceByHandle(theMaterial)->m_Id); + theId.append(QLatin1Char('_')); switch (inMapType) { case ETextureMapTypeDiffuse: - theId.append(L"diffusemap"); + theId.append(QStringLiteral("diffusemap")); break; case ETextureMapTypeOpacity: - theId.append(L"opacitymap"); + theId.append(QStringLiteral("opacitymap")); break; case ETextureMapTypeSpecular: - theId.append(L"specularmap"); + theId.append(QStringLiteral("specularmap")); break; case ETextureMapTypeEmissive: - theId.append(L"emissivemap"); + theId.append(QStringLiteral("emissivemap")); break; case ETextureMapTypeRoughness: - theId.append(L"roughnessmap"); + theId.append(QStringLiteral("roughnessmap")); break; } - InternalPushObject(theId.c_str(), ComposerObjectTypes::Image); + InternalPushObject(theId, ComposerObjectTypes::Image); TIMPHandle topObj = m_InstanceStack.back(); m_Import.SetInstancePropertyValue(topObj, m_Image.m_SourcePath, imgPath); } @@ -734,7 +727,7 @@ public: } SetInstancePropertyValue(theMaterial, m_Material.m_Opacity, theOpacity * 100.0f); - SetInstancePropertyValue(theMaterial, m_Material.m_BlendMode, L"Normal"); + SetInstancePropertyValue(theMaterial, m_Material.m_BlendMode, QStringLiteral("Normal")); } void SetTexture(long inMapType, const STextureParameters &inTextureParameters) override { @@ -836,32 +829,32 @@ public: } // tiling mode U - std::wstring theHorizontalTilingMode = L"Tiled"; // tiled + QString theHorizontalTilingMode = QStringLiteral("Tiled"); if (inTextureParameters.m_wrapU.m_Flag) { if (inTextureParameters.m_wrapU.m_Value == 0) - theHorizontalTilingMode = L"No Tiling"; // not tiled + theHorizontalTilingMode = QStringLiteral("No Tiling"); } if (inTextureParameters.m_mirrorU.m_Flag) { if (inTextureParameters.m_mirrorU.m_Value == 1) - theHorizontalTilingMode = L"Mirrored"; // mirrored + theHorizontalTilingMode = QStringLiteral("Mirrored"); } SetInstancePropertyValue(theImageInstance, m_Image.m_TilingU, - theHorizontalTilingMode.c_str()); + theHorizontalTilingMode); // tiling mode V - std::wstring theVerticalTilingMode = L"Tiled"; // tiled + QString theVerticalTilingMode = QStringLiteral("Tiled"); if (inTextureParameters.m_wrapV.m_Flag) { if (inTextureParameters.m_wrapV.m_Value == 0) - theVerticalTilingMode = L"No Tiling"; // not tiled + theVerticalTilingMode = QStringLiteral("No Tiling"); } if (inTextureParameters.m_mirrorV.m_Flag) { if (inTextureParameters.m_mirrorV.m_Value == 1) - theVerticalTilingMode = L"Mirrored"; // mirrored + theVerticalTilingMode = QStringLiteral("Mirrored"); } SetInstancePropertyValue(theImageInstance, m_Image.m_TilingV, - theVerticalTilingMode.c_str()); + theVerticalTilingMode); } } @@ -937,18 +930,18 @@ public: SetInstancePropertyValue(theNode, m_Node.m_Position, ConvertToSValue(theTranslation)); SetInstancePropertyValue(theNode, m_Node.m_Scale, ConvertToSValue(theScale)); - SetInstancePropertyValue(theNode, m_Node.m_Orientation, L"Right Handed"); - SetInstancePropertyValue(theNode, m_Node.m_RotationOrder, L"XYZr"); + SetInstancePropertyValue(theNode, m_Node.m_Orientation, QStringLiteral("Right Handed")); + SetInstancePropertyValue(theNode, m_Node.m_RotationOrder, QStringLiteral("XYZr")); } MeshBuilder *GetOrCreateMeshBuilder() { - ImportHashMap<TIMPHandle, MeshBuilder *>::iterator entry = + QHash<TIMPHandle, MeshBuilder *>::iterator entry = m_Helpers.find(m_InstanceStack.back()); if (entry != m_Helpers.end()) - return entry->second; + return *entry; MeshBuilder *newHelper = &MeshBuilder::CreateMeshBuilder(); - m_Helpers.insert(eastl::make_pair(m_InstanceStack.back(), newHelper)); + m_Helpers.insert(m_InstanceStack.back(), newHelper); return newHelper; } @@ -1077,10 +1070,11 @@ public: } TIMPHandle instance(m_InstanceStack.back()); InstanceDesc theDesc(m_Import.GetInstanceByHandle(instance)); - TCharPtr instId = theDesc.m_Id; + QString instId = theDesc.m_Id; + QVector<float> data(anim.m_Keyframes.size() * 4); + memcpy(data.data(), anim.m_Keyframes.data(), data.length() * 4); anim.m_Applier->Apply( - m_Import, instId, anim.m_SubPropIndex, EAnimationTypeEaseInOut, - toConstDataRef((float *)anim.m_Keyframes.begin(), (QT3DSU32)anim.m_Keyframes.size() * 4)); + m_Import, instId, anim.m_SubPropIndex, EAnimationTypeEaseInOut, data); } void CacheAnimationKey(const char *inBaseProperty, const char *inSubPropertyName, @@ -1138,14 +1132,14 @@ public: long idx = GetSubPropertyIndex(theSubPropertyName.c_str()); theTrack.m_SubPropIndex = idx; - Q3DStudio::CString theName(theStudioPropertyName.c_str()); + QString theName(theStudioPropertyName.c_str()); ComposerPropertyNames::Enum thePropertyName(ComposerPropertyNames::Convert(theName)); ImportVisitPropertyType(thePropertyName, theTrack); } void LogWarning(ESceneGraphWarningCode inWarningCode, const char *inAssociatedName) override { - m_Log.OnWarning(inWarningCode, m_Import.RegisterStr(ToImport(inAssociatedName))); + m_Log.OnWarning(inWarningCode, QString::fromLocal8Bit(inAssociatedName)); } }; } diff --git a/src/Authoring/QT3DSIMP/Qt3DSImportSGTranslation/Qt3DSImportTranslation.h b/src/Authoring/QT3DSIMP/Qt3DSImportSGTranslation/Qt3DSImportTranslation.h index 5ecd9d64..16b4d893 100644 --- a/src/Authoring/QT3DSIMP/Qt3DSImportSGTranslation/Qt3DSImportTranslation.h +++ b/src/Authoring/QT3DSIMP/Qt3DSImportSGTranslation/Qt3DSImportTranslation.h @@ -60,7 +60,7 @@ protected: virtual ~ISGTranslationLog() {} public: virtual void OnWarning(ESceneGraphWarningCode inWarningCode, - const wchar_t *inAssociatedName) = 0; + const QString &inAssociatedName) = 0; }; #ifdef QT3DS_IMPORT_TRANSLATION_INTERNAL @@ -72,7 +72,7 @@ public: class CImportTranslation { public: - static inline const wchar_t *GetRootNodeId() { return L"__import__root__"; } + static inline const QString GetRootNodeId() { return QStringLiteral("__import__root__"); } // Parse the collada file, marking when things don't line up correctly. // Translate a collada file into an import datastructure. static EXPORT_FUNCTION bool ParseColladaFile(const std::string &fileName, Import &import, @@ -87,9 +87,9 @@ public: struct STranslationLog : public qt3dsimp::ISGTranslationLog { - vector<pair<qt3dsimp::ESceneGraphWarningCode, Q3DStudio::CString>> m_Warnings; + vector<pair<qt3dsimp::ESceneGraphWarningCode, QString>> m_Warnings; void OnWarning(qt3dsimp::ESceneGraphWarningCode inWarningCode, - const wchar_t *inAssociatedName) override + const QString &inAssociatedName) override { m_Warnings.push_back(std::make_pair(inWarningCode, inAssociatedName)); } diff --git a/src/Authoring/Studio/Application/AboutDlg.cpp b/src/Authoring/Studio/Application/AboutDlg.cpp index 818c3556..6234467e 100644 --- a/src/Authoring/Studio/Application/AboutDlg.cpp +++ b/src/Authoring/Studio/Application/AboutDlg.cpp @@ -138,7 +138,7 @@ void CAboutDlg::OnInitDialog() m_ui->m_WebSite->setText(QString("<a href=\"%1\"><font color=\"#%2\">%3</font></a>").arg( theURL, - CStudioPreferences::GetMasterColor().GetString().toQString(), + CStudioPreferences::GetMasterColor().name(), theURL)); m_ui->m_WebSite->setToolTip(tr("Click to visit Qt web site")); m_ui->m_WebSite->setOpenExternalLinks(true); @@ -148,7 +148,7 @@ void CAboutDlg::OnInitDialog() m_ui->m_Email->setText(QString("<a href=\"%1\"><font color=\"#%2\">%3</font></a>").arg( theSupport, - CStudioPreferences::GetMasterColor().GetString().toQString(), + CStudioPreferences::GetMasterColor().name(), theSupport)); m_ui->m_Email->setToolTip(tr("Send a Studio support request to the Qt Company")); m_ui->m_Email->setOpenExternalLinks(true); diff --git a/src/Authoring/Studio/Application/ProjectFile.cpp b/src/Authoring/Studio/Application/ProjectFile.cpp index f174d796..6c155a69 100644 --- a/src/Authoring/Studio/Application/ProjectFile.cpp +++ b/src/Authoring/Studio/Application/ProjectFile.cpp @@ -293,11 +293,11 @@ void ProjectFile::writePresentationId(const QString &id, const QString &src) while (!iter.IsDone()) { qt3dsdm::Qt3DSDMInstanceHandle child = iter.GetCurrent(); if (bridge->GetObjectType(child) & (OBJTYPE_LAYER | OBJTYPE_IMAGE)) { - if (bridge->GetSourcePath(child).toQString() == oldId) { + if (bridge->GetSourcePath(child) == oldId) { propSystem->SetInstancePropertyValue(child, bridge->GetSourcePathProperty(), qt3dsdm::SValue(QVariant(theId))); } - if (bridge->getSubpresentation(child).toQString() == oldId) { + if (bridge->getSubpresentation(child) == oldId) { propSystem->SetInstancePropertyValue(child, bridge->getSubpresentationProperty(), qt3dsdm::SValue(QVariant(theId))); diff --git a/src/Authoring/Studio/Application/StudioApp.cpp b/src/Authoring/Studio/Application/StudioApp.cpp index 2b5580c8..7bc984a8 100644 --- a/src/Authoring/Studio/Application/StudioApp.cpp +++ b/src/Authoring/Studio/Application/StudioApp.cpp @@ -2171,7 +2171,7 @@ void CStudioApp::checkDeletedDatainputs() qt3dsimp::SImportAsset &theAsset(theTypes.GetImportAssetForType( qt3dsdm::ComposerObjectTypes::Node)); qt3dsdm::DataModelDataType::Value theType( - theAsset.GetPropertyDataType(propName.toStdWString().c_str())); + theAsset.GetPropertyDataType(propName)); spEntry.first = theType; spEntry.second = false; } diff --git a/src/Authoring/Studio/Controls/Renderer.h b/src/Authoring/Studio/Controls/Renderer.h index 7ef77fe3..f30121fa 100644 --- a/src/Authoring/Studio/Controls/Renderer.h +++ b/src/Authoring/Studio/Controls/Renderer.h @@ -35,7 +35,7 @@ #include <QColor> #include <QPoint> -#include "CColor.h" +#include <QtGui/qcolor.h> QT_BEGIN_NAMESPACE class QPainter; diff --git a/src/Authoring/Studio/DragAndDrop/BasicObjectDropSource.cpp b/src/Authoring/Studio/DragAndDrop/BasicObjectDropSource.cpp index 8060537a..ee819e78 100644 --- a/src/Authoring/Studio/DragAndDrop/BasicObjectDropSource.cpp +++ b/src/Authoring/Studio/DragAndDrop/BasicObjectDropSource.cpp @@ -185,43 +185,50 @@ CCmd *CBasicObjectDropSource::GenerateAssetCommand(qt3dsdm::Qt3DSDMInstanceHandl if (theComposerType != ComposerObjectTypes::Unknown) { if (theComposerType == ComposerObjectTypes::Text) { // For Text, we need to check if user already has font file inside fonts folder - CFilePath theFontFile; - CFilePath theFontDir = CFilePath::CombineBaseAndRelative( - CFilePath(g_StudioApp.GetCore()->getProjectFile().getProjectPath()), - CFilePath(L"fonts")); - if (!theFontDir.Exists()) { + QString theFontFile; + QString theFontDir = CFilePath::CombineBaseAndRelative( + g_StudioApp.GetCore()->getProjectFile().getProjectPath(), + QStringLiteral("fonts")); + QFileInfo info(theFontDir); + if (!info.exists()) { // Create font dir if necessary - theFontDir.CreateDir(true); + CFilePath::CreateDir(theFontDir, true); } else { // Recursively find the first font file in font dir - vector<CFilePath> theFiles; - theFontDir.RecursivelyFindFilesOfType(nullptr, theFiles, false); + vector<QFileInfo> theFiles; + QFileInfo fontDir(theFontDir); + Q3DStudio::CFilePath::RecursivelyFindFilesOfType(fontDir, QStringList(), + theFiles, false); for (size_t i = 0; i < theFiles.size(); ++i) { - if (CDialogs::IsFontFileExtension(theFiles[i].GetExtension())) { + if (CDialogs::IsFontFileExtension(theFiles[i].suffix())) { // Reuse the font in fonts subdirectory - theFontFile = theFiles[i]; + theFontFile = theFiles[i].absoluteFilePath(); break; } } } - if (theFontFile.filePath().isEmpty()) { + QFileInfo fontInfo(theFontFile); + if (fontInfo.filePath().isEmpty()) { // If user doesn't have any font file, copy the default font file from Studio's res // folder - CFilePath theResFontFile; + QString theResFontFile; QDir theResFontDir(resourcePath() + "/Font"); - Q_FOREACH (QFileInfo fontFile, theResFontDir.entryInfoList(QDir::Files | QDir::NoDotAndDotDot)) { - CString ext = CString::fromQString(fontFile.suffix()); + const QFileInfoList infoList(theResFontDir.entryInfoList( + QDir::Files | QDir::NoDotAndDotDot)); + for (const QFileInfo &fontFile : infoList) { + QString ext = fontFile.suffix(); if (CDialogs::IsFontFileExtension(ext)) { - theResFontFile = CString::fromQString(fontFile.absoluteFilePath()); - theFontFile = CFilePath::CombineBaseAndRelative(theFontDir, CString::fromQString(fontFile.fileName())); + theResFontFile = fontFile.absoluteFilePath(); + theFontFile = CFilePath::CombineBaseAndRelative(theFontDir, + fontFile.fileName()); break; } } - if (theResFontFile.filePath().isEmpty()) { + if (theResFontFile.isEmpty()) { QT3DS_ASSERT(false); std::shared_ptr<IImportFailedHandler> theHandler( theDoc->GetImportFailedHandler()); diff --git a/src/Authoring/Studio/DragAndDrop/ExplorerFileDropSource.cpp b/src/Authoring/Studio/DragAndDrop/ExplorerFileDropSource.cpp index a4f3e63e..c61c24f8 100644 --- a/src/Authoring/Studio/DragAndDrop/ExplorerFileDropSource.cpp +++ b/src/Authoring/Studio/DragAndDrop/ExplorerFileDropSource.cpp @@ -63,16 +63,15 @@ CExplorerFileDropSource::CExplorerFileDropSource(long inFlavor, void *inData, un { // Pull out all of the SDropItemData and build a file. m_File = *(Qt3DSFile *)inData; - Q3DStudio::CFilePath thePath(m_File.GetAbsolutePath()); - m_ObjectType = Q3DStudio::ImportUtils::GetObjectFileTypeForFile(thePath).m_IconType; + QFileInfo thePath(m_File.GetAbsolutePath().toQString()); + m_ObjectType = Q3DStudio::ImportUtils::GetObjectFileTypeForFile( + thePath.absoluteFilePath()).m_IconType; // Fix because DAE files are the *only* thing you can drop onto the project - if (thePath.GetExtension().Compare(CDialogs::GetWideDAEFileExtension(), - Q3DStudio::CString::ENDOFSTRING, false)) { + if (thePath.suffix().compare(CDialogs::GetDAEFileExtension(), Qt::CaseInsensitive) == 0) { m_ObjectType = OBJTYPE_GROUP; } #ifdef QT_3DSTUDIO_FBX - else if (thePath.GetExtension().Compare(CDialogs::GetWideFbxFileExtension(), - Q3DStudio::CString::ENDOFSTRING, false)) { + else if (thePath.suffix().compare(CDialogs::GetFbxFileExtension(), Qt::CaseInsensitive) == 0) { m_ObjectType = OBJTYPE_GROUP; } #endif diff --git a/src/Authoring/Studio/DragAndDrop/FileDropSource.cpp b/src/Authoring/Studio/DragAndDrop/FileDropSource.cpp index 833b21b0..29a19016 100644 --- a/src/Authoring/Studio/DragAndDrop/FileDropSource.cpp +++ b/src/Authoring/Studio/DragAndDrop/FileDropSource.cpp @@ -90,8 +90,8 @@ CFileDropSource::CFileDropSource(long inFlavor, void *inData, unsigned long inSi { // Pull out all of the SDropItemData and build a file. m_File = *(Qt3DSFile *)inData; - m_ObjectType = - Q3DStudio::ImportUtils::GetObjectFileTypeForFile(m_File.GetAbsolutePath()).m_ObjectType; + m_ObjectType = Q3DStudio::ImportUtils::GetObjectFileTypeForFile( + m_File.GetAbsolutePath().toQString()).m_ObjectType; } void CFileDropSource::SetHasValidTarget(bool inValid) @@ -131,7 +131,7 @@ CCmd *CFileDropSource::GenerateAssetCommand(qt3dsdm::Qt3DSDMInstanceHandle inTar if (theFilePath.IsFile()) { Q3DStudio::DocumentEditorFileType::Enum theDocType( - Q3DStudio::ImportUtils::GetObjectFileTypeForFile(theFilePath).m_FileType); + Q3DStudio::ImportUtils::GetObjectFileTypeForFile(theFilePath.toQString()).m_FileType); QString theCommandName; // TODO: internationalize switch (theDocType) { @@ -189,8 +189,8 @@ CCmd *CFileDropSource::GenerateAssetCommand(qt3dsdm::Qt3DSDMInstanceHandle inTar || theDocType == Q3DStudio::DocumentEditorFileType::QmlStream) { // set subpresentation QString pathFromRoot = QDir(theDoc.GetCore()->getProjectFile().getProjectPath()) .relativeFilePath(theFilePath.toQString()); - Q3DStudio::CString presentationId = Q3DStudio::CString::fromQString(theDoc.GetCore() - ->getProjectFile().getPresentationId(pathFromRoot)); + QString presentationId = theDoc.GetCore() + ->getProjectFile().getPresentationId(pathFromRoot); auto &bridge(*theDoc.GetStudioSystem()->GetClientDataModelBridge()); EStudioObjectType rowType = bridge.GetObjectType(inTarget); @@ -241,7 +241,7 @@ CCmd *CFileDropSource::GenerateAssetCommand(qt3dsdm::Qt3DSDMInstanceHandle inTar } } else { Q3DStudio::SCOPED_DOCUMENT_EDITOR(theDoc, theCommandName) - ->ImportFile(theDocType, theFilePath, inTarget, inSlide, + ->ImportFile(theDocType, theFilePath.toQString(), inTarget, inSlide, CDialogs::GetImportFileExtension(), Q3DStudio::ImportUtils::GetInsertTypeForDropType(inDestType), thePoint, theStartTime); diff --git a/src/Authoring/Studio/DragAndDrop/ProjectDropTarget.cpp b/src/Authoring/Studio/DragAndDrop/ProjectDropTarget.cpp index a6b2c428..cc07a2f3 100644 --- a/src/Authoring/Studio/DragAndDrop/ProjectDropTarget.cpp +++ b/src/Authoring/Studio/DragAndDrop/ProjectDropTarget.cpp @@ -103,39 +103,41 @@ bool CProjectDropTarget::Drop(CDropSource &inSource) if (theSourceFile.IsFile() && m_TargetDir.IsDirectory()) { // Get the file extension - Q3DStudio::CString theExtension(theSourceFile.GetExtension()); + QString theExtension(theSourceFile.suffix()); - Q3DStudio::CString theFileStem = theSourceFile.GetFileStem(); - Q3DStudio::CString outputFileName(theFileStem + L"." - + CDialogs::GetImportFileExtension()); + QString theFileStem(theSourceFile.baseName()); + QString outputFileName(theFileStem + QLatin1Char('.') + + CDialogs::GetImportFileExtension()); - if (theExtension.Compare(CDialogs::GetWideDAEFileExtension(), - Q3DStudio::CString::ENDOFSTRING, false)) { + if (theSourceFile.suffix().compare(CDialogs::GetDAEFileExtension(), + Qt::CaseInsensitive) == 0) { SColladaTranslator theTranslator(theSourceFile.toQString()); - CFilePath theOutputDir = - SFileTools::FindUniqueDestDirectory(m_TargetDir, theFileStem); - CFilePath theFullOutputFile( - CFilePath::CombineBaseAndRelative(theOutputDir, outputFileName)); - SImportResult theImportResult = - CPerformImport::TranslateToImportFile(theTranslator, theFullOutputFile); - bool forceError = theFullOutputFile.IsFile() == false; + QDir theOutputDir + = SFileTools::FindUniqueDestDirectory(m_TargetDir.toQString(), theFileStem); + QString theFullOutputFile( + CFilePath::CombineBaseAndRelative(theOutputDir.canonicalPath(), + outputFileName)); + SImportResult theImportResult + = CPerformImport::TranslateToImportFile(theTranslator, theFullOutputFile); + bool forceError = QFileInfo(theFullOutputFile).isFile() == false; IDocumentEditor::DisplayImportErrors( theSourceFile.toQString(), theImportResult.m_Error, g_StudioApp.GetCore()->GetDoc()->GetImportFailedHandler(), theTranslator.m_TranslationLog, forceError); #ifdef QT_3DSTUDIO_FBX - } else if (theExtension.Compare(CDialogs::GetWideFbxFileExtension(), - Q3DStudio::CString::ENDOFSTRING, false)) { + } else if (theSourceFile.suffix().compare(CDialogs::GetFbxFileExtension(), + Qt::CaseInsensitive) == 0) { SFbxTranslator theTranslator(theSourceFile.toQString()); - CFilePath theOutputDir = - SFileTools::FindUniqueDestDirectory(m_TargetDir, theFileStem); - CFilePath theFullOutputFile( - CFilePath::CombineBaseAndRelative(theOutputDir, outputFileName)); + QDir theOutputDir + = SFileTools::FindUniqueDestDirectory(m_TargetDir.toQString(), theFileStem); + QString theFullOutputFile( + CFilePath::CombineBaseAndRelative(theOutputDir.canonicalPath(), + outputFileName)); SImportResult theImportResult = CPerformImport::TranslateToImportFile(theTranslator, theFullOutputFile); - bool forceError = theFullOutputFile.IsFile() == false; + bool forceError = QFileInfo(theFullOutputFile).isFile() == false; IDocumentEditor::DisplayImportErrors( theSourceFile.toQString(), theImportResult.m_Error, g_StudioApp.GetCore()->GetDoc()->GetImportFailedHandler(), @@ -165,12 +167,12 @@ bool CProjectDropTarget::Drop(CDropSource &inSource) } else { } - std::vector<Q3DStudio::CString> theEffectFileSourcePaths; + std::vector<QString> theEffectFileSourcePaths; g_StudioApp.GetCore() ->GetDoc() ->GetDocumentReader() .ParseSourcePathsOutOfEffectFile( - Q3DStudio::CFilePath::GetAbsolutePath(theSourceFile), + Q3DStudio::CFilePath::GetAbsolutePath(theSourceFile).toQString(), theEffectFileSourcePaths); CFilePath theFileDir( diff --git a/src/Authoring/Studio/Palettes/Action/ActionModel.cpp b/src/Authoring/Studio/Palettes/Action/ActionModel.cpp index 556215de..276f7d03 100644 --- a/src/Authoring/Studio/Palettes/Action/ActionModel.cpp +++ b/src/Authoring/Studio/Palettes/Action/ActionModel.cpp @@ -190,28 +190,28 @@ QString ActionModel::actionString(const Qt3DSDMActionHandle &action) const Qt3DSDMEventHandle eventHandle = bridge->ResolveEvent(actionInfo); if (eventHandle.Valid()) eventFormalName = - QString::fromWCharArray(bridge->GetEventInfo(eventHandle).m_FormalName.wide_str()); + bridge->GetEventInfo(eventHandle).m_FormalName; // Query the asset name QString assetName = tr("[Unknown]"); - assetName = bridge->GetName(actionInfo.m_Owner).toQString(); + assetName = bridge->GetName(actionInfo.m_Owner); const auto sourceInstance = bridge->GetInstance(actionInfo.m_Owner, actionInfo.m_TriggerObject); const auto targetInstance = bridge->GetInstance(actionInfo.m_Owner, actionInfo.m_TargetObject); QString sourceName = sourceInstance.Valid() - ? bridge->GetName(sourceInstance).toQString() + ? bridge->GetName(sourceInstance) : tr("[Unknown Source]"); QString targetName = targetInstance.Valid() - ? bridge->GetName(targetInstance).toQString() + ? bridge->GetName(targetInstance) : tr("[Unknown Target]"); // Query the action name QString handlerFormalName(tr("[Unknown Handler]")); const auto handlerHandle = bridge->ResolveHandler(actionInfo); if (handlerHandle.Valid()) - handlerFormalName = QString::fromWCharArray(bridge->GetHandlerInfo(handlerHandle).m_FormalName.wide_str()); + handlerFormalName = bridge->GetHandlerInfo(handlerHandle).m_FormalName; // Format the strings if (actionInfo.m_Owner == sourceInstance) { diff --git a/src/Authoring/Studio/Palettes/Action/ActionView.cpp b/src/Authoring/Studio/Palettes/Action/ActionView.cpp index 58cb7b75..b41080ce 100644 --- a/src/Authoring/Studio/Palettes/Action/ActionView.cpp +++ b/src/Authoring/Studio/Palettes/Action/ActionView.cpp @@ -75,7 +75,7 @@ ActionView::ActionView(const QSize &preferredSize, QWidget *parent) m_propertyModel = new PropertyModel(this); const auto actionInfo = m_actionsModel->actionInfoAt(m_currentActionIndex); - if (actionInfo.m_Handler == L"Set Property") { + if (actionInfo.m_Handler == QLatin1String("Set Property")) { setPropertyValueInvalid(true); m_currentPropertyNameHandle = actionInfo.m_HandlerArgs.at(0); m_currentPropertyValueHandle = actionInfo.m_HandlerArgs.at(1); @@ -213,7 +213,7 @@ QString ActionView::itemText() const return tr("No Object Selected"); const auto data = m_objRefHelper->GetInfo(m_itemHandle); - return data.m_Name.toQString(); + return data.m_Name; } QColor ActionView::itemColor() const @@ -249,7 +249,7 @@ QString ActionView::targetObjectName() const GetBridge()->GetInstance(actionInfo.m_Owner, actionInfo.m_TargetObject); QString targetName = targetInstance.Valid() - ? GetBridge()->GetName(targetInstance).toQString() + ? GetBridge()->GetName(targetInstance) : tr("[Unknown Target]"); return targetName; @@ -266,7 +266,7 @@ QString ActionView::triggerObjectName() const GetBridge()->GetInstance(actionInfo.m_Owner, actionInfo.m_TriggerObject); QString sourceName = sourceInstance.Valid() - ? GetBridge()->GetName(sourceInstance).toQString() + ? GetBridge()->GetName(sourceInstance) : tr("[Unknown Source]"); return sourceName; @@ -282,14 +282,14 @@ QString ActionView::eventName() const const auto eventHandle = bridge->ResolveEvent(actionInfo); const auto eventInfo = bridge->GetEventInfo(eventHandle); - const QString formalName = QString::fromWCharArray(eventInfo.m_FormalName.wide_str()); + const QString formalName = eventInfo.m_FormalName; return formalName.isEmpty() ? tr("[Unknown Event]") : formalName; } QString ActionView::handlerName() const { if (!GetDoc()->IsValid() || !m_itemHandle.Valid()) - return QString(); + return {}; const auto actionInfo = m_actionsModel->actionInfoAt(m_currentActionIndex); const auto bridge = GetBridge(); @@ -297,7 +297,7 @@ QString ActionView::handlerName() const if (handlerHandle.Valid()) { const auto handlerInfo = bridge->GetHandlerInfo(handlerHandle); - return QString::fromWCharArray(handlerInfo.m_FormalName.wide_str()); + return handlerInfo.m_FormalName; } return tr("[Unknown Handler]"); @@ -380,8 +380,8 @@ void ActionView::addAction() // Query data model bridge to see the applicable events and actions for this instance. CClientDataModelBridge *theBridge = GetBridge(); - std::wstring theEventName = theBridge->GetDefaultEvent(m_itemHandle); - std::wstring theHandlerName = theBridge->GetDefaultHandler(m_itemHandle); + QString theEventName = theBridge->GetDefaultEvent(m_itemHandle); + QString theHandlerName = theBridge->GetDefaultHandler(m_itemHandle); Q3DStudio::SCOPED_DOCUMENT_EDITOR(*GetDoc(), QObject::tr("Add Action")) ->AddAction(GetDoc()->GetActiveSlide(), m_itemHandle, theEventName, @@ -516,7 +516,7 @@ QObject *ActionView::showEventBrowser(const QPoint &point) m_eventsBrowser->setModel(m_eventsModel); m_eventsBrowser->disconnect(); - m_eventsBrowser->selectAndExpand(QString::fromStdWString(actionInfo.m_Event)); + m_eventsBrowser->selectAndExpand(actionInfo.m_Event); CDialogs::showWidgetBrowser(this, m_eventsBrowser, point); connect(m_eventsBrowser, &EventsBrowserView::selectionChanged, @@ -552,7 +552,7 @@ QObject *ActionView::showHandlerBrowser(const QPoint &point) m_handlerBrowser->setModel(m_handlersModel); m_handlerBrowser->disconnect(); - m_handlerBrowser->selectAndExpand(QString::fromStdWString(actionInfo.m_Handler)); + m_handlerBrowser->selectAndExpand(actionInfo.m_Handler); CDialogs::showWidgetBrowser(this, m_handlerBrowser, point); connect(m_handlerBrowser, &EventsBrowserView::selectionChanged, @@ -594,9 +594,9 @@ QObject *ActionView::showEventBrowserForArgument(int handle, const QPoint &point for (Qt3DSDMEventHandle eventHandle : eventList) { if (oldValue == eventHandle.GetHandleValue()) { qt3dsdm::SEventInfo eventInfo = bridge->GetEventInfo(eventHandle); - eventName = QString::fromWCharArray(eventInfo.m_FormalName.wide_str()); + eventName = eventInfo.m_FormalName; if (eventName.isEmpty()) - eventName = QString::fromWCharArray(eventInfo.m_Name.wide_str()); + eventName = eventInfo.m_Name; } } m_fireEventsBrowser->disconnect(); @@ -618,7 +618,7 @@ void ActionView::updateFiredEvent() return; const auto actionInfo = m_actionsModel->actionInfoAt(m_currentActionIndex); - if (actionInfo.m_Handler != L"Fire Event") { + if (actionInfo.m_Handler != QLatin1String("Fire Event")) { m_firedEvent = tr("[Unknown event]"); return; } @@ -640,7 +640,7 @@ void ActionView::updateFiredEvent() theArgType = DataModelDataType::String; auto theEventHandle = get<qt3ds::QT3DSI32>(argumentInfo.m_Value); theArgValue = SValue(std::make_shared<CDataStr>( - bridge->GetEventInfo(theEventHandle).m_Name.wide_str())); + bridge->GetEventInfo(theEventHandle).m_Name)); m_firedEvent = theArgValue.toQVariant().toString(); Q_EMIT firedEventChanged(); } @@ -650,8 +650,7 @@ void ActionView::updateFiredEvent() void ActionView::updateFiredEventFromHandle(int handle) { - m_firedEvent = QString::fromWCharArray( - GetBridge()->GetEventInfo(handle).m_FormalName.wide_str()); + m_firedEvent = GetBridge()->GetEventInfo(handle).m_FormalName; Q_EMIT firedEventChanged(); } @@ -840,7 +839,7 @@ void ActionView::pasteAction() Qt3DSFile theTempAPFile = CStudioClipboard::GetActionFromClipboard(); Q3DStudio::SCOPED_DOCUMENT_EDITOR(*GetDoc(), QObject::tr("Paste Action")) - ->PasteAction(theTempAPFile.GetAbsolutePath(), m_itemHandle); + ->PasteAction(theTempAPFile.GetAbsolutePath().toQString(), m_itemHandle); updateActionStates(); } @@ -912,7 +911,7 @@ void ActionView::setEvent(const Qt3DSDMEventHandle &event) doc->GetStudioSystem() ->GetActionMetaData() ->GetEventInfo(event) - ->m_Name.wide_str()); + ->m_Name); g_StudioApp.GetCore()->ExecuteCommand(theCmd); } @@ -923,8 +922,8 @@ void ActionView::setHandler(const Qt3DSDMHandlerHandle &handler) auto doc = GetDoc(); const auto action = m_actionsModel->actionAt(m_currentActionIndex); - wstring handlerName(doc->GetStudioSystem()->GetActionMetaData()->GetHandlerInfo(handler) - ->m_Name.wide_str()); + QString handlerName(doc->GetStudioSystem()->GetActionMetaData()->GetHandlerInfo(handler) + ->m_Name); CCmdDataModelActionSetHandler *theCmd = new CCmdDataModelActionSetHandler(doc, action, handlerName); theCmd->ResetHandler(handlerName); // reset the handler args @@ -964,7 +963,7 @@ void ActionView::updateHandlerArguments() HandlerArgument argument; argument.m_handle = argHandle; argument.m_type = argMetaData->m_ArgType; - argument.m_name = QString::fromWCharArray(argumentInfo.m_Name.wide_str()); + argument.m_name = argumentInfo.m_Name; argument.m_value = argumentInfo.m_Value.toQVariant(); argument.m_completeType = argMetaData->m_CompleteType; m_handlerArguments.append(QVariant::fromValue(argument)); @@ -996,7 +995,7 @@ void ActionView::setArgumentValue(int handle, const QVariant &value) } const auto actionInfo = m_actionsModel->actionInfoAt(m_currentActionIndex); - if (actionInfo.m_Handler == L"Fire Event") { + if (actionInfo.m_Handler == QLatin1String("Fire Event")) { if (value.toInt()) updateFiredEventFromHandle(value.toInt()); } @@ -1048,7 +1047,7 @@ QStringList ActionView::slideNames() if (!m_itemHandle.Valid()) return {}; - std::list<Q3DStudio::CString> outSlideNames; + std::list<QString> outSlideNames; QStringList slideNames; CClientDataModelBridge *theBridge = GetBridge(); const auto action = m_actionsModel->actionAt(m_currentActionIndex); @@ -1056,7 +1055,7 @@ QStringList ActionView::slideNames() theBridge->GetSlideNamesOfAction(action, outSlideNames); for (auto slideName : outSlideNames) - slideNames.append(slideName.toQString()); + slideNames.append(slideName); return slideNames; } diff --git a/src/Authoring/Studio/Palettes/Action/EventsBrowserView.cpp b/src/Authoring/Studio/Palettes/Action/EventsBrowserView.cpp index 7dcb682d..ae67c160 100644 --- a/src/Authoring/Studio/Palettes/Action/EventsBrowserView.cpp +++ b/src/Authoring/Studio/Palettes/Action/EventsBrowserView.cpp @@ -27,7 +27,7 @@ ****************************************************************************/ #include "EventsBrowserView.h" -#include "CColor.h" +#include <QtGui/qcolor.h> #include "EventsModel.h" #include "Literals.h" #include "StudioUtils.h" diff --git a/src/Authoring/Studio/Palettes/Action/EventsModel.cpp b/src/Authoring/Studio/Palettes/Action/EventsModel.cpp index 6d8e4b19..b02cf3e7 100644 --- a/src/Authoring/Studio/Palettes/Action/EventsModel.cpp +++ b/src/Authoring/Studio/Palettes/Action/EventsModel.cpp @@ -55,25 +55,25 @@ void EventsModel::setEventList(const qt3dsdm::TEventHandleList &eventList) qt3dsdm::SEventInfo theEvent = theBridge->GetEventInfo(*thePos); CategoryInfo category; - category.name = QString::fromWCharArray(theEvent.m_Category.wide_str()); + category.name = (theEvent.m_Category); if (!m_events.contains(category.name)) { qt3dsdm::SCategoryInfo theCategoryMetaData = studioSystem->GetActionMetaData() ->GetEventCategory(theEvent.m_Category); - category.icon = QString::fromWCharArray(theCategoryMetaData.m_Icon.wide_str()); - category.highlightIcon = QString::fromWCharArray(theCategoryMetaData.m_HighlightIcon.wide_str()); - category.description = QString::fromWCharArray(theCategoryMetaData.m_Description.wide_str()); + category.icon = theCategoryMetaData.m_Icon; + category.highlightIcon = theCategoryMetaData.m_HighlightIcon; + category.description = theCategoryMetaData.m_Description; m_categories.append(category); m_rowCount++; } EventInfo eventInfo; // Use the formal name to display, but if the formal name is not set, use the name instead - eventInfo.name = QString::fromWCharArray(theEvent.m_FormalName.wide_str()); + eventInfo.name = theEvent.m_FormalName; if (eventInfo.name.isEmpty()) - eventInfo.name = QString::fromWCharArray(theEvent.m_Name.wide_str()); + eventInfo.name = theEvent.m_Name; eventInfo.handle = *thePos; - eventInfo.description = QString::fromWCharArray(theEvent.m_Description.wide_str()); + eventInfo.description = (theEvent.m_Description); m_events[category.name].append(eventInfo); m_rowCount++; @@ -97,25 +97,25 @@ void EventsModel::setHandlerList(const qt3dsdm::THandlerHandleList &handlerList) qt3dsdm::SHandlerInfo handlerInfo = theBridge->GetHandlerInfo(*thePos); CategoryInfo category; - category.name = QString::fromWCharArray(handlerInfo.m_Category.wide_str()); + category.name = (handlerInfo.m_Category); if (!m_events.contains(category.name)) { qt3dsdm::SCategoryInfo theCategoryMetaData = studioSystem->GetActionMetaData() ->GetHandlerCategory(handlerInfo.m_Category); - category.icon = QString::fromWCharArray(theCategoryMetaData.m_Icon.wide_str()); - category.highlightIcon = QString::fromWCharArray(theCategoryMetaData.m_HighlightIcon.wide_str()); - category.description = QString::fromWCharArray(theCategoryMetaData.m_Description.wide_str()); + category.icon = theCategoryMetaData.m_Icon; + category.highlightIcon = theCategoryMetaData.m_HighlightIcon; + category.description = theCategoryMetaData.m_Description; m_categories.append(category); m_rowCount++; } EventInfo eventInfo; // Use the formal name to display, but if the formal name is not set, use the name instead - eventInfo.name = QString::fromWCharArray(handlerInfo.m_FormalName.wide_str()); + eventInfo.name = handlerInfo.m_FormalName; if (eventInfo.name.isEmpty()) - eventInfo.name = QString::fromWCharArray(handlerInfo.m_Name.wide_str()); + eventInfo.name = handlerInfo.m_Name; eventInfo.handle = *thePos; - eventInfo.description = QString::fromWCharArray(handlerInfo.m_Description.wide_str()); + eventInfo.description = handlerInfo.m_Description; m_events[category.name].append(eventInfo); m_rowCount++; diff --git a/src/Authoring/Studio/Palettes/Action/PropertyModel.cpp b/src/Authoring/Studio/Palettes/Action/PropertyModel.cpp index da2c13fe..4473df2b 100644 --- a/src/Authoring/Studio/Palettes/Action/PropertyModel.cpp +++ b/src/Authoring/Studio/Palettes/Action/PropertyModel.cpp @@ -72,11 +72,8 @@ void PropertyModel::setAction(const qt3dsdm::Qt3DSDMActionHandle &action) if (propertyMetaInfo->m_IsHidden == false) { PropertyInfo property; property.m_handle = propertyMetaInfo->m_Property; - property.m_name = QString::fromWCharArray( - propertySystem->GetFormalName(instance, - property.m_handle).wide_str()); - property.m_nameId = QString::fromWCharArray( - propertySystem->GetName(property.m_handle).wide_str()); + property.m_name = propertySystem->GetFormalName(instance, property.m_handle); + property.m_nameId = propertySystem->GetName(property.m_handle); property.m_type = propertyMetaInfo->GetDataType(); property.m_additionalType = propertyMetaInfo->GetAdditionalType(); @@ -105,11 +102,11 @@ void PropertyModel::setAction(const qt3dsdm::Qt3DSDMActionHandle &action) break; } case qt3dsdm::AdditionalMetaDataType::Font: { - std::vector<Q3DStudio::CString> fontNames; + std::vector<QString> fontNames; doc->GetProjectFonts(fontNames); QStringList possibleValues; for (const auto &fontName: fontNames) - possibleValues.append(fontName.toQString()); + possibleValues.append(fontName); property.m_possibleValues = possibleValues; break; } diff --git a/src/Authoring/Studio/Palettes/BasicObjects/BasicObjectsView.cpp b/src/Authoring/Studio/Palettes/BasicObjects/BasicObjectsView.cpp index e3b35963..bfa2af71 100644 --- a/src/Authoring/Studio/Palettes/BasicObjects/BasicObjectsView.cpp +++ b/src/Authoring/Studio/Palettes/BasicObjects/BasicObjectsView.cpp @@ -28,7 +28,7 @@ #include "BasicObjectsView.h" #include "BasicObjectsModel.h" -#include "CColor.h" +#include <QtGui/qcolor.h> #include "Literals.h" #include "StudioPreferences.h" #include "StudioUtils.h" diff --git a/src/Authoring/Studio/Palettes/Inspector/ChooserModelBase.cpp b/src/Authoring/Studio/Palettes/Inspector/ChooserModelBase.cpp index f20c3425..d09c4bd2 100644 --- a/src/Authoring/Studio/Palettes/Inspector/ChooserModelBase.cpp +++ b/src/Authoring/Studio/Palettes/Inspector/ChooserModelBase.cpp @@ -152,7 +152,7 @@ QVariant ChooserModelBase::data(const QModelIndex &index, int role) const void ChooserModelBase::setCurrentFile(const QString &path) { const auto doc = g_StudioApp.GetCore()->GetDoc(); - const QDir documentDir(doc->GetDocumentDirectory().toQString()); + const QDir documentDir(doc->GetDocumentDirectory()); const QString fullPath = QDir::cleanPath(documentDir.filePath(path)); if (fullPath != m_currentFile) { @@ -379,7 +379,7 @@ bool ChooserModelBase::isExpanded(const QModelIndex &modelIndex) const EStudioObjectType ChooserModelBase::getIconType(const QString &path) const { - return Q3DStudio::ImportUtils::GetObjectFileTypeForFile(Q3DStudio::CFilePath(path)).m_IconType; + return Q3DStudio::ImportUtils::GetObjectFileTypeForFile(path).m_IconType; } QString ChooserModelBase::specialDisplayName(const ChooserModelBase::TreeItem &item) const diff --git a/src/Authoring/Studio/Palettes/Inspector/GuideInspectable.cpp b/src/Authoring/Studio/Palettes/Inspector/GuideInspectable.cpp index 01b0f25d..b22e7fb2 100644 --- a/src/Authoring/Studio/Palettes/Inspector/GuideInspectable.cpp +++ b/src/Authoring/Studio/Palettes/Inspector/GuideInspectable.cpp @@ -188,9 +188,9 @@ EStudioObjectType SGuideInspectableImpl::GetObjectType() return OBJTYPE_GUIDE; } -Q3DStudio::CString SGuideInspectableImpl::GetName() +QString SGuideInspectableImpl::GetName() { - return L"Guide"; + return QStringLiteral("Guide"); } long SGuideInspectableImpl::GetGroupCount() diff --git a/src/Authoring/Studio/Palettes/Inspector/GuideInspectable.h b/src/Authoring/Studio/Palettes/Inspector/GuideInspectable.h index f454e9b8..df95458d 100644 --- a/src/Authoring/Studio/Palettes/Inspector/GuideInspectable.h +++ b/src/Authoring/Studio/Palettes/Inspector/GuideInspectable.h @@ -52,7 +52,7 @@ public: Q3DStudio::IDocumentReader &Reader() const; // Interface EStudioObjectType GetObjectType() override; - Q3DStudio::CString GetName() override; + QString GetName() override; long GetGroupCount() override; CInspectorGroup *GetGroup(long) override; bool IsValid() const override; diff --git a/src/Authoring/Studio/Palettes/Inspector/ImageChooserView.cpp b/src/Authoring/Studio/Palettes/Inspector/ImageChooserView.cpp index 2863ae5f..158941af 100644 --- a/src/Authoring/Studio/Palettes/Inspector/ImageChooserView.cpp +++ b/src/Authoring/Studio/Palettes/Inspector/ImageChooserView.cpp @@ -119,7 +119,7 @@ void ImageChooserView::showEvent(QShowEvent *event) const auto imageInstance = doc->GetDocumentReader().GetInstanceForGuid(guid); if (imageInstance.Valid()) { - const QString path = doc->GetDocumentReader().GetSourcePath(imageInstance).toQString(); + const QString path = doc->GetDocumentReader().GetSourcePath(imageInstance); // If path is renderable id, we need to resolve the actual path const QString renderablePath = g_StudioApp.getRenderableAbsolutePath(path); diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectableBase.h b/src/Authoring/Studio/Palettes/Inspector/InspectableBase.h index 34973393..f08d87d4 100644 --- a/src/Authoring/Studio/Palettes/Inspector/InspectableBase.h +++ b/src/Authoring/Studio/Palettes/Inspector/InspectableBase.h @@ -57,7 +57,7 @@ public: // Interface virtual EStudioObjectType GetObjectType() = 0; // virtual std::wstring GetTypeString() const { return L""; } - virtual Q3DStudio::CString GetName() = 0; + virtual QString GetName() = 0; virtual long GetGroupCount() = 0; virtual CInspectorGroup *GetGroup(long inIndex) = 0; virtual bool IsValid() const = 0; diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp b/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp index 1f5a7d0c..ae634e5d 100644 --- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp +++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp @@ -67,23 +67,24 @@ static QStringList renderableItems() QStringList renderables; renderables.push_back(QObject::tr("No renderable item")); const CDoc *doc = g_StudioApp.GetCore()->GetDoc(); - Q3DStudio::CString docDir = doc->GetDocumentDirectory(); + QString docDir = doc->GetDocumentDirectory(); for (SubPresentationRecord r : qAsConst(g_StudioApp.m_subpresentations)) renderables.push_back(r.m_id); // second step, find the renderable plugins. { - Q3DStudio::CFilePath pluginDir + QFileInfo pluginDir = Q3DStudio::CFilePath::CombineBaseAndRelative(docDir, "plugins"); - if (pluginDir.Exists() && pluginDir.IsDirectory()) { - std::vector<Q3DStudio::CFilePath> dirFiles; - pluginDir.ListFilesAndDirectories(dirFiles); + if (pluginDir.exists() && pluginDir.isDir()) { + std::vector<QFileInfo> dirFiles; + Q3DStudio::CFilePath::ListFilesAndDirectories(pluginDir.canonicalPath(), dirFiles); for (size_t idx = 0, end = dirFiles.size(); idx < end; ++idx) { - if (dirFiles[idx].IsFile()) { - Q3DStudio::CFilePath relPath = - Q3DStudio::CFilePath::GetRelativePathFromBase(docDir, dirFiles[idx]); - renderables.push_back(relPath.toQString()); + if (dirFiles[idx].isFile()) { + QString relPath + = Q3DStudio::CFilePath::GetRelativePathFromBase( + docDir, dirFiles[idx].canonicalPath()); + renderables.push_back(relPath); } } } @@ -313,17 +314,17 @@ void InspectorControlModel::updateMatDataValues() void InspectorControlModel::setMaterials(std::vector<Q3DStudio::CFilePath> &materials) { m_materials.clear(); - const Q3DStudio::CString base = g_StudioApp.GetCore()->GetDoc()->GetDocumentDirectory(); + const QString base = g_StudioApp.GetCore()->GetDoc()->GetDocumentDirectory(); for (Q3DStudio::CFilePath path : materials) { const QString relativePath = path.toQString(); - const Q3DStudio::CFilePath absolutePath - = Q3DStudio::CFilePath::CombineBaseAndRelative(base, path); + const QString absolutePath + = Q3DStudio::CFilePath::CombineBaseAndRelative(base, relativePath); const QString name = g_StudioApp.GetCore()->GetDoc()->GetDocumentReader() .GetCustomMaterialName( - absolutePath.toCString()).toQString(); + absolutePath); m_materials.push_back({name, relativePath}); } @@ -364,21 +365,19 @@ void InspectorControlModel::setMatDatas(std::vector<Q3DStudio::CFilePath> &matDa && values.contains(QStringLiteral("filename"))) { if (values[QStringLiteral("presentation")] == doc->GetDocumentPath()) { if (!QFileInfo(values["path"]).exists()) { - const auto instance = sceneEditor->getMaterial( - Q3DStudio::CString::fromQString( - values[QStringLiteral("filename")])); + const auto instance + = sceneEditor->getMaterial(values[QStringLiteral("filename")]); if (instance.Valid()) { - sceneEditor->SetName(instance, Q3DStudio::CString::fromQString(name)); + sceneEditor->SetName(instance, name); needRewrite = true; } } } } - const auto nameCString = Q3DStudio::CString::fromQString(name); - bool isNewMaterial = !sceneEditor->getMaterial(nameCString).Valid(); + bool isNewMaterial = !sceneEditor->getMaterial(name).Valid(); - const auto material = sceneEditor->getOrCreateMaterial(nameCString); + const auto material = sceneEditor->getOrCreateMaterial(name); sceneEditor->setMaterialValues(name, values, textureValues); if (isNewMaterial) @@ -438,11 +437,11 @@ void InspectorControlModel::updateFontValues(InspectorControlBase *element) cons } if (fontElements.size()) { - std::vector<Q3DStudio::CString> fontNames; + std::vector<QString> fontNames; g_StudioApp.GetCore()->GetDoc()->GetProjectFonts(fontNames); QStringList possibleValues; for (const auto &fontName : fontNames) - possibleValues.append(fontName.toQString()); + possibleValues.append(fontName); for (auto fontElement : qAsConst(fontElements)) { fontElement->m_values = possibleValues; Q_EMIT fontElement->valuesChanged(); @@ -505,7 +504,7 @@ InspectorControlBase *InspectorControlModel::createMaterialTypeItem( const QStringList values = materialTypeValues(); item->m_values = values; - QString sourcePath = bridge->GetSourcePath(item->m_instance).toQString(); + QString sourcePath = bridge->GetSourcePath(item->m_instance); switch (type) { case OBJTYPE_MATERIAL: @@ -550,7 +549,7 @@ InspectorControlBase *InspectorControlModel::createShaderItem( const QStringList values = shaderValues(); item->m_values = values; - QString sourcePath = bridge->GetSourcePath(item->m_instance).toQString(); + QString sourcePath = bridge->GetSourcePath(item->m_instance); for (int matIdx = 0, end = int(m_materials.size()); matIdx < end; ++matIdx) { if (m_materials[matIdx].m_relativePath == sourcePath) @@ -580,11 +579,11 @@ InspectorControlBase *InspectorControlModel::createMatDataItem( const QStringList values = matDataValues(); item->m_values = values; - QString sourcePath = bridge->GetSourcePath(item->m_instance).toQString(); + QString sourcePath = bridge->GetSourcePath(item->m_instance); if (!sourcePath.isEmpty() && sourcePath != QLatin1String("Default")) { const auto doc = g_StudioApp.GetCore()->GetDoc(); - const auto dirPath = doc->GetDocumentDirectory().toQString(); + const auto dirPath = doc->GetDocumentDirectory(); QFileInfo fileInfo(dirPath + QStringLiteral("/") + sourcePath); if (!fileInfo.exists()) { const auto sceneEditor = g_StudioApp.GetCore()->GetDoc()->getSceneEditor(); @@ -592,12 +591,11 @@ InspectorControlBase *InspectorControlModel::createMatDataItem( if (refMaterial.Valid()) { const auto matName = sceneEditor->GetName(refMaterial); QFileInfo newFileInfo(fileInfo.absoluteDir().path() + QStringLiteral("/") - + matName.toQString() + QStringLiteral(".matdata")); + + matName + QStringLiteral(".matdata")); const QDir docDir(dirPath); const auto relPath = docDir.relativeFilePath(newFileInfo.absoluteFilePath()); - sceneEditor->setMaterialSourcePath(item->m_instance, - Q3DStudio::CString::fromQString(relPath)); - sourcePath = bridge->GetSourcePath(item->m_instance).toQString(); + sceneEditor->setMaterialSourcePath(item->m_instance, relPath); + sourcePath = bridge->GetSourcePath(item->m_instance); } } } @@ -631,17 +629,17 @@ InspectorControlBase* InspectorControlModel::createItem(Qt3DSDMInspectable *insp item->m_instance = inspectable->GetGroupInstance(groupIndex); item->m_metaProperty = metaProperty; - Q3DStudio::CString title; - title.Assign(metaProperty.m_FormalName.c_str()); - if (title.IsEmpty()) - title.Assign(metaProperty.m_Name.c_str()); - item->m_title = title.toQString(); + QString title; + title = metaProperty.m_FormalName; + if (title.isEmpty()) + title = metaProperty.m_Name; + item->m_title = title; const auto propertySystem = studio->GetPropertySystem(); item->m_dataType = propertySystem->GetDataType(metaProperty.m_Property); item->m_propertyType = static_cast<qt3dsdm::AdditionalMetaDataType::Value> (propertySystem->GetAdditionalMetaDataType(item->m_instance, metaProperty.m_Property)); - item->m_tooltip = Q3DStudio::CString(metaProperty.m_Description.c_str()).toQString(); + item->m_tooltip = metaProperty.m_Description; // \n is parsed as \\n from the material and effect files. Replace them to fix multi-line // tooltips item->m_tooltip.replace(QStringLiteral("\\n"), QStringLiteral("\n")); @@ -705,20 +703,20 @@ QString InspectorControlModel::currentControllerValue(long instance, int handle) qt3dsdm::SValue currPropVal = currentPropertyValue( instance, studio->GetPropertySystem()->GetAggregateInstancePropertyByName( - instance, qt3dsdm::TCharStr(L"controlledproperty"))); + instance, QStringLiteral("controlledproperty"))); if (!currPropVal.empty()) { - Q3DStudio::CString currPropValStr - = qt3dsdm::get<qt3dsdm::TDataStrPtr>(currPropVal)->GetData(); + QString currPropValStr + = qt3dsdm::get<qt3dsdm::TDataStrPtr>(currPropVal)->toQString(); - Q3DStudio::CString propName - = studio->GetPropertySystem()->GetName(handle).c_str(); + QString propName + = studio->GetPropertySystem()->GetName(handle); // Datainput controller name is always prepended with "$". Differentiate // between datainput and property that has the same name by searching specifically // for whitespace followed by property name. - long propNamePos = currPropValStr.find(" " + propName); - if ((propNamePos != currPropValStr.ENDOFSTRING) && (propNamePos != 0)) { - long posCtrlr = currPropValStr.substr(0, propNamePos).ReverseFind("$"); + long propNamePos = currPropValStr.indexOf(QStringLiteral(" ") + propName); + if (propNamePos != -1 && propNamePos != 0) { + long posCtrlr = currPropValStr.left(propNamePos).lastIndexOf(QLatin1Char('$')); // adjust pos if this is the first controller - property pair // in controlledproperty @@ -727,7 +725,7 @@ QString InspectorControlModel::currentControllerValue(long instance, int handle) // remove $ posCtrlr++; - return currPropValStr.substr(posCtrlr, propNamePos - posCtrlr).toQString(); + return currPropValStr.mid(posCtrlr, propNamePos - posCtrlr); } else return {}; @@ -742,22 +740,22 @@ void InspectorControlModel::updateControlledToggleState(InspectorControlBase* in // toggle if controlledproperty contains the name of this property qt3dsdm::SValue currPropVal = currentPropertyValue( inItem->m_instance, studio->GetPropertySystem()->GetAggregateInstancePropertyByName( - inItem->m_instance, qt3dsdm::TCharStr(L"controlledproperty"))); - Q3DStudio::CString currPropValStr; + inItem->m_instance, QStringLiteral("controlledproperty"))); + QString currPropValStr; if (!currPropVal.empty()) - currPropValStr = qt3dsdm::get<qt3dsdm::TDataStrPtr>(currPropVal)->GetData(); + currPropValStr = qt3dsdm::get<qt3dsdm::TDataStrPtr>(currPropVal)->toQString(); // Restore original tool tip from metadata when turning control off if (!currPropValStr.size()) { inItem->m_controlled = false; inItem->m_controller = ""; } else { - Q3DStudio::CString propName - = studio->GetPropertySystem()->GetName(inItem->m_property).c_str(); + QString propName + = studio->GetPropertySystem()->GetName(inItem->m_property); // Search specifically for whitespace followed with registered property name. // This avoids finding datainput with same name as the property, as datainput // name is always prepended with "$" - long propNamePos = currPropValStr.find(" " + propName); - if ((propNamePos == currPropValStr.ENDOFSTRING) + long propNamePos = currPropValStr.indexOf(QStringLiteral(" ") + propName); + if ((propNamePos == -1) && (propNamePos != 0)) { inItem->m_controlled = false; inItem->m_controller = ""; @@ -765,7 +763,7 @@ void InspectorControlModel::updateControlledToggleState(InspectorControlBase* in inItem->m_controlled = true; // controller name is prepended with "$" to differentiate from property // with same name. Reverse find specifically for $. - long posCtrlr = currPropValStr.substr(0, propNamePos).ReverseFind("$"); + long posCtrlr = currPropValStr.left(propNamePos).lastIndexOf(QLatin1Char('$')); // this is the first controller - property pair in controlledproperty if (posCtrlr < 0) @@ -773,8 +771,7 @@ void InspectorControlModel::updateControlledToggleState(InspectorControlBase* in // remove $ from controller name for showing it in UI posCtrlr++; - const QString ctrlName = currPropValStr.substr( - posCtrlr, propNamePos - posCtrlr).toQString(); + const QString ctrlName = currPropValStr.mid(posCtrlr, propNamePos - posCtrlr); inItem->m_controller = ctrlName; } @@ -888,7 +885,7 @@ auto InspectorControlModel::computeTree(CInspectableBase* inspectBase) QString materialSrcPath; if (instance.Valid()) - materialSrcPath = bridge->GetSourcePath(instance).toQString(); + materialSrcPath = bridge->GetSourcePath(instance); if (materialSrcPath != QLatin1String("Default") && bridge->GetSourcePath(refMaterial) != "Default") { @@ -1032,8 +1029,7 @@ void InspectorControlModel::updatePropertyValue(InspectorControlBase *element) c int selectedIndex = -1; qt3dsdm::SStringOrInt stringOrInt = qt3dsdm::get<qt3dsdm::SStringOrInt>(value); if (stringOrInt.GetType() == qt3dsdm::SStringOrIntTypes::String) - listOpt = QString::fromWCharArray(qt3dsdm::get<qt3dsdm::TDataStrPtr> - (stringOrInt.m_Value)->GetData()); + listOpt = qt3dsdm::get<qt3dsdm::TDataStrPtr>(stringOrInt.m_Value)->toQString(); else selectedSlideHandle = qt3dsdm::get<long>(stringOrInt.m_Value); @@ -1046,7 +1042,7 @@ void InspectorControlModel::updatePropertyValue(InspectorControlBase *element) c auto currentSlide = slideSystem->GetSlideByIndex(masterSlide, slideIndex); auto currentInstance = slideSystem->GetSlideInstance(currentSlide); - QString slideName = bridge->GetName(currentInstance).toQString(); + QString slideName = bridge->GetName(currentInstance); //hack to add a separator before the item if (slideIndex == 1 && itemCount > 0) slideName += "|separator"; @@ -1109,9 +1105,9 @@ void InspectorControlModel::updatePropertyValue(InspectorControlBase *element) c qt3dsdm::Qt3DSDMInstanceHandle imageInstance = doc->GetDocumentReader() .GetInstanceForGuid(guid); if (imageInstance.Valid()) { - Q3DStudio::CString path = doc->GetDocumentReader().GetSourcePath(imageInstance); - Q3DStudio::CFilePath relPath(path); - element->m_value = QVariant(relPath.GetFileName().toQString()); + QString path = doc->GetDocumentReader().GetSourcePath(imageInstance); + QFileInfo relPath(path); + element->m_value = QVariant(relPath.fileName()); } else { element->m_value = QVariant(QString("")); } @@ -1174,7 +1170,7 @@ void InspectorControlModel::updatePropertyValue(InspectorControlBase *element) c IObjectReferenceHelper *objRefHelper = doc->GetDataModelObjectReferenceHelper(); if (objRefHelper) { qt3dsdm::Qt3DSDMInstanceHandle refInstance = objRefHelper->Resolve(value, instance); - QString refName = objRefHelper->LookupObjectFormalName(refInstance).toQString(); + QString refName = objRefHelper->LookupObjectFormalName(refInstance); if (bridge->IsReferencedMaterialInstance(instance) && !refName.isEmpty()) { // get the material's object name (parent) auto parentInstance = bridge->GetParentInstance(refInstance); @@ -1289,11 +1285,11 @@ void InspectorControlModel::saveIfMaterial(qt3dsdm::Qt3DSDMInstanceHandle instan studio->GetPropertySystem()->GetInstancePropertyValue( material, bridge->GetObjectDefinitions().m_Named.m_NameProp, value); qt3dsdm::TDataStrPtr namePtr(qt3dsdm::get<qt3dsdm::TDataStrPtr>(value)); - QString materialName = QString::fromWCharArray(namePtr->GetData(), namePtr->GetLength()); + QString materialName = namePtr->toQString(); QString sourcePath; for (int i = 0; i < m_matDatas.size(); ++i) { if (m_matDatas[i].m_name == materialName) { - sourcePath = doc->GetDocumentDirectory().toQString() + QDir::separator() + sourcePath = doc->GetDocumentDirectory() + QDir::separator() + m_matDatas[i].m_relativePath; } } @@ -1308,27 +1304,27 @@ void InspectorControlModel::setMaterialTypeValue(long instance, int handle, cons Q_UNUSED(handle) const QString typeValue = value.toString(); - Q3DStudio::CString v; + QString v; bool changeMaterialFile = false; if (typeValue == getStandardMaterialString()) { - v = Q3DStudio::CString("Standard Material"); + v = QStringLiteral("Standard Material"); } else if (typeValue == getCustomMaterialString()) { if (m_materials.size() > 0) - v = Q3DStudio::CString::fromQString(m_materials[0].m_relativePath); + v = m_materials[0].m_relativePath; } else if (typeValue == getSharedMaterialString()) { - v = Q3DStudio::CString("Referenced Material"); + v = QStringLiteral("Referenced Material"); changeMaterialFile = true; } else if (typeValue == getReferencedMaterialString()) { - v = Q3DStudio::CString("Referenced Material"); + v = QStringLiteral("Referenced Material"); } const auto doc = g_StudioApp.GetCore()->GetDoc(); const auto sceneEditor = doc->getSceneEditor(); - const Q3DStudio::CString oldType = sceneEditor->GetObjectTypeName(instance); + const QString oldType = sceneEditor->GetObjectTypeName(instance); qt3dsdm::Qt3DSDMInstanceHandle refMaterial; - if (oldType == "ReferencedMaterial" && typeValue == getStandardMaterialString()) + if (oldType == QLatin1String("ReferencedMaterial") && typeValue == getStandardMaterialString()) sceneEditor->getMaterialReference(instance, refMaterial); Q3DStudio::ScopedDocumentEditor scopedEditor( @@ -1358,11 +1354,11 @@ void InspectorControlModel::setMaterialTypeValue(long instance, int handle, cons void InspectorControlModel::setShaderValue(long instance, int handle, const QVariant &value) { const QString typeValue = value.toString(); - Q3DStudio::CString v; + QString v; for (size_t matIdx = 0, end = m_materials.size(); matIdx < end; ++matIdx) { if (m_materials[matIdx].m_name == typeValue) - v = Q3DStudio::CString::fromQString(m_materials[matIdx].m_relativePath); + v = m_materials[matIdx].m_relativePath; } Q3DStudio::SCOPED_DOCUMENT_EDITOR(*g_StudioApp.GetCore()->GetDoc(), @@ -1376,25 +1372,25 @@ void InspectorControlModel::setMatDataValue(long instance, int handle, const QVa { Q_UNUSED(handle); const QString typeValue = value.toString(); - Q3DStudio::CString v; + QString strValue; QString name; - Q3DStudio::CString srcPath; + QString srcPath; QMap<QString, QString> values; QMap<QString, QMap<QString, QString>> textureValues; bool changeMaterialFile = false; if (typeValue == getDefaultMaterialString()) { - v = Q3DStudio::CString("Referenced Material"); + strValue = QStringLiteral("Referenced Material"); name = QLatin1String("Default"); srcPath = "Default"; changeMaterialFile = true; } else { for (size_t matIdx = 0, end = m_matDatas.size(); matIdx < end; ++matIdx) { if (m_matDatas[matIdx].m_name == typeValue) { - v = Q3DStudio::CString("Referenced Material"); + strValue = QStringLiteral("Referenced Material"); changeMaterialFile = true; name = m_matDatas[matIdx].m_name; - srcPath = Q3DStudio::CString::fromQString(m_matDatas[matIdx].m_relativePath); + srcPath = m_matDatas[matIdx].m_relativePath; values = m_matDatas[matIdx].m_values; textureValues = m_matDatas[matIdx].m_textureValues; break; @@ -1407,7 +1403,7 @@ void InspectorControlModel::setMatDataValue(long instance, int handle, const QVa Q3DStudio::SCOPED_DOCUMENT_EDITOR(*doc, tr("Set Material Type"))); scopedEditor->BeginAggregateOperation(); - scopedEditor->SetMaterialType(instance, v); + scopedEditor->SetMaterialType(instance, strValue); if (changeMaterialFile) { scopedEditor->setMaterialProperties(instance, name, srcPath, values, textureValues); @@ -1428,16 +1424,15 @@ void InspectorControlModel::setRenderableValue(long instance, int handle, const { qt3dsdm::SValue oldValue = currentPropertyValue(instance, handle); - QString v = value.toString(); - if (v == QObject::tr("No renderable item")) - v = QString(); + QString strValue = value.toString(); + if (strValue == QObject::tr("No renderable item")) + strValue.clear(); - if (v == qt3dsdm::get<QString>(oldValue)) + if (strValue == qt3dsdm::get<QString>(oldValue)) return; Q3DStudio::SCOPED_DOCUMENT_EDITOR(*g_StudioApp.GetCore()->GetDoc(), QObject::tr("Set Property")) - ->SetInstancePropertyValueAsRenderable(instance, handle, - Q3DStudio::CString::fromQString(v)); + ->SetInstancePropertyValueAsRenderable(instance, handle, strValue); } void InspectorControlModel::setPropertyValue(long instance, int handle, const QVariant &value, @@ -1455,17 +1450,16 @@ void InspectorControlModel::setPropertyValue(long instance, int handle, const QV m_modifiedProperty.second = 0; m_previouslyCommittedValue = {}; - Q3DStudio::CString currentName = bridge->GetName(instance); - Q3DStudio::CString newName = Q3DStudio::CString::fromQString(value.toString()); - if (!newName.IsEmpty()) { + QString currentName = bridge->GetName(instance); + QString newName = value.toString(); + if (!newName.isEmpty()) { qt3dsdm::Qt3DSDMInstanceHandle parentInstance = bridge->GetParentInstance(instance); if (!bridge->CheckNameUnique(parentInstance, instance, newName)) { - QString origNewName = newName.toQString(); + QString origNewName = newName; newName = bridge->GetUniqueChildName(parentInstance, instance, newName); // Display rename message box asynchronously so focus loss won't trigger setting // the name again - g_StudioApp.GetDialogs()->DisplayObjectRenamed(origNewName, newName.toQString(), - true); + g_StudioApp.GetDialogs()->DisplayObjectRenamed(origNewName, newName, true); } if (newName != currentName) { bool canRename = false; @@ -1473,15 +1467,15 @@ void InspectorControlModel::setPropertyValue(long instance, int handle, const QV const auto sceneEditor = g_StudioApp.GetCore()->GetDoc()->getSceneEditor(); if (sceneEditor->isInsideMaterialContainer(instance)) { const auto doc = g_StudioApp.GetCore()->GetDoc(); - const auto dirPath = doc->GetDocumentDirectory().toQString(); + const auto dirPath = doc->GetDocumentDirectory(); for (size_t matIdx = 0, end = m_matDatas.size(); matIdx < end; ++matIdx) { - if (m_matDatas[matIdx].m_name == currentName.toQString()) { + if (m_matDatas[matIdx].m_name == currentName) { QFileInfo fileInfo(dirPath + QStringLiteral("/") + m_matDatas[matIdx].m_relativePath); const QString oldFile = fileInfo.absoluteFilePath(); const QString newFile = fileInfo.absolutePath() + QStringLiteral("/") - + newName.toQString() + + newName + QStringLiteral(".matdata"); canRename = QFile::rename(oldFile, newFile); break; @@ -1530,7 +1524,7 @@ void InspectorControlModel::setPropertyValue(long instance, int handle, const QV = studio->GetPropertySystem()->GetAdditionalMetaDataType(instance, handle); if (theType == EStudioObjectType::OBJTYPE_CAMERA && - studio->GetPropertySystem()->GetName(handle) == Q3DStudio::CString("scale")) { + studio->GetPropertySystem()->GetName(handle) == QLatin1String("scale")) { const QVector3D theFloat3 = qt3dsdm::get<QVector3D>(v); if (theFloat3.x() == 0.0f || theFloat3.y() == 0.0f || theFloat3.z() == 0.0f ) v = oldValue; @@ -1614,14 +1608,13 @@ void InspectorControlModel::setSlideSelection(long instance, int handle, int ind } void InspectorControlModel::setPropertyControllerInstance( - long instance,int property, Q3DStudio::CString controllerInstance, bool controlled) + long instance,int property, const QString &controllerInstance, bool controlled) { CDoc *doc = g_StudioApp.GetCore()->GetDoc(); IObjectReferenceHelper *objRefHelper = doc->GetDataModelObjectReferenceHelper(); - Q3DStudio::CString instancepath = Q3DStudio::CString( - objRefHelper->GetObjectReferenceString(doc->GetSceneInstance(), - CRelativePathTools::EPATHTYPE_GUID, instance)); + QString instancepath = objRefHelper->GetObjectReferenceString(doc->GetSceneInstance(), + CRelativePathTools::EPATHTYPE_GUID, instance); Q_ASSERT(instancepath.size()); doc->SetInstancePropertyControlled(instance, instancepath, property, diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.h b/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.h index 823be523..f5af1ab2 100644 --- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.h +++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.h @@ -132,8 +132,8 @@ public: qt3dsdm::SValue currentPropertyValue(long instance, int handle) const; QString currentControllerValue(long instance, int handle) const; - void setPropertyControllerInstance(long instance,int handle, - Q3DStudio::CString controllerInstance, + void setPropertyControllerInstance(long instance, int handle, + const QString &controllerInstance, bool controlled); Q_INVOKABLE void setMaterialTypeValue(long instance, int handle, const QVariant &value); diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp index 153e2447..094226c0 100644 --- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp +++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp @@ -28,7 +28,7 @@ #include "InspectorControlView.h" #include "Literals.h" -#include "CColor.h" +#include <QtGui/qcolor.h> #include "Qt3DSDMValue.h" #include "StudioUtils.h" #include "InspectorControlModel.h" @@ -82,10 +82,10 @@ InspectorControlView::InspectorControlView(const QSize &preferredSize, QWidget * std::bind(&InspectorControlView::OnSelectionSet, this, std::placeholders::_1)); } -static bool isInList(const wchar_t **list, const Q3DStudio::CString &inStr) +static bool isInList(const QStringList &list, const QString &inStr) { - for (const wchar_t **item = list; item && *item; ++item) { - if (inStr.Compare(*item, Q3DStudio::CString::ENDOFSTRING, false)) + for (const QString &item : list) { + if (inStr.compare(item, Qt::CaseInsensitive) == 0) return true; } return false; @@ -93,24 +93,22 @@ static bool isInList(const wchar_t **list, const Q3DStudio::CString &inStr) void InspectorControlView::filterMaterials(std::vector<Q3DStudio::CFilePath> &materials) { - static const wchar_t *extensions[] = { - L"material", - nullptr + static const QStringList extensions = { + {"material"} }; for (size_t i = 0; i < m_fileList.size(); ++i) { - if (isInList(extensions, m_fileList[i].GetExtension())) + if (isInList(extensions, m_fileList[i].suffix())) materials.push_back(m_fileList[i]); } } void InspectorControlView::filterMatDatas(std::vector<Q3DStudio::CFilePath> &matDatas) { - static const wchar_t *extensions[] = { - L"matdata", - nullptr + static const QStringList extensions = { + {"matdata"} }; for (size_t i = 0; i < m_fileList.size(); ++i) { - if (isInList(extensions, m_fileList[i].GetExtension())) + if (isInList(extensions, m_fileList[i].suffix())) matDatas.push_back(m_fileList[i]); } } @@ -145,35 +143,33 @@ void InspectorControlView::OnTimeChanged() void InspectorControlView::onFilesChanged( const Q3DStudio::TFileModificationList &inFileModificationList) { - static const wchar_t *materialExtensions[] = { - L"material", L"matdata", - nullptr + static const QStringList materialExtensions = { + {"material"}, {"matdata"} }; - static const wchar_t *fontExtensions[] = { - L"ttf", L"otf", - nullptr + static const QStringList fontExtensions = { + {"ttf"}, {"otf"} }; bool updateFonts = false; for (size_t idx = 0, end = inFileModificationList.size(); idx < end; ++idx) { const Q3DStudio::SFileModificationRecord &record(inFileModificationList[idx]); if (record.m_FileInfo.IsFile()) { - if (isInList(materialExtensions, record.m_File.GetExtension())) { + if (isInList(materialExtensions, record.m_File.suffix())) { Q3DStudio::CFilePath relativePath( Q3DStudio::CFilePath::GetRelativePathFromBase( g_StudioApp.GetCore()->GetDoc()->GetDocumentDirectory(), - record.m_File)); + record.m_File.canonicalFilePath())); if (record.m_ModificationType == Q3DStudio::FileModificationType::Created) qt3dsdm::binary_sort_insert_unique(m_fileList, relativePath); else if (record.m_ModificationType == Q3DStudio::FileModificationType::Destroyed) qt3dsdm::binary_sort_erase(m_fileList, relativePath); - } else if (isInList(fontExtensions, record.m_File.GetExtension())) { + } else if (isInList(fontExtensions, record.m_File.suffix())) { if (record.m_ModificationType == Q3DStudio::FileModificationType::Created || record.m_ModificationType == Q3DStudio::FileModificationType::Destroyed) { updateFonts = true; } } else if (record.m_ModificationType == Q3DStudio::FileModificationType::Modified - && record.m_File.toQString() + && record.m_File.canonicalFilePath() == g_StudioApp.GetCore()->getProjectFile().getProjectFilePath()) { g_StudioApp.GetCore()->getProjectFile().loadSubpresentationsAndDatainputs( g_StudioApp.m_subpresentations, g_StudioApp.m_dataInputDialogItems); @@ -240,11 +236,11 @@ QAbstractItemModel *InspectorControlView::inspectorControlModel() const QString InspectorControlView::titleText() const { if (m_inspectableBase) { - Q3DStudio::CString theName = m_inspectableBase->GetName(); - if (theName == L"PathAnchorPoint") + QString theName = m_inspectableBase->GetName(); + if (theName == QLatin1String("PathAnchorPoint")) return tr("Anchor Point"); else - return theName.toQString(); + return theName; } return tr("No Object Selected"); } @@ -410,7 +406,7 @@ void InspectorControlView::setPropertyValueFromFilename(long instance, int handl if (name != tr("[None]")) { // Relativize the path to the project const auto doc = g_StudioApp.GetCore()->GetDoc(); - const QDir documentDir(doc->GetDocumentDirectory().toQString()); + const QDir documentDir(doc->GetDocumentDirectory()); QString relativeName = documentDir.relativeFilePath(name); value = relativeName; } @@ -431,7 +427,7 @@ QObject *InspectorControlView::showImageChooser(int handle, int instance, const Q3DStudio::SCOPED_DOCUMENT_EDITOR(*g_StudioApp.GetCore()->GetDoc(), QObject::tr("Set Property")) ->setInstanceImagePropertyValueAsRenderable( - instance, handle, Q3DStudio::CString::fromQString(renderableId)); + instance, handle, renderableId); } m_imageChooserView->hide(); }); @@ -605,7 +601,7 @@ void InspectorControlView::showDataInputChooser(int handle, int instance, const m_inspectorControlModel ->setPropertyControllerInstance( instance, handle, - Q3DStudio::CString::fromQString(controllerName), controlled); + controllerName, controlled); m_inspectorControlModel->setPropertyControlled(instance, handle); }); } diff --git a/src/Authoring/Studio/Palettes/Inspector/ObjectBrowserView.cpp b/src/Authoring/Studio/Palettes/Inspector/ObjectBrowserView.cpp index e6faa1db..162af7bc 100644 --- a/src/Authoring/Studio/Palettes/Inspector/ObjectBrowserView.cpp +++ b/src/Authoring/Studio/Palettes/Inspector/ObjectBrowserView.cpp @@ -27,7 +27,7 @@ ****************************************************************************/ #include "ObjectBrowserView.h" -#include "CColor.h" +#include <QtGui/qcolor.h> #include "Literals.h" #include "ObjectListModel.h" #include "StudioPreferences.h" diff --git a/src/Authoring/Studio/Palettes/Inspector/ObjectListModel.cpp b/src/Authoring/Studio/Palettes/Inspector/ObjectListModel.cpp index 51e65e56..127cd332 100644 --- a/src/Authoring/Studio/Palettes/Inspector/ObjectListModel.cpp +++ b/src/Authoring/Studio/Palettes/Inspector/ObjectListModel.cpp @@ -117,7 +117,7 @@ QVariant ObjectListModel::data(const QModelIndex &index, return nameForHandle(handle); } case PathReferenceRole: { - Q3DStudio::CString data; + QString data; if (startingIndex.isValid()) { data = m_objRefHelper->GetObjectReferenceString( handleForIndex(startingIndex), @@ -129,12 +129,12 @@ QVariant ObjectListModel::data(const QModelIndex &index, CRelativePathTools::EPATHTYPE_RELATIVE, handle); } - return data.toQString(); + return data; } case AbsolutePathRole: { - Q3DStudio::CString data(m_objRefHelper->GetObjectReferenceString( + QString data(m_objRefHelper->GetObjectReferenceString( m_baseHandle, CRelativePathTools::EPATHTYPE_GUID, handle)); - return data.toQString(); + return data; } case HandleRole: { return (int)handleForIndex(index); @@ -250,7 +250,7 @@ qt3dsdm::TInstanceHandleList ObjectListModel::childrenList( QString ObjectListModel::nameForHandle(const qt3dsdm::Qt3DSDMInstanceHandle &handle) const { const auto data = m_objRefHelper->GetInfo(handle); - return data.m_Name.toQString(); + return data.m_Name; } QModelIndex ObjectListModel::indexForHandle(const qt3dsdm::Qt3DSDMInstanceHandle &handle, diff --git a/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMInspectable.cpp b/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMInspectable.cpp index 1f17c44d..ab3ed435 100644 --- a/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMInspectable.cpp +++ b/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMInspectable.cpp @@ -66,7 +66,7 @@ Qt3DSDMInspectable::Qt3DSDMInspectable(CStudioApp &inApp, CCore *inCore, /** * Query the name of the inspectable item */ -Q3DStudio::CString Qt3DSDMInspectable::GetName() +QString Qt3DSDMInspectable::GetName() { CClientDataModelBridge *theBridge = m_Core->GetDoc()->GetStudioSystem()->GetClientDataModelBridge(); @@ -74,7 +74,7 @@ Q3DStudio::CString Qt3DSDMInspectable::GetName() if (m_Instance == m_DualPersonalityInstance) return theBridge->GetName(m_Instance); - Q3DStudio::CString theName = theBridge->GetName(m_Instance); + QString theName = theBridge->GetName(m_Instance); theName += " ("; theName += theBridge->GetName(m_DualPersonalityInstance); theName += ")"; @@ -128,7 +128,7 @@ TMetaDataPropertyHandleList Qt3DSDMInspectable::GetGroupProperties(long inIndex) qt3dsdm::IPropertySystem &thePropertySystem( *m_Core->GetDoc()->GetStudioSystem()->GetPropertySystem()); // get name of the current group fofr filtering - Option<qt3dsdm::TCharStr> theGroupFilterName = + Option<QString> theGroupFilterName = theMetaData.GetGroupFilterNameForInstance(GetGroupInstance(inIndex), inIndex); long theGroupCount = GetGroupCount(); @@ -187,18 +187,15 @@ TMetaDataPropertyHandleList Qt3DSDMInspectable::GetGroupProperties(long inIndex) */ QString Qt3DSDMInspectable::GetGroupName(long inGroupIndex) { - std::vector<TCharStr> theGroupNames; + std::vector<QString> theGroupNames; IMetaData &theMetaData = *m_Core->GetDoc()->GetStudioSystem()->GetActionMetaData(); theMetaData.GetGroupNamesForInstance(GetGroupInstance(inGroupIndex), theGroupNames); size_t theIndex = inGroupIndex; - if (theGroupNames.size() > theIndex) { - Q3DStudio::CString theName = theGroupNames[inGroupIndex].wide_str(); - return theName.toQString(); - } else { - return QObject::tr("Basic Properties"); - } + if (theGroupNames.size() > theIndex) + return theGroupNames[inGroupIndex]; + return QObject::tr("Basic Properties"); } //============================================================================== @@ -214,10 +211,10 @@ Qt3DSDMInstanceHandle Qt3DSDMInspectable::GetGroupInstance(long inGroupIndex) EStudioObjectType Qt3DSDMInspectable::GetObjectType() { IMetaData &theMetaData = *m_Core->GetDoc()->GetStudioSystem()->GetActionMetaData(); - Option<qt3dsdm::TCharStr> theObjTypeName = theMetaData.GetTypeForInstance(m_Instance); + Option<QString> theObjTypeName = theMetaData.GetTypeForInstance(m_Instance); if (theObjTypeName.hasValue()) { ComposerObjectTypes::Enum theType = - ComposerObjectTypes::Convert(theObjTypeName->wide_str()); + ComposerObjectTypes::Convert(theObjTypeName); switch (theType) { case ComposerObjectTypes::Slide: { CDoc *theDoc = m_Core->GetDoc(); @@ -225,10 +222,10 @@ EStudioObjectType Qt3DSDMInspectable::GetObjectType() theDoc->GetStudioSystem()->GetClientDataModelBridge(); qt3dsdm::Qt3DSDMInstanceHandle theInstance = theBridge->GetOwningComponentInstance(theDoc->GetActiveSlide()); - Option<TCharStr> theObjTypeName = theMetaData.GetTypeForInstance(theInstance); + Option<QString> theObjTypeName = theMetaData.GetTypeForInstance(theInstance); if (theObjTypeName.hasValue()) { ComposerObjectTypes::Enum theType = - ComposerObjectTypes::Convert(theObjTypeName->wide_str()); + ComposerObjectTypes::Convert(theObjTypeName); if (theType == ComposerObjectTypes::Scene) return OBJTYPE_SCENE; else diff --git a/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMInspectable.h b/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMInspectable.h index 0f6dc626..d8372806 100644 --- a/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMInspectable.h +++ b/src/Authoring/Studio/Palettes/Inspector/Qt3DSDMInspectable.h @@ -56,7 +56,7 @@ public: // Constructor qt3dsdm::Qt3DSDMInstanceHandle inDualPersonalityInstance = 0); public: // CInspectableBase - Q3DStudio::CString GetName() override; + QString GetName() override; long GetGroupCount() override; CInspectorGroup *GetGroup(long) override; EStudioObjectType GetObjectType() override; diff --git a/src/Authoring/Studio/Palettes/Project/ChooseImagePropertyDlg.cpp b/src/Authoring/Studio/Palettes/Project/ChooseImagePropertyDlg.cpp index 77dbd4b9..6dfe2093 100644 --- a/src/Authoring/Studio/Palettes/Project/ChooseImagePropertyDlg.cpp +++ b/src/Authoring/Studio/Palettes/Project/ChooseImagePropertyDlg.cpp @@ -76,8 +76,7 @@ void ChooseImagePropertyDlg::fillList() for (auto &p : props) { auto metaDataType = propertySystem->GetAdditionalMetaDataType(m_instance, p); if (metaDataType == qt3dsdm::AdditionalMetaDataType::Value::Image) { - QString propName = QString::fromStdWString(propertySystem->GetFormalName(m_instance, p) - .wide_str()); + QString propName = propertySystem->GetFormalName(m_instance, p); QListWidgetItem *newItem = new QListWidgetItem(propName); newItem->setData(Qt::UserRole, QVariant(p)); m_ui->listProps->addItem(newItem); diff --git a/src/Authoring/Studio/Palettes/Project/ProjectFileSystemModel.cpp b/src/Authoring/Studio/Palettes/Project/ProjectFileSystemModel.cpp index 13fc58b3..ec63ca39 100644 --- a/src/Authoring/Studio/Palettes/Project/ProjectFileSystemModel.cpp +++ b/src/Authoring/Studio/Palettes/Project/ProjectFileSystemModel.cpp @@ -183,13 +183,13 @@ void ProjectFileSystemModel::updateReferences() SubPresentationRecord({}, doc->getPresentationId(), projectDir.relativeFilePath(doc->GetDocumentPath()))); - auto addReferencesPresentation = [this, doc, &projectPath](const Q3DStudio::CString &str) { - addPathsToReferences(projectPath, doc->GetResolvedPathToDoc(str).toQString()); + auto addReferencesPresentation = [this, doc, &projectPath](const QString &str) { + addPathsToReferences(projectPath, doc->GetResolvedPathToDoc(str)); }; - auto addReferencesProject = [this, doc, &projectPath](const Q3DStudio::CString &str) { + auto addReferencesProject = [this, doc, &projectPath](const QString &str) { addPathsToReferences( projectPath, - doc->GetCore()->getProjectFile().getResolvedPathTo(str.toQString())); + doc->GetCore()->getProjectFile().getResolvedPathTo(str)); }; auto addReferencesRenderable = [this, &projectPath, &projectPathSlash, &subpresentationRecord] (const QString &id) { @@ -358,10 +358,10 @@ bool ProjectFileSystemModel::hasValidUrlsForDropping(const QList<QUrl> &urls) co const QFileInfo fileInfo(path); if (fileInfo.isFile()) { const QString extension = fileInfo.suffix(); - return extension.compare(QLatin1String(CDialogs::GetDAEFileExtension()), + return extension.compare(CDialogs::GetDAEFileExtension(), Qt::CaseInsensitive) == 0 #ifdef QT_3DSTUDIO_FBX - || extension.compare(QLatin1String(CDialogs::GetFbxFileExtension()), + || extension.compare(CDialogs::GetFbxFileExtension(), Qt::CaseInsensitive) == 0 #endif || getIconType(path) != OBJTYPE_UNKNOWN; @@ -385,7 +385,7 @@ void ProjectFileSystemModel::showInfo(int row) if (fi.suffix() == QLatin1String("matdata")) { const auto sceneEditor = g_StudioApp.GetCore()->GetDoc()->getSceneEditor(); const auto material = sceneEditor - ->getOrCreateMaterial(Q3DStudio::CString::fromQString(fi.completeBaseName())); + ->getOrCreateMaterial(fi.completeBaseName()); QString name; QMap<QString, QString> values; QMap<QString, QMap<QString, QString>> textureValues; @@ -497,23 +497,23 @@ void ProjectFileSystemModel::importUrl(QDir &targetDir, const QUrl &url, const QString fileStem = fileInfo.baseName(); const QString outputFileName = QStringLiteral("%1.%2").arg(fileStem).arg(CDialogs::GetImportFileExtension()); - if (extension.compare(QLatin1String(CDialogs::GetDAEFileExtension()), Qt::CaseInsensitive) == 0) { + if (extension.compare(CDialogs::GetDAEFileExtension(), Qt::CaseInsensitive) == 0) { SColladaTranslator translator(sourceFile); const QDir outputDir = SFileTools::FindUniqueDestDirectory(targetDir, fileStem); const QString fullOutputFile = outputDir.filePath(outputFileName); const SImportResult importResult = - CPerformImport::TranslateToImportFile(translator, CFilePath(fullOutputFile)); + CPerformImport::TranslateToImportFile(translator, fullOutputFile); bool forceError = QFileInfo(fullOutputFile).isFile() == false; IDocumentEditor::DisplayImportErrors( sourceFile, importResult.m_Error, doc->GetImportFailedHandler(), translator.m_TranslationLog, forceError); #ifdef QT_3DSTUDIO_FBX - } else if (extension.compare(QLatin1String(CDialogs::GetFbxFileExtension()), Qt::CaseInsensitive) == 0) { + } else if (extension.compare(CDialogs::GetFbxFileExtension(), Qt::CaseInsensitive) == 0) { SFbxTranslator translator(sourceFile); const QDir outputDir = SFileTools::FindUniqueDestDirectory(targetDir, fileStem); const QString fullOutputFile = outputDir.filePath(outputFileName); const SImportResult importResult = - CPerformImport::TranslateToImportFile(translator, CFilePath(fullOutputFile)); + CPerformImport::TranslateToImportFile(translator, fullOutputFile); bool forceError = QFileInfo(fullOutputFile).isFile() == false; IDocumentEditor::DisplayImportErrors( sourceFile, importResult.m_Error, doc->GetImportFailedHandler(), @@ -551,7 +551,7 @@ void ProjectFileSystemModel::importUrl(QDir &targetDir, const QUrl &url, bool copyResult = SFileTools::FindAndCopyDestFile(targetDir, sourceFile, destPath); Q_ASSERT(copyResult); - if (CDialogs::isPresentationFileExtension(extension.toLatin1().data())) { + if (CDialogs::isPresentationFileExtension(extension)) { // Don't override id with empty if it is already added, which can happen when // multi-importing both presentation and its subpresentation if (!outPresentationNodes.contains(destPath)) @@ -565,19 +565,19 @@ void ProjectFileSystemModel::importUrl(QDir &targetDir, const QUrl &url, } // For effect and custom material files, automatically copy related resources - if (CDialogs::IsEffectFileExtension(extension.toLatin1().data()) - || CDialogs::IsMaterialFileExtension(extension.toLatin1().data())) { - std::vector<Q3DStudio::CString> effectFileSourcePaths; + if (CDialogs::IsEffectFileExtension(extension) + || CDialogs::IsMaterialFileExtension(extension)) { + std::vector<QString> effectFileSourcePaths; doc->GetDocumentReader().ParseSourcePathsOutOfEffectFile( - Q3DStudio::CFilePath::GetAbsolutePath(CFilePath(sourceFile)), + QFileInfo(sourceFile).absoluteFilePath(), effectFileSourcePaths); const QDir fileDir = QFileInfo(sourceFile).dir(); const QDir projectDir(g_StudioApp.GetCore()->getProjectFile().getProjectPath()); for (const auto &effectFile : effectFileSourcePaths) { - const QString sourcePath = fileDir.filePath(effectFile.toQString()); - const QString resultPath = projectDir.filePath(effectFile.toQString()); + const QString sourcePath = fileDir.filePath(effectFile); + const QString resultPath = projectDir.filePath(effectFile); const QFileInfo resultFileInfo(resultPath); if (!resultFileInfo.exists()) { @@ -760,8 +760,7 @@ bool ProjectFileSystemModel::isExpanded(const QModelIndex &modelIndex) const EStudioObjectType ProjectFileSystemModel::getIconType(const QString &path) const { - Q3DStudio::CFilePath filePath(Q3DStudio::CString::fromQString(path)); - return Q3DStudio::ImportUtils::GetObjectFileTypeForFile(filePath).m_IconType; + return Q3DStudio::ImportUtils::GetObjectFileTypeForFile(path).m_IconType; } QString ProjectFileSystemModel::getIconName(const QString &path) const diff --git a/src/Authoring/Studio/Palettes/Project/ProjectView.cpp b/src/Authoring/Studio/Palettes/Project/ProjectView.cpp index 1cbc6747..dca995e8 100644 --- a/src/Authoring/Studio/Palettes/Project/ProjectView.cpp +++ b/src/Authoring/Studio/Palettes/Project/ProjectView.cpp @@ -343,9 +343,8 @@ void ProjectView::copyPath(int row) const return; const auto path = m_ProjectModel->filePath(row); const auto doc = g_StudioApp.GetCore()->GetDoc(); - const auto relativePath = doc->GetRelativePathToDoc( - Q3DStudio::CFilePath(Q3DStudio::CString::fromQString(path))); - CStudioClipboard::CopyTextToClipboard(relativePath.toQString()); + const auto relativePath = doc->GetRelativePathToDoc(path); + CStudioClipboard::CopyTextToClipboard(relativePath); } void ProjectView::copyFullPath(int row) const @@ -360,7 +359,7 @@ bool ProjectView::isGroup(int row) const { if (row == -1) return false; - Q3DStudio::CFilePath path(Q3DStudio::CString::fromQString(m_ProjectModel->filePath(row))); + QString path(m_ProjectModel->filePath(row)); return Q3DStudio::ImportUtils::GetObjectFileTypeForFile(path).m_ObjectType == OBJTYPE_GROUP; } diff --git a/src/Authoring/Studio/Palettes/Slide/SlideModel.cpp b/src/Authoring/Studio/Palettes/Slide/SlideModel.cpp index 75d5a266..710dd4b8 100644 --- a/src/Authoring/Studio/Palettes/Slide/SlideModel.cpp +++ b/src/Authoring/Studio/Palettes/Slide/SlideModel.cpp @@ -326,7 +326,7 @@ QString SlideModel::slideName(const qt3dsdm::Qt3DSDMSlideHandle &handle) const if (!doc->IsValid()) return {}; const auto instanceHandle = doc->GetStudioSystem()->GetSlideSystem()->GetSlideInstance(handle); - return GetBridge()->GetName(instanceHandle).toQString(); + return GetBridge()->GetName(instanceHandle); } void SlideModel::setSlideName(const qt3dsdm::Qt3DSDMSlideHandle &handle, const QString &name) @@ -373,7 +373,7 @@ void SlideModel::refreshSlideLabel(qt3dsdm::Qt3DSDMInstanceHandle instanceHandle qt3dsdm::Qt3DSDMSlideHandle slideHandle = m_slideLookupHash.value(instanceHandle); for (int i = 0; i < m_slides.size(); ++i) { if (m_slides[i] == slideHandle) { - setData(index(i, 0), GetBridge()->GetName(instanceHandle).toQString(), + setData(index(i, 0), GetBridge()->GetName(instanceHandle), SlideModel::NameRole); } } diff --git a/src/Authoring/Studio/Palettes/Slide/SlideView.cpp b/src/Authoring/Studio/Palettes/Slide/SlideView.cpp index 19695809..408a1da1 100644 --- a/src/Authoring/Studio/Palettes/Slide/SlideView.cpp +++ b/src/Authoring/Studio/Palettes/Slide/SlideView.cpp @@ -27,7 +27,7 @@ ****************************************************************************/ #include "SlideView.h" -#include "CColor.h" +#include <QtGui/qcolor.h> #include "Core.h" #include "Dispatch.h" #include "Doc.h" @@ -467,7 +467,7 @@ void SlideView::rebuildSlideList(const qt3dsdm::Qt3DSDMSlideHandle &inActiveSlid const auto instanceHandle = GetDoc()->GetStudioSystem()->GetSlideSystem()->GetSlideInstance(theSlideHandle); m_SlidesModel->setData(index, - GetBridge()->GetName(instanceHandle).toQString(), + GetBridge()->GetName(instanceHandle), SlideModel::NameRole); // This slide is the active slide if (theSlideHandle == m_ActiveSlideHandle) { diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/EmptyTimelineTimebar.cpp b/src/Authoring/Studio/Palettes/Timeline/Bindings/EmptyTimelineTimebar.cpp index 8b2ea242..d96e274f 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/EmptyTimelineTimebar.cpp +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/EmptyTimelineTimebar.cpp @@ -82,7 +82,7 @@ void CEmptyTimelineTimebar::RollbackTimeChange() { } -::CColor CEmptyTimelineTimebar::GetTimebarColor() +QColor CEmptyTimelineTimebar::GetTimebarColor() { return CStudioPreferences::GetObjectTimebarColor(); } diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/EmptyTimelineTimebar.h b/src/Authoring/Studio/Palettes/Timeline/Bindings/EmptyTimelineTimebar.h index 1ddc261d..522721cd 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/EmptyTimelineTimebar.h +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/EmptyTimelineTimebar.h @@ -58,7 +58,7 @@ public: void ChangeTime(long inTime, bool inSetStart) override; void CommitTimeChange() override; void RollbackTimeChange() override; - ::CColor GetTimebarColor() override; + QColor GetTimebarColor() override; Q3DStudio::CString GetTimebarComment() override; void SetTimebarComment(const Q3DStudio::CString &inComment) override; void SetTimebarTime(ITimeChangeCallback *inCallback = nullptr) override; diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/GroupTimelineItemBinding.cpp b/src/Authoring/Studio/Palettes/Timeline/Bindings/GroupTimelineItemBinding.cpp index a860b24c..d2746158 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/GroupTimelineItemBinding.cpp +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/GroupTimelineItemBinding.cpp @@ -96,8 +96,8 @@ bool CGroupTimelineItemBinding::IsImported() const ->GetSourcePathProperty(), theValue)) { qt3dsdm::TDataStrPtr theSrcPath(qt3dsdm::get<qt3dsdm::TDataStrPtr>(theValue)); - Q3DStudio::CFilePath theFilePath(theSrcPath->GetData()); - if (theFilePath.GetExtension() == CDialogs::GetWideImportFileExtension()) + QFileInfo theFilePath(theSrcPath->toQString()); + if (theFilePath.suffix() == CDialogs::GetImportFileExtension()) return true; } // If it is, check to be sure that diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/ITimelineItemBinding.h b/src/Authoring/Studio/Palettes/Timeline/Bindings/ITimelineItemBinding.h index 02979934..0f8fcdde 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/ITimelineItemBinding.h +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/ITimelineItemBinding.h @@ -107,7 +107,7 @@ public: // ContextMenu virtual bool IsValidTransaction(EUserTransaction inTransaction) = 0; virtual void PerformTransaction(EUserTransaction inTransaction) = 0; - virtual Q3DStudio::CString GetObjectPath() = 0; + virtual QString GetObjectPath() = 0; virtual bool IsExternalizeable() { return false; } virtual void Externalize() {} diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/ITimelineItemProperty.h b/src/Authoring/Studio/Palettes/Timeline/Bindings/ITimelineItemProperty.h index 72488480..039f1ef9 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/ITimelineItemProperty.h +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/ITimelineItemProperty.h @@ -48,7 +48,7 @@ class ITimelineItemProperty public: virtual ~ITimelineItemProperty() {} - virtual Q3DStudio::CString GetName() const = 0; + virtual QString GetName() const = 0; virtual bool IsMaster() const = 0; virtual qt3dsdm::TDataTypePair GetType() const = 0; virtual float GetMaximumValue() const = 0; diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/ITimelineTimebar.h b/src/Authoring/Studio/Palettes/Timeline/Bindings/ITimelineTimebar.h index 01c41155..3044dcab 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/ITimelineTimebar.h +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/ITimelineTimebar.h @@ -33,9 +33,10 @@ #include "Qt3DSString.h" +#include <QtGui/qcolor.h> + class ITimeChangeCallback; -class CColor; //============================================================================= /** @@ -64,7 +65,7 @@ public: virtual void CommitTimeChange() = 0; virtual void RollbackTimeChange() = 0; // - virtual CColor GetTimebarColor() = 0; + virtual QColor GetTimebarColor() = 0; virtual Q3DStudio::CString GetTimebarComment() = 0; virtual void SetTimebarComment(const Q3DStudio::CString &inComment) = 0; virtual void SetTimebarTime(ITimeChangeCallback *inCallback = nullptr) = 0; diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/ImageTimelineItemBinding.cpp b/src/Authoring/Studio/Palettes/Timeline/Bindings/ImageTimelineItemBinding.cpp index ac0fa169..3f8a5ca1 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/ImageTimelineItemBinding.cpp +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/ImageTimelineItemBinding.cpp @@ -48,12 +48,12 @@ ITimelineTimebar *CImageTimelineItemBinding::GetTimebar() return new CEmptyTimelineTimebar(); } -Q3DStudio::CString CImageTimelineItemBinding::GetName() const +QString CImageTimelineItemBinding::GetName() const { return m_Name; } -void CImageTimelineItemBinding::SetName(const Q3DStudio::CString &inName) +void CImageTimelineItemBinding::SetName(const QString &inName) { m_Name = inName; } diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/ImageTimelineItemBinding.h b/src/Authoring/Studio/Palettes/Timeline/Bindings/ImageTimelineItemBinding.h index b9343872..2c011341 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/ImageTimelineItemBinding.h +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/ImageTimelineItemBinding.h @@ -56,8 +56,8 @@ public: // Qt3DSDMTimelineItemBinding ITimelineTimebar *GetTimebar() override; - Q3DStudio::CString GetName() const override; - void SetName(const Q3DStudio::CString &inName) override; + QString GetName() const override; + void SetName(const QString &inName) override; EStudioObjectType GetObjectType() const override; bool ShowToggleControls() const override; bool OpenAssociatedEditor() override; @@ -69,7 +69,7 @@ public: qt3dsdm::Qt3DSDMPropertyHandle GetPropertyHandle() const { return m_PropertyHandle; } protected: - Q3DStudio::CString m_Name; + QString m_Name; qt3dsdm::Qt3DSDMPropertyHandle m_PropertyHandle; }; diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/LayerTimelineItemBinding.cpp b/src/Authoring/Studio/Palettes/Timeline/Bindings/LayerTimelineItemBinding.cpp index 79d5da54..6f1ed44e 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/LayerTimelineItemBinding.cpp +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/LayerTimelineItemBinding.cpp @@ -53,7 +53,7 @@ using namespace qt3dsdm; namespace { bool ImageSlotIsFilled(qt3dsdm::IPropertySystem *inPropertySystem, Qt3DSDMInstanceHandle inInstance, - const TCharStr &inStr) + const QString &inStr) { Qt3DSDMPropertyHandle theProperty = inPropertySystem->GetAggregateInstancePropertyByName(inInstance, inStr); @@ -84,8 +84,8 @@ CLayerTimelineItemBinding::CLayerTimelineItemBinding(CTimelineTranslationManager thePropertySystem->GetAdditionalMetaDataType(inDataHandle, theProperty); if (theAdditionalMetaDataType == AdditionalMetaDataType::Image) { - TCharStr theName(thePropertySystem->GetName(theProperty)); - TCharStr theFormalName(thePropertySystem->GetFormalName(inDataHandle, theProperty)); + QString theName(thePropertySystem->GetName(theProperty)); + QString theFormalName(thePropertySystem->GetFormalName(inDataHandle, theProperty)); TNameFormalNamePair thePair = std::make_tuple(theName, theFormalName, theProperty); m_ImageNameFormalNamePairs.push_back(thePair); @@ -165,7 +165,7 @@ CLayerTimelineItemBinding::GetImage(qt3dsdm::Qt3DSDMPropertyHandle inPropertyHan ITimelineItemBinding * CLayerTimelineItemBinding::GetOrCreateImageBinding(qt3dsdm::Qt3DSDMPropertyHandle inPropertyHandle, - const wchar_t *inName) + const QString &inName) { qt3dsdm::Qt3DSDMInstanceHandle theImageInstance = GetImage(inPropertyHandle); if (!theImageInstance.Valid()) @@ -202,7 +202,8 @@ ITimelineItemBinding *CLayerTimelineItemBinding::GetOrCreateBinding(Qt3DSDMInsta qt3dsdm::SLong4 theGuid; { Qt3DSDMPropertyHandle theTypeProperty = - thePropertySystem->GetAggregateInstancePropertyByName(instance, L"id"); + thePropertySystem->GetAggregateInstancePropertyByName( + instance, QStringLiteral("id")); SValue theIdValue; thePropertySystem->GetInstancePropertyValue(instance, theTypeProperty, theIdValue); theGuid = qt3dsdm::get<qt3dsdm::SLong4>(theIdValue); @@ -246,7 +247,7 @@ ITimelineItemBinding *CLayerTimelineItemBinding::GetOrCreateBinding(Qt3DSDMInsta m_DataHandle, std::get<0>(m_ImageNameFormalNamePairs[theSlotCursor])); return GetOrCreateImageBinding( theImageProperty, - std::get<1>(m_ImageNameFormalNamePairs[theSlotCursor]).wide_str()); + std::get<1>(m_ImageNameFormalNamePairs[theSlotCursor])); } else return m_TransMgr->GetOrCreate(instance); } diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/LayerTimelineItemBinding.h b/src/Authoring/Studio/Palettes/Timeline/Bindings/LayerTimelineItemBinding.h index 74630a64..50d9d20e 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/LayerTimelineItemBinding.h +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/LayerTimelineItemBinding.h @@ -48,7 +48,7 @@ class CStudioSystem; class CLayerTimelineItemBinding : public Qt3DSDMTimelineItemBinding { public: // Types - typedef std::tuple<qt3dsdm::TCharStr, qt3dsdm::TCharStr, qt3dsdm::Qt3DSDMPropertyHandle> + typedef std::tuple<QString, QString, qt3dsdm::Qt3DSDMPropertyHandle> TNameFormalNamePair; typedef std::vector<TNameFormalNamePair> TNameFormalNamePairList; @@ -72,7 +72,7 @@ public: // Qt3DSDMTimelineItemBinding protected: qt3dsdm::Qt3DSDMInstanceHandle GetImage(qt3dsdm::Qt3DSDMPropertyHandle inPropertyHandle); ITimelineItemBinding *GetOrCreateImageBinding(qt3dsdm::Qt3DSDMPropertyHandle inPropertyHandle, - const wchar_t *inName); + const QString &inName); ITimelineItemBinding *GetOrCreateBinding(qt3dsdm::Qt3DSDMInstanceHandle instance); }; diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/MaterialTimelineItemBinding.cpp b/src/Authoring/Studio/Palettes/Timeline/Bindings/MaterialTimelineItemBinding.cpp index d34faf1b..bc664c94 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/MaterialTimelineItemBinding.cpp +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/MaterialTimelineItemBinding.cpp @@ -64,8 +64,8 @@ CMaterialTimelineItemBinding::CMaterialTimelineItemBinding(CTimelineTranslationM thePropertySystem->GetAdditionalMetaDataType(inDataHandle, theProperty); if (theAdditionalMetaDataType == AdditionalMetaDataType::Image) { - TCharStr theName(thePropertySystem->GetName(theProperty)); - TCharStr theFormalName(thePropertySystem->GetFormalName(inDataHandle, theProperty)); + QString theName(thePropertySystem->GetName(theProperty)); + QString theFormalName(thePropertySystem->GetFormalName(inDataHandle, theProperty)); TNameFormalNamePair thePair = std::make_tuple(theName, theFormalName); m_ImageNameFormalNamePairs.push_back(thePair); } @@ -93,7 +93,7 @@ bool CMaterialTimelineItemBinding::ShowToggleControls() const } bool ImageSlotIsFilled(qt3dsdm::IPropertySystem *inPropertySystem, Qt3DSDMInstanceHandle inInstance, - const TCharStr &inStr) + const QString &inStr) { Qt3DSDMPropertyHandle theProperty = inPropertySystem->GetAggregateInstancePropertyByName(inInstance, inStr); @@ -149,7 +149,7 @@ ITimelineItemBinding *CMaterialTimelineItemBinding::GetChild(long inIndex) Qt3DSDMPropertyHandle theImageProperty = thePropertySystem->GetAggregateInstancePropertyByName( m_DataHandle, std::get<0>(m_ImageNameFormalNamePairs[theSlotCursor])); return GetOrCreateImageBinding( - theImageProperty, std::get<1>(m_ImageNameFormalNamePairs[theSlotCursor]).wide_str()); + theImageProperty, std::get<1>(m_ImageNameFormalNamePairs[theSlotCursor])); } QList<ITimelineItemBinding *> CMaterialTimelineItemBinding::GetChildren() @@ -197,7 +197,7 @@ CMaterialTimelineItemBinding::GetImage(qt3dsdm::Qt3DSDMPropertyHandle inProperty ITimelineItemBinding * CMaterialTimelineItemBinding::GetOrCreateImageBinding(qt3dsdm::Qt3DSDMPropertyHandle inPropertyHandle, - const wchar_t *inName) + const QString &inName) { qt3dsdm::Qt3DSDMInstanceHandle theImageInstance = GetImage(inPropertyHandle); ITimelineItemBinding *theImageTimelineRow = m_TransMgr->GetBinding(theImageInstance); diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/MaterialTimelineItemBinding.h b/src/Authoring/Studio/Palettes/Timeline/Bindings/MaterialTimelineItemBinding.h index 9f5bebdd..98dacb25 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/MaterialTimelineItemBinding.h +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/MaterialTimelineItemBinding.h @@ -50,7 +50,7 @@ class CTimelineTranslationManager; class CMaterialTimelineItemBinding : public Qt3DSDMTimelineItemBinding { public: // Types - typedef std::tuple<qt3dsdm::TCharStr, qt3dsdm::TCharStr> TNameFormalNamePair; + typedef std::tuple<QString, QString> TNameFormalNamePair; typedef std::vector<TNameFormalNamePair> TNameFormalNamePairList; protected: // Members @@ -77,7 +77,7 @@ public: // Qt3DSDMTimelineItemBinding protected: qt3dsdm::Qt3DSDMInstanceHandle GetImage(qt3dsdm::Qt3DSDMPropertyHandle inPropertyHandle); ITimelineItemBinding *GetOrCreateImageBinding(qt3dsdm::Qt3DSDMPropertyHandle inPropertyHandle, - const wchar_t *inName); + const QString &inName); }; #endif // INCLUDED_MATERIAL_TIMELINEITEM_BINDING_H diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/PasteKeyframesCommandHelper.h b/src/Authoring/Studio/Palettes/Timeline/Bindings/PasteKeyframesCommandHelper.h index ead15d2e..495de704 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/PasteKeyframesCommandHelper.h +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/PasteKeyframesCommandHelper.h @@ -82,7 +82,7 @@ public: // Construction CClientDataModelBridge *theBridge = inDoc->GetStudioSystem()->GetClientDataModelBridge(); for (; theIter != m_CopiedKeyframeList.end(); ++theIter) { - TCharStr thePropertyName = thePropertySystem->GetName(theIter->m_Property); + QString thePropertyName = thePropertySystem->GetName(theIter->m_Property); DataModelDataType::Value thePropertyType = thePropertySystem->GetDataType(theIter->m_Property); Qt3DSDMPropertyHandle theTargetPropertyHandle = diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/PathAnchorPointTimelineItemBinding.h b/src/Authoring/Studio/Palettes/Timeline/Bindings/PathAnchorPointTimelineItemBinding.h index b806093d..06a3ead5 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/PathAnchorPointTimelineItemBinding.h +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/PathAnchorPointTimelineItemBinding.h @@ -61,8 +61,8 @@ public: // Construction bool IsShy() const override { return false; } void SetShy(bool) override {} bool IsVisibilityControlled() const override { return false; } - Q3DStudio::CString GetName() const override { return L"Anchor Point"; } - void SetName(const Q3DStudio::CString &) override {} + QString GetName() const override { return QStringLiteral("Anchor Point"); } + void SetName(const QString &) override {} }; #endif diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/PathTimelineItemBinding.cpp b/src/Authoring/Studio/Palettes/Timeline/Bindings/PathTimelineItemBinding.cpp index f646415d..207b35c5 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/PathTimelineItemBinding.cpp +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/PathTimelineItemBinding.cpp @@ -39,9 +39,11 @@ bool CPathTimelineItemBinding::IsExternalizeable() void CPathTimelineItemBinding::Externalize() { +#if RUNTIME_SPLIT_TEMPORARILY_REMOVED Q3DStudio::ScopedDocumentEditor(*m_TransMgr->GetDoc(), QObject::tr("Externalize Path Buffer"), __FILE__, __LINE__) ->ExternalizePath(GetInstance()); +#endif } bool CPathTimelineItemBinding::IsInternalizeable() @@ -52,7 +54,9 @@ bool CPathTimelineItemBinding::IsInternalizeable() void CPathTimelineItemBinding::Internalize() { +#if RUNTIME_SPLIT_TEMPORARILY_REMOVED Q3DStudio::ScopedDocumentEditor(*m_TransMgr->GetDoc(), QObject::tr("Internalize Path Buffer"), __FILE__, __LINE__) ->InternalizePath(GetInstance()); +#endif } diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp index 7fa26eaa..3d49a34c 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp @@ -140,9 +140,8 @@ bool Qt3DSDMTimelineItemBinding::IsMaster() const theQueryHandle = theReader.GetParent(m_DataHandle); // logic: you can't unlink name, so if name is linked then, this is master. - Qt3DSDMPropertyHandle theNamePropHandle = - m_StudioSystem->GetPropertySystem()->GetAggregateInstancePropertyByName(theQueryHandle, - L"name"); + Qt3DSDMPropertyHandle theNamePropHandle = m_StudioSystem->GetPropertySystem() + ->GetAggregateInstancePropertyByName(theQueryHandle, QStringLiteral("name")); return theReader.IsPropertyLinked(theQueryHandle, theNamePropHandle); } @@ -167,7 +166,7 @@ bool Qt3DSDMTimelineItemBinding::IsVisibilityControlled() const Qt3DSDMPropertyHandle theNamePropHandle = m_StudioSystem->GetPropertySystem()->GetAggregateInstancePropertyByName( - m_DataHandle, L"controlledproperty"); + m_DataHandle, QStringLiteral("controlledproperty")); if (!theNamePropHandle) return false; @@ -331,29 +330,26 @@ ITimelineTimebar *Qt3DSDMTimelineItemBinding::GetTimebar() return m_TimelineTimebar; } -Q3DStudio::CString Qt3DSDMTimelineItemBinding::GetName() const +QString Qt3DSDMTimelineItemBinding::GetName() const { if (m_StudioSystem->IsInstance(m_DataHandle) == false) - return L""; - Qt3DSDMPropertyHandle theNamePropHandle = - m_StudioSystem->GetPropertySystem()->GetAggregateInstancePropertyByName(m_DataHandle, - L"name"); + return {}; + Qt3DSDMPropertyHandle theNamePropHandle = m_StudioSystem->GetPropertySystem() + ->GetAggregateInstancePropertyByName(m_DataHandle, QStringLiteral("name")); SValue theNameValue; m_StudioSystem->GetPropertySystem()->GetInstancePropertyValue(m_DataHandle, theNamePropHandle, theNameValue); - TDataStrPtr theName = qt3dsdm::get<TDataStrPtr>(theNameValue); - - return (theName) ? Q3DStudio::CString(theName->GetData()) : ""; + return qt3dsdm::get<TDataStrPtr>(theNameValue)->toQString(); } -void Qt3DSDMTimelineItemBinding::SetName(const Q3DStudio::CString &inName) +void Qt3DSDMTimelineItemBinding::SetName(const QString &inName) { // Ignore if setting the name to what it currently is to avoid duplicate undo points if (inName == GetName()) return; // Display warning dialog if user tried to enter an empty string - if (inName.IsEmpty()) { + if (inName.isEmpty()) { QString theTitle = QObject::tr("Rename Object Error"); QString theString = QObject::tr("Object name cannot be an empty string."); g_StudioApp.GetDialogs()->DisplayMessageBox(theTitle, theString, @@ -371,7 +367,7 @@ void Qt3DSDMTimelineItemBinding::SetName(const Q3DStudio::CString &inName) *m_TransMgr->GetDoc(), QObject::tr("Set Name"))->SetName(m_DataHandle, inName, true); g_StudioApp.GetDialogs()->DisplayObjectRenamed( - inName.toQString(), theBridge->GetName(m_DataHandle).toQString()); + inName, theBridge->GetName(m_DataHandle)); return; } @@ -719,7 +715,7 @@ void Qt3DSDMTimelineItemBinding::PerformTransaction(EUserTransaction inTransacti } } -Q3DStudio::CString Qt3DSDMTimelineItemBinding::GetObjectPath() +QString Qt3DSDMTimelineItemBinding::GetObjectPath() { CDoc *theDoc = m_TransMgr->GetDoc(); // Because we are getting absolute path, the base id doesn't matter. diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.h b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.h index 5ababf96..f18259bf 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.h +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.h @@ -115,8 +115,8 @@ public: ITimelineTimebar *GetTimebar() override; // INamable - Q3DStudio::CString GetName() const override; - void SetName(const Q3DStudio::CString &inName) override; + QString GetName() const override; + void SetName(const QString &inName) override; // ITimelineItemBinding ITimelineItem *GetTimelineItem() override; @@ -142,7 +142,7 @@ public: // ContextMenu bool IsValidTransaction(EUserTransaction inTransaction) override; void PerformTransaction(EUserTransaction inTransaction) override; - Q3DStudio::CString GetObjectPath() override; + QString GetObjectPath() override; // ITimelineItemKeyframesHolder void InsertKeyframe() override; diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemProperty.cpp b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemProperty.cpp index 73a7bb7d..ea017041 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemProperty.cpp +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemProperty.cpp @@ -141,14 +141,14 @@ void Qt3DSDMTimelineItemProperty::InitializeCachedVariables(qt3dsdm::Qt3DSDMInst m_Type.second = thePropertySystem->GetAdditionalMetaDataType(inInstance, m_PropertyHandle); // Name doesn't change either. - TCharStr theFormalName = thePropertySystem->GetFormalName(inInstance, m_PropertyHandle); + QString theFormalName = thePropertySystem->GetFormalName(inInstance, m_PropertyHandle); - if (theFormalName.empty()) // fallback on property name + if (theFormalName.isEmpty()) // fallback on property name theFormalName = thePropertySystem->GetName(m_PropertyHandle); - m_Name = theFormalName.c_str(); + m_Name = theFormalName; } -Q3DStudio::CString Qt3DSDMTimelineItemProperty::GetName() const +QString Qt3DSDMTimelineItemProperty::GetName() const { return m_Name; } diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemProperty.h b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemProperty.h index 1b1524e4..effdab06 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemProperty.h +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemProperty.h @@ -57,7 +57,7 @@ public: virtual ~Qt3DSDMTimelineItemProperty(); // ITimelineProperty - Q3DStudio::CString GetName() const override; + QString GetName() const override; bool IsMaster() const override; qt3dsdm::TDataTypePair GetType() const override; float GetMaximumValue() const override; @@ -104,7 +104,7 @@ protected: CCmdDataModelSetKeyframeValue *m_SetKeyframeValueCommand; // for merging modifying keyframe values via graph qt3dsdm::TDataTypePair m_Type; - Q3DStudio::CString m_Name; + QString m_Name; std::vector<std::shared_ptr<qt3dsdm::ISignalConnection>> m_Signals; private: diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineTimebar.cpp b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineTimebar.cpp index 8c76046c..85df6075 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineTimebar.cpp +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineTimebar.cpp @@ -62,9 +62,8 @@ Qt3DSDMTimelineTimebar::Qt3DSDMTimelineTimebar( m_DataHandle, theClientDataModelBridge->GetSceneAsset().m_TimebarColor, theValue)) { qt3dsdm::SFloat3 theTimebarColor = qt3dsdm::get<qt3dsdm::SFloat3>(theValue); - m_Color.SetRGB(static_cast<int>(theTimebarColor.m_Floats[0] * 255.0f), - static_cast<int>(theTimebarColor.m_Floats[1] * 255.0f), - static_cast<int>(theTimebarColor.m_Floats[2] * 255.0f)); + m_Color.setRgbF(theTimebarColor.m_Floats[0], theTimebarColor.m_Floats[1], + theTimebarColor.m_Floats[2]); } qt3dsdm::IStudioFullSystemSignalProvider *theProvider = inTimelineTranslationManager->GetStudioSystem()->GetFullSystem()->GetSignalProvider(); @@ -91,9 +90,8 @@ void Qt3DSDMTimelineTimebar::OnPropertyChanged(qt3dsdm::Qt3DSDMInstanceHandle in theValue)) { qt3dsdm::SFloat3 theTimebarColor = qt3dsdm::get<qt3dsdm::SFloat3>(theValue); - m_Color.SetRGB(static_cast<int>(theTimebarColor.m_Floats[0] * 255.0f), - static_cast<int>(theTimebarColor.m_Floats[1] * 255.0f), - static_cast<int>(theTimebarColor.m_Floats[2] * 255.0f)); + m_Color.setRgbF(theTimebarColor.m_Floats[0], theTimebarColor.m_Floats[1], + theTimebarColor.m_Floats[2]); } else { switch (theClientDataModelBridge->GetObjectType(inInstance)) { case OBJTYPE_LAYER: diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineTimebar.h b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineTimebar.h index 49db6229..56e01724 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineTimebar.h +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineTimebar.h @@ -65,7 +65,7 @@ protected: qt3dsdm::Qt3DSDMInstanceHandle m_DataHandle; // The Instance Handle for this Timeline Timeber. qt3dsdm::Qt3DSDMPropertyHandle m_StartTime; qt3dsdm::Qt3DSDMPropertyHandle m_EndTime; - ::CColor m_Color; // Timebar color + QColor m_Color; // Timebar color Q3DStudio::CString m_Comment; // Timebar comment text std::shared_ptr<qt3dsdm::ISignalConnection> m_PropertyChangedSignal; @@ -83,7 +83,7 @@ public: void ChangeTime(long inTime, bool inSetStart) override; void CommitTimeChange() override; void RollbackTimeChange() override; - ::CColor GetTimebarColor() override { return m_Color; } + QColor GetTimebarColor() override { return m_Color; } Q3DStudio::CString GetTimebarComment() override { return m_Comment; } void SetTimebarComment(const Q3DStudio::CString &inComment) override; void SetTimebarTime(ITimeChangeCallback *inCallback = nullptr) override; diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/SlideTimelineItemBinding.cpp b/src/Authoring/Studio/Palettes/Timeline/Bindings/SlideTimelineItemBinding.cpp index 6707f717..20d298b6 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/SlideTimelineItemBinding.cpp +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/SlideTimelineItemBinding.cpp @@ -70,7 +70,7 @@ ITimelineTimebar *CSlideTimelineItemBinding::GetTimebar() return new CEmptyTimelineTimebar(); } -void CSlideTimelineItemBinding::SetName(const Q3DStudio::CString & /*inName*/) +void CSlideTimelineItemBinding::SetName(const QString & /*inName*/) { // Do nothing because name is read only } diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/SlideTimelineItemBinding.h b/src/Authoring/Studio/Palettes/Timeline/Bindings/SlideTimelineItemBinding.h index 54f01ce5..7dffc72a 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/SlideTimelineItemBinding.h +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/SlideTimelineItemBinding.h @@ -56,7 +56,7 @@ public: // Qt3DSDMTimelineItemBinding ITimelineTimebar *GetTimebar() override; - void SetName(const Q3DStudio::CString &inName) override; + void SetName(const QString &inName) override; bool IsValidTransaction(EUserTransaction inTransaction) override; // No properties diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/TimelineBreadCrumbProvider.cpp b/src/Authoring/Studio/Palettes/Timeline/Bindings/TimelineBreadCrumbProvider.cpp index ff7077aa..3c485f3e 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/TimelineBreadCrumbProvider.cpp +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/TimelineBreadCrumbProvider.cpp @@ -36,7 +36,7 @@ #include "StudioApp.h" #include "Cmd.h" #include "ResourceCache.h" -#include "CColor.h" +#include <QtGui/qcolor.h> #include "ClientDataModelBridge.h" #include "Qt3DSDMStudioSystem.h" @@ -83,10 +83,10 @@ static inline void FillBreadCrumb(SBreadCrumb &outBreadCrumb, // Determine the color outBreadCrumb.m_Color = - theIsMaster ? CColor(0, 0, 255) : CColor(0, 0, 0); // blue for master, black otherwise + theIsMaster ? QColor(0, 0, 255) : QColor(0, 0, 0); // blue for master, black otherwise // Determine the text string - outBreadCrumb.m_String = theBridge->GetName(inInstance).toQString(); + outBreadCrumb.m_String = theBridge->GetName(inInstance); outBreadCrumb.m_String += " ("; if (theIsMaster) { outBreadCrumb.m_String += QObject::tr("Master"); @@ -95,7 +95,7 @@ static inline void FillBreadCrumb(SBreadCrumb &outBreadCrumb, theSlideSystem->GetSlideByIndex(theMasterSlide, theActiveIndex); Qt3DSDMInstanceHandle theInstanceHandle = theSlideSystem->GetSlideInstance(theActiveSlide); Q_ASSERT(theInstanceHandle.Valid()); - outBreadCrumb.m_String += theBridge->GetName(theInstanceHandle).toQString(); + outBreadCrumb.m_String += theBridge->GetName(theInstanceHandle); } outBreadCrumb.m_String += ")"; } diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/TimelineTranslationManager.cpp b/src/Authoring/Studio/Palettes/Timeline/Bindings/TimelineTranslationManager.cpp index 1a191b19..955c6303 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/TimelineTranslationManager.cpp +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/TimelineTranslationManager.cpp @@ -67,36 +67,37 @@ ITimelineItemBinding *CTimelineTranslationManager::GetOrCreate(Qt3DSDMInstanceHa Qt3DSDMTimelineItemBinding *theReturn = nullptr; qt3dsdm::IPropertySystem *thePropertySystem = GetStudioSystem()->GetPropertySystem(); Qt3DSDMPropertyHandle theTypeProperty = - thePropertySystem->GetAggregateInstancePropertyByName(inInstance, L"type"); + thePropertySystem->GetAggregateInstancePropertyByName(inInstance, + QStringLiteral("type")); SValue theTypeValue; thePropertySystem->GetInstancePropertyValue(inInstance, theTypeProperty, theTypeValue); - std::wstring theWideTypeString(qt3dsdm::get<TDataStrPtr>(theTypeValue)->GetData()); + QString type(qt3dsdm::get<TDataStrPtr>(theTypeValue)->toQString()); - if (theWideTypeString == L"Material" || theWideTypeString == L"CustomMaterial" - || theWideTypeString == L"ReferencedMaterial") + if (type == QLatin1String("Material") || type == QLatin1String("CustomMaterial") + || type == QLatin1String("ReferencedMaterial")) { theReturn = new CMaterialTimelineItemBinding(this, inInstance); - else if (theWideTypeString == L"Image") + } else if (type == QLatin1String("Image")) { theReturn = new CImageTimelineItemBinding(this, inInstance); - else if (theWideTypeString == L"Group" || theWideTypeString == L"Component") + } else if (type == QLatin1String("Group") || type == QLatin1String("Component")) { theReturn = new CGroupTimelineItemBinding(this, inInstance); - else if (theWideTypeString == L"Behavior") + } else if (type == QLatin1String("Behavior")) { theReturn = new CBehaviorTimelineItemBinding(this, inInstance); - else if (theWideTypeString == L"Slide") + } else if (type == QLatin1String("Slide")) { theReturn = new CSlideTimelineItemBinding(this, inInstance); - else if (theWideTypeString == L"PathAnchorPoint") + } else if (type == QLatin1String("PathAnchorPoint")) { theReturn = new CPathAnchorPointTimelineItemBinding(this, inInstance); - else if (theWideTypeString == L"Path") + } else if (type == QLatin1String("Path")) { theReturn = new CPathTimelineItemBinding(this, inInstance); - else if (theWideTypeString == L"Layer") + } else if (type == QLatin1String("Layer")) { theReturn = new CLayerTimelineItemBinding(this, inInstance); - else if (theWideTypeString == L"Model" || theWideTypeString == L"Text" - || theWideTypeString == L"Camera" || theWideTypeString == L"Effect" - || theWideTypeString == L"Light" || theWideTypeString == L"RenderPlugin" - || theWideTypeString == L"Alias" || theWideTypeString == L"SubPath") + } else if (type == QLatin1String("Model") || type == QLatin1String("Text") + || type == QLatin1String("Camera") || type == QLatin1String("Effect") + || type == QLatin1String("Light") || type == QLatin1String("RenderPlugin") + || type == QLatin1String("Alias") || type == QLatin1String("SubPath")) { theReturn = new Qt3DSDMTimelineItemBinding(this, inInstance); - else { + } else { // Add support for additional DataModel types here. Q_ASSERT(0); } diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowManager.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowManager.cpp index 40ea3869..a68a8204 100644 --- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowManager.cpp +++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowManager.cpp @@ -85,7 +85,7 @@ RowTree *RowManager::createRowFromBinding(ITimelineItemBinding *binding, RowTree int index) { RowTree *newRow = createRow(binding->GetTimelineItem()->GetObjectType(), parentRow, - binding->GetTimelineItem()->GetName().toQString(), + binding->GetTimelineItem()->GetName(), QString(), index); // connect the new row and its binding @@ -103,7 +103,7 @@ RowTree *RowManager::createRowFromBinding(ITimelineItemBinding *binding, RowTree // create property rows for (int i = 0; i < binding->GetPropertyCount(); i++) { ITimelineItemProperty *prop_i = binding->GetProperty(i); - RowTree *propRow = getOrCreatePropertyRow(newRow, prop_i->GetName().toQString()); + RowTree *propRow = getOrCreatePropertyRow(newRow, prop_i->GetName()); // connect the property row and its binding prop_i->setRowTree(propRow); diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp index 0c5bfeed..56ae154e 100644 --- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp +++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp @@ -1041,7 +1041,7 @@ void TimelineGraphicsScene::handleCopyObjectPath() RowTree *selectedRow = m_rowManager->selectedRow(); if (selectedRow) { CStudioClipboard::CopyTextToClipboard( - selectedRow->getBinding()->GetObjectPath().toQString()); + selectedRow->getBinding()->GetObjectPath()); } } diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineWidget.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineWidget.cpp index 572c7e04..f9f95c2c 100644 --- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineWidget.cpp +++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineWidget.cpp @@ -589,7 +589,7 @@ void TimelineWidget::onAnimationCreated(qt3dsdm::Qt3DSDMInstanceHandle parentIns // create the property UI row RowTree *propRow = m_graphicsScene->rowManager() - ->getOrCreatePropertyRow(binding->getRowTree(), propBinding->GetName().toQString(), + ->getOrCreatePropertyRow(binding->getRowTree(), propBinding->GetName(), binding->getAnimatedPropertyIndex(property)); // connect the row and binding @@ -742,7 +742,7 @@ void TimelineWidget::onPropertyChanged(qt3dsdm::Qt3DSDMInstanceHandle inInstance const SDataModelSceneAsset &asset = m_bridge->GetSceneAsset(); CDoc *doc = g_StudioApp.GetCore()->GetDoc(); auto ctrldPropHandle = doc->GetPropertySystem() - ->GetAggregateInstancePropertyByName(inInstance, L"controlledproperty"); + ->GetAggregateInstancePropertyByName(inInstance, QStringLiteral("controlledproperty")); if (inProperty == asset.m_Eyeball || inProperty == asset.m_Locked || inProperty == asset.m_Shy || inProperty == asset.m_StartTime || inProperty == asset.m_EndTime @@ -855,7 +855,7 @@ void TimelineWidget::onAsyncUpdate() const auto props = m_dirtyProperties.values(instance); const auto ctrldPropHandle = doc->GetPropertySystem()->GetAggregateInstancePropertyByName( - instance, L"controlledproperty"); + instance, QStringLiteral("controlledproperty")); for (auto prop : props) { filterProperty = filterProperty || prop == asset.m_Eyeball || prop == asset.m_Locked || prop == asset.m_Shy diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.cpp index 2b5d7abe..2d476f8d 100644 --- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.cpp +++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.cpp @@ -105,9 +105,7 @@ void RowTree::initialize() [this](const QString &label) { // Update label on timeline and on model m_label = label; - // TODO: Get rid of CString APIs - auto clabel = Q3DStudio::CString::fromQString(m_label); - m_binding->GetTimelineItem()->SetName(clabel); + m_binding->GetTimelineItem()->SetName(m_label); }); } @@ -738,7 +736,7 @@ void RowTree::updateFromBinding() void RowTree::updateLabel() { if (m_binding) - m_labelItem.setLabel(m_binding->GetTimelineItem()->GetName().toQString()); + m_labelItem.setLabel(m_binding->GetTimelineItem()->GetName()); } void RowTree::setRowVisible(bool visible) diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTreeContextMenu.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTreeContextMenu.cpp index 473cfad9..4549bf9d 100644 --- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTreeContextMenu.cpp +++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTreeContextMenu.cpp @@ -181,13 +181,13 @@ void RowTreeContextMenu::addSubPresentation(QAction *action) CDoc &doc(*g_StudioApp.GetCore()->GetDoc()); qt3dsdm::Qt3DSDMInstanceHandle instance = static_cast<Qt3DSDMTimelineItemBinding *>(m_TimelineItemBinding)->GetInstance(); - Q3DStudio::CString presentationId; + QString presentationId; if (action->text() != tr("[None]")) - presentationId = Q3DStudio::CString::fromQString(action->text()); + presentationId = action->text(); if (m_RowTree->rowType() == OBJTYPE_LAYER) { qt3dsdm::Qt3DSDMPropertyHandle propHandle = doc.GetPropertySystem() - ->GetAggregateInstancePropertyByName(instance, L"sourcepath"); + ->GetAggregateInstancePropertyByName(instance, QStringLiteral("sourcepath")); Q3DStudio::SCOPED_DOCUMENT_EDITOR(doc, tr("Set layer sub-presentation")) ->SetInstancePropertyValueAsRenderable(instance, propHandle, presentationId); } else if (m_RowTree->rowType() == OBJTYPE_MATERIAL) { @@ -222,7 +222,7 @@ void RowTreeContextMenu::addSubPresentation(QAction *action) } } else if (m_RowTree->rowType() == OBJTYPE_IMAGE) { qt3dsdm::Qt3DSDMPropertyHandle propHandle = doc.GetPropertySystem() - ->GetAggregateInstancePropertyByName(instance, L"subpresentation"); + ->GetAggregateInstancePropertyByName(instance, QStringLiteral("subpresentation")); Q3DStudio::SCOPED_DOCUMENT_EDITOR(doc, tr("Set image sub-presentation")) ->SetInstancePropertyValueAsRenderable(instance, propHandle, presentationId); } @@ -319,7 +319,7 @@ void RowTreeContextMenu::makeComponent() void RowTreeContextMenu::copyObjectPath() { CStudioClipboard::CopyTextToClipboard( - m_TimelineItemBinding->GetObjectPath().toQString()); + m_TimelineItemBinding->GetObjectPath()); } bool RowTreeContextMenu::canCopyObject() const diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/TimelineToolbar.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/TimelineToolbar.cpp index 0fa1e28b..1aa3b60d 100644 --- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/TimelineToolbar.cpp +++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/TimelineToolbar.cpp @@ -379,8 +379,7 @@ void TimelineToolbar::onDataInputChange(int handle, int instance, const QString m_diLabel->setText(m_currController); qt3dsdm::SValue fullCtrlPropVal - = std::make_shared<qt3dsdm::CDataStr>( - Q3DStudio::CString::fromQString(existingCtrl)); + = std::make_shared<qt3dsdm::CDataStr>(existingCtrl); Q3DStudio::SCOPED_DOCUMENT_EDITOR(*doc, QObject::tr("Set Timeline control")) ->SetInstancePropertyValue(timeCtxRoot, ctrldPropertyHandle, fullCtrlPropVal); } diff --git a/src/Authoring/Studio/Render/Q3DSGraphObjectTranslator.cpp b/src/Authoring/Studio/Render/Q3DSGraphObjectTranslator.cpp index 47da8e9f..7366d87c 100644 --- a/src/Authoring/Studio/Render/Q3DSGraphObjectTranslator.cpp +++ b/src/Authoring/Studio/Render/Q3DSGraphObjectTranslator.cpp @@ -49,12 +49,9 @@ Q3DSGraphObjectTranslator::Q3DSGraphObjectTranslator(qt3dsdm::Qt3DSDMInstanceHan void Q3DSGraphObjectTranslator::pushTranslation(Q3DSTranslation &translation) { - Q3DStudio::CString theId = translation.reader().GetFileId(instanceHandle()); - if (theId.size() && theId.toQString() != graphObject().id()) { - qt3ds::foundation::CRegisteredString rid - = Q3DSStringTable::instance()->GetRenderStringTable() - .RegisterStr(theId.toQString()); - QByteArray data = rid.qstring().toLatin1(); + QString theId = translation.reader().GetFileId(instanceHandle()); + if (theId.size() && theId != graphObject().id()) { + QByteArray data = theId.toLatin1(); translation.presentation()->registerObject(data, &graphObject()); } setDirty(false); diff --git a/src/Authoring/Studio/Render/Q3DSTranslation.cpp b/src/Authoring/Studio/Render/Q3DSTranslation.cpp index 9af63325..8db32379 100644 --- a/src/Authoring/Studio/Render/Q3DSTranslation.cpp +++ b/src/Authoring/Studio/Render/Q3DSTranslation.cpp @@ -162,7 +162,7 @@ Q3DSTranslation::THandleTranslatorPairList &Q3DSTranslation::getTranslatorsForIn void Q3DSTranslation::markDirty(qt3dsdm::Qt3DSDMInstanceHandle instance) { // Anchor points are not handled individually. - if (m_reader.GetObjectTypeName(instance) == L"PathAnchorPoint") + if (m_reader.GetObjectTypeName(instance) == QLatin1String("PathAnchorPoint")) instance = m_assetGraph.GetParent(instance); getOrCreateTranslator(instance); @@ -179,7 +179,7 @@ void Q3DSTranslation::markPropertyDirty(qt3dsdm::Qt3DSDMInstanceHandle instance, SValue value; qt3dsdm::IPropertySystem *prop = m_doc.GetPropertySystem(); prop->GetInstancePropertyValue(instance, property, value); - QString name = QString::fromWCharArray(prop->GetName(property).wide_str()); + QString name = prop->GetName(property); // ignore these properties if (name == QLatin1String("shy")) @@ -221,16 +221,12 @@ void Q3DSTranslation::markComponentSeconds(qt3dsdm::Qt3DSDMSlideHandle) QByteArray Q3DSTranslation::getInstanceObjectId(qt3dsdm::Qt3DSDMInstanceHandle instance) { QByteArray ret; - Q3DStudio::CString theId = m_reader.GetFileId(instance); - if (!theId.size()) + QString theId = m_reader.GetFileId(instance); + if (theId.isEmpty()) theId = m_reader.GetName(instance); - if (theId.size()) { - qt3ds::foundation::CRegisteredString rid - = Q3DSStringTable::instance()->GetRenderStringTable() - .RegisterStr(theId.toQString()); - ret = rid.qstring().toLatin1(); - } + if (!theId.isEmpty()) + ret = theId.toLatin1(); // slides require component name prepended if (m_objectDefinitions.GetType(instance) == qt3dsdm::ComposerObjectTypes::Slide) { @@ -238,12 +234,11 @@ QByteArray Q3DSTranslation::getInstanceObjectId(qt3dsdm::Qt3DSDMInstanceHandle i ->GetSlideByInstance(instance)); qt3dsdm::Qt3DSDMInstanceHandle component(m_reader.GetComponentForSlide(slide)); if (component.Valid()) { - Q3DStudio::CString cId = m_reader.GetFileId(component); - if (!theId.size()) + QString cId = m_reader.GetFileId(component); + if (theId.isEmpty()) cId = m_reader.GetName(component); - QString qcid(cId.toQString()); - qcid.append(QLatin1String("-")); - ret = qcid.toLatin1().append(ret); + cId.append(QLatin1String("-")); + ret = cId.toLatin1().append(ret); } else if (ret.isEmpty()) { ret = QByteArrayLiteral("Master Slide"); } else if (ret != QByteArrayLiteral("Master Slide")){ @@ -272,13 +267,12 @@ Q3DSGraphObjectTranslator *Q3DSTranslation::createEffectTranslator( qt3dsdm::Qt3DSDMInstanceHandle instance, qt3dsdm::Qt3DSDMInstanceHandle parentClass, const QByteArray &id) { - const QString instanceName = m_reader.GetName(parentClass).toQString(); - const QString instancePath = m_reader.GetSourcePath(parentClass).toQString(); + const QString instanceName = m_reader.GetName(parentClass); + const QString instancePath = m_reader.GetSourcePath(parentClass); const QString assetPath = m_presentation->assetFileName(instancePath, nullptr); qt3dsdm::IMetaData &metadata(*m_studioSystem.GetActionMetaData()); if (!metadata.IsEffectInstanceRegistered(qPrintable(assetPath))) { - WQString nameStr(toWQString(instanceName)); auto inputStreamFactory = IInputStreamFactory::Create(); std::vector<qt3dsdm::SMetaDataLoadWarning> warnings; IRefCountedInputStream stream = inputStreamFactory->getStreamForFile(assetPath); @@ -286,8 +280,8 @@ Q3DSGraphObjectTranslator *Q3DSTranslation::createEffectTranslator( qWarning() << __FUNCTION__ << " Unable to open effect: " << instancePath; return nullptr; } - metadata.LoadEffectXMLFromSourcePath(qPrintable(instancePath), - instance, nameStr.data(), warnings, *stream); + metadata.LoadEffectXMLFromSourcePath(instancePath, + instance, instanceName, warnings, *stream); } Q3DSEffect effect = m_presentation->effect(assetPath); @@ -305,13 +299,12 @@ Q3DSGraphObjectTranslator *Q3DSTranslation::createCustomMaterialTranslator( qt3dsdm::Qt3DSDMInstanceHandle instance, qt3dsdm::Qt3DSDMInstanceHandle parentClass, const QByteArray &id) { - const QString instanceName = m_reader.GetName(parentClass).toQString(); - const QString instancePath = m_reader.GetSourcePath(parentClass).toQString(); + const QString instanceName = m_reader.GetName(parentClass); + const QString instancePath = m_reader.GetSourcePath(parentClass); const QString assetPath = m_presentation->assetFileName(instancePath, nullptr); qt3dsdm::IMetaData &metadata(*m_studioSystem.GetActionMetaData()); - if (!metadata.IsMaterialClassRegistered(qPrintable(assetPath))) { - WQString nameStr(toWQString(instanceName)); + if (!metadata.IsMaterialClassRegistered(assetPath)) { auto inputStreamFactory = IInputStreamFactory::Create(); std::vector<qt3dsdm::SMetaDataLoadWarning> warnings; IRefCountedInputStream stream = inputStreamFactory->getStreamForFile(assetPath); @@ -319,8 +312,8 @@ Q3DSGraphObjectTranslator *Q3DSTranslation::createCustomMaterialTranslator( qWarning() << __FUNCTION__ << " Unable to open custom material: " << instancePath; return nullptr; } - metadata.LoadMaterialClassFromSourcePath(qPrintable(instancePath), - instance, nameStr.data(), warnings, *stream); + metadata.LoadMaterialClassFromSourcePath(instancePath, + instance, instanceName, warnings, *stream); } Q3DSCustomMaterial material = m_presentation->customMaterial(assetPath); diff --git a/src/Authoring/Studio/Render/Q3DSTranslators.cpp b/src/Authoring/Studio/Render/Q3DSTranslators.cpp index 1170f68f..fc915635 100644 --- a/src/Authoring/Studio/Render/Q3DSTranslators.cpp +++ b/src/Authoring/Studio/Render/Q3DSTranslators.cpp @@ -276,15 +276,12 @@ struct Q3DSTranslatorDataModelParser { if (parseProperty(inProperty, outValue)) { if (!outValue.isEmpty() && outValue[0] != QLatin1Char('#')) { - Q3DStudio::CFilePath theDirectory + QString theDirectory = g_StudioApp.GetCore()->GetDoc()->GetDocumentDirectory(); - Q3DStudio::CFilePath theResolvedPath - = Q3DStudio::CFilePath::CombineBaseAndRelative(theDirectory, - Q3DStudio::CString::fromQString(outValue)); - if (theResolvedPath.exists()) { - std::shared_ptr<Q3DSStringTable> strTable = Q3DSStringTable::instance(); - outValue = strTable->GetRenderStringTable().RegisterStr(outValue); - } + QString theResolvedPath + = Q3DStudio::CFilePath::CombineBaseAndRelative(theDirectory, outValue); + if (QFileInfo(theResolvedPath).exists()) + outValue = theResolvedPath; } return true; } @@ -308,8 +305,7 @@ struct Q3DSTranslatorDataModelParser Option<qt3dsdm::SStringOrInt> temp = propertyValue<qt3dsdm::SStringOrInt>(inProperty); if (temp.hasValue()) { const bool isInt = temp->GetType() == qt3dsdm::SStringOrIntTypes::Int; - QString str = !isInt ? QString::fromWCharArray( - temp->m_Value.getData<qt3dsdm::TDataStrPtr>()->GetData()) + QString str = !isInt ? temp->m_Value.getData<qt3dsdm::TDataStrPtr>()->toQString() : QString(); const bool isRef = (!isInt && str[0] == QLatin1Char('#')); if (isInt || isRef) { @@ -1949,10 +1945,9 @@ void Q3DSDynamicObjectTranslator::pushTranslation(Q3DSTranslation &inContext) const auto propertyKeys = properties->keys(); for (auto property : propertyKeys) { - WQString name(toWQString(property)); const Q3DSMaterial::PropertyElement &element = (*properties)[property]; qt3dsdm::Qt3DSDMPropertyHandle theProperty = - inContext.reader().FindProperty(instanceHandle(), name.data()); + inContext.reader().FindProperty(instanceHandle(), property); if (!datacore->IsProperty(theProperty)) continue; diff --git a/src/Authoring/Studio/Render/Q3DStudioRenderer.cpp b/src/Authoring/Studio/Render/Q3DStudioRenderer.cpp index 92dc4e58..f9d78d75 100644 --- a/src/Authoring/Studio/Render/Q3DStudioRenderer.cpp +++ b/src/Authoring/Studio/Render/Q3DStudioRenderer.cpp @@ -38,6 +38,7 @@ #include "StudioFullSystem.h" #include "StudioCoreSystem.h" #include "HotKeys.h" +#include "Q3DSRenderBufferManager.h" #include <QtWidgets/qwidget.h> #include <QtWidgets/qopenglwidget.h> @@ -95,10 +96,10 @@ Q3DStudioRenderer::Q3DStudioRenderer() m_dispatch.AddSceneDragListener(this); m_dispatch.AddToolbarChangeListener(this); - ::CColor color = CStudioPreferences::GetRulerBackgroundColor(); // Rectangles under tick marks - m_rectColor = QColor(int(color.GetRed()), int(color.GetGreen()), int(color.GetBlue())); - color = CStudioPreferences::GetRulerTickColor(); // Tick marks - m_lineColor = QColor(int(color.GetRed()), int(color.GetGreen()), int(color.GetBlue())); + // Rectangles under tick marks + m_rectColor = CStudioPreferences::GetRulerBackgroundColor(); + // Tick marks + m_lineColor = CStudioPreferences::GetRulerTickColor(); m_editCameraInformation.resize(g_numEditCameras); } @@ -125,7 +126,7 @@ QT3DSVec3 Q3DStudioRenderer::GetIntendedPosition(qt3dsdm::Qt3DSDMInstanceHandle Q3DSRenderBufferManager *Q3DStudioRenderer::GetBufferManager() { - return nullptr; + return Q3DSRenderBufferManager::Create(m_engine.data(), *IInputStreamFactory::Create()).data(); } IPathManager *Q3DStudioRenderer::GetPathManager() diff --git a/src/Authoring/Studio/Render/StudioVisualAidWidget.cpp b/src/Authoring/Studio/Render/StudioVisualAidWidget.cpp index faadd7e6..d95dc803 100644 --- a/src/Authoring/Studio/Render/StudioVisualAidWidget.cpp +++ b/src/Authoring/Studio/Render/StudioVisualAidWidget.cpp @@ -491,7 +491,7 @@ void SVisualAidWidget::renderCamera(SNode *node, IRenderWidgetContext &inWidgetC * theSetup.m_WidgetInfo.m_NodeParentToCamera * node->m_GlobalTransform); - ::CColor color = CStudioPreferences::GetSingleBoundingBoxColor(); + QColor color = CStudioPreferences::GetSingleBoundingBoxColor(); QT3DSVec3 colorVec(color.GetRed() / 255.f, color.GetGreen() / 255.f, color.GetBlue() / 255.f); @@ -623,7 +623,7 @@ void SVisualAidWidget::renderLight(SNode *node, IRenderWidgetContext &inWidgetCo * node->m_GlobalTransform * areaScaleMatrix); - ::CColor color = CStudioPreferences::GetSingleBoundingBoxColor(); + QColor color = CStudioPreferences::GetSingleBoundingBoxColor(); QT3DSVec3 colorVec(color.GetRed() / 255.f, color.GetGreen() / 255.f, color.GetBlue() / 255.f); diff --git a/src/Authoring/Studio/UI/StudioAppPrefsPage.cpp b/src/Authoring/Studio/UI/StudioAppPrefsPage.cpp index bfea1bac..c20b6727 100644 --- a/src/Authoring/Studio/UI/StudioAppPrefsPage.cpp +++ b/src/Authoring/Studio/UI/StudioAppPrefsPage.cpp @@ -385,7 +385,7 @@ void CStudioAppPrefsPage::setAutosaveInterval(int interval) void CStudioAppPrefsPage::onClearAutosaveFiles() { // Find all *_autosave.uip files and delete them - QDirIterator files(g_StudioApp.GetCore()->GetDoc()->GetDocumentDirectory().toQString()); + QDirIterator files(g_StudioApp.GetCore()->GetDoc()->GetDocumentDirectory()); while (files.hasNext()) { if (files.next().endsWith(QStringLiteral("_autosave.uip"))) QFile::remove(files.filePath()); diff --git a/src/Authoring/Studio/Utils/ImportUtils.cpp b/src/Authoring/Studio/Utils/ImportUtils.cpp index bd2d85b5..effa1c63 100644 --- a/src/Authoring/Studio/Utils/ImportUtils.cpp +++ b/src/Authoring/Studio/Utils/ImportUtils.cpp @@ -35,32 +35,29 @@ namespace Q3DStudio { -SObjectFileType ImportUtils::GetObjectFileTypeForFile(const CFilePath &inFile, +SObjectFileType ImportUtils::GetObjectFileTypeForFile(const QString &inFile, bool inCheckFileExists /*= true*/) { - if (inCheckFileExists && !inFile.isFile()) + QFileInfo info(inFile); + if (inCheckFileExists && !info.isFile()) return SObjectFileType(OBJTYPE_UNKNOWN, DocumentEditorFileType::Unknown); - Q3DStudio::CString theExtension(inFile.GetExtension()); - theExtension.ToLower(); + QString theExtension(info.suffix()); - if (theExtension.Compare(CDialogs::GetImportFileExtension(), Q3DStudio::CString::ENDOFSTRING, - false)) { + if (theExtension.compare(CDialogs::GetImportFileExtension(), Qt::CaseInsensitive) == 0) { return SObjectFileType(OBJTYPE_GROUP, DocumentEditorFileType::Import); - } else if (theExtension.Compare(CDialogs::GetMeshFileExtension(), Q3DStudio::CString::ENDOFSTRING, - false)) { + } else if (theExtension.compare(CDialogs::GetMeshFileExtension(), Qt::CaseInsensitive) == 0) { return SObjectFileType(OBJTYPE_MODEL, DocumentEditorFileType::Mesh); } else if (CDialogs::IsImageFileExtension(theExtension)) { return SObjectFileType( OBJTYPE_MODEL, OBJTYPE_IMAGE, DocumentEditorFileType::Image); // Drag-drop image to scene will auto-map to Rectangle. - } else if (theExtension.Compare(CDialogs::GetQmlFileExtension(), - Q3DStudio::CString::ENDOFSTRING, false)) { - return g_StudioApp.isQmlStream(inFile.absoluteFilePath()) + } else if (theExtension.compare(CDialogs::GetQmlFileExtension(), Qt::CaseInsensitive) == 0) { + return g_StudioApp.isQmlStream(info.absoluteFilePath()) ? SObjectFileType(OBJTYPE_QML_STREAM, DocumentEditorFileType::QmlStream) : SObjectFileType(OBJTYPE_BEHAVIOR, DocumentEditorFileType::Behavior); - } else if (theExtension.Compare(CDialogs::GetMaterialDataFileExtension(), - Q3DStudio::CString::ENDOFSTRING, false)) { + } else if (theExtension.compare(CDialogs::GetMaterialDataFileExtension(), + Qt::CaseInsensitive) == 0) { return SObjectFileType(OBJTYPE_MATERIALDATA, DocumentEditorFileType::MaterialData); } else if (CDialogs::IsFontFileExtension(theExtension)) { return SObjectFileType(OBJTYPE_TEXT, DocumentEditorFileType::Font); diff --git a/src/Authoring/Studio/Utils/ImportUtils.h b/src/Authoring/Studio/Utils/ImportUtils.h index 0a41dd9c..7d1759cf 100644 --- a/src/Authoring/Studio/Utils/ImportUtils.h +++ b/src/Authoring/Studio/Utils/ImportUtils.h @@ -63,10 +63,10 @@ struct SObjectFileType class ImportUtils { public: - static SObjectFileType GetObjectFileTypeForFile(const CFilePath &inPath, + static SObjectFileType GetObjectFileTypeForFile(const QString &inPath, bool inCheckFileExists = true); static DocumentEditorInsertType::Enum GetInsertTypeForDropType(EDROPDESTINATION inDestination); }; } -#endif
\ No newline at end of file +#endif diff --git a/src/Authoring/Studio/Utils/SystemPreferences.cpp b/src/Authoring/Studio/Utils/SystemPreferences.cpp index 38a7020b..3f1e95d8 100644 --- a/src/Authoring/Studio/Utils/SystemPreferences.cpp +++ b/src/Authoring/Studio/Utils/SystemPreferences.cpp @@ -28,7 +28,7 @@ ****************************************************************************/ #include "Qt3DSCommonPrecompile.h" -#include "CColor.h" +#include <QtGui/qcolor.h> #include "SystemPreferences.h" #include <QtWidgets/qapplication.h> diff --git a/src/Authoring/Studio/Utils/SystemPreferences.h b/src/Authoring/Studio/Utils/SystemPreferences.h index 2d72780e..a3172b88 100644 --- a/src/Authoring/Studio/Utils/SystemPreferences.h +++ b/src/Authoring/Studio/Utils/SystemPreferences.h @@ -32,7 +32,7 @@ #pragma once -class CColor; +#include <QtGui/qcolor.h> class CSystemPreferences { diff --git a/src/Authoring/Studio/Workspace/Dialogs.cpp b/src/Authoring/Studio/Workspace/Dialogs.cpp index e1737fb4..1160ef26 100644 --- a/src/Authoring/Studio/Workspace/Dialogs.cpp +++ b/src/Authoring/Studio/Workspace/Dialogs.cpp @@ -68,13 +68,13 @@ namespace { -inline Q3DStudio::CString CreateExtensionsList(const char **extList) +inline QString CreateExtensionsList(const QStringList &extList) { - Q3DStudio::CString retval; - for (const char **ext = extList; *ext != nullptr; ++ext) { - if (retval.Length()) - retval += " "; - retval += Q3DStudio::CString("*.") + *ext; + QString retval; + for (const QString &ext : extList) { + if (retval.length()) + retval += QLatin1Char(' '); + retval += QStringLiteral("*.") + ext; } return retval; } @@ -83,91 +83,68 @@ struct SAllowedTypesEntry { Q3DStudio::DocumentEditorFileType::Enum m_FileType; QString m_ResourceString; // Model Files, Image Files, etc - const char **m_FileExtensions; + QStringList m_FileExtensions; }; -const char *imgExts[] = { - "png", "jpg", "jpeg", "dds", "bmp", "gif", "hdr", "ktx", nullptr, +static const QStringList imgExts = { + "png", "jpg", "jpeg", "dds", "bmp", "gif", "hdr", "ktx", }; -const wchar_t *wideImgExts[] = { - L"png", L"jpg", L"jpeg", L"dds", L"bmp", L"gif", L"hdr", L"ktx", nullptr, -}; - -const char *modelExts[] = { +const QStringList modelExts = { CDialogs::GetDAEFileExtension(), #ifdef QT_3DSTUDIO_FBX CDialogs::GetFbxFileExtension(), #endif - nullptr, -}; - -const char *meshExts[] = { - CDialogs::GetMeshFileExtension(), nullptr, -}; - -const char *importExts[] = { - CDialogs::GetImportFileExtension(), nullptr, }; -const char *behaviorExts[] = { - CDialogs::GetQmlFileExtension(), nullptr, +static const QStringList meshExts = { + CDialogs::GetMeshFileExtension() }; -const char *presentationExts[] = { - "uip", nullptr, +static const QStringList importExts = { + CDialogs::GetImportFileExtension() }; -const wchar_t *widePresentationExts[] = { - L"uip", nullptr, +static const QStringList behaviorExts = { + CDialogs::GetQmlFileExtension() }; -const char *qmlStreamExts[] = { - "qml", nullptr, +static const QStringList presentationExts = { + "uip" }; -const wchar_t *wideQmlStreamExts[] = { - L"qml", nullptr, +static const QStringList qmlStreamExts = { + "qml" }; -const char *projectExts[] = { - "uia", nullptr, +static const QStringList projectExts = { + "uia" }; -const wchar_t *wideProjectExts[] = { - L"uia", nullptr, +static const QStringList fontExts = { + "ttf", "otf" }; -const char *fontExts[] = { - "ttf", "otf", nullptr, -}; -const wchar_t *wideFontExts[] = { - L"ttf", L"otf", nullptr, +static const QStringList effectExts = { + "effect" }; -const char *effectExts[] = { - "effect", nullptr, +static const QStringList materialExts = { + "material" }; -const wchar_t *wideEffectExts[] = { - L"effect", nullptr, +static const QStringList soundExts = { + "wav" }; -const char *materialExts[] = { - "material", nullptr, +static const QStringList pathExts = { + "svg" }; -const wchar_t *wideMaterialExts[] = { - L"material", nullptr, +static const QStringList bufferExts = { + "path" }; -const char *soundExts[] = { - "wav", nullptr, -}; - -const wchar_t *wideSoundExts[] = { - L"wav", nullptr, -}; // List of file types allowed during import // Note: Despite its name, Q3DStudio::DocumentEditorFileType::DAE type includes @@ -289,7 +266,7 @@ void CDialogs::DisplayAssetDeleteFailed() /** * Get the export choice. */ -Qt3DSFile CDialogs::GetExportChoice(const Q3DStudio::CString &, const Q3DStudio::CString &) +Qt3DSFile CDialogs::GetExportChoice(const QString &, const QString &) { // Need to fix this for windows if we decide to use it return Qt3DSFile("", false, false); @@ -706,208 +683,118 @@ int CDialogs::displayOverrideAssetBox(const QString &assetPath) } } -const char *CDialogs::GetDAEFileExtension() +QString CDialogs::GetDAEFileExtension() { - return "dae"; + return QStringLiteral("dae"); } -const char *CDialogs::GetFbxFileExtension() +QString CDialogs::GetFbxFileExtension() { - return "fbx"; + return QStringLiteral("fbx"); } // Null terminated list -const char **CDialogs::GetImgFileExtensions() +QStringList CDialogs::GetImgFileExtensions() { return imgExts; } -const char *CDialogs::GetImportFileExtension() +QString CDialogs::GetImportFileExtension() { - return "import"; + return QStringLiteral("import"); } -const char *CDialogs::GetMeshFileExtension() +QString CDialogs::GetMeshFileExtension() { - return "mesh"; + return QStringLiteral("mesh"); } -const char *CDialogs::GetQmlFileExtension() +QString CDialogs::GetQmlFileExtension() { - return "qml"; + return QStringLiteral("qml"); } -const char *CDialogs::GetMaterialDataFileExtension() +QString CDialogs::GetMaterialDataFileExtension() { - return "matdata"; + return QStringLiteral("matdata"); } -const char **CDialogs::GetFontFileExtensions() +QStringList CDialogs::GetFontFileExtensions() { return fontExts; } -const char **CDialogs::GetEffectFileExtensions() +QStringList CDialogs::GetEffectFileExtensions() { return effectExts; } -const char **CDialogs::GetMaterialFileExtensions() +QStringList CDialogs::GetMaterialFileExtensions() { return materialExts; } -const char **CDialogs::GetSoundFileExtensions() +QStringList CDialogs::GetSoundFileExtensions() { return soundExts; } -bool IsFileExtension(const char *inExt, const char **inExts) +bool IsFileExtension(const QString &inExt, const QStringList &inExts) { - if (inExt == nullptr) - return false; - for (const char **ext = inExts; *ext != nullptr; ++ext) { - if (QString::compare(inExt, *ext, Qt::CaseInsensitive) == 0) + for (const QString ext: inExts) { + if (QString::compare(inExt, ext, Qt::CaseInsensitive) == 0) return true; } return false; } -bool CDialogs::IsImageFileExtension(const char *inExt) +bool CDialogs::IsImageFileExtension(const QString &inExt) { return IsFileExtension(inExt, imgExts); } -bool CDialogs::IsFontFileExtension(const char *inExt) +bool CDialogs::IsFontFileExtension(const QString &inExt) { return IsFileExtension(inExt, fontExts); } -bool CDialogs::IsEffectFileExtension(const char *inExt) +bool CDialogs::IsEffectFileExtension(const QString &inExt) { return IsFileExtension(inExt, effectExts); } -bool CDialogs::IsMaterialFileExtension(const char *inExt) +bool CDialogs::IsMaterialFileExtension(const QString &inExt) { return IsFileExtension(inExt, materialExts); } -bool CDialogs::IsSoundFileExtension(const char *inExt) +bool CDialogs::IsSoundFileExtension(const QString &inExt) { return IsFileExtension(inExt, soundExts); } -bool CDialogs::isMeshFileExtension(const char *inExt) +bool CDialogs::isMeshFileExtension(const QString &inExt) { return IsFileExtension(inExt, meshExts); } -bool CDialogs::isPresentationFileExtension(const char *inExt) +bool CDialogs::isPresentationFileExtension(const QString &inExt) { return IsFileExtension(inExt, presentationExts); } -bool CDialogs::isProjectFileExtension(const char *inExt) +bool CDialogs::isProjectFileExtension(const QString &inExt) { return IsFileExtension(inExt, projectExts); } -const wchar_t **CDialogs::GetWideImgFileExtensions() -{ - return wideImgExts; -} - -const wchar_t *CDialogs::GetWideDAEFileExtension() -{ - return L"dae"; -} - -const wchar_t *CDialogs::GetWideFbxFileExtension() -{ - return L"fbx"; -} - -const wchar_t *CDialogs::GetWideImportFileExtension() -{ - return L"import"; -} - -const wchar_t *CDialogs::GetWideMeshFileExtension() -{ - return L"mesh"; -} - -const wchar_t **CDialogs::GetWideFontFileExtensions() -{ - return wideFontExts; -} - -const wchar_t **CDialogs::GetWideEffectFileExtensions() -{ - return wideEffectExts; -} - -const wchar_t **CDialogs::GetWideMaterialFileExtensions() -{ - return wideMaterialExts; -} - -bool IsFileExtension(const wchar_t *inExt, const wchar_t **inExts) -{ - if (inExt == nullptr) - return false; - for (const wchar_t **ext = inExts; *ext != nullptr; ++ext) { - if (QString::compare(QString::fromWCharArray(inExt), - QString::fromWCharArray(*ext), Qt::CaseInsensitive) == 0) { - return true; - } - } - return false; -} - -bool CDialogs::IsImageFileExtension(const wchar_t *inExt) -{ - return IsFileExtension(inExt, wideImgExts); -} - -bool CDialogs::IsFontFileExtension(const wchar_t *inExt) -{ - return IsFileExtension(inExt, wideFontExts); -} - -bool CDialogs::IsEffectFileExtension(const wchar_t *inExt) -{ - return IsFileExtension(inExt, wideEffectExts); -} - -bool CDialogs::IsMaterialFileExtension(const wchar_t *inExt) -{ - return IsFileExtension(inExt, wideMaterialExts); -} - -bool CDialogs::IsPathFileExtension(const wchar_t *inExt) -{ - return QString::compare(QString::fromWCharArray(inExt), "svg", Qt::CaseInsensitive) == 0; -} - -bool CDialogs::IsPathBufferExtension(const wchar_t *inExt) -{ - return QString::compare(QString::fromWCharArray(inExt), "path", Qt::CaseInsensitive) == 0; -} - -bool CDialogs::IsSoundFileExtension(const wchar_t *inExt) -{ - return IsFileExtension(inExt, wideSoundExts); -} - -bool CDialogs::isPresentationFileExtension(const wchar_t *inExt) +bool CDialogs::IsPathFileExtension(const QString &inExt) { - return IsFileExtension(inExt, widePresentationExts); + return IsFileExtension(inExt, pathExts); } -bool CDialogs::isProjectFileExtension(const wchar_t *inExt) +bool CDialogs::IsPathBufferExtension(const QString &inExt) { - return IsFileExtension(inExt, wideProjectExts); + return IsFileExtension(inExt, bufferExts); } //============================================================================== @@ -928,13 +815,14 @@ QString CDialogs::CreateAllowedTypesString(Q3DStudio::DocumentEditorFileType::En forImport ? g_AllowedImportTypes[idx] : g_AllowedFileReferencesTypes[idx]; if (!exclusive || fileTypeFilter == entry.m_FileType) { QString theTypeString(entry.m_ResourceString); - QString theExtensions(CreateExtensionsList(entry.m_FileExtensions).toQString()); - const QString filterString = theTypeString + " (" + theExtensions + ");;"; + QString theExtensions(CreateExtensionsList(entry.m_FileExtensions)); + const QString filterString = theTypeString + QStringLiteral(" (") + + theExtensions + QStringLiteral(");;"); theReturnString += filterString; if (exclusive) outInitialFilter = filterString; else - combinedFilter += theExtensions + " "; + combinedFilter += theExtensions + QLatin1Char(' '); } } if (!combinedFilter.isEmpty()) { @@ -1082,17 +970,17 @@ QString CDialogs::GetSaveAsChoice(const QString &inDialogTitle, bool isProject) // New directory is only created when creating a new project. When doing a "save as" // or "save copy", a new directory is not created. if (isProject) { - Q3DStudio::CFilePath theFinalDir; - Q3DStudio::CFilePath theFinalDoc; + QString theFinalDir; + QString theFinalDoc; g_StudioApp.GetCore()->GetCreateDirectoryFileName(selectedName, theFinalDir, theFinalDoc); // Update last save file to final doc - m_LastSaveFile = theFinalDoc.absoluteFilePath(); - if (theFinalDoc.Exists()) { + m_LastSaveFile = theFinalDoc; + QFileInfo info(theFinalDoc); + if (info.exists()) { const QString theTitle(QObject::tr("Confirm Save As")); - const QString filePath(theFinalDir.GetFileName().toQString() + QDir::separator() - + theFinalDoc.GetFileName().toQString()); + const QString filePath(theFinalDir + QLatin1Char('/') + info.fileName()); const QString theString = QObject::tr("%1 already exists.\nDo you want to " "replace it?").arg(filePath); @@ -1380,86 +1268,37 @@ void CDialogs::DisplayGLVersionDialog(const Q3DStudio::CString &inGLVersion, QStringList CDialogs::effectExtensions() { - static QStringList exts; - if (exts.isEmpty()) { - for (const char *ext : effectExts) { - if (ext) - exts << QString::fromLatin1(ext); - } - } - return exts; + return effectExts; } QStringList CDialogs::fontExtensions() { - static QStringList exts; - if (exts.isEmpty()) { - for (const char *ext : fontExts) { - if (ext) - exts << QString::fromLatin1(ext); - } - } - return exts; + return fontExts; } QStringList CDialogs::mapExtensions() { - static QStringList exts; - if (exts.isEmpty()) { - for (const char *ext : imgExts) { - if (ext) - exts << QString::fromLatin1(ext); - } - } - return exts; + return imgExts; } QStringList CDialogs::materialExtensions() { - static QStringList exts; - if (exts.isEmpty()) { - for (const char *ext : materialExts) { - if (ext) - exts << QString::fromLatin1(ext); - } - } - return exts; + return materialExts; } QStringList CDialogs::modelExtensions() { - static QStringList exts; - if (exts.isEmpty()) { - for (const char *ext : modelExts) { - if (ext) - exts << QString::fromLatin1(ext); - } - } - return exts; + return modelExts; } QStringList CDialogs::behaviorExtensions() { - static QStringList exts; - if (exts.isEmpty()) { - for (const char *ext : behaviorExts) { - if (ext) - exts << QString::fromLatin1(ext); - } - } - return exts; + return behaviorExts; } QStringList CDialogs::presentationExtensions() { - static QStringList exts; - if (exts.isEmpty()) { - for (const char *ext : presentationExts) { - if (ext) - exts << QString::fromLatin1(ext); - } - } - return exts; + return presentationExts; } QColor CDialogs::displayColorDialog(const QColor &color) const diff --git a/src/Authoring/Studio/Workspace/Dialogs.h b/src/Authoring/Studio/Workspace/Dialogs.h index f1e93ef6..02ce0dd0 100644 --- a/src/Authoring/Studio/Workspace/Dialogs.h +++ b/src/Authoring/Studio/Workspace/Dialogs.h @@ -42,7 +42,7 @@ #include "StudioObjectTypes.h" #include "Qt3DSMessageBox.h" #include "Qt3DSFileTools.h" -#include "CColor.h" +#include <QtGui/qcolor.h> #include "DocumentEditorEnumerations.h" #include <QtWidgets/qmessagebox.h> @@ -86,48 +86,31 @@ public: // This is not an appropriate place for these, but better // in an inappropriate place than duplicated - static const char *GetDAEFileExtension(); - static const char *GetFbxFileExtension(); + static QString GetDAEFileExtension(); + static QString GetFbxFileExtension(); // Null terminated list - static const char **GetImgFileExtensions(); - static const char *GetImportFileExtension(); - static const char *GetMeshFileExtension(); - static const char *GetQmlFileExtension(); - static const char *GetMaterialDataFileExtension(); - static const char **GetFontFileExtensions(); - static const char **GetEffectFileExtensions(); - static const char **GetMaterialFileExtensions(); - static const char **GetSoundFileExtensions(); - static bool IsImageFileExtension(const char *inExt); - static bool IsFontFileExtension(const char *inExt); - static bool IsEffectFileExtension(const char *inExt); - static bool IsMaterialFileExtension(const char *inExt); - static bool IsSoundFileExtension(const char *inExt); - static bool isPresentationFileExtension(const char *inExt); - static bool isMeshFileExtension(const char *inExt); - static bool isProjectFileExtension(const char *inExt); - - static const wchar_t *GetWideDAEFileExtension(); - static const wchar_t *GetWideFbxFileExtension(); - static const wchar_t *GetWideImportFileExtension(); - static const wchar_t *GetWideMeshFileExtension(); - static const wchar_t **GetWideFontFileExtensions(); - static const wchar_t **GetWideImgFileExtensions(); - static const wchar_t **GetWideEffectFileExtensions(); - static const wchar_t **GetWideMaterialFileExtensions(); - static const wchar_t **GetWideSoundFileExtensions(); - static bool IsImageFileExtension(const wchar_t *inExt); - static bool IsFontFileExtension(const wchar_t *inExt); - static bool IsEffectFileExtension(const wchar_t *inExt); - static bool IsMaterialFileExtension(const wchar_t *inExt); - static bool IsPathFileExtension(const wchar_t *inExt); - static bool IsPathBufferExtension(const wchar_t *inExt); - static bool IsSoundFileExtension(const wchar_t *inExt); - static bool isPresentationFileExtension(const wchar_t *inExt); - static bool isProjectFileExtension(const wchar_t *inExt); - - Qt3DSFile GetExportChoice(const Q3DStudio::CString &inExtension, - const Q3DStudio::CString &inDefaultName); + static QStringList GetImgFileExtensions(); + static QString GetImportFileExtension(); + static QString GetMeshFileExtension(); + static QString GetQmlFileExtension(); + static QString GetMaterialDataFileExtension(); + static QStringList GetFontFileExtensions(); + static QStringList GetEffectFileExtensions(); + static QStringList GetMaterialFileExtensions(); + static QStringList GetSoundFileExtensions(); + static bool IsImageFileExtension(const QString &inExt); + static bool IsFontFileExtension(const QString &inExt); + static bool IsEffectFileExtension(const QString &inExt); + static bool IsMaterialFileExtension(const QString &inExt); + static bool IsSoundFileExtension(const QString &inExt); + static bool isPresentationFileExtension(const QString &inExt); + static bool isMeshFileExtension(const QString &inExt); + static bool isProjectFileExtension(const QString &inExt); + static bool IsPathFileExtension(const QString &inExt); + static bool IsPathBufferExtension(const QString &inExt); + + Qt3DSFile GetExportChoice(const QString &inExtension, + const QString &inDefaultName); QString GetSaveAsChoice(const QString &inDialogTitle = {}, bool isProject = false); QString GetNewDocumentChoice(const QString &inInitialDirectory = {}, bool isProject = true); diff --git a/src/shared/header/foundation/Qt3DSBasicTemplates.h b/src/shared/header/foundation/Qt3DSBasicTemplates.h deleted file mode 100644 index e8d386c7..00000000 --- a/src/shared/header/foundation/Qt3DSBasicTemplates.h +++ /dev/null @@ -1,113 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2008-2012 NVIDIA Corporation. -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt 3D Studio. -** -** $QT_BEGIN_LICENSE:GPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QT3DS_FOUNDATION_PSBASICTEMPLATES_H -#define QT3DS_FOUNDATION_PSBASICTEMPLATES_H - -#include "Qt3DS.h" - -namespace qt3ds { -namespace foundation { - template <typename A> - struct Equal - { - bool operator()(const A &a, const A &b) const { return a == b; } - }; - - template <typename A> - struct Less - { - bool operator()(const A &a, const A &b) const { return a < b; } - }; - - template <typename A> - struct Greater - { - bool operator()(const A &a, const A &b) const { return a > b; } - }; - - template <class F, class S> - class Pair - { - public: - F first; - S second; - Pair() - : first(F()) - , second(S()) - { - } - Pair(const F &f, const S &s) - : first(f) - , second(s) - { - } - Pair(const Pair &p) - : first(p.first) - , second(p.second) - { - } - // CN - fix for /.../Qt3DSBasicTemplates.h(61) : warning C4512: 'nv::foundation::Pair<F,S>' : - // assignment operator could not be generated - Pair &operator=(const Pair &p) - { - first = p.first; - second = p.second; - return *this; - } - bool operator==(const Pair &p) const { return first == p.first && second == p.second; } - }; - - template <unsigned int A> - struct LogTwo - { - static const unsigned int value = LogTwo<(A >> 1)>::value + 1; - }; - template <> - struct LogTwo<1> - { - static const unsigned int value = 0; - }; - - template <typename T> - struct UnConst - { - typedef T Type; - }; - template <typename T> - struct UnConst<const T> - { - typedef T Type; - }; - -} // namespace foundation -} // namespace qt3ds - -#endif diff --git a/src/shared/header/foundation/XML.h b/src/shared/header/foundation/XML.h index 8fb35531..5b78cbe7 100644 --- a/src/shared/header/foundation/XML.h +++ b/src/shared/header/foundation/XML.h @@ -427,7 +427,7 @@ namespace foundation { virtual bool Value(TXMLCharPtr &outValue) = 0; // Get the element this reader was created with - virtual SDOMElement *GetTopElement() = 0; + virtual SDOMElement *GetTopElement() const = 0; bool Att(TXMLCharPtr name, TXMLStr &outValue) { @@ -569,8 +569,8 @@ namespace foundation { // Get the number of tabs required to line up the next line // with the opening of the previous line virtual QT3DSU32 GetTabs() = 0; - virtual SDOMElement *GetTopElement() = 0; - virtual NVScopedRefCounted<IDOMFactory> GetFactory() = 0; + virtual SDOMElement *GetTopElement() const = 0; + virtual NVScopedRefCounted<IDOMFactory> GetFactory() const = 0; // Move this item before this sibling. Function does not rearrange the // tree in any major way and will not work if inItem and inSibling aren't // siblings. diff --git a/src/shared/header/render/Qt3DSRenderDynamicObjectSystemCommands.h b/src/shared/header/render/Qt3DSRenderDynamicObjectSystemCommands.h index 8ddc49ad..6c89de07 100644 --- a/src/shared/header/render/Qt3DSRenderDynamicObjectSystemCommands.h +++ b/src/shared/header/render/Qt3DSRenderDynamicObjectSystemCommands.h @@ -66,13 +66,13 @@ namespace dynamic { struct SPropertyDefinition { - CRegisteredString m_Name; + QString m_Name; //*not* relative to the presentation directory - CRegisteredString m_ImagePath; + QString m_ImagePath; // The datatypes map directly to the obvious types *except* // for NVRenderTexture2DPtr. This type will be interpreted as a - // CRegisteredString and will be used to lookup the texture + // QString and will be used to lookup the texture // from the buffer manager. NVRenderShaderDataTypes::Enum m_DataType; // All offsets are relative to the beginning of the SEffect @@ -80,7 +80,7 @@ namespace dynamic { QT3DSU32 m_Offset; // Sizeof this datatype. QT3DSU32 m_ByteSize; - NVConstDataRef<CRegisteredString> m_EnumValueNames; + QStringList m_EnumValueNames; NVRenderTextureTypeValue::Enum m_TexUsageType; ///< texture usage type like diffuse, specular, ... @@ -102,7 +102,7 @@ namespace dynamic { , m_IsEnumProperty(false) { } - SPropertyDefinition(CRegisteredString inName, NVRenderShaderDataTypes::Enum inType, + SPropertyDefinition(const QString &inName, NVRenderShaderDataTypes::Enum inType, QT3DSU32 inOffset, QT3DSU32 inByteSize) : m_Name(inName) , m_DataType(inType) @@ -240,7 +240,7 @@ namespace dynamic { struct SAllocateBuffer : public SCommand { - CRegisteredString m_Name; + QString m_Name; NVRenderTextureFormats::Enum m_Format; NVRenderTextureMagnifyingOp::Enum m_FilterOp; NVRenderTextureCoordOp::Enum m_TexCoordOp; @@ -254,7 +254,7 @@ namespace dynamic { , m_SizeMultiplier(1.0f) { } - SAllocateBuffer(CRegisteredString inName, NVRenderTextureFormats::Enum inFormat, + SAllocateBuffer(const QString &inName, NVRenderTextureFormats::Enum inFormat, NVRenderTextureMagnifyingOp::Enum inFilterOp, NVRenderTextureCoordOp::Enum inCoordOp, QT3DSF32 inMultiplier, SAllocateBufferFlags inFlags) @@ -289,7 +289,7 @@ namespace dynamic { { m_Type = CommandTypes::AllocateImage; } - SAllocateImage(CRegisteredString inName, NVRenderTextureFormats::Enum inFormat, + SAllocateImage(const QString &inName, NVRenderTextureFormats::Enum inFormat, NVRenderTextureMagnifyingOp::Enum inFilterOp, NVRenderTextureCoordOp::Enum inCoordOp, QT3DSF32 inMultiplier, SAllocateBufferFlags inFlags, NVRenderImageAccessType::Enum inAccess) @@ -311,9 +311,9 @@ namespace dynamic { struct SAllocateDataBuffer : public SCommand { - CRegisteredString m_Name; + QString m_Name; NVRenderBufferBindValues::Enum m_DataBufferType; - CRegisteredString m_WrapName; + QString m_WrapName; NVRenderBufferBindValues::Enum m_DataBufferWrapType; QT3DSF32 m_Size; SAllocateBufferFlags m_BufferFlags; @@ -323,9 +323,9 @@ namespace dynamic { { } - SAllocateDataBuffer(CRegisteredString inName, + SAllocateDataBuffer(const QString &inName, NVRenderBufferBindValues::Enum inBufferType, - CRegisteredString inWrapName, + const QString &inWrapName, NVRenderBufferBindValues::Enum inBufferWrapType, QT3DSF32 inSize, SAllocateBufferFlags inFlags) : SCommand(CommandTypes::AllocateDataBuffer) @@ -368,9 +368,9 @@ namespace dynamic { struct SBindBuffer : public SCommand { - CRegisteredString m_BufferName; + QString m_BufferName; bool m_NeedsClear; - SBindBuffer(CRegisteredString inBufName, bool inNeedsClear) + SBindBuffer(const QString &inBufName, bool inNeedsClear) : SCommand(CommandTypes::BindBuffer) , m_BufferName(inBufName) , m_NeedsClear(inNeedsClear) @@ -386,14 +386,14 @@ namespace dynamic { struct SBindShader : public SCommand { - CRegisteredString m_ShaderPath; + QString m_ShaderPath; // One GLSL file can hold multiple shaders in the case of multipass effects. // This makes it significantly easier for authors to reason about the shader // but it means we need to #define a preprocessor token to indicate which // effect we intend to compile at this point. - CRegisteredString m_ShaderDefine; - SBindShader(CRegisteredString inShaderPath, - CRegisteredString inShaderDefine = CRegisteredString()) + QString m_ShaderDefine; + SBindShader(const QString &inShaderPath, + const QString &inShaderDefine = {}) : SCommand(CommandTypes::BindShader) , m_ShaderPath(inShaderPath) , m_ShaderDefine(inShaderDefine) @@ -418,12 +418,12 @@ namespace dynamic { struct SApplyInstanceValue : public SCommand { // Name of value to apply in shader - CRegisteredString m_PropertyName; + QString m_PropertyName; // type of value NVRenderShaderDataTypes::Enum m_ValueType; // offset in the effect data section of value. QT3DSU32 m_ValueOffset; - SApplyInstanceValue(CRegisteredString inName, NVRenderShaderDataTypes::Enum inValueType, + SApplyInstanceValue(const QString &inName, NVRenderShaderDataTypes::Enum inValueType, QT3DSU32 inValueOffset) : SCommand(CommandTypes::ApplyInstanceValue) , m_PropertyName(inName) @@ -449,10 +449,10 @@ namespace dynamic { struct SApplyValue : public SCommand { - CRegisteredString m_PropertyName; + QString m_PropertyName; NVRenderShaderDataTypes::Enum m_ValueType; - NVDataRef<QT3DSU8> m_Value; - SApplyValue(CRegisteredString inName, NVRenderShaderDataTypes::Enum inValueType) + QVariant m_Value; + SApplyValue(const QString &inName, NVRenderShaderDataTypes::Enum inValueType) : SCommand(CommandTypes::ApplyValue) , m_PropertyName(inName) , m_ValueType(inValueType) @@ -479,12 +479,12 @@ namespace dynamic { { // If no buffer name is given then the special buffer [source] // is assumed. - CRegisteredString m_BufferName; + QString m_BufferName; // If no param name is given, the buffer is bound to the // input texture parameter (texture0). - CRegisteredString m_ParamName; + QString m_ParamName; - SApplyBufferValue(CRegisteredString bufferName, CRegisteredString shaderParam) + SApplyBufferValue(const QString &bufferName, const QString &shaderParam) : SCommand(CommandTypes::ApplyBufferValue) , m_BufferName(bufferName) , m_ParamName(shaderParam) @@ -501,12 +501,12 @@ namespace dynamic { // bind a buffer to a given shader parameter. struct SApplyImageValue : public SCommand { - CRegisteredString m_ImageName; ///< name which the image was allocated - CRegisteredString m_ParamName; ///< must match the name in the shader + QString m_ImageName; ///< name which the image was allocated + QString m_ParamName; ///< must match the name in the shader bool m_BindAsTexture; ///< bind image as texture bool m_NeedSync; ///< if true we add a memory barrier before usage - SApplyImageValue(CRegisteredString bufferName, CRegisteredString shaderParam, + SApplyImageValue(const QString &bufferName, const QString &shaderParam, bool inBindAsTexture, bool inNeedSync) : SCommand(CommandTypes::ApplyImageValue) , m_ImageName(bufferName) @@ -528,10 +528,10 @@ namespace dynamic { // bind a buffer to a given shader parameter. struct SApplyDataBufferValue : public SCommand { - CRegisteredString m_ParamName; ///< must match the name in the shader + QString m_ParamName; ///< must match the name in the shader NVRenderBufferBindValues::Enum m_BindAs; ///< to which target we bind this buffer - SApplyDataBufferValue(CRegisteredString inShaderParam, + SApplyDataBufferValue(const QString &inShaderParam, NVRenderBufferBindValues::Enum inBufferType) : SCommand(CommandTypes::ApplyDataBufferValue) , m_ParamName(inShaderParam) @@ -550,8 +550,8 @@ namespace dynamic { { // If no param name is given, the buffer is bound to the // input texture parameter (texture0). - CRegisteredString m_ParamName; - SApplyDepthValue(CRegisteredString param) + QString m_ParamName; + SApplyDepthValue(const QString ¶m) : SCommand(CommandTypes::ApplyDepthValue) , m_ParamName(param) { @@ -624,13 +624,13 @@ namespace dynamic { { // If no buffer name is given then the special buffer [source] // is assumed. Which is the default render target - CRegisteredString m_SourceBufferName; + QString m_SourceBufferName; // If no buffer name is given then the special buffer [dest] // is assumed. Which is the default render target - CRegisteredString m_DestBufferName; + QString m_DestBufferName; - SApplyBlitFramebuffer(CRegisteredString inSourceBufferName, - CRegisteredString inDestBufferName) + SApplyBlitFramebuffer(const QString &inSourceBufferName, + const QString &inDestBufferName) : SCommand(CommandTypes::ApplyBlitFramebuffer) , m_SourceBufferName(inSourceBufferName) , m_DestBufferName(inDestBufferName) @@ -671,7 +671,7 @@ namespace dynamic { struct SDepthStencil : public SCommand { - CRegisteredString m_BufferName; + QString m_BufferName; SDepthStencilFlags m_Flags; qt3ds::render::NVRenderStencilOp::Enum m_StencilFailOperation; qt3ds::render::NVRenderStencilOp::Enum m_DepthPassOperation; @@ -691,7 +691,7 @@ namespace dynamic { { } - SDepthStencil(CRegisteredString bufName, SDepthStencilFlags flags, + SDepthStencil(const QString &bufName, SDepthStencilFlags flags, qt3ds::render::NVRenderStencilOp::Enum inStencilOp, qt3ds::render::NVRenderStencilOp::Enum inDepthPassOp, qt3ds::render::NVRenderStencilOp::Enum inDepthFailOp, |