1 /**************************************************************************** 2 ** 3 ** Copyright (C) 2016 The Qt Company Ltd. 4 ** Contact: https://www.qt.io/licensing/ 5 ** 6 ** This file is part of Qt Creator. 7 ** 8 ** Commercial License Usage 9 ** Licensees holding valid commercial Qt licenses may use this file in 10 ** accordance with the commercial license agreement provided with the 11 ** Software or, alternatively, in accordance with the terms contained in 12 ** a written agreement between you and The Qt Company. For licensing terms 13 ** and conditions see https://www.qt.io/terms-conditions. For further 14 ** information use the contact form at https://www.qt.io/contact-us. 15 ** 16 ** GNU General Public License Usage 17 ** Alternatively, this file may be used under the terms of the GNU 18 ** General Public License version 3 as published by the Free Software 19 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT 20 ** included in the packaging of this file. Please review the following 21 ** information to ensure the GNU General Public License requirements will 22 ** be met: https://www.gnu.org/licenses/gpl-3.0.html. 23 ** 24 ****************************************************************************/ 25 26 #pragma once 27 28 #include "debugger_global.h" 29 #include "debuggerconstants.h" 30 31 #include <projectexplorer/abi.h> 32 33 #include <utils/fileutils.h> 34 #include <utils/environment.h> 35 36 #include <QDateTime> 37 #include <QList> 38 #include <QVariant> 39 40 namespace Debugger { 41 42 class DebuggerItemManager; 43 44 namespace Internal { 45 class DebuggerConfigWidget; 46 class DebuggerItemConfigWidget; 47 class DebuggerItemModel; 48 } // namespace Internal 49 50 // ----------------------------------------------------------------------- 51 // DebuggerItem 52 // ----------------------------------------------------------------------- 53 54 class DEBUGGER_EXPORT DebuggerItem 55 { 56 public: 57 DebuggerItem(); 58 DebuggerItem(const QVariantMap &data); 59 60 void createId(); canClone()61 bool canClone() const { return true; } 62 bool isValid() const; 63 QString engineTypeName() const; 64 65 QVariantMap toMap() const; 66 id()67 QVariant id() const { return m_id; } 68 69 QString displayName() const; unexpandedDisplayName()70 QString unexpandedDisplayName() const { return m_unexpandedDisplayName; } 71 void setUnexpandedDisplayName(const QString &unexpandedDisplayName); 72 engineType()73 DebuggerEngineType engineType() const { return m_engineType; } 74 void setEngineType(const DebuggerEngineType &engineType); 75 command()76 Utils::FilePath command() const { return m_command; } 77 void setCommand(const Utils::FilePath &command); 78 isAutoDetected()79 bool isAutoDetected() const { return m_isAutoDetected; } 80 void setAutoDetected(bool isAutoDetected); 81 82 QString version() const; 83 void setVersion(const QString &version); 84 abis()85 const ProjectExplorer::Abis &abis() const { return m_abis; } 86 void setAbis(const ProjectExplorer::Abis &abis); 87 void setAbi(const ProjectExplorer::Abi &abi); 88 89 enum MatchLevel { DoesNotMatch, MatchesSomewhat, MatchesWell, MatchesPerfectly, MatchesPerfectlyInPath }; 90 MatchLevel matchTarget(const ProjectExplorer::Abi &targetAbi) const; 91 92 QStringList abiNames() const; 93 QDateTime lastModified() const; 94 95 QIcon decoration() const; 96 QString validityMessage() const; 97 98 bool operator==(const DebuggerItem &other) const; 99 bool operator!=(const DebuggerItem &other) const { return !operator==(other); } 100 101 void reinitializeFromFile(const Utils::Environment &sysEnv = Utils::Environment::systemEnvironment(), 102 QString *error = nullptr); 103 workingDirectory()104 Utils::FilePath workingDirectory() const { return m_workingDirectory; } setWorkingDirectory(const Utils::FilePath & workingPath)105 void setWorkingDirectory(const Utils::FilePath &workingPath) { m_workingDirectory = workingPath; } 106 detectionSource()107 QString detectionSource() const { return m_detectionSource; } setDetectionSource(const QString & source)108 void setDetectionSource(const QString &source) { m_detectionSource = source; } 109 110 private: 111 DebuggerItem(const QVariant &id); 112 void initMacroExpander(); 113 114 QVariant m_id; 115 QString m_unexpandedDisplayName; 116 DebuggerEngineType m_engineType = NoEngineType; 117 Utils::FilePath m_command; 118 Utils::FilePath m_workingDirectory; 119 bool m_isAutoDetected = false; 120 QString m_version; 121 ProjectExplorer::Abis m_abis; 122 QDateTime m_lastModified; 123 QString m_detectionSource; 124 125 friend class Internal::DebuggerConfigWidget; 126 friend class Internal::DebuggerItemConfigWidget; 127 friend class Internal::DebuggerItemModel; 128 friend class DebuggerItemManager; 129 }; 130 131 } // namespace Debugger 132