forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -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();
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
|
@@ -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);
|
||||
};
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
|
@@ -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)
|
||||
{
|
||||
|
@@ -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
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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
|
||||
|
@@ -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();
|
||||
|
@@ -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;
|
||||
|
@@ -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
|
||||
|
@@ -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);
|
||||
|
||||
|
@@ -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);
|
||||
|
@@ -42,8 +42,6 @@
|
||||
#include "../../modelinglibtr.h"
|
||||
|
||||
#include <QMenu>
|
||||
#include <QFileInfo>
|
||||
#include <QDir>
|
||||
#include <QQueue>
|
||||
#include <QPair>
|
||||
|
||||
|
@@ -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 {
|
||||
|
@@ -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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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;
|
||||
};
|
||||
|
||||
|
@@ -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
|
||||
|
@@ -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;
|
||||
|
@@ -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,
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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);
|
||||
};
|
||||
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
|
@@ -62,7 +62,6 @@
|
||||
#include <QAction>
|
||||
#include <QActionGroup>
|
||||
#include <QComboBox>
|
||||
#include <QDir>
|
||||
#include <QEvent>
|
||||
#include <QFileDialog>
|
||||
#include <QFileInfo>
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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(
|
||||
|
Reference in New Issue
Block a user