2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2019 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2019-07-22 14:39:01 +02:00
|
|
|
|
|
|
|
|
#include "pythonproject.h"
|
|
|
|
|
|
2023-11-09 08:28:12 +01:00
|
|
|
#include "pythonbuildsystem.h"
|
2019-07-22 14:39:01 +02:00
|
|
|
#include "pythonconstants.h"
|
|
|
|
|
|
|
|
|
|
#include <coreplugin/icontext.h>
|
2020-09-21 19:39:24 +03:00
|
|
|
|
2023-11-09 08:28:12 +01:00
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
2023-11-01 15:05:03 +01:00
|
|
|
#include <projectexplorer/target.h>
|
2019-07-22 14:39:01 +02:00
|
|
|
|
|
|
|
|
using namespace Core;
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
using namespace Utils;
|
|
|
|
|
|
2022-07-15 11:49:34 +02:00
|
|
|
namespace Python::Internal {
|
2019-07-22 14:39:01 +02:00
|
|
|
|
|
|
|
|
PythonProject::PythonProject(const FilePath &fileName)
|
2023-11-01 15:05:03 +01:00
|
|
|
: Project(Constants::C_PY_PROJECT_MIME_TYPE, fileName)
|
2019-07-22 14:39:01 +02:00
|
|
|
{
|
|
|
|
|
setId(PythonProjectId);
|
2020-12-02 13:33:59 +01:00
|
|
|
setProjectLanguages(Context(ProjectExplorer::Constants::PYTHON_LANGUAGE_ID));
|
2021-06-04 07:59:00 +02:00
|
|
|
setDisplayName(fileName.completeBaseName());
|
2023-12-01 06:51:07 +01:00
|
|
|
|
|
|
|
|
setBuildSystemCreator([](Target *t) { return new PythonBuildSystem(t); });
|
2019-07-22 14:39:01 +02:00
|
|
|
}
|
|
|
|
|
|
2023-08-23 16:53:06 +02:00
|
|
|
Project::RestoreResult PythonProject::fromMap(const Store &map, QString *errorMessage)
|
2019-07-22 14:39:01 +02:00
|
|
|
{
|
|
|
|
|
Project::RestoreResult res = Project::fromMap(map, errorMessage);
|
|
|
|
|
if (res == RestoreResult::Ok) {
|
|
|
|
|
if (!activeTarget())
|
|
|
|
|
addTargetForDefaultKit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-09 08:28:12 +01:00
|
|
|
PythonProjectNode::PythonProjectNode(const FilePath &path)
|
|
|
|
|
: ProjectNode(path)
|
2019-07-22 14:39:01 +02:00
|
|
|
{
|
2023-11-09 08:28:12 +01:00
|
|
|
setDisplayName(path.completeBaseName());
|
|
|
|
|
setAddFileFilter("*.py");
|
2019-07-22 14:39:01 +02:00
|
|
|
}
|
|
|
|
|
|
2023-11-09 08:28:12 +01:00
|
|
|
PythonFileNode::PythonFileNode(const FilePath &filePath,
|
|
|
|
|
const QString &nodeDisplayName,
|
|
|
|
|
FileType fileType)
|
|
|
|
|
: FileNode(filePath, fileType)
|
|
|
|
|
, m_displayName(nodeDisplayName)
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
QString PythonFileNode::displayName() const
|
2019-07-22 14:39:01 +02:00
|
|
|
{
|
2023-11-09 08:28:12 +01:00
|
|
|
return m_displayName;
|
2019-07-22 14:39:01 +02:00
|
|
|
}
|
|
|
|
|
|
2022-07-15 11:49:34 +02:00
|
|
|
} // Python::Internal
|