aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Schulz <david.schulz@qt.io>2023-06-06 09:23:14 +0200
committerDavid Schulz <david.schulz@qt.io>2023-06-06 10:42:13 +0000
commitbeaf86f9deb219565da0c1b92e727d3138cf6526 (patch)
tree5c9c4c8037cc9d3555ec4d6fe2f4390f65d334ff
parentb3e51d62428efa807d7d41919fcf7595421fc3db (diff)
Python: filepathify python project path for saving
Change-Id: Ibcea9de6c8844cb826b61aa40357890153923854 Reviewed-by: hjk <hjk@qt.io>
-rw-r--r--src/plugins/python/pythonproject.cpp25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/plugins/python/pythonproject.cpp b/src/plugins/python/pythonproject.cpp
index a29847ac7b..86afde46e8 100644
--- a/src/plugins/python/pythonproject.cpp
+++ b/src/plugins/python/pythonproject.cpp
@@ -52,12 +52,12 @@ public:
QString name() const override { return QLatin1String("python"); }
bool saveRawFileList(const QStringList &rawFileList);
- bool saveRawList(const QStringList &rawList, const QString &fileName);
+ bool saveRawList(const QStringList &rawList, const FilePath &filePath);
void parse();
QStringList processEntries(const QStringList &paths,
QHash<QString, QString> *map = nullptr) const;
- bool writePyProjectFile(const QString &fileName, QString &content,
+ bool writePyProjectFile(const FilePath &filePath, QString &content,
const QStringList &rawList, QString *errorMessage);
void triggerParsing() final;
@@ -268,25 +268,24 @@ void PythonBuildSystem::triggerParsing()
bool PythonBuildSystem::saveRawFileList(const QStringList &rawFileList)
{
- const bool result = saveRawList(rawFileList, projectFilePath().toString());
+ const bool result = saveRawList(rawFileList, projectFilePath());
// refresh(PythonProject::Files);
return result;
}
-bool PythonBuildSystem::saveRawList(const QStringList &rawList, const QString &fileName)
+bool PythonBuildSystem::saveRawList(const QStringList &rawList, const FilePath &filePath)
{
- const FilePath filePath = FilePath::fromString(fileName);
- FileChangeBlocker changeGuarg(filePath);
+ const FileChangeBlocker changeGuarg(filePath);
bool result = false;
// New project file
- if (fileName.endsWith(".pyproject")) {
+ if (filePath.endsWith(".pyproject")) {
FileSaver saver(filePath, QIODevice::ReadOnly | QIODevice::Text);
if (!saver.hasError()) {
QString content = QTextStream(saver.file()).readAll();
if (saver.finalize(ICore::dialogParent())) {
QString errorMessage;
- result = writePyProjectFile(fileName, content, rawList, &errorMessage);
+ result = writePyProjectFile(filePath, content, rawList, &errorMessage);
if (!errorMessage.isEmpty())
MessageManager::writeDisrupting(errorMessage);
}
@@ -305,13 +304,13 @@ bool PythonBuildSystem::saveRawList(const QStringList &rawList, const QString &f
return result;
}
-bool PythonBuildSystem::writePyProjectFile(const QString &fileName, QString &content,
- const QStringList &rawList, QString *errorMessage)
+bool PythonBuildSystem::writePyProjectFile(const FilePath &filePath, QString &content,
+ const QStringList &rawList, QString *errorMessage)
{
- QFile file(fileName);
+ QFile file(filePath.toString());
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
- *errorMessage = Tr::tr("Unable to open \"%1\" for reading: %2")
- .arg(fileName, file.errorString());
+ *errorMessage = Tr::tr("Unable to open \"%1\" for writing: %2")
+ .arg(filePath.toUserOutput(), file.errorString());
return false;
}