Move MCUPackage and MCUToolChain package to separate files

Also move `packagePathFromSettings` so it can be used from multiple
places. This function will probably move into a separate utility file
in future changes.

Change-Id: I208a5a7bc8aa689829178809a1f4053a961d93be
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: <piotr.mucko@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Erik Verbruggen
2022-02-01 14:30:35 +01:00
committed by piotr.mucko
parent a3596e6527
commit 6b6b35f59e
9 changed files with 498 additions and 392 deletions

View File

@@ -25,10 +25,8 @@
#pragma once
#include "mcusupportversiondetection.h"
#include "mcusupport_global.h"
#include <utils/id.h>
#include <projectexplorer/kitinformation.h>
#include <QObject>
@@ -51,115 +49,11 @@ class ToolChain;
namespace McuSupport {
namespace Internal {
class McuPackage;
class McuToolChainPackage;
void printMessage(const QString &message, bool important);
class McuPackage : public QObject
{
Q_OBJECT
public:
enum Status {
EmptyPath,
InvalidPath,
ValidPathInvalidPackage,
ValidPackageMismatchedVersion,
ValidPackage
};
McuPackage(const QString &label, const Utils::FilePath &defaultPath,
const QString &detectionPath, const QString &settingsKey,
const McuPackageVersionDetector *versionDetector = nullptr);
virtual ~McuPackage() = default;
Utils::FilePath basePath() const;
Utils::FilePath path() const;
QString label() const;
Utils::FilePath defaultPath() const;
QString detectionPath() const;
QString statusText() const;
void updateStatus();
Status status() const;
bool validStatus() const;
void setDownloadUrl(const QString &url);
void setEnvironmentVariableName(const QString &name);
void setAddToPath(bool addToPath);
bool addToPath() const;
void writeGeneralSettings() const;
bool writeToSettings() const;
void setRelativePathModifier(const QString &path);
void setVersions(const QStringList &versions);
bool automaticKitCreationEnabled() const;
void setAutomaticKitCreationEnabled(const bool enabled);
QWidget *widget();
QString environmentVariableName() const;
signals:
void changed();
void statusChanged();
private:
void updatePath();
void updateStatusUi();
QWidget *m_widget = nullptr;
Utils::PathChooser *m_fileChooser = nullptr;
Utils::InfoLabel *m_infoLabel = nullptr;
const QString m_label;
const Utils::FilePath m_defaultPath;
const QString m_detectionPath;
const QString m_settingsKey;
const McuPackageVersionDetector *m_versionDetector;
Utils::FilePath m_path;
QString m_relativePathModifier; // relative path to m_path to be returned by path()
QString m_detectedVersion;
QStringList m_versions;
QString m_downloadUrl;
QString m_environmentVariableName;
bool m_addToPath = false;
bool m_automaticKitCreation = true;
Status m_status = InvalidPath;
};
class McuToolChainPackage : public McuPackage
{
public:
enum Type {
TypeArmGcc,
TypeIAR,
TypeKEIL,
TypeGHS,
TypeMSVC,
TypeGCC,
TypeGHSArm,
TypeUnsupported
};
McuToolChainPackage(const QString &label,
const Utils::FilePath &defaultPath,
const QString &detectionPath,
const QString &settingsKey,
Type type,
const McuPackageVersionDetector *versionDetector = nullptr
);
Type type() const;
bool isDesktopToolchain() const;
ProjectExplorer::ToolChain *toolChain(Utils::Id language) const;
QString toolChainName() const;
QString cmakeToolChainFileName() const;
QVariant debuggerId() const;
private:
const Type m_type;
};
class McuTarget : public QObject
{
Q_OBJECT