aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJochen Becher <jochen_becher@gmx.de>2024-05-05 19:40:09 +0200
committerJochen Becher <jochen_becher@gmx.de>2024-05-10 18:50:22 +0000
commit76f2b6d5e1ec563d144087d0c3eed777876da900 (patch)
treea3ce8d982b7401b8cec76c7ca26957be8e1ec0c6
parent99acd3247fa5d92ff4237350d16c32305eb1cd5c (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>
-rw-r--r--src/libs/modelinglib/qmt/config/configcontroller.cpp26
-rw-r--r--src/libs/modelinglib/qmt/config/configcontroller.h4
-rw-r--r--src/libs/modelinglib/qmt/controller/namecontroller.cpp39
-rw-r--r--src/libs/modelinglib/qmt/controller/namecontroller.h10
-rw-r--r--src/libs/modelinglib/qmt/document_controller/documentcontroller.cpp6
-rw-r--r--src/libs/modelinglib/qmt/document_controller/documentcontroller.h6
-rw-r--r--src/libs/modelinglib/qmt/infrastructure/ioexceptions.cpp14
-rw-r--r--src/libs/modelinglib/qmt/infrastructure/ioexceptions.h20
-rw-r--r--src/libs/modelinglib/qmt/project/project.cpp4
-rw-r--r--src/libs/modelinglib/qmt/project/project.h14
-rw-r--r--src/libs/modelinglib/qmt/project_controller/projectcontroller.cpp6
-rw-r--r--src/libs/modelinglib/qmt/project_controller/projectcontroller.h10
-rw-r--r--src/libs/modelinglib/qmt/serializer/infrastructureserializer.h18
-rw-r--r--src/libs/modelinglib/qmt/serializer/projectserializer.cpp8
-rw-r--r--src/libs/modelinglib/qmt/serializer/projectserializer.h6
-rw-r--r--src/libs/modelinglib/qmt/tasks/diagramscenecontroller.cpp2
-rw-r--r--src/plugins/modeleditor/componentviewcontroller.cpp12
-rw-r--r--src/plugins/modeleditor/elementtasks.cpp42
-rw-r--r--src/plugins/modeleditor/elementtasks.h9
-rw-r--r--src/plugins/modeleditor/extdocumentcontroller.cpp7
-rw-r--r--src/plugins/modeleditor/extdocumentcontroller.h4
-rw-r--r--src/plugins/modeleditor/extpropertiesmview.cpp31
-rw-r--r--src/plugins/modeleditor/jsextension.cpp2
-rw-r--r--src/plugins/modeleditor/jsextension.h4
-rw-r--r--src/plugins/modeleditor/modeldocument.cpp24
-rw-r--r--src/plugins/modeleditor/modeldocument.h3
-rw-r--r--src/plugins/modeleditor/modeleditor.cpp1
-rw-r--r--src/plugins/modeleditor/modelindexer.cpp2
-rw-r--r--src/plugins/modeleditor/modelsmanager.cpp4
-rw-r--r--src/plugins/modeleditor/pxnodecontroller.cpp11
-rw-r--r--src/plugins/modeleditor/pxnodeutilities.cpp6
31 files changed, 191 insertions, 164 deletions
diff --git a/src/libs/modelinglib/qmt/config/configcontroller.cpp b/src/libs/modelinglib/qmt/config/configcontroller.cpp
index 4bb9b806c4..2337c6873b 100644
--- a/src/libs/modelinglib/qmt/config/configcontroller.cpp
+++ b/src/libs/modelinglib/qmt/config/configcontroller.cpp
@@ -9,11 +9,8 @@
#include "qmt/stereotype/stereotypecontroller.h"
-#include <QDir>
-#include <QFileInfo>
-#include <QFile>
-
#include <QDebug>
+#include <QFile>
namespace qmt {
@@ -39,7 +36,7 @@ void ConfigController::setStereotypeController(StereotypeController *stereotypeC
d->m_stereotypeController = stereotypeController;
}
-void ConfigController::readStereotypeDefinitions(const QString &path)
+void ConfigController::readStereotypeDefinitions(const Utils::FilePath &path)
{
if (path.isEmpty()) {
// TODO add error handling
@@ -54,22 +51,17 @@ void ConfigController::readStereotypeDefinitions(const QString &path)
connect(&parser, &StereotypeDefinitionParser::toolbarParsed,
this, &ConfigController::onToolbarParsed);
- QStringList fileNames;
- QDir dir;
- QFileInfo fileInfo(path);
- if (fileInfo.isFile()) {
- dir.setPath(fileInfo.path());
- fileNames.append(fileInfo.fileName());
- } else if (fileInfo.isDir()) {
- dir.setPath(path);
- dir.setNameFilters(QStringList("*.def"));
- fileNames = dir.entryList(QDir::Files);
+ Utils::FilePaths paths;
+ if (path.isFile()) {
+ paths.append(path);
+ } else if (path.isDir()) {
+ paths = path.dirEntries({ { "*.def" } });
} else {
// TODO add error handling
return;
}
- for (const QString &fileName : std::as_const(fileNames)) {
- QFile file(QFileInfo(dir, fileName).absoluteFilePath());
+ for (const auto &filePath : std::as_const(paths)) {
+ QFile file(filePath.toString());
if (file.open(QIODevice::ReadOnly)) {
QString text = QString::fromUtf8(file.readAll());
file.close();
diff --git a/src/libs/modelinglib/qmt/config/configcontroller.h b/src/libs/modelinglib/qmt/config/configcontroller.h
index 28e6d65afc..7d8af82f6e 100644
--- a/src/libs/modelinglib/qmt/config/configcontroller.h
+++ b/src/libs/modelinglib/qmt/config/configcontroller.h
@@ -5,6 +5,8 @@
#include "qmt/infrastructure/qmt_global.h"
+#include <utils/filepath.h>
+
#include <QObject>
namespace qmt {
@@ -24,7 +26,7 @@ public:
void setStereotypeController(StereotypeController *stereotypeController);
- void readStereotypeDefinitions(const QString &path);
+ void readStereotypeDefinitions(const Utils::FilePath &path);
private:
void onStereotypeIconParsed(const StereotypeIcon &stereotypeIcon);
diff --git a/src/libs/modelinglib/qmt/controller/namecontroller.cpp b/src/libs/modelinglib/qmt/controller/namecontroller.cpp
index d910be4b12..a6ffe99d58 100644
--- a/src/libs/modelinglib/qmt/controller/namecontroller.cpp
+++ b/src/libs/modelinglib/qmt/controller/namecontroller.cpp
@@ -3,7 +3,6 @@
#include "namecontroller.h"
-#include <QFileInfo>
#include <QDebug>
namespace qmt {
@@ -17,10 +16,9 @@ NameController::~NameController()
{
}
-QString NameController::convertFileNameToElementName(const QString &fileName)
+QString NameController::convertFileNameToElementName(const Utils::FilePath &fileName)
{
- QFileInfo fileInfo(fileName);
- QString baseName = fileInfo.baseName().trimmed();
+ QString baseName = fileName.baseName().trimmed();
QString elementName;
bool makeTitlecase = true;
bool insertSpace = false;
@@ -65,13 +63,19 @@ QString NameController::convertElementNameToBaseFileName(const QString &elementN
return baseFileName;
}
-QString NameController::calcRelativePath(const QString &absoluteFileName, const QString &anchorPath)
+Utils::FilePath NameController::calcRelativePath(const Utils::FilePath &absoluteFileName,
+ const Utils::FilePath &anchorPath)
{
+ // TODO try using Utils::FilePath::relativePath
+ QString absoluteFilePath = absoluteFileName.toString();
+ QString anchorPathString = anchorPath.toString();
int secondLastSlashIndex = -1;
int slashIndex = -1;
int i = 0;
- while (i < absoluteFileName.size() && i < anchorPath.size() && absoluteFileName.at(i) == anchorPath.at(i)) {
- if (absoluteFileName.at(i) == QLatin1Char('/')) {
+ while (i < absoluteFilePath.size() && i < anchorPathString.size()
+ && absoluteFilePath.at(i) == anchorPathString.at(i))
+ {
+ if (absoluteFilePath.at(i) == QLatin1Char('/')) {
secondLastSlashIndex = slashIndex;
slashIndex = i;
}
@@ -81,22 +85,22 @@ QString NameController::calcRelativePath(const QString &absoluteFileName, const
QString relativePath;
if (slashIndex < 0) {
- relativePath = absoluteFileName;
- } else if (i >= absoluteFileName.size()) {
+ relativePath = absoluteFilePath;
+ } else if (i >= absoluteFilePath.size()) {
// absoluteFileName is a substring of anchor path.
if (slashIndex == i - 1) {
if (secondLastSlashIndex < 0)
- relativePath = absoluteFileName;
+ relativePath = absoluteFilePath;
else
- relativePath = absoluteFileName.mid(secondLastSlashIndex + 1);
+ relativePath = absoluteFilePath.mid(secondLastSlashIndex + 1);
} else {
- relativePath = absoluteFileName.mid(slashIndex + 1);
+ relativePath = absoluteFilePath.mid(slashIndex + 1);
}
} else {
- relativePath = absoluteFileName.mid(slashIndex + 1);
+ relativePath = absoluteFilePath.mid(slashIndex + 1);
}
- return relativePath;
+ return Utils::FilePath::fromString(relativePath);
}
QString NameController::calcElementNameSearchId(const QString &elementName)
@@ -109,16 +113,17 @@ QString NameController::calcElementNameSearchId(const QString &elementName)
return searchId;
}
-QStringList NameController::buildElementsPath(const QString &filePath, bool ignoreLastFilePathPart)
+QStringList NameController::buildElementsPath(const Utils::FilePath &filePath,
+ bool ignoreLastFilePathPart)
{
QList<QString> relativeElements;
- QStringList split = filePath.split("/");
+ QStringList split = filePath.toString().split("/");
QStringList::const_iterator splitEnd = split.constEnd();
if (ignoreLastFilePathPart || split.last().isEmpty())
--splitEnd;
for (auto it = split.constBegin(); it != splitEnd; ++it) {
- QString packageName = qmt::NameController::convertFileNameToElementName(*it);
+ QString packageName = qmt::NameController::convertFileNameToElementName(Utils::FilePath::fromString(*it));
relativeElements.append(packageName);
}
return relativeElements;
diff --git a/src/libs/modelinglib/qmt/controller/namecontroller.h b/src/libs/modelinglib/qmt/controller/namecontroller.h
index 03e3be30bb..bb1ff0c3e1 100644
--- a/src/libs/modelinglib/qmt/controller/namecontroller.h
+++ b/src/libs/modelinglib/qmt/controller/namecontroller.h
@@ -6,6 +6,8 @@
#include <QObject>
#include "qmt/infrastructure/qmt_global.h"
+#include <utils/filepath.h>
+
#include <QString>
#include <QStringList>
@@ -18,12 +20,12 @@ private:
~NameController() override;
public:
- static QString convertFileNameToElementName(const QString &fileName);
+ static QString convertFileNameToElementName(const Utils::FilePath &fileName);
static QString convertElementNameToBaseFileName(const QString &elementName);
- // TODO use Utils::FilePath instead
- static QString calcRelativePath(const QString &absoluteFileName, const QString &anchorPath);
+ static Utils::FilePath calcRelativePath(const Utils::FilePath &absoluteFileName,
+ const Utils::FilePath &anchorPath);
static QString calcElementNameSearchId(const QString &elementName);
- static QStringList buildElementsPath(const QString &filePath, bool ignoreLastFilePathPart);
+ static QStringList buildElementsPath(const Utils::FilePath &filePath, bool ignoreLastFilePathPart);
static bool parseClassName(const QString &fullClassName, QString *umlNamespace,
QString *className, QStringList *templateParameters);
};
diff --git a/src/libs/modelinglib/qmt/document_controller/documentcontroller.cpp b/src/libs/modelinglib/qmt/document_controller/documentcontroller.cpp
index 68184d2fb5..12ec26048e 100644
--- a/src/libs/modelinglib/qmt/document_controller/documentcontroller.cpp
+++ b/src/libs/modelinglib/qmt/document_controller/documentcontroller.cpp
@@ -32,8 +32,6 @@
#include "../../modelinglibtr.h"
-#include <QFileInfo>
-
namespace qmt {
DocumentController::DocumentController(QObject *parent) :
@@ -233,7 +231,7 @@ MDiagram *DocumentController::findOrCreateRootDiagram()
return rootDiagram;
}
-void DocumentController::createNewProject(const QString &fileName)
+void DocumentController::createNewProject(const Utils::FilePath &fileName)
{
m_diagramsManager->removeAllDiagrams();
m_treeModel->setModelController(nullptr);
@@ -246,7 +244,7 @@ void DocumentController::createNewProject(const QString &fileName)
m_modelController->setRootPackage(m_projectController->project()->rootPackage());
}
-void DocumentController::loadProject(const QString &fileName)
+void DocumentController::loadProject(const Utils::FilePath &fileName)
{
m_diagramsManager->removeAllDiagrams();
m_treeModel->setModelController(nullptr);
diff --git a/src/libs/modelinglib/qmt/document_controller/documentcontroller.h b/src/libs/modelinglib/qmt/document_controller/documentcontroller.h
index 8053d189e0..9c5188e3f7 100644
--- a/src/libs/modelinglib/qmt/document_controller/documentcontroller.h
+++ b/src/libs/modelinglib/qmt/document_controller/documentcontroller.h
@@ -7,6 +7,8 @@
#include "qmt/infrastructure/qmt_global.h"
#include "qmt/model_controller/modelcontroller.h"
+#include <utils/filepath.h>
+
namespace qmt {
class ProjectController;
@@ -77,8 +79,8 @@ public:
MDiagram *findRootDiagram();
MDiagram *findOrCreateRootDiagram();
- void createNewProject(const QString &fileName);
- void loadProject(const QString &fileName);
+ void createNewProject(const Utils::FilePath &fileName);
+ void loadProject(const Utils::FilePath &fileName);
private:
ProjectController *m_projectController = nullptr;
diff --git a/src/libs/modelinglib/qmt/infrastructure/ioexceptions.cpp b/src/libs/modelinglib/qmt/infrastructure/ioexceptions.cpp
index 4af8df9236..04778cd0e3 100644
--- a/src/libs/modelinglib/qmt/infrastructure/ioexceptions.cpp
+++ b/src/libs/modelinglib/qmt/infrastructure/ioexceptions.cpp
@@ -14,39 +14,39 @@ IOException::IOException(const QString &errorMsg)
{
}
-FileIOException::FileIOException(const QString &errorMsg, const QString &fileName, int lineNumber)
+FileIOException::FileIOException(const QString &errorMsg, const Utils::FilePath &fileName, int lineNumber)
: IOException(errorMsg),
m_fileName(fileName),
m_lineNumber(lineNumber)
{
}
-FileNotFoundException::FileNotFoundException(const QString &fileName)
+FileNotFoundException::FileNotFoundException(const Utils::FilePath &fileName)
: FileIOException(Tr::tr("File not found."), fileName)
{
}
-FileCreationException::FileCreationException(const QString &fileName)
+FileCreationException::FileCreationException(const Utils::FilePath &fileName)
: FileIOException(Tr::tr("Unable to create file."), fileName)
{
}
-FileWriteError::FileWriteError(const QString &fileName, int lineNumber)
+FileWriteError::FileWriteError(const Utils::FilePath &fileName, int lineNumber)
: FileIOException(Tr::tr("Writing to file failed."), fileName, lineNumber)
{
}
-FileReadError::FileReadError(const QString &fileName, int lineNumber)
+FileReadError::FileReadError(const Utils::FilePath &fileName, int lineNumber)
: FileIOException(Tr::tr("Reading from file failed."), fileName, lineNumber)
{
}
-IllegalXmlFile::IllegalXmlFile(const QString &fileName, int lineNumber)
+IllegalXmlFile::IllegalXmlFile(const Utils::FilePath &fileName, int lineNumber)
: FileIOException(Tr::tr("Illegal XML file."), fileName, lineNumber)
{
}
-UnknownFileVersion::UnknownFileVersion(int version, const QString &fileName, int lineNumber)
+UnknownFileVersion::UnknownFileVersion(int version, const Utils::FilePath &fileName, int lineNumber)
: FileIOException(Tr::tr("Unable to handle file version %1.")
.arg(version), fileName, lineNumber)
{
diff --git a/src/libs/modelinglib/qmt/infrastructure/ioexceptions.h b/src/libs/modelinglib/qmt/infrastructure/ioexceptions.h
index aece890529..7dc91ff4ba 100644
--- a/src/libs/modelinglib/qmt/infrastructure/ioexceptions.h
+++ b/src/libs/modelinglib/qmt/infrastructure/ioexceptions.h
@@ -5,6 +5,8 @@
#include "exceptions.h"
+#include <utils/filepath.h>
+
namespace qmt {
class IOException : public Exception
@@ -16,51 +18,51 @@ public:
class FileIOException : public IOException
{
public:
- explicit FileIOException(const QString &errorMsg, const QString &fileName = QString(),
+ explicit FileIOException(const QString &errorMsg, const Utils::FilePath &fileName = {},
int lineNumber = -1);
- QString fileName() const { return m_fileName; }
+ Utils::FilePath fileName() const { return m_fileName; }
int lineNumber() const { return m_lineNumber; }
private:
- QString m_fileName;
+ Utils::FilePath m_fileName;
int m_lineNumber = -1;
};
class FileNotFoundException : public FileIOException
{
public:
- explicit FileNotFoundException(const QString &fileName);
+ explicit FileNotFoundException(const Utils::FilePath &fileName);
};
class FileCreationException : public FileIOException
{
public:
- explicit FileCreationException(const QString &fileName);
+ explicit FileCreationException(const Utils::FilePath &fileName);
};
class FileWriteError : public FileIOException
{
public:
- explicit FileWriteError(const QString &fileName, int lineNumber = -1);
+ explicit FileWriteError(const Utils::FilePath &fileName, int lineNumber = -1);
};
class FileReadError : public FileIOException
{
public:
- explicit FileReadError(const QString &fileName, int lineNumber = -1);
+ explicit FileReadError(const Utils::FilePath &fileName, int lineNumber = -1);
};
class IllegalXmlFile : public FileIOException
{
public:
- explicit IllegalXmlFile(const QString &fileName, int lineNumber = -1);
+ explicit IllegalXmlFile(const Utils::FilePath &fileName, int lineNumber = -1);
};
class UnknownFileVersion : public FileIOException
{
public:
- UnknownFileVersion(int version, const QString &fileName, int lineNumber = -1);
+ UnknownFileVersion(int version, const Utils::FilePath &fileName, int lineNumber = -1);
};
} // namespace qmt
diff --git a/src/libs/modelinglib/qmt/project/project.cpp b/src/libs/modelinglib/qmt/project/project.cpp
index 098db684ef..bc0ed449a3 100644
--- a/src/libs/modelinglib/qmt/project/project.cpp
+++ b/src/libs/modelinglib/qmt/project/project.cpp
@@ -23,7 +23,7 @@ bool Project::hasFileName() const
return !m_fileName.isEmpty();
}
-void Project::setFileName(const QString &fileName)
+void Project::setFileName(const Utils::FilePath &fileName)
{
m_fileName = fileName;
}
@@ -33,7 +33,7 @@ void Project::setRootPackage(MPackage *rootPackage)
m_rootPackage = rootPackage;
}
-void Project::setConfigPath(const QString &configPath)
+void Project::setConfigPath(const Utils::FilePath &configPath)
{
m_configPath = configPath;
}
diff --git a/src/libs/modelinglib/qmt/project/project.h b/src/libs/modelinglib/qmt/project/project.h
index fab6bb4228..556471e9ed 100644
--- a/src/libs/modelinglib/qmt/project/project.h
+++ b/src/libs/modelinglib/qmt/project/project.h
@@ -5,6 +5,8 @@
#include "qmt/infrastructure/uid.h"
+#include <utils/filepath.h>
+
#include <QString>
namespace qmt {
@@ -20,18 +22,18 @@ public:
Uid uid() const { return m_uid; }
void setUid(const Uid &uid);
bool hasFileName() const;
- QString fileName() const { return m_fileName; }
- void setFileName(const QString &fileName);
+ Utils::FilePath fileName() const { return m_fileName; }
+ void setFileName(const Utils::FilePath &fileName);
MPackage *rootPackage() const { return m_rootPackage; }
void setRootPackage(MPackage *rootPackage);
- QString configPath() const { return m_configPath; }
- void setConfigPath(const QString &configPath);
+ Utils::FilePath configPath() const { return m_configPath; }
+ void setConfigPath(const Utils::FilePath &configPath);
private:
Uid m_uid;
- QString m_fileName;
+ Utils::FilePath m_fileName;
MPackage *m_rootPackage = nullptr;
- QString m_configPath;
+ Utils::FilePath m_configPath;
};
} // namespace qmt
diff --git a/src/libs/modelinglib/qmt/project_controller/projectcontroller.cpp b/src/libs/modelinglib/qmt/project_controller/projectcontroller.cpp
index f7a7e6d2c9..f5d5225d03 100644
--- a/src/libs/modelinglib/qmt/project_controller/projectcontroller.cpp
+++ b/src/libs/modelinglib/qmt/project_controller/projectcontroller.cpp
@@ -31,7 +31,7 @@ ProjectController::~ProjectController()
{
}
-void ProjectController::newProject(const QString &fileName)
+void ProjectController::newProject(const Utils::FilePath &fileName)
{
m_project.reset(new Project());
auto rootPackage = new MPackage();
@@ -43,7 +43,7 @@ void ProjectController::newProject(const QString &fileName)
emit changed();
}
-void ProjectController::setFileName(const QString &fileName)
+void ProjectController::setFileName(const Utils::FilePath &fileName)
{
if (fileName != m_project->fileName()) {
m_project->setFileName(fileName);
@@ -82,7 +82,7 @@ void ProjectController::save()
emit changed();
}
-void ProjectController::saveAs(const QString &fileName)
+void ProjectController::saveAs(const Utils::FilePath &fileName)
{
setFileName(fileName);
save();
diff --git a/src/libs/modelinglib/qmt/project_controller/projectcontroller.h b/src/libs/modelinglib/qmt/project_controller/projectcontroller.h
index 1992c72448..09cf65074a 100644
--- a/src/libs/modelinglib/qmt/project_controller/projectcontroller.h
+++ b/src/libs/modelinglib/qmt/project_controller/projectcontroller.h
@@ -6,6 +6,8 @@
#include "qmt/infrastructure/exceptions.h"
#include "qmt/infrastructure/qmt_global.h"
+#include <utils/filepath.h>
+
#include <QObject>
#include <QString>
@@ -35,19 +37,19 @@ public:
signals:
void changed();
- void fileNameChanged(const QString &fileName);
+ void fileNameChanged(const Utils::FilePath &fileName);
public:
Project *project() const { return m_project.data(); }
bool isModified() const { return m_isModified; }
- void newProject(const QString &fileName);
- void setFileName(const QString &fileName);
+ void newProject(const Utils::FilePath &fileName);
+ void setFileName(const Utils::FilePath &fileName);
void setModified();
void load();
void save();
- void saveAs(const QString &fileName);
+ void saveAs(const Utils::FilePath &fileName);
private:
QScopedPointer<Project> m_project;
diff --git a/src/libs/modelinglib/qmt/serializer/infrastructureserializer.h b/src/libs/modelinglib/qmt/serializer/infrastructureserializer.h
index e67e5af4eb..2313ab8aba 100644
--- a/src/libs/modelinglib/qmt/serializer/infrastructureserializer.h
+++ b/src/libs/modelinglib/qmt/serializer/infrastructureserializer.h
@@ -3,6 +3,8 @@
#pragma once
+#include <utils/filepath.h>
+
#include "qmt/infrastructure/handle.h"
#include "qmt/infrastructure/handles.h"
#include "qmt/infrastructure/uid.h"
@@ -51,4 +53,20 @@ inline void serialize(Archive &archive, qmt::Handles<T> &handles)
|| end;
}
+// Utils::FilePath
+
+template<class Archive>
+inline void save(Archive &archive, const Utils::FilePath &filePath)
+{
+ archive.write(filePath.toString());
+}
+
+template<class Archive>
+inline void load(Archive &archive, Utils::FilePath &filePath)
+{
+ QString s;
+ archive.read(&s);
+ filePath = Utils::FilePath::fromString(s);
+}
+
} // namespace qark
diff --git a/src/libs/modelinglib/qmt/serializer/projectserializer.cpp b/src/libs/modelinglib/qmt/serializer/projectserializer.cpp
index 77f231b358..ecb5538f0c 100644
--- a/src/libs/modelinglib/qmt/serializer/projectserializer.cpp
+++ b/src/libs/modelinglib/qmt/serializer/projectserializer.cpp
@@ -48,11 +48,11 @@ ProjectSerializer::~ProjectSerializer()
{
}
-void ProjectSerializer::save(const QString &fileName, const Project *project)
+void ProjectSerializer::save(const Utils::FilePath &fileName, const Project *project)
{
QMT_ASSERT(project, return);
- QFile file(fileName);
+ QFile file(fileName.toString());
if (!file.open(QIODevice::WriteOnly))
throw FileCreationException(fileName);
@@ -84,11 +84,11 @@ QByteArray ProjectSerializer::save(const Project *project)
return buffer;
}
-void ProjectSerializer::load(const QString &fileName, Project *project)
+void ProjectSerializer::load(const Utils::FilePath &fileName, Project *project)
{
QMT_ASSERT(project, return);
- QFile file(fileName);
+ QFile file(fileName.toString());
if (!file.open(QIODevice::ReadOnly))
throw FileNotFoundException(fileName);
diff --git a/src/libs/modelinglib/qmt/serializer/projectserializer.h b/src/libs/modelinglib/qmt/serializer/projectserializer.h
index c6dd74bcd8..bafa407071 100644
--- a/src/libs/modelinglib/qmt/serializer/projectserializer.h
+++ b/src/libs/modelinglib/qmt/serializer/projectserializer.h
@@ -5,6 +5,8 @@
#include "qmt/infrastructure/qmt_global.h"
+#include <utils/filepath.h>
+
#include <QString>
QT_BEGIN_NAMESPACE
@@ -21,9 +23,9 @@ public:
ProjectSerializer();
~ProjectSerializer();
- void save(const QString &fileName, const Project *project);
+ void save(const Utils::FilePath &fileName, const Project *project);
QByteArray save(const Project *project);
- void load(const QString &fileName, Project *project);
+ void load(const Utils::FilePath &fileName, Project *project);
private:
void write(QXmlStreamWriter *writer, const Project *project);
diff --git a/src/libs/modelinglib/qmt/tasks/diagramscenecontroller.cpp b/src/libs/modelinglib/qmt/tasks/diagramscenecontroller.cpp
index 51f414f66e..23f6ddc297 100644
--- a/src/libs/modelinglib/qmt/tasks/diagramscenecontroller.cpp
+++ b/src/libs/modelinglib/qmt/tasks/diagramscenecontroller.cpp
@@ -42,8 +42,6 @@
#include "../../modelinglibtr.h"
#include <QMenu>
-#include <QFileInfo>
-#include <QDir>
#include <QQueue>
#include <QPair>
diff --git a/src/plugins/modeleditor/componentviewcontroller.cpp b/src/plugins/modeleditor/componentviewcontroller.cpp
index 684d104fd9..b370c10d2d 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 173ccd6524..c13f96e39c 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 caee1e9e6f..2eb2d3a272 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 46df6f7472..ad2940c05f 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 8a0f2a28ec..0fc50aca17 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 fcae9ada22..68dac749f1 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 cfe31ddea7..60f00a113a 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 1cc9c262f2..d9f3484919 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 a1c271539c..cc0ac3aa7d 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 e606420805..6b2037e007 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 bd39057f45..a518be67d0 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 163d0d60b5..ed15c27036 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 787c5556fd..bd85e38695 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 f659e46f3d..c83934db0f 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 c9e58d5052..08de4bdb05 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(