diff options
author | Jochen Becher <jochen_becher@gmx.de> | 2024-05-05 19:40:09 +0200 |
---|---|---|
committer | Jochen Becher <jochen_becher@gmx.de> | 2024-05-10 18:50:22 +0000 |
commit | 76f2b6d5e1ec563d144087d0c3eed777876da900 (patch) | |
tree | a3ce8d982b7401b8cec76c7ca26957be8e1ec0c6 /src/plugins/modeleditor | |
parent | 99acd3247fa5d92ff4237350d16c32305eb1cd5c (diff) |
ModelEditor: Use Utils::FilePath
More replacements of QString with Utils::FilePath and removal of
QFileInfo and QDir will follow.
Change-Id: Iceec1c009c562bd9a05f9ab1d1a9f83ad48a4467
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'src/plugins/modeleditor')
-rw-r--r-- | src/plugins/modeleditor/componentviewcontroller.cpp | 12 | ||||
-rw-r--r-- | src/plugins/modeleditor/elementtasks.cpp | 42 | ||||
-rw-r--r-- | src/plugins/modeleditor/elementtasks.h | 9 | ||||
-rw-r--r-- | src/plugins/modeleditor/extdocumentcontroller.cpp | 7 | ||||
-rw-r--r-- | src/plugins/modeleditor/extdocumentcontroller.h | 4 | ||||
-rw-r--r-- | src/plugins/modeleditor/extpropertiesmview.cpp | 31 | ||||
-rw-r--r-- | src/plugins/modeleditor/jsextension.cpp | 2 | ||||
-rw-r--r-- | src/plugins/modeleditor/jsextension.h | 4 | ||||
-rw-r--r-- | src/plugins/modeleditor/modeldocument.cpp | 24 | ||||
-rw-r--r-- | src/plugins/modeleditor/modeldocument.h | 3 | ||||
-rw-r--r-- | src/plugins/modeleditor/modeleditor.cpp | 1 | ||||
-rw-r--r-- | src/plugins/modeleditor/modelindexer.cpp | 2 | ||||
-rw-r--r-- | src/plugins/modeleditor/modelsmanager.cpp | 4 | ||||
-rw-r--r-- | src/plugins/modeleditor/pxnodecontroller.cpp | 11 | ||||
-rw-r--r-- | src/plugins/modeleditor/pxnodeutilities.cpp | 6 |
15 files changed, 82 insertions, 80 deletions
diff --git a/src/plugins/modeleditor/componentviewcontroller.cpp b/src/plugins/modeleditor/componentviewcontroller.cpp index 684d104fd9f..b370c10d2d1 100644 --- a/src/plugins/modeleditor/componentviewcontroller.cpp +++ b/src/plugins/modeleditor/componentviewcontroller.cpp @@ -52,9 +52,9 @@ private: void FindComponentFromFilePath::setFilePath(const QString &filePath) { - m_elementName = qmt::NameController::convertFileNameToElementName(filePath); + m_elementName = qmt::NameController::convertFileNameToElementName(Utils::FilePath::fromString(filePath)); QFileInfo fileInfo(filePath); - m_elementsPath = qmt::NameController::buildElementsPath(fileInfo.path(), false); + m_elementsPath = qmt::NameController::buildElementsPath(Utils::FilePath::fromString(fileInfo.path()), false); } void FindComponentFromFilePath::visitMComponent(qmt::MComponent *component) @@ -218,10 +218,10 @@ void UpdateIncludeDependenciesVisitor::collectElementPaths(const ProjectExplorer QMultiHash<QString, Node> *filePathsMap) { folderNode->forEachFileNode([&](FileNode *fileNode) { - QString elementName = qmt::NameController::convertFileNameToElementName(fileNode->filePath().toString()); + QString elementName = qmt::NameController::convertFileNameToElementName(fileNode->filePath()); QFileInfo fileInfo = fileNode->filePath().toFileInfo(); QString nodePath = fileInfo.path(); - QStringList elementsPath = qmt::NameController::buildElementsPath(nodePath, false); + QStringList elementsPath = qmt::NameController::buildElementsPath(Utils::FilePath::fromString(nodePath), false); filePathsMap->insert(elementName, Node(fileNode->filePath().toString(), elementsPath)); }); folderNode->forEachFolderNode([&](FolderNode *subNode) { @@ -309,7 +309,7 @@ void ComponentViewController::doCreateComponentModel(const QString &filePath, qm { for (const QString &fileName : QDir(filePath).entryList(QDir::Files)) { QString file = filePath + "/" + fileName; - QString componentName = qmt::NameController::convertFileNameToElementName(file); + QString componentName = qmt::NameController::convertFileNameToElementName(Utils::FilePath::fromString(file)); qmt::MComponent *component = nullptr; bool isSource = false; CppEditor::ProjectFile::Kind kind = CppEditor::ProjectFile::classify(file); @@ -341,7 +341,7 @@ void ComponentViewController::doCreateComponentModel(const QString &filePath, qm } if (component) { QStringList relativeElements = qmt::NameController::buildElementsPath( - d->pxnodeUtilities->calcRelativePath(file, anchorFolder), false); + Utils::FilePath::fromString(d->pxnodeUtilities->calcRelativePath(file, anchorFolder)), false); if (d->pxnodeUtilities->findSameObject(relativeElements, component)) { delete component; } else { diff --git a/src/plugins/modeleditor/elementtasks.cpp b/src/plugins/modeleditor/elementtasks.cpp index 173ccd65241..c13f96e39ca 100644 --- a/src/plugins/modeleditor/elementtasks.cpp +++ b/src/plugins/modeleditor/elementtasks.cpp @@ -401,17 +401,22 @@ void ElementTasks::createAndOpenDiagram(const qmt::DElement *element, const qmt: createAndOpenDiagram(melement); } +Utils::FilePath ElementTasks::linkedFile(const qmt::MObject *mobject) const +{ + Utils::FilePath filepath = Utils::FilePath::fromString(mobject->linkedFileName()); + if (!filepath.isEmpty()) { + Utils::FilePath projectName = d->documentController->projectController()->project()->fileName(); + filepath = projectName.absolutePath().resolvePath(filepath).canonicalPath(); + } + return filepath; +} + bool ElementTasks::hasLinkedFile(const qmt::MElement *element) const { if (auto mobject = dynamic_cast<const qmt::MObject *>(element)) { - QString filename = mobject->linkedFileName(); - if (!filename.isEmpty()) { - QString projectName = d->documentController->projectController()->project()->fileName(); - Utils::FilePath relativePath = Utils::FilePath::fromString(filename); - Utils::FilePath projectPath = Utils::FilePath::fromString(projectName); - QString filepath = relativePath.resolvePath(projectPath).toString(); - return QFileInfo::exists(filepath); - } + Utils::FilePath filepath = linkedFile(mobject); + if (!filepath.isEmpty()) + return filepath.exists(); } return false; } @@ -429,25 +434,20 @@ bool ElementTasks::hasLinkedFile(const qmt::DElement *element, const qmt::MDiagr void ElementTasks::openLinkedFile(const qmt::MElement *element) { if (auto mobject = dynamic_cast<const qmt::MObject *>(element)) { - QString filename = mobject->linkedFileName(); - if (!filename.isEmpty()) { - QString projectName = d->documentController->projectController()->project()->fileName(); - QString filepath; - if (QFileInfo(filename).isRelative()) - filepath = QFileInfo(QFileInfo(projectName).path() + "/" + filename).canonicalFilePath(); - else - filepath = filename; - if (QFileInfo::exists(filepath)) { - Core::EditorFactories list = Core::IEditorFactory::preferredEditorFactories(Utils::FilePath::fromString(filepath)); + Utils::FilePath filepath = linkedFile(mobject); + if (!filepath.isEmpty()) { + if (filepath.exists()) { + Core::EditorFactories list = Core::IEditorFactory::preferredEditorFactories(filepath); if (list.empty() || (list.count() <= 1 && list.at(0)->id() == "Core.BinaryEditor")) { // intentionally ignore return code - (void) Core::EditorManager::instance()->openExternalEditor(Utils::FilePath::fromString(filepath), "CorePlugin.OpenWithSystemEditor"); + (void) Core::EditorManager::instance()->openExternalEditor(filepath, "CorePlugin.OpenWithSystemEditor"); } else { // intentionally ignore return code - (void) Core::EditorManager::instance()->openEditor(Utils::FilePath::fromString(filepath)); + (void) Core::EditorManager::instance()->openEditor(filepath); } } else { - QMessageBox::critical(Core::ICore::dialogParent(), Tr::tr("Opening File"), Tr::tr("File %1 does not exist.").arg(filepath)); + QMessageBox::critical(Core::ICore::dialogParent(), Tr::tr("Opening File"), + Tr::tr("File %1 does not exist.").arg(filepath.toUserOutput())); } } } diff --git a/src/plugins/modeleditor/elementtasks.h b/src/plugins/modeleditor/elementtasks.h index caee1e9e6f0..2eb2d3a272f 100644 --- a/src/plugins/modeleditor/elementtasks.h +++ b/src/plugins/modeleditor/elementtasks.h @@ -6,7 +6,12 @@ #include <QObject> #include "qmt/tasks/ielementtasks.h" -namespace qmt { class DocumentController; } +#include <utils/filepath.h> + +namespace qmt { +class DocumentController; +class MObject; +} namespace ModelEditor { namespace Internal { @@ -75,6 +80,8 @@ public: bool handleContextMenuAction(qmt::DElement *element, qmt::MDiagram *diagram, const QString &id) override; private: + Utils::FilePath linkedFile(const qmt::MObject *mobject) const; + ElementTasksPrivate *d; }; diff --git a/src/plugins/modeleditor/extdocumentcontroller.cpp b/src/plugins/modeleditor/extdocumentcontroller.cpp index 46df6f7472e..ad2940c05f2 100644 --- a/src/plugins/modeleditor/extdocumentcontroller.cpp +++ b/src/plugins/modeleditor/extdocumentcontroller.cpp @@ -9,8 +9,6 @@ #include "qmt/project_controller/projectcontroller.h" #include "qmt/tasks/diagramscenecontroller.h" -#include <QFileInfo> - namespace ModelEditor { namespace Internal { @@ -51,10 +49,9 @@ PxNodeController *ExtDocumentController::pxNodeController() const return d->pxNodeController; } -void ExtDocumentController::onProjectFileNameChanged(const QString &fileName) +void ExtDocumentController::onProjectFileNameChanged(const Utils::FilePath &fileName) { - QFileInfo fileInfo(fileName); - d->pxNodeController->setAnchorFolder(fileInfo.path()); + d->pxNodeController->setAnchorFolder(fileName.path()); } } // namespace Internal diff --git a/src/plugins/modeleditor/extdocumentcontroller.h b/src/plugins/modeleditor/extdocumentcontroller.h index 8a0f2a28ec3..0fc50aca178 100644 --- a/src/plugins/modeleditor/extdocumentcontroller.h +++ b/src/plugins/modeleditor/extdocumentcontroller.h @@ -5,6 +5,8 @@ #include "qmt/document_controller/documentcontroller.h" +#include <utils/filepath.h> + namespace ModelEditor { namespace Internal { @@ -25,7 +27,7 @@ public: PxNodeController *pxNodeController() const; private: - void onProjectFileNameChanged(const QString &fileName); + void onProjectFileNameChanged(const Utils::FilePath &fileName); private: ExtDocumentControllerPrivate *d; diff --git a/src/plugins/modeleditor/extpropertiesmview.cpp b/src/plugins/modeleditor/extpropertiesmview.cpp index fcae9ada222..68dac749f1e 100644 --- a/src/plugins/modeleditor/extpropertiesmview.cpp +++ b/src/plugins/modeleditor/extpropertiesmview.cpp @@ -83,8 +83,7 @@ void ExtPropertiesMView::visitMPackage(const qmt::MPackage *package) m_configPath = new Utils::PathChooser(m_topWidget); m_configPath->setPromptDialogTitle(Tr::tr("Select Custom Configuration Folder")); m_configPath->setExpectedKind(Utils::PathChooser::ExistingDirectory); - m_configPath->setInitialBrowsePathBackup( - Utils::FilePath::fromString(project->fileName()).absolutePath()); + m_configPath->setInitialBrowsePathBackup(project->fileName().absolutePath()); addRow(Tr::tr("Config path:"), m_configPath, "configpath"); connect(m_configPath, &Utils::PathChooser::textChanged, this, &ExtPropertiesMView::onConfigPathChanged, @@ -95,8 +94,8 @@ void ExtPropertiesMView::visitMPackage(const qmt::MPackage *package) m_configPath->setFilePath({}); } else { // make path absolute (may be relative to current project's directory) - QDir projectDir = QFileInfo(project->fileName()).absoluteDir(); - m_configPath->setPath(QFileInfo(projectDir, project->configPath()).canonicalFilePath()); + auto projectDir = project->fileName().absolutePath(); + m_configPath->setPath(projectDir.resolvePath(project->configPath()).toUserOutput()); } } if (!m_configPathInfo) { @@ -115,7 +114,7 @@ void ExtPropertiesMView::visitMObjectBehind(const qmt::MObject *object) m_filelinkPathChooser = new Utils::PathChooser(m_topWidget); m_filelinkPathChooser->setPromptDialogTitle((Tr::tr("Select File Target"))); m_filelinkPathChooser->setExpectedKind(Utils::PathChooser::File); - m_filelinkPathChooser->setInitialBrowsePathBackup(Utils::FilePath::fromString(QFileInfo(project->fileName()).absolutePath())); + m_filelinkPathChooser->setInitialBrowsePathBackup(project->fileName().absolutePath()); addRow(Tr::tr("Linked file:"), m_filelinkPathChooser, "filelink"); connect(m_filelinkPathChooser, &Utils::PathChooser::textChanged, this, &ExtPropertiesMView::onFileLinkPathChanged, @@ -128,7 +127,7 @@ void ExtPropertiesMView::visitMObjectBehind(const qmt::MObject *object) m_filelinkPathChooser->setPath(QString()); } else { Utils::FilePath relativePath = Utils::FilePath::fromString(path); - Utils::FilePath projectPath = Utils::FilePath::fromString(project->fileName()); + Utils::FilePath projectPath = project->fileName(); QString filePath = absoluteFromRelativePath(relativePath, projectPath).toString(); m_filelinkPathChooser->setPath(filePath); } @@ -150,8 +149,7 @@ void ExtPropertiesMView::visitDObjectBefore(const qmt::DObject *object) m_imagePathChooser->setPromptDialogTitle(Tr::tr("Select Image File")); m_imagePathChooser->setExpectedKind(Utils::PathChooser::File); m_imagePathChooser->setPromptDialogFilter(imageNameFilterString()); - m_imagePathChooser->setInitialBrowsePathBackup( - Utils::FilePath::fromString(QFileInfo(project->fileName()).absolutePath())); + m_imagePathChooser->setInitialBrowsePathBackup(project->fileName().absolutePath()); addRow(Tr::tr("Image:"), m_imagePathChooser, "imagepath"); connect(m_imagePathChooser, &Utils::PathChooser::textChanged, this, &ExtPropertiesMView::onImagePathChanged, @@ -164,8 +162,7 @@ void ExtPropertiesMView::visitDObjectBefore(const qmt::DObject *object) m_imagePathChooser->setPath(QString()); } else { Utils::FilePath relativePath = Utils::FilePath::fromString(path); - Utils::FilePath projectPath = Utils::FilePath::fromString(project->fileName()); - QString filePath = absoluteFromRelativePath(relativePath, projectPath).toString(); + QString filePath = absoluteFromRelativePath(relativePath, project->fileName()).toString(); m_imagePathChooser->setPath(filePath); } } @@ -182,16 +179,15 @@ void ExtPropertiesMView::onConfigPathChanged(const QString &path) qmt::Project *project = m_projectController->project(); if (path.isEmpty()) { if (!project->configPath().isEmpty()) { - project->setConfigPath(QString()); + project->setConfigPath({ }); m_projectController->setModified(); modified = true; } } else { // make path relative to current project's directory - QFileInfo absConfigPath = Utils::FilePath::fromString(path).toFileInfo(); - absConfigPath.makeAbsolute(); - QDir projectDir = QFileInfo(project->fileName()).dir(); - QString configPath = projectDir.relativeFilePath(absConfigPath.filePath()); + Utils::FilePath absConfigPath = Utils::FilePath::fromString(path).absoluteFilePath(); + Utils::FilePath projectDir = project->fileName().absolutePath(); + Utils::FilePath configPath = absConfigPath.relativePathFrom(projectDir); if (configPath != project->configPath()) { project->setConfigPath(configPath); m_projectController->setModified(); @@ -211,7 +207,7 @@ void ExtPropertiesMView::onFileLinkPathChanged(const QString &path) } else { // make path relative to current project's directory Utils::FilePath filePath = Utils::FilePath::fromString(path); - Utils::FilePath projectPath = Utils::FilePath::fromString(QFileInfo(project->fileName()).path()); + Utils::FilePath projectPath = project->fileName().absolutePath(); QString relativeFilePath = filePath.relativePathFrom(projectPath).toString(); if (!relativeFilePath.isEmpty()) { assignModelElement<qmt::MObject, QString>(m_modelElements, SelectionSingle, relativeFilePath, @@ -231,8 +227,7 @@ void ExtPropertiesMView::onImagePathChanged(const QString &path) } else { // make path relative to current project's directory Utils::FilePath filePath = Utils::FilePath::fromString(path); - Utils::FilePath projectPath = Utils::FilePath::fromString( - QFileInfo(project->fileName()).path()); + Utils::FilePath projectPath = project->fileName().absolutePath(); QString relativeFilePath = filePath.relativePathFrom(projectPath).toString(); if (!relativeFilePath.isEmpty() && isValueChanged<qmt::DObject, QString>(m_diagramElements, SelectionSingle, relativeFilePath, diff --git a/src/plugins/modeleditor/jsextension.cpp b/src/plugins/modeleditor/jsextension.cpp index cfe31ddea7d..60f00a113a5 100644 --- a/src/plugins/modeleditor/jsextension.cpp +++ b/src/plugins/modeleditor/jsextension.cpp @@ -5,7 +5,7 @@ #include <qmt/controller/namecontroller.h> -QString ModelEditor::Internal::JsExtension::fileNameToElementName(const QString &file) +QString ModelEditor::Internal::JsExtension::fileNameToElementName(const Utils::FilePath &file) { return qmt::NameController::convertFileNameToElementName(file); } diff --git a/src/plugins/modeleditor/jsextension.h b/src/plugins/modeleditor/jsextension.h index 1cc9c262f29..d9f3484919c 100644 --- a/src/plugins/modeleditor/jsextension.h +++ b/src/plugins/modeleditor/jsextension.h @@ -5,6 +5,8 @@ #include <QObject> +#include <utils/filepath.h> + namespace ModelEditor { namespace Internal { @@ -15,7 +17,7 @@ class JsExtension : public QObject public: JsExtension() {} - Q_INVOKABLE QString fileNameToElementName(const QString &file); + Q_INVOKABLE QString fileNameToElementName(const Utils::FilePath &file); Q_INVOKABLE QString elementNameToFileName(const QString &element); }; diff --git a/src/plugins/modeleditor/modeldocument.cpp b/src/plugins/modeleditor/modeldocument.cpp index a1c271539c6..cc0ac3aa7da 100644 --- a/src/plugins/modeleditor/modeldocument.cpp +++ b/src/plugins/modeleditor/modeldocument.cpp @@ -19,9 +19,6 @@ #include <utils/id.h> #include <utils/fileutils.h> -#include <QFileInfo> -#include <QDir> - namespace ModelEditor { namespace Internal { @@ -51,7 +48,7 @@ Core::IDocument::OpenResult ModelDocument::open(QString *errorString, { Q_UNUSED(filePath) - OpenResult result = load(errorString, realFilePath.toString()); + OpenResult result = load(errorString, realFilePath); return result; } @@ -62,7 +59,7 @@ bool ModelDocument::saveImpl(QString *errorString, const Utils::FilePath &filePa return false; } - d->documentController->projectController()->setFileName(filePath.toString()); + d->documentController->projectController()->setFileName(filePath); try { d->documentController->projectController()->save(); } catch (const qmt::Exception &ex) { @@ -73,7 +70,7 @@ bool ModelDocument::saveImpl(QString *errorString, const Utils::FilePath &filePa if (autoSave) { d->documentController->projectController()->setModified(); } else { - setFilePath(Utils::FilePath::fromString(d->documentController->projectController()->project()->fileName())); + setFilePath(d->documentController->projectController()->project()->fileName()); emit changed(); } @@ -102,12 +99,13 @@ bool ModelDocument::reload(QString *errorString, Core::IDocument::ReloadFlag fla if (flag == FlagIgnore) return true; try { - d->documentController->loadProject(filePath().toString()); + d->documentController->loadProject(filePath()); } catch (const qmt::FileNotFoundException &ex) { *errorString = ex.errorMessage(); return false; } catch (const qmt::Exception &ex) { - *errorString = Tr::tr("Could not open \"%1\" for reading: %2.").arg(filePath().toString()).arg(ex.errorMessage()); + *errorString = Tr::tr("Could not open \"%1\" for reading: %2.") + .arg(filePath().toUserOutput(), ex.errorMessage()); return false; } emit contentSet(); @@ -119,25 +117,25 @@ ExtDocumentController *ModelDocument::documentController() const return d->documentController; } -Core::IDocument::OpenResult ModelDocument::load(QString *errorString, const QString &fileName) +Core::IDocument::OpenResult ModelDocument::load(QString *errorString, const Utils::FilePath &fileName) { d->documentController = ModelEditorPlugin::modelsManager()->createModel(this); connect(d->documentController, &qmt::DocumentController::changed, this, &IDocument::changed); try { d->documentController->loadProject(fileName); - setFilePath(Utils::FilePath::fromString(d->documentController->projectController()->project()->fileName())); + setFilePath(d->documentController->projectController()->project()->fileName()); } catch (const qmt::FileNotFoundException &ex) { *errorString = ex.errorMessage(); return OpenResult::ReadError; } catch (const qmt::Exception &ex) { - *errorString = Tr::tr("Could not open \"%1\" for reading: %2.").arg(fileName).arg(ex.errorMessage()); + *errorString = Tr::tr("Could not open \"%1\" for reading: %2.").arg(fileName.toUserOutput(), ex.errorMessage()); return OpenResult::CannotHandle; } - QString configPath = d->documentController->projectController()->project()->configPath(); + Utils::FilePath configPath = d->documentController->projectController()->project()->configPath(); if (!configPath.isEmpty()) { - QString canonicalPath = QFileInfo(QDir(QFileInfo(fileName).path()).filePath(configPath)).canonicalFilePath(); + Utils::FilePath canonicalPath =fileName.absolutePath().resolvePath(configPath); if (!canonicalPath.isEmpty()) { // TODO error output on reading definition files d->documentController->configController()->readStereotypeDefinitions(canonicalPath); diff --git a/src/plugins/modeleditor/modeldocument.h b/src/plugins/modeleditor/modeldocument.h index e606420805b..6b2037e007d 100644 --- a/src/plugins/modeleditor/modeldocument.h +++ b/src/plugins/modeleditor/modeldocument.h @@ -4,6 +4,7 @@ #pragma once #include <coreplugin/idocument.h> +#include <utils/filepath.h> namespace qmt { class Uid; } @@ -36,7 +37,7 @@ public: ExtDocumentController *documentController() const; - OpenResult load(QString *errorString, const QString &fileName); + OpenResult load(QString *errorString, const Utils::FilePath &fileName); protected: bool saveImpl(QString *errorString, const Utils::FilePath &filePath, bool autoSave) override; diff --git a/src/plugins/modeleditor/modeleditor.cpp b/src/plugins/modeleditor/modeleditor.cpp index bd39057f453..a518be67d0f 100644 --- a/src/plugins/modeleditor/modeleditor.cpp +++ b/src/plugins/modeleditor/modeleditor.cpp @@ -62,7 +62,6 @@ #include <QAction> #include <QActionGroup> #include <QComboBox> -#include <QDir> #include <QEvent> #include <QFileDialog> #include <QFileInfo> diff --git a/src/plugins/modeleditor/modelindexer.cpp b/src/plugins/modeleditor/modelindexer.cpp index 163d0d60b53..ed15c27036f 100644 --- a/src/plugins/modeleditor/modelindexer.cpp +++ b/src/plugins/modeleditor/modelindexer.cpp @@ -275,7 +275,7 @@ void ModelIndexer::IndexerThread::onFilesQueued() qmt::ProjectSerializer projectSerializer; qmt::Project project; try { - projectSerializer.load(queuedFile.file(), &project); + projectSerializer.load(Utils::FilePath::fromString(queuedFile.file()), &project); } catch (const qmt::Exception &e) { qWarning() << e.errorMessage(); return; diff --git a/src/plugins/modeleditor/modelsmanager.cpp b/src/plugins/modeleditor/modelsmanager.cpp index 787c5556fda..bd85e38695e 100644 --- a/src/plugins/modeleditor/modelsmanager.cpp +++ b/src/plugins/modeleditor/modelsmanager.cpp @@ -38,8 +38,6 @@ #include <projectexplorer/projecttree.h> #include <utils/fileutils.h> -#include <QFileInfo> -#include <QDir> #include <QTimer> #include <QAction> @@ -121,7 +119,7 @@ ExtDocumentController *ModelsManager::createModel(ModelDocument *modelDocument) auto documentController = new ExtDocumentController(this); // TODO error output on reading definition files documentController->configController()->readStereotypeDefinitions( - Core::ICore::resourcePath("modeleditor").toString()); + Core::ICore::resourcePath("modeleditor")); d->managedModels.append(ManagedModel(documentController, modelDocument)); return documentController; diff --git a/src/plugins/modeleditor/pxnodecontroller.cpp b/src/plugins/modeleditor/pxnodecontroller.cpp index f659e46f3d5..c83934db0f0 100644 --- a/src/plugins/modeleditor/pxnodecontroller.cpp +++ b/src/plugins/modeleditor/pxnodecontroller.cpp @@ -146,7 +146,7 @@ void PxNodeController::addFileSystemEntry(const QString &filePath, int line, int { QMT_ASSERT(diagram, return); - QString elementName = qmt::NameController::convertFileNameToElementName(filePath); + QString elementName = qmt::NameController::convertFileNameToElementName(Utils::FilePath::fromString(filePath)); QFileInfo fileInfo(filePath); if (fileInfo.exists() && fileInfo.isFile()) { @@ -212,7 +212,7 @@ qmt::MDiagram *PxNodeController::findDiagramForExplorerNode(const ProjectExplore return nullptr; QStringList relativeElements = qmt::NameController::buildElementsPath( - d->pxnodeUtilities->calcRelativePath(node, d->anchorFolder), false); + Utils::FilePath::fromString(d->pxnodeUtilities->calcRelativePath(node, d->anchorFolder)), false); QQueue<qmt::MPackage *> roots; roots.append(d->diagramSceneController->modelController()->rootPackage()); @@ -322,7 +322,7 @@ void PxNodeController::onMenuActionTriggered(PxNodeController::MenuAction *actio package->setStereotypes({action->stereotype}); d->diagramSceneController->modelController()->undoController()->beginMergeSequence(Tr::tr("Create Component Model")); QStringList relativeElements = qmt::NameController::buildElementsPath( - d->pxnodeUtilities->calcRelativePath(filePath, d->anchorFolder), true); + Utils::FilePath::fromString(d->pxnodeUtilities->calcRelativePath(filePath, d->anchorFolder)), true); if (qmt::MObject *existingObject = d->pxnodeUtilities->findSameObject(relativeElements, package)) { delete package; package = dynamic_cast<qmt::MPackage *>(existingObject); @@ -363,8 +363,9 @@ void PxNodeController::onMenuActionTriggered(PxNodeController::MenuAction *actio } else { qmt::MObject *parentForDiagram = nullptr; QStringList relativeElements = qmt::NameController::buildElementsPath( - d->pxnodeUtilities->calcRelativePath(filePath, d->anchorFolder), - dynamic_cast<qmt::MPackage *>(newObject) != nullptr); + Utils::FilePath::fromString( + d->pxnodeUtilities->calcRelativePath(filePath, d->anchorFolder)), + dynamic_cast<qmt::MPackage *>(newObject) != nullptr); if (qmt::MObject *existingObject = d->pxnodeUtilities->findSameObject(relativeElements, newObject)) { delete newObject; newObject = nullptr; diff --git a/src/plugins/modeleditor/pxnodeutilities.cpp b/src/plugins/modeleditor/pxnodeutilities.cpp index c9e58d5052e..08de4bdb05f 100644 --- a/src/plugins/modeleditor/pxnodeutilities.cpp +++ b/src/plugins/modeleditor/pxnodeutilities.cpp @@ -51,7 +51,8 @@ QString PxNodeUtilities::calcRelativePath(const ProjectExplorer::Node *node, ? node->filePath().toFileInfo().path() : node->filePath().toString(); - return qmt::NameController::calcRelativePath(nodePath, anchorFolder); + return qmt::NameController::calcRelativePath(Utils::FilePath::fromString(nodePath), + Utils::FilePath::fromString(anchorFolder)).toString(); } QString PxNodeUtilities::calcRelativePath(const QString &filePath, const QString &anchorFolder) @@ -63,7 +64,8 @@ QString PxNodeUtilities::calcRelativePath(const QString &filePath, const QString path = fileInfo.path(); else path = filePath; - return qmt::NameController::calcRelativePath(path, anchorFolder); + return qmt::NameController::calcRelativePath(Utils::FilePath::fromString(path), + Utils::FilePath::fromString(anchorFolder)).toString(); } qmt::MPackage *PxNodeUtilities::createBestMatchingPackagePath( |