qbsnodes.h 5.86 KB
Newer Older
Tobias Hunger's avatar
Tobias Hunger committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** 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
** a written agreement between you and Digia.  For licensing terms and
** conditions see http://qt.digia.com/licensing.  For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights.  These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/

#ifndef QBSNODES_H
#define QBSNODES_H

#include <projectexplorer/projectnodes.h>

#include <api/projectdata.h>

37
38
#include <QIcon>

Tobias Hunger's avatar
Tobias Hunger committed
39
40
41
42
43
44
namespace qbs { class Project; }

namespace QbsProjectManager {
namespace Internal {

class FileTreeNode;
45
class QbsProject;
Tobias Hunger's avatar
Tobias Hunger committed
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
class QbsProjectFile;

// ----------------------------------------------------------------------
// QbsFileNode:
// ----------------------------------------------------------------------

class QbsFileNode : public ProjectExplorer::FileNode
{
    Q_OBJECT
public:
    QbsFileNode(const QString &filePath, const ProjectExplorer::FileType fileType, bool generated,
                int line);
    int line() const { return m_line; }

    void setLine(int l);

62
63
    QString displayName() const;

64
65
    bool update(const qbs::CodeLocation &loc);

Tobias Hunger's avatar
Tobias Hunger committed
66
67
68
69
70
71
72
73
private:
    int m_line;
};

// ---------------------------------------------------------------------------
// QbsBaseProjectNode:
// ---------------------------------------------------------------------------

74
75
class QbsGroupNode;

Tobias Hunger's avatar
Tobias Hunger committed
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
class QbsBaseProjectNode : public ProjectExplorer::ProjectNode
{
    Q_OBJECT

public:
    explicit QbsBaseProjectNode(const QString &path);

    bool hasBuildTargets() const;

    QList<ProjectAction> supportedActions(Node *node) const;

    bool canAddSubProject(const QString &proFilePath) const;

    bool addSubProjects(const QStringList &proFilePaths);

    bool removeSubProjects(const QStringList &proFilePaths);

93
94
95
96
    bool addFiles(const QStringList &filePaths, QStringList *notAdded = 0);
    bool removeFiles(const QStringList &filePaths, QStringList *notRemoved = 0);
    bool deleteFiles(const QStringList &filePaths);
    bool renameFile(const QString &filePath, const QString &newFilePath);
Tobias Hunger's avatar
Tobias Hunger committed
97
98

    QList<ProjectExplorer::RunConfiguration *> runConfigurationsFor(Node *node);
99
100
101

private:
    friend class QbsGroupNode;
Tobias Hunger's avatar
Tobias Hunger committed
102
103
104
105
106
107
108
109
110
111
112
};

// --------------------------------------------------------------------
// QbsGroupNode:
// --------------------------------------------------------------------

class QbsGroupNode : public QbsBaseProjectNode
{
    Q_OBJECT

public:
113
    QbsGroupNode(const qbs::GroupData *grp, const QString &productPath);
Tobias Hunger's avatar
Tobias Hunger committed
114
115

    bool isEnabled() const;
116
117
    void updateQbsGroupData(const qbs::GroupData *grp, const QString &productPath,
                            bool productWasEnabled, bool productIsEnabled);
118

119
    const qbs::GroupData *qbsGroupData() const { return m_qbsGroupData; }
Tobias Hunger's avatar
Tobias Hunger committed
120

121
122
    QString productPath() const;

123
    static void setupFiles(QbsBaseProjectNode *root, const QStringList &files,
124
                           const QString &productPath, bool updateExisting);
125

Tobias Hunger's avatar
Tobias Hunger committed
126
private:
127
    static void setupFolder(ProjectExplorer::FolderNode *folder,
128
                            const FileTreeNode *subFileTree, const QString &baseDir, bool updateExisting);
129
    const qbs::GroupData *m_qbsGroupData;
130
    QString m_productPath;
131
132

    static QIcon m_groupIcon;
Tobias Hunger's avatar
Tobias Hunger committed
133
134
135
136
137
138
139
140
141
142
143
};

// --------------------------------------------------------------------
// QbsProductNode:
// --------------------------------------------------------------------

class QbsProductNode : public QbsBaseProjectNode
{
    Q_OBJECT

public:
144
    explicit QbsProductNode(const qbs::ProductData &prd);
Tobias Hunger's avatar
Tobias Hunger committed
145
146
147

    bool isEnabled() const;

148
149
    void setQbsProductData(const qbs::ProductData prd);
    const qbs::ProductData qbsProductData() const { return m_qbsProductData; }
Tobias Hunger's avatar
Tobias Hunger committed
150

151
152
    QList<ProjectExplorer::RunConfiguration *> runConfigurationsFor(Node *node);

Tobias Hunger's avatar
Tobias Hunger committed
153
154
155
private:
    QbsGroupNode *findGroupNode(const QString &name);

156
    qbs::ProductData m_qbsProductData;
157
    static QIcon m_productIcon;
Tobias Hunger's avatar
Tobias Hunger committed
158
159
160
161
162
163
164
165
166
167
168
};

// ---------------------------------------------------------------------------
// QbsProjectNode:
// ---------------------------------------------------------------------------

class QbsProjectNode : public QbsBaseProjectNode
{
    Q_OBJECT

public:
169
    explicit QbsProjectNode(QbsProject *project);
Tobias Hunger's avatar
Tobias Hunger committed
170
    explicit QbsProjectNode(const QString &path);
Tobias Hunger's avatar
Tobias Hunger committed
171
172
173
    ~QbsProjectNode();

    void update(const qbs::Project *prj);
Tobias Hunger's avatar
Tobias Hunger committed
174
    void update(const qbs::ProjectData &prjData);
Tobias Hunger's avatar
Tobias Hunger committed
175

176
    QbsProject *project() const;
177
    const qbs::Project *qbsProject() const;
178
    const qbs::ProjectData qbsProjectData() const;
Tobias Hunger's avatar
Tobias Hunger committed
179
180

private:
Tobias Hunger's avatar
Tobias Hunger committed
181
182
    void ctor();

Tobias Hunger's avatar
Tobias Hunger committed
183
    QbsProductNode *findProductNode(const QString &name);
Tobias Hunger's avatar
Tobias Hunger committed
184
    QbsProjectNode *findProjectNode(const QString &name);
Tobias Hunger's avatar
Tobias Hunger committed
185

186
187
    QbsProject *m_project;

188
    const qbs::Project *m_qbsProject;
189
    qbs::ProjectData m_qbsProjectData;
190
    static QIcon m_projectIcon;
Tobias Hunger's avatar
Tobias Hunger committed
191
192
193
194
195
};
} // namespace Internal
} // namespace QbsProjectManager

#endif // QBSNODES_H