projectconfiguration.h 3.25 KB
Newer Older
hjk's avatar
hjk committed
1
/****************************************************************************
2
**
3 4
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
5
**
hjk's avatar
hjk committed
6
** This file is part of Qt Creator.
7
**
hjk's avatar
hjk committed
8 9 10 11
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
12 13 14
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
15
**
16 17 18 19 20 21 22
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
con's avatar
con committed
23
**
hjk's avatar
hjk committed
24
****************************************************************************/
25

Tobias Hunger's avatar
Tobias Hunger committed
26
#pragma once
27 28 29

#include "projectexplorer_export.h"

30
#include <coreplugin/id.h>
31
#include <utils/macroexpander.h>
32

33 34 35
#include <QObject>
#include <QString>
#include <QVariantMap>
36 37 38 39 40 41 42 43 44 45 46

namespace ProjectExplorer {

class Project;

class PROJECTEXPLORER_EXPORT ProjectConfiguration : public QObject
{
    Q_OBJECT

public:
    // ctors are protected
47
    ~ProjectConfiguration() = default;
48

49
    Core::Id id() const;
50
    QString displayName() const;
51 52

    bool usesDefaultDisplayName() const;
53
    void setDisplayName(const QString &name);
54
    void setDefaultDisplayName(const QString &name);
55

56 57 58
    void setToolTip(const QString &text);
    QString toolTip() const;

59
    // Note: Make sure subclasses call the superclasses' fromMap() function!
60 61
    virtual bool fromMap(const QVariantMap &map);

62
    // Note: Make sure subclasses call the superclasses' toMap() function!
63 64
    virtual QVariantMap toMap() const;

65 66 67
    Utils::MacroExpander *macroExpander() { return &m_macroExpander; }
    const Utils::MacroExpander *macroExpander() const { return &m_macroExpander; }

68 69
signals:
    void displayNameChanged();
70
    void toolTipChanged();
71 72

protected:
73
    ProjectConfiguration(QObject *parent, Core::Id id);
Tobias Hunger's avatar
Tobias Hunger committed
74
    ProjectConfiguration(QObject *parent, const ProjectConfiguration *source);
75 76

private:
77
    Core::Id m_id;
78
    QString m_displayName;
79
    QString m_defaultDisplayName;
80
    QString m_toolTip;
81
    Utils::MacroExpander m_macroExpander;
82 83
};

84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
class PROJECTEXPLORER_EXPORT StatefulProjectConfiguration : public ProjectConfiguration
{
    Q_OBJECT

public:
    StatefulProjectConfiguration() = default;

    bool isEnabled() const;

    virtual QString disabledReason() const = 0;

signals:
    void enabledChanged();

protected:
    StatefulProjectConfiguration(QObject *parent, Core::Id id);
    StatefulProjectConfiguration(QObject *parent, const StatefulProjectConfiguration *source);

    void setEnabled(bool enabled);

private:
105
    bool m_isEnabled = false;
106 107
};

108
// helper functions:
109
PROJECTEXPLORER_EXPORT Core::Id idFromMap(const QVariantMap &map);
110 111 112
PROJECTEXPLORER_EXPORT QString displayNameFromMap(const QVariantMap &map);

} // namespace ProjectExplorer