diff options
author | Mahmoud Badri <mahmoud.badri@qt.io> | 2019-05-22 17:16:30 +0300 |
---|---|---|
committer | Mahmoud Badri <mahmoud.badri@qt.io> | 2019-05-23 12:35:54 +0300 |
commit | 9456f4b6cefc47a4162e1f77eb5b030f5f0a1d16 (patch) | |
tree | 365c5f51bad339ddc7c1ffa8807332876d412f81 | |
parent | b49058947d3ba45afbb254c707c1d3f8de6373cc (diff) |
Some CString to QString conversions
plus some tweaks.
Change-Id: I714c9fea4afcfd3f15380c2e74c11fba515ae107
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Reviewed-by: Antti Määttä <antti.maatta@qt.io>
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
25 files changed, 216 insertions, 264 deletions
diff --git a/src/Authoring/Client/Code/Core/Doc/ClientDataModelBridge/ClientDataModelBridge.cpp b/src/Authoring/Client/Code/Core/Doc/ClientDataModelBridge/ClientDataModelBridge.cpp index 7d39ab97..7d1b11a5 100644 --- a/src/Authoring/Client/Code/Core/Doc/ClientDataModelBridge/ClientDataModelBridge.cpp +++ b/src/Authoring/Client/Code/Core/Doc/ClientDataModelBridge/ClientDataModelBridge.cpp @@ -445,7 +445,6 @@ SLong4 CClientDataModelBridge::GetComponentGuid(qt3dsdm::Qt3DSDMSlideHandle inSl return theComponentGuid; } -//============================================================================== /** * Helper method to check whether this asset is active. * An asset is active if it meets the following criteria @@ -477,7 +476,6 @@ bool CClientDataModelBridge::IsActive(qt3dsdm::Qt3DSDMInstanceHandle inInstanceH return true; } -//============================================================================== /** * Get the active slide index of this component (or scene) * @param inAsset the controlling component (component or scene) @@ -743,7 +741,8 @@ Qt3DSDMInstanceHandle CClientDataModelBridge::GetInstanceByGUID(SLong4 inLong4) { if (inLong4 == SLong4(0, 0, 0, 0)) return 0; - if (m_InstanceCachePropertyChangedConnection == NULL && m_Doc->GetStudioSystem() + + if (!m_InstanceCachePropertyChangedConnection && m_Doc->GetStudioSystem() && m_Doc->GetStudioSystem()->GetFullSystem()) { IStudioFullSystemSignalProvider *theProvider( m_Doc->GetStudioSystem()->GetFullSystem()->GetSignalProvider()); @@ -768,6 +767,7 @@ Qt3DSDMInstanceHandle CClientDataModelBridge::GetInstanceByGUID(SLong4 inLong4) GetObjectDefinitions().m_Guided.m_GuidProp); m_CachedGUIDToInstancesHash.insert(std::make_pair(inLong4, retval)); m_CachedInstanceToGUIDHash.insert(std::make_pair(retval, inLong4)); + return retval; } @@ -1020,7 +1020,6 @@ bool CClientDataModelBridge::IsInComponent(qt3dsdm::Qt3DSDMInstanceHandle inInst return (GetOwningComponentInstance(inInstance) == inComponentInstance); } -//============================================================================== /** * Get the component that this instance is a member of. * The component is the independent group or the Scene. inIsFirstCall is used @@ -1042,7 +1041,6 @@ CClientDataModelBridge::GetParentComponent(qt3dsdm::Qt3DSDMInstanceHandle inInst return 0; } -//============================================================================= /** * Get a unique, non-conflicting name for a child. * This will stip off all trailing numbers, find the base name then find a @@ -1121,21 +1119,20 @@ bool CClientDataModelBridge::CheckNameUnique(qt3dsdm::Qt3DSDMInstanceHandle inPa return ((int)theExistingChild == 0 || theExistingChild == inInstance); } -//============================================================================= /** * Get SourcePath value for this instance */ -Q3DStudio::CString -CClientDataModelBridge::GetSourcePath(qt3dsdm::Qt3DSDMInstanceHandle inInstance) const +QString CClientDataModelBridge::GetSourcePath(qt3dsdm::Qt3DSDMInstanceHandle inInstance) const { if (inInstance.Valid()) { qt3dsdm::SValue theValue; 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<QString>(theValue); + } + + return {}; } /** @@ -1237,7 +1234,7 @@ bool CClientDataModelBridge::isDefaultMaterial(Qt3DSDMInstanceHandle instance) c return false; return GetObjectType(instance) == OBJTYPE_REFERENCEDMATERIAL - && GetSourcePath(instance) == Q3DStudio::CString::fromQString(getDefaultMaterialName()); + && GetSourcePath(instance) == getDefaultMaterialName(); } Qt3DSDMInstanceHandle CClientDataModelBridge::getMaterialContainer() const @@ -1254,7 +1251,6 @@ Qt3DSDMInstanceHandle CClientDataModelBridge::getMaterialContainer() const return Qt3DSDMInstanceHandle(); } -//============================================================================= /** * Get all instances that are derived from ItemBase Instance. */ @@ -1265,15 +1261,6 @@ TInstanceHandleList CClientDataModelBridge::GetItemBaseInstances() const return theInstances; } -inline void AddSourcePathToList(std::set<Q3DStudio::CString> &ioSourcePathList, - const SValue &inValue) -{ - Q3DStudio::CFilePath theSourcePath = qt3dsdm::get<TDataStrPtr>(inValue)->GetData(); - if (!theSourcePath.filePath().isEmpty()) - ioSourcePathList.insert(theSourcePath.toCString()); -} - -//============================================================================= /** * Get list of values from all instances derived from inParentInstance */ @@ -1305,7 +1292,6 @@ std::vector<SValue> CClientDataModelBridge::GetValueList(Qt3DSDMInstanceHandle i return theValueList; } -//============================================================================= /** * Get list of values from all slides */ @@ -1333,16 +1319,16 @@ void CClientDataModelBridge::GetValueListFromAllSlides(Qt3DSDMInstanceHandle inI theSlideSystem->GetSlideByIndex(theSlide, theSlideIndex); if (theSlideCore->GetSpecificInstancePropertyValue(theSpecificSlide, inInstance, inProperty, theValue) - && (inFilter == NULL || inFilter->KeepValue(inInstance, inProperty, theValue))) + && (!inFilter || inFilter->KeepValue(inInstance, inProperty, theValue))) outValueList.push_back(theValue); } } else { // Else, we can get the property value qt3dsdm::SValue theValue; if (thePropertySystem->GetInstancePropertyValue(inInstance, inProperty, theValue) - && (inFilter == NULL - || inFilter->KeepValue(inInstance, inProperty, theValue.toOldSkool()))) + && (!inFilter || inFilter->KeepValue(inInstance, inProperty, theValue.toOldSkool()))) { outValueList.push_back(theValue.toOldSkool()); + } } } @@ -1363,76 +1349,68 @@ 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; - for (std::vector<SValue>::iterator theIter = theValueList.begin(); - theIter != theValueList.end(); ++theIter) - AddSourcePathToList(theSourcePathList, *theIter); + // Translate from SValue to QString and also remove the identifier + std::set<QString> theSourcePathList; + for (auto &val : theValueList) { + Q3DStudio::CFilePath theSourcePath = qt3dsdm::get<QString>(val); + if (!theSourcePath.filePath().isEmpty()) + theSourcePathList.insert(theSourcePath.toQString()); + } return theSourcePathList; } -inline void AddStringToList(std::set<Q3DStudio::CString> &ioStringList, const SValue &inValue) -{ - Q3DStudio::CString theString = qt3dsdm::get<TDataStrPtr>(inValue)->GetData(); - if (theString != L"") - ioStringList.insert(theString); -} - -//============================================================================= /** * 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; - for (std::vector<SValue>::iterator theIter = theValueList.begin(); - theIter != theValueList.end(); ++theIter) - AddStringToList(theFontNameList, *theIter); + std::set<QString> theFontNameList; + for (auto &val : theValueList) { + QString font = get<QString>(val); + if (!font.isEmpty()) + theFontNameList.insert(font); + } - // early return if (theFontNameList.empty()) 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 &font : 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 &fontPair : theFontNameFileList) { + if (fontPair.first == font) { theFontFound = true; - theFontFile = theFontNameFileList[idx].second; + theFontFile = fontPair.second; break; } } - if (!theFontFound) { - theFontFile = L"fonts\\File with font name ["; - theFontFile.append(*theFontNameIter); - theFontFile.append(" ]"); - } - theFontFileList.insert(Q3DStudio::CFilePath(theFontFile).toCString()); + if (!theFontFound) + theFontFile = QStringLiteral("fonts\\File with font name [%1]").arg(font); + + theFontFileList.insert(theFontFile); } + return theFontFileList; } @@ -1485,11 +1463,10 @@ 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; @@ -1502,11 +1479,13 @@ std::set<Q3DStudio::CString> CClientDataModelBridge::GetDynamicObjectTextureList GetDynamicObjecTextures(*m_DataCore, *thePropertySystem, m_CustomMaterial.m_Instance, theValueList, *this); - // Translate from SValue to Q3DStudio::CString and also remove the identifier - std::set<Q3DStudio::CString> theSourcePathList; - for (std::vector<SValue>::iterator theIter = theValueList.begin(); - theIter != theValueList.end(); ++theIter) - AddSourcePathToList(theSourcePathList, *theIter); + // Translate from SValue to QString and also remove the identifier + std::set<QString> theSourcePathList; + for (auto &val : theValueList) { + Q3DStudio::CFilePath theSourcePath = qt3dsdm::get<QString>(val); + if (!theSourcePath.filePath().isEmpty()) + theSourcePathList.insert(theSourcePath.toQString()); + } return theSourcePathList; } @@ -1520,8 +1499,8 @@ std::set<QString> CClientDataModelBridge::getRenderableList() const valueList.insert(valueList.end(), imageList.begin(), imageList.end()); std::set<QString> idList; - for (auto it = valueList.begin(); it != valueList.end(); ++it) { - QString renderableId = qt3dsdm::get<TDataStrPtr>(*it)->toQString(); + for (auto &val : valueList) { + QString renderableId = qt3dsdm::get<QString>(val); if (!renderableId.isEmpty()) idList.insert(renderableId); } @@ -1642,7 +1621,6 @@ bool CClientDataModelBridge::IsMaster(qt3dsdm::Qt3DSDMInstanceHandle inInstance) } } -//============================================================================= /** * Get the layer that this instance lies in. */ @@ -1663,7 +1641,6 @@ CClientDataModelBridge::GetResidingLayer(qt3dsdm::Qt3DSDMInstanceHandle inInstan } } -//============================================================================= /** * Get a child object by it's name in the active Slide. * This is meant to only be used by GetUniqueChildName, names are not Unique diff --git a/src/Authoring/Client/Code/Core/Doc/ClientDataModelBridge/ClientDataModelBridge.h b/src/Authoring/Client/Code/Core/Doc/ClientDataModelBridge/ClientDataModelBridge.h index 9050a1f8..aa7a5dee 100644 --- a/src/Authoring/Client/Code/Core/Doc/ClientDataModelBridge/ClientDataModelBridge.h +++ b/src/Authoring/Client/Code/Core/Doc/ClientDataModelBridge/ClientDataModelBridge.h @@ -341,7 +341,7 @@ public: bool CheckNameUnique(qt3dsdm::Qt3DSDMInstanceHandle inParentInstance, qt3dsdm::Qt3DSDMInstanceHandle inInstance, Q3DStudio::CString inDesiredName); - Q3DStudio::CString GetSourcePath(qt3dsdm::Qt3DSDMInstanceHandle inInstance) const; + QString GetSourcePath(qt3dsdm::Qt3DSDMInstanceHandle inInstance) const; Q3DStudio::CString getSubpresentation(qt3dsdm::Qt3DSDMInstanceHandle inInstance) const; qt3dsdm::Qt3DSDMInstanceHandle getMaterialReference(qt3dsdm::Qt3DSDMInstanceHandle instance); bool isMaterialContainer(qt3dsdm::Qt3DSDMInstanceHandle instance) const; @@ -353,9 +353,9 @@ public: QString getMaterialContainerPath() const; bool isDefaultMaterial(qt3dsdm::Qt3DSDMInstanceHandle instance) const; qt3dsdm::Qt3DSDMInstanceHandle getMaterialContainer() const; - std::set<Q3DStudio::CString> GetSourcePathList() const; - std::set<Q3DStudio::CString> GetFontFileList() const; - std::set<Q3DStudio::CString> GetDynamicObjectTextureList() 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); diff --git a/src/Authoring/Client/Code/Core/Doc/Doc.cpp b/src/Authoring/Client/Code/Core/Doc/Doc.cpp index 7d668d38..006b58c0 100644 --- a/src/Authoring/Client/Code/Core/Doc/Doc.cpp +++ b/src/Authoring/Client/Code/Core/Doc/Doc.cpp @@ -1092,47 +1092,37 @@ void CDoc::SetSceneGraph(std::shared_ptr<Q3DStudio::IDocSceneGraph> inGraph) m_SceneGraph = inGraph; } -inline Q3DStudio::CString ConvertToWide(const char8_t *inStr) -{ - eastl::basic_string<char16_t> theConvertStr; - qt3ds::foundation::ConvertUTF(inStr, 0, theConvertStr); - return Q3DStudio::CString(theConvertStr.c_str()); -} - -void CDoc::GetProjectFonts( - std::vector<std::pair<Q3DStudio::CString, Q3DStudio::CString>> &outFontNameFileList) +void CDoc::GetProjectFonts(std::vector<std::pair<QString, QString>> &outFontNameFileList) { outFontNameFileList.clear(); qt3ds::render::ITextRenderer *theRenderer = m_SceneGraph->GetTextRenderer(); if (theRenderer) { - qt3ds::render::NVConstDataRef<qt3ds::render::SRendererFontEntry> theProjectFonts = - theRenderer->GetProjectFontList(); - for (uint32_t idx = 0, end = theProjectFonts.size(); idx < end; ++idx) - outFontNameFileList.push_back( - std::make_pair(ConvertToWide(theProjectFonts[idx].m_FontName), - ConvertToWide(theProjectFonts[idx].m_FontFile))); + auto theProjectFonts = theRenderer->GetProjectFontList(); + for (uint32_t idx = 0, end = theProjectFonts.size(); idx < end; ++idx) { + outFontNameFileList.push_back({theProjectFonts[idx].m_FontName, + theProjectFonts[idx].m_FontFile}); + } } } -void CDoc::GetProjectFonts(std::vector<Q3DStudio::CString> &outFonts) +void CDoc::GetProjectFonts(std::vector<QString> &outFonts) { outFonts.clear(); qt3ds::render::ITextRenderer *theRenderer = m_SceneGraph->GetTextRenderer(); if (theRenderer) { - qt3ds::render::NVConstDataRef<qt3ds::render::SRendererFontEntry> theProjectFonts = - theRenderer->GetProjectFontList(); + auto theProjectFonts = theRenderer->GetProjectFontList(); for (uint32_t idx = 0, end = theProjectFonts.size(); idx < end; ++idx) - outFonts.push_back(ConvertToWide(theProjectFonts[idx].m_FontName)); + outFonts.push_back(theProjectFonts[idx].m_FontName); } } -Q3DStudio::CString CDoc::GetProjectFontName(const Q3DStudio::CFilePath &inFullPathToFontFile) +// Given a font path, return the font name +QString CDoc::GetProjectFontName(const Q3DStudio::CFilePath &inFullPathToFontFile) { qt3ds::render::ITextRenderer *theRenderer = m_SceneGraph->GetTextRenderer(); - Q3DStudio::CString theFont; + QString theFont; if (theRenderer) { - qt3ds::render::NVConstDataRef<qt3ds::render::SRendererFontEntry> theProjectFonts = - theRenderer->GetProjectFontList(); + auto theProjectFonts = theRenderer->GetProjectFontList(); qCInfo(qt3ds::TRACE_INFO) << "Attempting to find font: " << inFullPathToFontFile.filePath(); for (uint32_t idx = 0, end = theProjectFonts.size(); idx < end; ++idx) { @@ -1140,11 +1130,11 @@ Q3DStudio::CString CDoc::GetProjectFontName(const Q3DStudio::CFilePath &inFullPa // the data coming from fontconfig. For example, they always use forward slashes // instead of // back slashes. - Q3DStudio::CFilePath theFontFile(ConvertToWide(theProjectFonts[idx].m_FontFile)); + Q3DStudio::CFilePath theFontFile(theProjectFonts[idx].m_FontFile); if (inFullPathToFontFile == theFontFile) { qCInfo(qt3ds::TRACE_INFO) << "Matching against: " << theFontFile.filePath() << " SUCCEEDED"; - theFont = ConvertToWide(theProjectFonts[idx].m_FontName); + theFont = theProjectFonts[idx].m_FontName; break; } else { qCInfo(qt3ds::TRACE_INFO) << "Matching against: " << theFontFile.filePath() @@ -1228,7 +1218,7 @@ void CDoc::onPropertyChanged(qt3dsdm::Qt3DSDMInstanceHandle inInstance, // and the referenced materials that refer to that renamed material if (inProperty == bridge->GetNameProperty() && bridge->isInsideMaterialContainer(inInstance)) { const auto sceneEditor = getSceneEditor(); - const auto dirPath = GetDocumentDirectory().toQString(); + const QString dirPath = GetDocumentDirectory(); const auto renameMaterial = [&](const QPair<QString, QString> &materialRename) { const QString oldFile @@ -1239,6 +1229,7 @@ void CDoc::onPropertyChanged(qt3dsdm::Qt3DSDMInstanceHandle inInstance, // rename the referenced materials regardless if (QFileInfo(oldFile).exists()) QFile::rename(oldFile, newFile); + if (QFileInfo(newFile).exists()) { const QString newRelPath = QDir(dirPath).relativeFilePath(newFile); @@ -1246,7 +1237,7 @@ void CDoc::onPropertyChanged(qt3dsdm::Qt3DSDMInstanceHandle inInstance, getSceneReferencedMaterials(GetSceneInstance(), refMats); for (auto &refMat : qAsConst(refMats)) { const auto origMat = bridge->getMaterialReference(refMat); - if (origMat.Valid() && (long)origMat == inInstance) { + if (origMat.Valid() && long(origMat) == inInstance) { sceneEditor->setMaterialSourcePath(refMat, Q3DStudio::CString::fromQString(newRelPath)); sceneEditor->SetName(refMat, bridge->GetName(inInstance, true)); @@ -1619,44 +1610,37 @@ 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).path(); } /** - * Given an absolute path, return the relative path to doc if it is in doc's subdirectory. - * Else, return normalized path so that we can easily do string comparison to compare path. + * Given an absolute path, return the relative path to doc. * 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) +QString CDoc::GetRelativePathToDoc(const Q3DStudio::CFilePath &inPath) { - Q3DStudio::CFilePath thePath(inPath); - Q3DStudio::CFilePath theDocumentPath(GetDocumentDirectory()); - if (thePath.IsInSubDirectory(theDocumentPath)) - thePath.ConvertToRelative(theDocumentPath); - - return thePath; + return QDir(GetDocumentDirectory()).relativeFilePath(inPath.toQString()); } /** - * Given a path (may be relative or absolute), return the path with respect to doc. + * Given a path (may be relative or absolute), return an absolute path. * If the path is relative, it will be resolved based on document path. - * 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) +QString 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 QDir::cleanPath(QFileInfo(m_DocumentPath).dir() + .absoluteFilePath(inPath.toQString())); } - return inPath.toCString(); + return inPath.toQString(); } /** diff --git a/src/Authoring/Client/Code/Core/Doc/Doc.h b/src/Authoring/Client/Code/Core/Doc/Doc.h index e0e1f299..47f25fc8 100644 --- a/src/Authoring/Client/Code/Core/Doc/Doc.h +++ b/src/Authoring/Client/Code/Core/Doc/Doc.h @@ -198,9 +198,9 @@ 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 GetRelativePathToDoc(const Q3DStudio::CFilePath &inPath); + QString GetResolvedPathToDoc(const Q3DStudio::CFilePath &inPath); QString getRelativePath() const; QString CreateUntitledDocument() const; @@ -405,12 +405,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); + + QString GetProjectFontName(const Q3DStudio::CFilePath &inFullPathToFontFile); void setPlayBackPreviewState(bool state); bool isPlayBackPreviewOn() const; int getSelectedInstancesCount() const; diff --git a/src/Authoring/Client/Code/Core/Doc/DocumentBufferCache.cpp b/src/Authoring/Client/Code/Core/Doc/DocumentBufferCache.cpp index 056d0366..1ff4bd5a 100644 --- a/src/Authoring/Client/Code/Core/Doc/DocumentBufferCache.cpp +++ b/src/Authoring/Client/Code/Core/Doc/DocumentBufferCache.cpp @@ -105,10 +105,10 @@ struct SDocBufferCache : public IDocumentBufferCache IBufferManager *GetBufferManager() { - if (m_Doc.GetSceneGraph()) { + if (m_Doc.GetSceneGraph()) return m_Doc.GetSceneGraph()->GetBufferManager(); - } - return NULL; + + return nullptr; } void Reset() @@ -140,7 +140,7 @@ struct SDocBufferCache : public IDocumentBufferCache const wchar_t **GetPrimitiveNames() override { static const wchar_t *retval[] = { - L"#Rectangle", L"#Sphere", L"#Cone", L"#Cylinder", L"#Cube", NULL, + L"#Rectangle", L"#Sphere", L"#Cone", L"#Cylinder", L"#Cube", nullptr, }; return retval; } diff --git a/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp b/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp index 5d406fc6..ac3c3b31 100644 --- a/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp +++ b/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp @@ -131,9 +131,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 @@ -887,7 +887,7 @@ public: } } - Q3DStudio::CString GetCustomMaterialName(const Q3DStudio::CString &inFullPathToFile) const override + Q3DStudio::CString GetCustomMaterialName(const QString &inFullPathToFile) const override { Q3DStudio::CString retval; qt3ds::foundation::CFileSeekableIOStream theStream(inFullPathToFile, @@ -920,7 +920,7 @@ public: { Q3DStudio::Q3DSMaterialDefinitionParser::getMaterialInfo( inAbsoluteFilePath, g_StudioApp.GetCore()->getProjectFile().getProjectPath(), - m_Doc.GetDocumentDirectory().toQString(), outName, outValues, outTextureValues); + m_Doc.GetDocumentDirectory(), outName, outValues, outTextureValues); // Fix the outName to follow the file name (in case it has changed) outName = getMaterialNameFromFilePath(inAbsoluteFilePath); @@ -1645,8 +1645,8 @@ public: } TInstanceHandle SetInstancePropertyValueAsImage(TInstanceHandle instance, - TPropertyHandle propName, - const Q3DStudio::CString &inSourcePath) override + TPropertyHandle propName, + const Q3DStudio::CString &inSourcePath) override { CFilePath thePath = m_Doc.GetResolvedPathToDoc(inSourcePath); assert(thePath.IsFile()); @@ -1841,7 +1841,7 @@ public: } void SetMaterialType(TInstanceHandle instance, - const Q3DStudio::CString &inRelativePathToMaterialFile) override + const QString &inRelativePathToMaterialFile) override { if (m_Bridge.GetSourcePath(instance) == inRelativePathToMaterialFile) return; @@ -1882,13 +1882,13 @@ public: instance, m_Bridge.GetObjectDefinitions().m_Lightmaps.m_LightmapShadow); DeleteInstance(instance); - if (inRelativePathToMaterialFile == "Standard Material") - newMaterial = - CreateSceneGraphInstance(ComposerObjectTypes::Material, model, theSlide, instance); - else if (inRelativePathToMaterialFile == "Referenced Material") + if (inRelativePathToMaterialFile == QLatin1String("Standard Material")) { + newMaterial = CreateSceneGraphInstance(ComposerObjectTypes::Material, model, theSlide, + instance); + } else if (inRelativePathToMaterialFile == QLatin1String("Referenced Material")) { newMaterial = CreateSceneGraphInstance(ComposerObjectTypes::ReferencedMaterial, model, theSlide, instance); - else { + } else { CFilePath thePath = m_Doc.GetResolvedPathToDoc(inRelativePathToMaterialFile); newMaterial = LoadCustomMaterial(thePath, model, theSlide, DocumentEditorInsertType::LastChild, 0, instance); @@ -1977,7 +1977,7 @@ public: QFile file(actualSourcePath); if ((createNewFile && !file.exists()) || (!createNewFile && file.exists())) saveMaterial(instance, file); - return m_Doc.GetRelativePathToDoc(actualSourcePath); + return Q3DStudio::CString::fromQString(m_Doc.GetRelativePathToDoc(actualSourcePath)); } return ""; @@ -2058,7 +2058,7 @@ public: QMap<QString, Qt3DSDMInstanceHandle> textureHandles; qt3dsdm::TPropertyHandleList propList; - const QDir docDir(m_Doc.GetDocumentDirectory().toQString()); + const QDir docDir = m_Doc.GetDocumentDirectory(); const QDir projDir = g_StudioApp.GetCore()->getProjectFile().getProjectPath(); auto sourcePathProp = m_Bridge.GetSourcePathProperty(); // Importing interprets "./" prefix to mean project dir relative @@ -2086,7 +2086,7 @@ public: if (guid.Valid()) { auto ref = m_Bridge.GetInstanceByGUID(guid); textureHandles[name] = ref; - strValue = m_Bridge.GetSourcePath(ref).toQString(); + strValue = m_Bridge.GetSourcePath(ref); if (strValue.isEmpty()) { strValue = m_Bridge.getSubpresentation(ref).toQString(); isPath = false; @@ -2200,9 +2200,10 @@ public: if (path.contains(QLatin1String(".materialdef"))) { QDir dir(path); if (dir.isAbsolute()) - dirPath = QDir(m_Doc.GetDocumentDirectory().toQString()).relativeFilePath(path); + dirPath = m_Doc.GetRelativePathToDoc(path); else dirPath = dir.path(); + QFileInfo fi = QFileInfo(dirPath); materialName = fi.completeBaseName(); dirPath = fi.path(); @@ -2254,7 +2255,7 @@ public: const QMap<QString, QString> &values, const QMap<QString, QMap<QString, QString>> &textureValues) override { - SetMaterialType(instance, "Referenced Material"); + SetMaterialType(instance, QStringLiteral("Referenced Material")); setMaterialSourcePath(instance, materialSourcePath); setMaterialValues(materialSourcePath.toQString(), values, textureValues); setMaterialReferenceByPath(instance, materialSourcePath.toQString()); @@ -2414,8 +2415,7 @@ public: if (values.contains(QStringLiteral("type"))) { if (values[QStringLiteral("type")] == QLatin1String("CustomMaterial") && values.contains(QStringLiteral("sourcepath"))) { - SetMaterialType(instance, Q3DStudio::CString::fromQString( - values[QStringLiteral("sourcepath")])); + SetMaterialType(instance, values[QStringLiteral("sourcepath")]); if (values.contains(QStringLiteral("name"))) { SetName(instance, Q3DStudio::CString::fromQString( values[QStringLiteral("name")])); @@ -2515,7 +2515,8 @@ public: SLong4 guid = get<qt3dsdm::SLong4>(value); if (guid.Valid()) { srcChild = m_Bridge.GetInstanceByGUID(guid); - const auto path = std::make_shared<CDataStr>(m_Bridge.GetSourcePath(srcChild)); + const auto path = std::make_shared<CDataStr>(CString::fromQString( + m_Bridge.GetSourcePath(srcChild))); SetInstancePropertyValue(dst, prop, path); } } else { @@ -3279,16 +3280,16 @@ public: if (refMaterial.Valid()) { const Q3DStudio::CString refType = GetObjectTypeName(refMaterial); - Q3DStudio::CString v; + QString v; if (refType == "CustomMaterial") v = m_Bridge.GetSourcePath(refMaterial); else - v = "Standard Material"; + v = QStringLiteral("Standard Material"); SetMaterialType(instance, v); copyMaterialProperties(refMaterial, instance); } else { - SetMaterialType(instance, "Standard Material"); + SetMaterialType(instance, QStringLiteral("Standard Material")); } const auto name = GetName(instance); @@ -3888,7 +3889,7 @@ public: setInstanceImagePropertyValue(imageMaterial, prop, absSrc, true); } else { CFilePath absPath(absSrc); - relPath = m_Doc.GetRelativePathToDoc(absPath); + relPath = CString::fromQString(m_Doc.GetRelativePathToDoc(absPath)); materialName = findUniqueMaterialName(absPath.GetFileStem().toQString(), relPath.toQString()); imageMaterial = getOrCreateMaterial(materialName); @@ -3922,9 +3923,9 @@ public: return 0; } CFilePath relativePath = m_Doc.GetRelativePathToDoc(imageSrc); - SImageTextureData theImageBuffer = - m_Doc.GetBufferCache().GetOrCreateImageBuffer(relativePath); - if (theImageBuffer.m_Texture == NULL) { + SImageTextureData theImageBuffer = m_Doc.GetBufferCache() + .GetOrCreateImageBuffer(relativePath); + if (!theImageBuffer.m_Texture) { if (theHandler) theHandler->DisplayImportFailed(imageSrc.toQString(), QObject::tr("Can't Load Image File"), false); @@ -3976,17 +3977,19 @@ public: QObject::tr("Source File Doesn't Exist"), false); return 0; } - Q3DStudio::CString theRelativePath(m_Doc.GetRelativePathToDoc(inFullPathToDocument)); + Q3DStudio::CString theRelativePath = Q3DStudio::CString::fromQString( + m_Doc.GetRelativePathToDoc(inFullPathToDocument)); SModelBufferAndPath theModelBuffer = m_Doc.GetBufferCache().GetOrCreateModelBuffer(theRelativePath); - if (theModelBuffer.m_ModelBuffer == NULL) { + if (!theModelBuffer.m_ModelBuffer) { if (theHandler) theHandler->DisplayImportFailed(imageSrc.toQString(), QObject::tr("Could Not Load Model Buffer"), false); return 0; } // Ensure we include the model buffer version in the relative path - theRelativePath = m_Doc.GetRelativePathToDoc(theModelBuffer.m_FilePath); + theRelativePath = Q3DStudio::CString::fromQString( + m_Doc.GetRelativePathToDoc(theModelBuffer.m_FilePath)); qt3dsdm::Qt3DSDMInstanceHandle theModelInstance = CreateSceneGraphInstance(ComposerObjectTypes::Model, inParent, inSlide); @@ -4008,11 +4011,12 @@ public: static void *l_alloc(void *ud, void *ptr, size_t osize, size_t nsize) { - (void)ud; - (void)osize; /* not used */ + Q_UNUSED(ud) + Q_UNUSED(osize) + if (nsize == 0) { free(ptr); - return NULL; + return nullptr; } else return realloc(ptr, nsize); } @@ -4023,7 +4027,7 @@ public: QQmlEngine engine; QString path = inFile.filePath(); - path.replace('\\', '/'); + path.replace(QLatin1Char('\\'), QLatin1Char('/')); QQmlComponent component(&engine, QUrl::fromLocalFile(path), QQmlComponent::CompilationMode::PreferSynchronous); if (component.status() == QQmlComponent::Error) @@ -4359,8 +4363,8 @@ public: } // Get the font name of the font file - CString theFontName = m_Doc.GetProjectFontName(theFontFile); - if (theFontName.size() == 0) { + QString theFontName = m_Doc.GetProjectFontName(theFontFile); + if (theFontName.isEmpty()) { if (theHandler) theHandler->DisplayImportFailed(theFontFile.toQString(), QObject::tr("Unable to load Font File"), false); @@ -4375,7 +4379,8 @@ public: // Set the Font property to the font file m_PropertySystem.SetInstancePropertyValue(theTextInstance, m_Bridge.GetText().m_Font, - std::make_shared<qt3dsdm::CDataStr>(theFontName)); + std::make_shared<qt3dsdm::CDataStr>( + Q3DStudio::CString::fromQString(theFontName))); if (inStartTime != -1) SetStartTime(theTextInstance, inStartTime); @@ -4513,7 +4518,7 @@ public: long inStartTime) { std::shared_ptr<IImportFailedHandler> theHandler(m_Doc.GetImportFailedHandler()); - Q3DStudio::CString relPath = m_Doc.GetRelativePathToDoc(inFullPathToDocument); + QString relPath = m_Doc.GetRelativePathToDoc(inFullPathToDocument); TInstanceHandle retval = CreateSceneGraphInstance(ComposerObjectTypes::Path, inParent, inSlide); Q3DStudio::CFilePath theFilePath(relPath); @@ -4531,7 +4536,7 @@ public: inSlide, retval, m_Bridge.GetObjectDefinitions().m_Path.m_PathType, TDataStrPtr(new CDataStr(L"Painted"))); SetInstancePropertyValue(retval, m_Bridge.GetObjectDefinitions().m_Asset.m_SourcePath, - TDataStrPtr(new CDataStr(relPath.c_str()))); + TDataStrPtr(new CDataStr(CString::fromQString(relPath)))); FinalizeAddOrDrop(retval, inParent, inDropType, CPt(), inStartTime == -1, false); return retval; } @@ -4703,12 +4708,12 @@ public: // of this asset. We now need to attempt to run the refresh algorithm. qt3dsimp::ImportPtrOrError theImportPtr = qt3dsimp::Import::Load(theImportFilePath.toCString()); - if (theImportPtr.m_Value == NULL) { + if (!theImportPtr.m_Value) { QT3DS_ASSERT(false); continue; } - if (inNewFile.Exists() == false) { + if (!inNewFile.Exists()) { QT3DS_ASSERT(false); continue; } @@ -5149,13 +5154,14 @@ public: else theFullSrcPath = theSrcFile; TCharPtr theDAERelativePath = - m_StringTable.RegisterStr(m_Doc.GetRelativePathToDoc(theFullSrcPath)); + m_StringTable.RegisterStr(CString::fromQString( + m_Doc.GetRelativePathToDoc(theFullSrcPath))); pair<unordered_map<TCharPtr, TCharPtr>::iterator, bool> theInsertResult = m_ImportFileToDAEMap.insert( make_pair(m_StringTable.RegisterStr(theRelativePath.toCString()), theDAERelativePath)); theImportPtr.m_Value->Release(); - if (theInsertResult.second == false) + if (!theInsertResult.second) theInsertResult.first->second = theDAERelativePath; } } @@ -5270,7 +5276,8 @@ public: CFilePath theFullSrcPath = CFilePath::CombineBaseAndRelative(theDestDir, theSrcFile); TCharPtr theDAERelativePath = - m_StringTable.RegisterStr(m_Doc.GetRelativePathToDoc(theFullSrcPath)); + m_StringTable.RegisterStr(CString::fromQString( + m_Doc.GetRelativePathToDoc(theFullSrcPath))); pair<unordered_map<TCharPtr, TCharPtr>::iterator, bool> theInsertResult = m_ImportFileToDAEMap.insert( make_pair(m_StringTable.RegisterStr(theRelativePath.toCString()), @@ -5427,7 +5434,7 @@ IDocumentEditor::GetAlwaysUnlinkedProperties(qt3dsdm::SComposerObjectDefinitions void IDocumentEditor::fixDefaultTexturePaths(Qt3DSDMInstanceHandle instance) { const auto core = g_StudioApp.GetCore(); - const QDir docDir(core->GetDoc()->GetDocumentDirectory().toQString()); + const QDir docDir(core->GetDoc()->GetDocumentDirectory()); const QDir projDir = core->getProjectFile().getProjectPath(); const auto propertySystem = core->GetDoc()->GetStudioSystem()->GetPropertySystem(); qt3dsdm::TPropertyHandleList propList; @@ -5524,8 +5531,7 @@ IDocumentEditor::ParseScriptFile(const CFilePath &inFullPathToDocument, using namespace ScriptParser; std::shared_ptr<qt3dsdm::IStringTable> theStringTable(inStringTable); std::shared_ptr<IDOMFactory> theFactory(IDOMFactory::CreateDOMFactory(theStringTable)); - SImportXmlErrorHandler theXmlErrorHandler(inHandler, - inFullPathToDocument.toCString()); + SImportXmlErrorHandler theXmlErrorHandler(inHandler, inFullPathToDocument.toQString()); std::shared_ptr<IDOMReader> theReaderPtr( SScriptParser::ParseScriptFile(theFactory, inStringTable, inFullPathToDocument.toQString(), @@ -5550,8 +5556,7 @@ IDocumentEditor::ParsePluginFile(const Q3DStudio::CFilePath &inFullPathToDocumen { std::shared_ptr<qt3dsdm::IStringTable> theStringTable(inStringTable); std::shared_ptr<IDOMFactory> theFactory(IDOMFactory::CreateDOMFactory(theStringTable)); - SImportXmlErrorHandler theXmlErrorHandler(inHandler, - inFullPathToDocument.toCString()); + SImportXmlErrorHandler theXmlErrorHandler(inHandler, inFullPathToDocument.toQString()); std::shared_ptr<IDOMReader> theReaderPtr = CRenderPluginParser::ParseFile( theFactory, theStringTable, theStringTable->GetNarrowStr(inFullPathToDocument.toCString()), @@ -5575,8 +5580,7 @@ IDocumentEditor::ParseCustomMaterialFile(const Q3DStudio::CFilePath &inFullPathT { std::shared_ptr<qt3dsdm::IStringTable> theStringTable(inStringTable); std::shared_ptr<IDOMFactory> theFactory(IDOMFactory::CreateDOMFactory(theStringTable)); - SImportXmlErrorHandler theXmlErrorHandler(inHandler, - inFullPathToDocument.toCString()); + SImportXmlErrorHandler theXmlErrorHandler(inHandler, inFullPathToDocument.toQString()); std::shared_ptr<IDOMReader> theReaderPtr = CRenderPluginParser::ParseFile( theFactory, theStringTable, theStringTable->GetNarrowStr(inFullPathToDocument.toCString()), diff --git a/src/Authoring/Client/Code/Core/Doc/IDocumentEditor.h b/src/Authoring/Client/Code/Core/Doc/IDocumentEditor.h index cba7bdc7..d49f8062 100644 --- a/src/Authoring/Client/Code/Core/Doc/IDocumentEditor.h +++ b/src/Authoring/Client/Code/Core/Doc/IDocumentEditor.h @@ -241,7 +241,7 @@ public: const Q3DStudio::CString &inSourcePath) = 0; virtual void SetMaterialType(TInstanceHandle instance, - const Q3DStudio::CString &inRelativePathToMaterialFile) = 0; + const QString &inRelativePathToMaterialFile) = 0; virtual void setMaterialProperties(TInstanceHandle instance, const Q3DStudio::CString &materialSourcePath, diff --git a/src/Authoring/Client/Code/Core/Doc/IDocumentReader.h b/src/Authoring/Client/Code/Core/Doc/IDocumentReader.h index 514d1f98..010a9fe6 100644 --- a/src/Authoring/Client/Code/Core/Doc/IDocumentReader.h +++ b/src/Authoring/Client/Code/Core/Doc/IDocumentReader.h @@ -234,7 +234,7 @@ public: QHash<QString, QString> &outPathMap, QSet<QString> &outPropertyMap) = 0; - virtual Q3DStudio::CString GetCustomMaterialName(const Q3DStudio::CString &inFullPathToFile) const = 0; + virtual Q3DStudio::CString 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/Studio/Application/ProjectFile.cpp b/src/Authoring/Studio/Application/ProjectFile.cpp index a306a976..b4c18c50 100644 --- a/src/Authoring/Studio/Application/ProjectFile.cpp +++ b/src/Authoring/Studio/Application/ProjectFile.cpp @@ -290,7 +290,7 @@ void ProjectFile::writePresentationId(const QString &id, const QString &src) qt3dsdm::Qt3DSDMInstanceHandle child = iter.GetCurrent(); if (bridge->GetObjectType(child) & (OBJTYPE_LAYER | OBJTYPE_IMAGE)) { bool add = false; - if (bridge->GetSourcePath(child).toQString() == oldId) { + if (bridge->GetSourcePath(child) == oldId) { propSystem->SetInstancePropertyValue(child, bridge->GetSourcePathProperty(), qt3dsdm::SValue(QVariant(theId))); add = true; diff --git a/src/Authoring/Studio/DragAndDrop/FileDropSource.cpp b/src/Authoring/Studio/DragAndDrop/FileDropSource.cpp index 85bc1962..e88fb401 100644 --- a/src/Authoring/Studio/DragAndDrop/FileDropSource.cpp +++ b/src/Authoring/Studio/DragAndDrop/FileDropSource.cpp @@ -252,7 +252,7 @@ CCmd *CFileDropSource::GenerateAssetCommand(qt3dsdm::Qt3DSDMInstanceHandle inTar Q3DStudio::SCOPED_DOCUMENT_EDITOR(theDoc, tr("Set material diffuse map"))); editor->BeginAggregateOperation(); - editor->SetMaterialType(inTarget, "Standard Material"); + editor->SetMaterialType(inTarget, QStringLiteral("Standard Material")); editor->setInstanceImagePropertyValue(inTarget, propHandle, src, isPres); editor->EndAggregateOperation(); } else { @@ -295,12 +295,12 @@ CCmd *CFileDropSource::GenerateAssetCommand(qt3dsdm::Qt3DSDMInstanceHandle inTar Q3DStudio::ScopedDocumentEditor sceneEditor( Q3DStudio::SCOPED_DOCUMENT_EDITOR( *doc, tr("Drag and Drop Material"))); - Q3DStudio::CString docDir = theDoc.GetDocumentDirectory(); - Q3DStudio::CFilePath relPath = Q3DStudio::CFilePath::GetRelativePathFromBase( - docDir, Q3DStudio::CString::fromQString(m_FilePath)); - sceneEditor->SetMaterialType(inTarget, "Referenced Material"); - sceneEditor->setMaterialSourcePath(inTarget, relPath); - sceneEditor->setMaterialReferenceByPath(inTarget, relPath.toQString()); + QString relPath = theDoc.GetRelativePathToDoc(m_FilePath); + + sceneEditor->SetMaterialType(inTarget, QStringLiteral("Referenced Material")); + sceneEditor->setMaterialSourcePath(inTarget, + Q3DStudio::CString::fromQString(relPath)); + sceneEditor->setMaterialReferenceByPath(inTarget, relPath); theDoc.SelectDataModelObject(inTarget); } else { g_StudioApp.GetDialogs()->DisplayMessageBox( diff --git a/src/Authoring/Studio/Palettes/Action/PropertyModel.cpp b/src/Authoring/Studio/Palettes/Action/PropertyModel.cpp index da2c13fe..b19e2117 100644 --- a/src/Authoring/Studio/Palettes/Action/PropertyModel.cpp +++ b/src/Authoring/Studio/Palettes/Action/PropertyModel.cpp @@ -105,11 +105,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/Inspector/ChooserModelBase.cpp b/src/Authoring/Studio/Palettes/Inspector/ChooserModelBase.cpp index 8cd3c577..3a1a008b 100644 --- a/src/Authoring/Studio/Palettes/Inspector/ChooserModelBase.cpp +++ b/src/Authoring/Studio/Palettes/Inspector/ChooserModelBase.cpp @@ -166,7 +166,7 @@ void ChooserModelBase::setCurrentFile(const QString &path) int fixedItemIndex = getFixedItemIndex(path); const auto doc = g_StudioApp.GetCore()->GetDoc(); - const QDir documentDir(doc->GetDocumentDirectory().toQString()); + const QDir documentDir(doc->GetDocumentDirectory()); const QString fullPath = fixedItemIndex == -1 ? QDir::cleanPath(documentDir.filePath(path)) : path; diff --git a/src/Authoring/Studio/Palettes/Inspector/ImageChooserView.cpp b/src/Authoring/Studio/Palettes/Inspector/ImageChooserView.cpp index cdc5f008..e8180f94 100644 --- a/src/Authoring/Studio/Palettes/Inspector/ImageChooserView.cpp +++ b/src/Authoring/Studio/Palettes/Inspector/ImageChooserView.cpp @@ -106,8 +106,7 @@ QString ImageChooserView::currentDataModelPath() const else cleanPath = renderablePath; - cleanPath = QDir::cleanPath( - QDir(doc->GetDocumentDirectory().toQString()).filePath(cleanPath)); + cleanPath = QDir::cleanPath(QDir(doc->GetDocumentDirectory()).filePath(cleanPath)); } else { cleanPath = ChooserModelBase::noneString(); } diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp b/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp index f50418e9..7fb01bc2 100644 --- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp +++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp @@ -60,7 +60,7 @@ 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(); + Q3DStudio::CString docDir = Q3DStudio::CString::fromQString(doc->GetDocumentDirectory()); for (SubPresentationRecord r : qAsConst(g_StudioApp.m_subpresentations)) renderables.push_back(r.m_id); @@ -300,8 +300,7 @@ void InspectorControlModel::addMaterial() const auto type = getBridge()->GetObjectType(instance); if (type == OBJTYPE_REFERENCEDMATERIAL) { sceneEditor->setMaterialReferenceByPath(instance, absPath); - const auto relPath = QDir(doc->GetDocumentDirectory().toQString()) - .relativeFilePath(absPath); + const auto relPath = doc->GetRelativePathToDoc(absPath); sceneEditor->setMaterialSourcePath(instance, Q3DStudio::CString::fromQString(relPath)); sceneEditor->SetName(instance, getBridge()->GetName(newMaterial, true)); @@ -364,8 +363,7 @@ void InspectorControlModel::duplicateMaterial() if (type == OBJTYPE_REFERENCEDMATERIAL) { scopedEditor->setMaterialReferenceByPath(instance, absPath); - const auto relPath = QDir(doc->GetDocumentDirectory().toQString()) - .relativeFilePath(absPath); + const auto relPath = doc->GetRelativePathToDoc(absPath); scopedEditor->setMaterialSourcePath(instance, Q3DStudio::CString::fromQString(relPath)); scopedEditor->SetName(instance, getBridge()->GetName(duplicate, true)); doc->GetStudioSystem()->GetFullSystemSignalSender()->SendInstancePropertyValue( @@ -418,18 +416,12 @@ void InspectorControlModel::updateMatDataValues() void InspectorControlModel::setMaterials(std::vector<Q3DStudio::CFilePath> &materials) { m_materials.clear(); - const Q3DStudio::CString 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); - + for (Q3DStudio::CFilePath &path : materials) { + const QString absolutePath = g_StudioApp.GetCore()->GetDoc()->GetResolvedPathToDoc(path); const QString name = g_StudioApp.GetCore()->GetDoc()->GetDocumentReader() - .GetCustomMaterialName(absolutePath.toCString()).toQString(); + .GetCustomMaterialName(absolutePath).toQString(); - m_materials.push_back({name, relativePath}); + m_materials.push_back({name, path.toQString()}); } if (!isDefaultMaterial()) @@ -595,11 +587,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(); @@ -663,7 +655,7 @@ InspectorControlBase *InspectorControlModel::createMaterialTypeItem( const QStringList values = materialTypeValues(); item->m_values = values; - QString sourcePath = getBridge()->GetSourcePath(item->m_instance).toQString(); + QString sourcePath = getBridge()->GetSourcePath(item->m_instance); switch (inspectable->getObjectType()) { case OBJTYPE_MATERIAL: @@ -705,7 +697,7 @@ InspectorControlBase *InspectorControlModel::createShaderItem( const QStringList values = shaderValues(); item->m_values = values; - QString sourcePath = getBridge()->GetSourcePath(item->m_instance).toQString(); + QString sourcePath = getBridge()->GetSourcePath(item->m_instance); item->m_value = values[0]; for (int matIdx = 0, end = int(m_materials.size()); matIdx < end; ++matIdx) { @@ -731,7 +723,7 @@ InspectorControlBase *InspectorControlModel::createMatDataItem( const QStringList values = matDataValues(); item->m_values = values; - QString sourcePath = getBridge()->GetSourcePath(item->m_instance).toQString(); + QString sourcePath = getBridge()->GetSourcePath(item->m_instance); item->m_value = getDefaultMaterialString(); for (int matIdx = 0, end = int(m_matDatas.size()); matIdx < end; ++matIdx) { @@ -995,11 +987,11 @@ auto InspectorControlModel::computeTree(CInspectableBase *inspectBase) if (refMaterialInspectable) { QString materialSrcPath; if (instance.Valid()) - materialSrcPath = getBridge()->GetSourcePath(instance).toQString(); + materialSrcPath = getBridge()->GetSourcePath(instance); if (materialSrcPath != getBridge()->getDefaultMaterialName() - && getBridge()->GetSourcePath(refMaterial) != Q3DStudio::CString::fromQString( - getBridge()->getDefaultMaterialName())) { + && getBridge()->GetSourcePath(refMaterial) + != getBridge()->getDefaultMaterialName()) { result.append(computeGroup(refMaterialInspectable, refMaterialInspectable->getGroupCount() - 1, true, true)); @@ -1465,7 +1457,7 @@ void InspectorControlModel::saveIfMaterial(qt3dsdm::Qt3DSDMInstanceHandle instan QString sourcePath; for (int i = 0; i < m_matDatas.size(); ++i) { if (QString::compare(m_matDatas[i].m_name, materialName, Qt::CaseInsensitive) == 0) { - sourcePath = doc->GetDocumentDirectory().toQString() + QLatin1Char('/') + sourcePath = doc->GetDocumentDirectory() + QLatin1Char('/') + m_matDatas[i].m_relativePath; } } @@ -1479,7 +1471,7 @@ void InspectorControlModel::setMaterialTypeValue(long instance, int handle, cons Q_UNUSED(handle) const QString typeValue = value.toString(); - Q3DStudio::CString v; + QString v; const auto doc = g_StudioApp.GetCore()->GetDoc(); const auto sceneEditor = doc->getSceneEditor(); @@ -1491,22 +1483,22 @@ void InspectorControlModel::setMaterialTypeValue(long instance, int handle, cons bool changeMaterialFile = false; bool canCopyProperties = false; if (typeValue == getAnimatableMaterialString()) { - v = Q3DStudio::CString("Standard Material"); + v = QStringLiteral("Standard Material"); if (refMaterial.Valid()) { const auto refSourcePath = getBridge()->GetSourcePath(refMaterial); for (auto &material : m_materials) { - if (refSourcePath.toQString() == material.m_relativePath) { - v = Q3DStudio::CString::fromQString(material.m_relativePath); + if (refSourcePath == material.m_relativePath) { + v = material.m_relativePath; break; } } } canCopyProperties = true; } else if (typeValue == getBasicMaterialString()) { - v = Q3DStudio::CString("Referenced Material"); + v = QStringLiteral("Referenced Material"); changeMaterialFile = true; } else if (typeValue == getReferencedMaterialString()) { - v = Q3DStudio::CString("Referenced Material"); + v = QStringLiteral("Referenced Material"); } Q3DStudio::ScopedDocumentEditor scopedEditor( @@ -1546,10 +1538,10 @@ void InspectorControlModel::setShaderValue(long instance, int handle, const QVar Q_UNUSED(handle) const QString typeValue = value.toString(); - Q3DStudio::CString v("Standard Material"); + QString v = QStringLiteral("Standard Material"); 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; } const auto doc = g_StudioApp.GetCore()->GetDoc(); @@ -1562,7 +1554,7 @@ void InspectorControlModel::setShaderValue(long instance, int handle, const QVar doc->getSceneReferencedMaterials(doc->GetSceneInstance(), refMats); for (auto &refMat : qAsConst(refMats)) { const auto origMat = getBridge()->getMaterialReference(refMat); - if (origMat.Valid() && (long)origMat == instance) + if (origMat.Valid() && long(origMat) == instance) dispatch->FireImmediateRefreshInstance(refMat); } @@ -1574,7 +1566,7 @@ void InspectorControlModel::setMatDataValue(long instance, int handle, const QVa Q_UNUSED(handle) const QString typeValue = value.toString(); - Q3DStudio::CString v; + QString v; QString name; Q3DStudio::CString srcPath; QMap<QString, QString> values; @@ -1584,7 +1576,7 @@ void InspectorControlModel::setMatDataValue(long instance, int handle, const QVa bool changeMaterialFile = false; if (typeValue == getDefaultMaterialString()) { - v = Q3DStudio::CString("Referenced Material"); + v = QStringLiteral("Referenced Material"); name = getBridge()->getDefaultMaterialName(); srcPath = Q3DStudio::CString::fromQString(name); changeMaterialFile = true; @@ -1599,7 +1591,7 @@ void InspectorControlModel::setMatDataValue(long instance, int handle, const QVa + m_matDatas[matIdx].m_relativePath + QLatin1Char(')'), typeValue, Qt::CaseInsensitive) == 0 || QString::compare(shownName, typeValue, Qt::CaseInsensitive) == 0) { - v = Q3DStudio::CString("Referenced Material"); + v = QStringLiteral("Referenced Material"); changeMaterialFile = true; name = m_matDatas[matIdx].m_name; srcPath = Q3DStudio::CString::fromQString(m_matDatas[matIdx].m_relativePath); @@ -1608,7 +1600,7 @@ void InspectorControlModel::setMatDataValue(long instance, int handle, const QVa // Get the correct case source path const auto absPath = sceneEditor->getFilePathFromMaterialName( sceneEditor->GetName(material).toQString()); - const auto relPath = QDir(doc->GetDocumentDirectory().toQString()) + const auto relPath = QDir(doc->GetDocumentDirectory()) .relativeFilePath(absPath); srcPath = Q3DStudio::CString::fromQString(relPath); } @@ -1755,7 +1747,7 @@ void InspectorControlModel::setPropertyValue(long instance, int handle, const QV if (newName != currentName) { if (getBridge()->isInsideMaterialContainer(instance)) { const auto properOldName = sceneEditor->GetName(instance).toQString(); - const auto dirPath = doc->GetDocumentDirectory().toQString(); + const QString dirPath = doc->GetDocumentDirectory(); for (size_t matIdx = 0, end = m_matDatas.size(); matIdx < end; ++matIdx) { if (m_matDatas[matIdx].m_name == properOldName) { QFileInfo fileInfo(dirPath + QLatin1Char('/') diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp index 38f65da8..e4e0379f 100644 --- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp +++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp @@ -601,7 +601,7 @@ void InspectorControlView::setPropertyValueFromFilename(long instance, int handl if (name != ChooserModelBase::noneString()) { // Relativize the path to the presentation 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; } diff --git a/src/Authoring/Studio/Palettes/Inspector/MeshChooserView.cpp b/src/Authoring/Studio/Palettes/Inspector/MeshChooserView.cpp index c740eaf8..1aac4731 100644 --- a/src/Authoring/Studio/Palettes/Inspector/MeshChooserView.cpp +++ b/src/Authoring/Studio/Palettes/Inspector/MeshChooserView.cpp @@ -107,12 +107,10 @@ void MeshChooserView::updateSelection() QString currentFile; const QString meshValue = qt3dsdm::get<QString>(value); - if (meshValue.startsWith(QLatin1Char('#'))) { + if (meshValue.startsWith(QLatin1Char('#'))) currentFile = meshValue.mid(1); - } else { - currentFile = QDir::cleanPath(QDir(doc->GetDocumentDirectory().toQString()) - .filePath(meshValue)); - } + else + currentFile = QDir::cleanPath(QDir(doc->GetDocumentDirectory()).filePath(meshValue)); m_model->setCurrentFile(currentFile); } diff --git a/src/Authoring/Studio/Palettes/Inspector/TextureChooserView.cpp b/src/Authoring/Studio/Palettes/Inspector/TextureChooserView.cpp index 59e8bfac..8804e675 100644 --- a/src/Authoring/Studio/Palettes/Inspector/TextureChooserView.cpp +++ b/src/Authoring/Studio/Palettes/Inspector/TextureChooserView.cpp @@ -107,8 +107,7 @@ QString TextureChooserView::currentDataModelPath() const else cleanPath = renderablePath; - cleanPath = QDir::cleanPath( - QDir(doc->GetDocumentDirectory().toQString()).filePath(cleanPath)); + cleanPath = QDir::cleanPath(QDir(doc->GetDocumentDirectory()).filePath(cleanPath)); } return cleanPath; } diff --git a/src/Authoring/Studio/Palettes/Project/ProjectFileSystemModel.cpp b/src/Authoring/Studio/Palettes/Project/ProjectFileSystemModel.cpp index 35048336..4f62cd59 100644 --- a/src/Authoring/Studio/Palettes/Project/ProjectFileSystemModel.cpp +++ b/src/Authoring/Studio/Palettes/Project/ProjectFileSystemModel.cpp @@ -192,8 +192,8 @@ void ProjectFileSystemModel::updateReferences() SubPresentationRecord({}, doc->getPresentationId(), projectDir.relativeFilePath(doc->GetDocumentPath()))); - auto addReferencesPresentation = [this, doc, &projectPath](const Q3DStudio::CString &str) { - addPathsToReferences(m_references, projectPath, doc->GetResolvedPathToDoc(str).toQString()); + auto addReferencesPresentation = [this, doc, &projectPath](const QString &str) { + addPathsToReferences(m_references, projectPath, doc->GetResolvedPathToDoc(str)); }; auto addReferencesRenderable = [this, &projectPath, &projectPathSlash, &subpresentationRecord] (const QString &id) { diff --git a/src/Authoring/Studio/Palettes/Project/ProjectView.cpp b/src/Authoring/Studio/Palettes/Project/ProjectView.cpp index c0ba2724..dadb5895 100644 --- a/src/Authoring/Studio/Palettes/Project/ProjectView.cpp +++ b/src/Authoring/Studio/Palettes/Project/ProjectView.cpp @@ -333,11 +333,11 @@ void ProjectView::copyPath(int row) const { if (row == -1) 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 QString path = m_ProjectModel->filePath(row); + const QString relativePath = doc->GetRelativePathToDoc(path); + CStudioClipboard::CopyTextToClipboard(relativePath); } void ProjectView::copyFullPath(int row) const diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp index 53768a47..d71ef582 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp @@ -576,7 +576,7 @@ bool Qt3DSDMTimelineItemBinding::IsValidTransaction(EUserTransaction inTransacti case EUserTransaction_Rename: return (GetObjectType() != OBJTYPE_SCENE && GetObjectType() != OBJTYPE_IMAGE && (bridge->GetObjectType(theInstance) != OBJTYPE_REFERENCEDMATERIAL - || bridge->GetSourcePath(theInstance).IsEmpty())); + || bridge->GetSourcePath(theInstance).isEmpty())); case EUserTransaction_Duplicate: if (theInstance.Valid()) diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp index df49701a..d7b2d091 100644 --- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp +++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp @@ -872,7 +872,7 @@ void TimelineGraphicsScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *even const auto bridge = g_StudioApp.GetCore()->GetDoc()->GetStudioSystem() ->GetClientDataModelBridge(); if (bridge->GetObjectType(instance) != OBJTYPE_REFERENCEDMATERIAL - || bridge->GetSourcePath(instance).IsEmpty()) { + || bridge->GetSourcePath(instance).isEmpty()) { // Tree labels text can be edited with double-click, // except for Scene label and basic materials treeLabelItem->setEnabled(true); diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTreeContextMenu.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTreeContextMenu.cpp index a7b301a2..9544903e 100644 --- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTreeContextMenu.cpp +++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTreeContextMenu.cpp @@ -267,7 +267,7 @@ void RowTreeContextMenu::addSubPresentation(QAction *action) Q3DStudio::ScopedDocumentEditor editor(Q3DStudio::SCOPED_DOCUMENT_EDITOR(doc, tr("Set material sub-presentation"))); editor->BeginAggregateOperation(); - editor->SetMaterialType(instance, "Standard Material"); + editor->SetMaterialType(instance, QStringLiteral("Standard Material")); editor->setInstanceImagePropertyValue(instance, propHandle, presentationId); editor->EndAggregateOperation(); } else { diff --git a/src/Authoring/Studio/UI/StudioAppPrefsPage.cpp b/src/Authoring/Studio/UI/StudioAppPrefsPage.cpp index 36d9f247..1c1cef75 100644 --- a/src/Authoring/Studio/UI/StudioAppPrefsPage.cpp +++ b/src/Authoring/Studio/UI/StudioAppPrefsPage.cpp @@ -379,9 +379,9 @@ 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"))) + if (files.next().endsWith(QLatin1String("_autosave.uip"))) QFile::remove(files.filePath()); } } diff --git a/src/Runtime/Source/runtimerender/Qt3DSQtTextRenderer.cpp b/src/Runtime/Source/runtimerender/Qt3DSQtTextRenderer.cpp index 637aba94..029ccea2 100644 --- a/src/Runtime/Source/runtimerender/Qt3DSQtTextRenderer.cpp +++ b/src/Runtime/Source/runtimerender/Qt3DSQtTextRenderer.cpp @@ -342,10 +342,11 @@ struct Qt3DSQtTextRenderer : public ITextRenderer if (m_installedFonts.empty()) { m_installedFonts.reserve(m_projectFontInfos.size()); for (FontInfo &fi : m_projectFontInfos.values()) { - m_installedFonts.push_back(SRendererFontEntry( - QStringToRegisteredString(fi.fontName), - QStringToRegisteredString(fi.fontFileName))); - } + m_installedFonts.push_back(SRendererFontEntry( + fi.fontName, + fi.fontFileName)); + } + } return m_installedFonts; } diff --git a/src/Runtime/Source/runtimerender/Qt3DSTextRenderer.h b/src/Runtime/Source/runtimerender/Qt3DSTextRenderer.h index 65b7cb00..11c9ec6e 100644 --- a/src/Runtime/Source/runtimerender/Qt3DSTextRenderer.h +++ b/src/Runtime/Source/runtimerender/Qt3DSTextRenderer.h @@ -41,11 +41,11 @@ namespace render { struct SRendererFontEntry { - CRegisteredString m_FontName; - CRegisteredString m_FontFile; + QString m_FontName; + QString m_FontFile; SRendererFontEntry() {} - SRendererFontEntry(CRegisteredString nm, CRegisteredString file) - : m_FontName(nm) + SRendererFontEntry(QString name, QString file) + : m_FontName(name) , m_FontFile(file) { } |