2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2012-01-26 18:33:46 +01:00
|
|
|
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-07-19 12:26:56 +02:00
|
|
|
** Contact: http://www.qt-project.org/
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** 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.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
**************************************************************************/
|
2008-12-02 16:19:05 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#ifndef PROJECTNODES_H
|
|
|
|
|
#define PROJECTNODES_H
|
|
|
|
|
|
|
|
|
|
#include "projectexplorer_export.h"
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QIcon>
|
2011-08-18 13:46:52 +02:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QObject>
|
|
|
|
|
#include <QStringList>
|
2011-01-20 18:05:58 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
class QFileInfo;
|
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
|
|
|
|
namespace Core {
|
|
|
|
|
class MimeDatabase;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
namespace ProjectExplorer {
|
2011-08-18 13:46:52 +02:00
|
|
|
class RunConfiguration;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
enum NodeType {
|
|
|
|
|
FileNodeType = 1,
|
|
|
|
|
FolderNodeType,
|
2012-05-04 11:49:37 +02:00
|
|
|
VirtualFolderNodeType,
|
2008-12-02 12:01:29 +01:00
|
|
|
ProjectNodeType,
|
|
|
|
|
SessionNodeType
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// File types common for qt projects
|
|
|
|
|
enum FileType {
|
|
|
|
|
UnknownFileType = 0,
|
|
|
|
|
HeaderType,
|
|
|
|
|
SourceType,
|
|
|
|
|
FormType,
|
|
|
|
|
ResourceType,
|
2010-08-10 16:27:35 +02:00
|
|
|
QMLType,
|
2008-12-02 12:01:29 +01:00
|
|
|
ProjectFileType,
|
|
|
|
|
FileTypeSize
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class Node;
|
|
|
|
|
class FileNode;
|
|
|
|
|
class FileContainerNode;
|
|
|
|
|
class FolderNode;
|
|
|
|
|
class ProjectNode;
|
|
|
|
|
class NodesWatcher;
|
|
|
|
|
class NodesVisitor;
|
2012-01-31 13:40:59 +01:00
|
|
|
class SessionManager;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2011-04-14 12:58:14 +02:00
|
|
|
// Documentation inside.
|
2008-12-02 12:01:29 +01:00
|
|
|
class PROJECTEXPLORER_EXPORT Node : public QObject {
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
|
|
|
|
NodeType nodeType() const;
|
|
|
|
|
ProjectNode *projectNode() const; // managing project
|
|
|
|
|
FolderNode *parentFolderNode() const; // parent folder or project
|
|
|
|
|
QString path() const; // file system path
|
2012-05-04 11:49:37 +02:00
|
|
|
virtual QString displayName() const;
|
|
|
|
|
virtual QString tooltip() const;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
Node(NodeType nodeType, const QString &path);
|
|
|
|
|
|
|
|
|
|
void setNodeType(NodeType type);
|
|
|
|
|
void setProjectNode(ProjectNode *project);
|
|
|
|
|
void setParentFolderNode(FolderNode *parentFolder);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
NodeType m_nodeType;
|
|
|
|
|
ProjectNode *m_projectNode;
|
|
|
|
|
FolderNode *m_folderNode;
|
|
|
|
|
QString m_path;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class PROJECTEXPLORER_EXPORT FileNode : public Node {
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
|
|
|
|
FileNode(const QString &filePath, const FileType fileType, bool generated);
|
|
|
|
|
|
|
|
|
|
FileType fileType() const;
|
|
|
|
|
bool isGenerated() const;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
// managed by ProjectNode
|
|
|
|
|
friend class ProjectNode;
|
|
|
|
|
|
|
|
|
|
FileType m_fileType;
|
|
|
|
|
bool m_generated;
|
|
|
|
|
};
|
|
|
|
|
|
2011-04-14 12:58:14 +02:00
|
|
|
// Documentation inside.
|
2008-12-02 12:01:29 +01:00
|
|
|
class PROJECTEXPLORER_EXPORT FolderNode : public Node {
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
2012-05-04 11:49:37 +02:00
|
|
|
explicit FolderNode(const QString &folderPath, NodeType nodeType = FolderNodeType);
|
2008-12-02 12:01:29 +01:00
|
|
|
virtual ~FolderNode();
|
|
|
|
|
|
2010-01-07 18:17:24 +01:00
|
|
|
QString displayName() const;
|
2008-12-02 12:01:29 +01:00
|
|
|
QIcon icon() const;
|
|
|
|
|
|
|
|
|
|
QList<FileNode*> fileNodes() const;
|
|
|
|
|
QList<FolderNode*> subFolderNodes() const;
|
|
|
|
|
|
|
|
|
|
virtual void accept(NodesVisitor *visitor);
|
|
|
|
|
|
2010-02-24 15:03:54 +01:00
|
|
|
void setDisplayName(const QString &name);
|
2008-12-02 12:01:29 +01:00
|
|
|
void setIcon(const QIcon &icon);
|
|
|
|
|
|
2009-08-17 17:59:57 +02:00
|
|
|
protected:
|
2008-12-02 12:01:29 +01:00
|
|
|
QList<FolderNode*> m_subFolderNodes;
|
|
|
|
|
QList<FileNode*> m_fileNodes;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
// managed by ProjectNode
|
|
|
|
|
friend class ProjectNode;
|
2010-02-24 15:03:54 +01:00
|
|
|
QString m_displayName;
|
2010-07-07 12:16:09 +02:00
|
|
|
mutable QIcon m_icon;
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
2012-05-04 11:49:37 +02:00
|
|
|
class PROJECTEXPLORER_EXPORT VirtualFolderNode : public FolderNode
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
|
|
|
|
explicit VirtualFolderNode(const QString &folderPath, int priority);
|
|
|
|
|
virtual ~VirtualFolderNode();
|
|
|
|
|
|
|
|
|
|
int priority() const;
|
|
|
|
|
private:
|
|
|
|
|
int m_priority;
|
|
|
|
|
};
|
|
|
|
|
|
2011-04-14 12:58:14 +02:00
|
|
|
// Documentation inside.
|
2008-12-02 12:01:29 +01:00
|
|
|
class PROJECTEXPLORER_EXPORT ProjectNode : public FolderNode
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
enum ProjectAction {
|
|
|
|
|
AddSubProject,
|
|
|
|
|
RemoveSubProject,
|
2010-08-24 17:17:11 +02:00
|
|
|
// Let's the user select to which project file
|
|
|
|
|
// the file is added
|
|
|
|
|
AddNewFile,
|
|
|
|
|
AddExistingFile,
|
|
|
|
|
// Removes a file from the project, optionally also
|
|
|
|
|
// delete it on disc
|
2010-05-11 14:13:38 +02:00
|
|
|
RemoveFile,
|
2010-08-24 17:17:11 +02:00
|
|
|
// Deletes a file from the file system, informs the project
|
|
|
|
|
// that a file was deleted
|
2010-08-11 14:49:42 +02:00
|
|
|
// DeleteFile is a define on windows...
|
|
|
|
|
EraseFile,
|
2011-01-20 18:05:58 +01:00
|
|
|
Rename,
|
|
|
|
|
HasSubProjectRunConfigurations
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// all subFolders that are projects
|
|
|
|
|
QList<ProjectNode*> subProjectNodes() const;
|
|
|
|
|
|
|
|
|
|
// determines if the project will be shown in the flat view
|
|
|
|
|
// TODO find a better name
|
2010-11-18 17:31:30 +01:00
|
|
|
void aboutToChangeHasBuildTargets();
|
|
|
|
|
void hasBuildTargetsChanged();
|
2010-02-02 11:59:24 +01:00
|
|
|
virtual bool hasBuildTargets() const = 0;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-05-11 14:13:38 +02:00
|
|
|
virtual QList<ProjectAction> supportedActions(Node *node) const = 0;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-08-26 18:33:16 +02:00
|
|
|
virtual bool canAddSubProject(const QString &proFilePath) const = 0;
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
virtual bool addSubProjects(const QStringList &proFilePaths) = 0;
|
|
|
|
|
|
|
|
|
|
virtual bool removeSubProjects(const QStringList &proFilePaths) = 0;
|
|
|
|
|
|
|
|
|
|
virtual bool addFiles(const FileType fileType,
|
|
|
|
|
const QStringList &filePaths,
|
|
|
|
|
QStringList *notAdded = 0) = 0;
|
|
|
|
|
// TODO: Maybe remove fileType, can be detected by project
|
|
|
|
|
virtual bool removeFiles(const FileType fileType,
|
|
|
|
|
const QStringList &filePaths,
|
|
|
|
|
QStringList *notRemoved = 0) = 0;
|
2010-08-10 16:27:35 +02:00
|
|
|
virtual bool deleteFiles(const FileType fileType,
|
|
|
|
|
const QStringList &filePaths) = 0;
|
2008-12-02 12:01:29 +01:00
|
|
|
virtual bool renameFile(const FileType fileType,
|
|
|
|
|
const QString &filePath,
|
|
|
|
|
const QString &newFilePath) = 0;
|
2010-08-24 17:17:11 +02:00
|
|
|
// by default returns false
|
|
|
|
|
virtual bool deploysFolder(const QString &folder) const;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2011-01-20 18:05:58 +01:00
|
|
|
// TODO node parameter not really needed
|
|
|
|
|
virtual QList<ProjectExplorer::RunConfiguration *> runConfigurationsFor(Node *node) = 0;
|
|
|
|
|
|
2010-08-10 16:27:35 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
QList<NodesWatcher*> watchers() const;
|
|
|
|
|
void registerWatcher(NodesWatcher *watcher);
|
|
|
|
|
void unregisterWatcher(NodesWatcher *watcher);
|
|
|
|
|
|
|
|
|
|
void accept(NodesVisitor *visitor);
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
// this is just the in-memory representation, a subclass
|
|
|
|
|
// will add the persistent stuff
|
|
|
|
|
explicit ProjectNode(const QString &projectFilePath);
|
|
|
|
|
|
|
|
|
|
// to be called in implementation of
|
|
|
|
|
// the corresponding public methods
|
|
|
|
|
void addProjectNodes(const QList<ProjectNode*> &subProjects);
|
|
|
|
|
void removeProjectNodes(const QList<ProjectNode*> &subProjects);
|
|
|
|
|
|
|
|
|
|
void addFolderNodes(const QList<FolderNode*> &subFolders, FolderNode *parentFolder);
|
|
|
|
|
void removeFolderNodes(const QList<FolderNode*> &subFolders, FolderNode *parentFolder);
|
|
|
|
|
|
|
|
|
|
void addFileNodes(const QList<FileNode*> &files, FolderNode *parentFolder);
|
|
|
|
|
void removeFileNodes(const QList<FileNode*> &files, FolderNode *parentFolder);
|
|
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
|
void watcherDestroyed(QObject *watcher);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
QList<ProjectNode*> m_subProjectNodes;
|
|
|
|
|
QList<NodesWatcher*> m_watchers;
|
|
|
|
|
|
|
|
|
|
// let SessionNode call setParentFolderNode
|
|
|
|
|
friend class SessionNode;
|
|
|
|
|
};
|
|
|
|
|
|
2011-04-14 12:58:14 +02:00
|
|
|
// Documentation inside.
|
2008-12-02 12:01:29 +01:00
|
|
|
class PROJECTEXPLORER_EXPORT SessionNode : public FolderNode {
|
|
|
|
|
Q_OBJECT
|
2012-01-31 13:40:59 +01:00
|
|
|
friend class SessionManager;
|
2008-12-02 12:01:29 +01:00
|
|
|
public:
|
2012-01-31 13:40:59 +01:00
|
|
|
SessionNode(QObject *parentObject);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
QList<ProjectNode*> projectNodes() const;
|
|
|
|
|
|
|
|
|
|
QList<NodesWatcher*> watchers() const;
|
|
|
|
|
void registerWatcher(NodesWatcher *watcher);
|
|
|
|
|
void unregisterWatcher(NodesWatcher *watcher);
|
|
|
|
|
|
|
|
|
|
void accept(NodesVisitor *visitor);
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
void addProjectNodes(const QList<ProjectNode*> &projectNodes);
|
|
|
|
|
void removeProjectNodes(const QList<ProjectNode*> &projectNodes);
|
|
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
|
void watcherDestroyed(QObject *watcher);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
QList<ProjectNode*> m_projectNodes;
|
|
|
|
|
QList<NodesWatcher*> m_watchers;
|
|
|
|
|
};
|
|
|
|
|
|
2011-04-14 12:58:14 +02:00
|
|
|
// Documentation inside.
|
2008-12-02 12:01:29 +01:00
|
|
|
class PROJECTEXPLORER_EXPORT NodesWatcher : public QObject {
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
|
|
|
|
explicit NodesWatcher(QObject *parent = 0);
|
|
|
|
|
|
|
|
|
|
signals:
|
2010-11-18 17:31:30 +01:00
|
|
|
// projects
|
|
|
|
|
void aboutToChangeHasBuildTargets(ProjectExplorer::ProjectNode*);
|
|
|
|
|
void hasBuildTargetsChanged(ProjectExplorer::ProjectNode *node);
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
// folders & projects
|
|
|
|
|
void foldersAboutToBeAdded(FolderNode *parentFolder,
|
|
|
|
|
const QList<FolderNode*> &newFolders);
|
|
|
|
|
void foldersAdded();
|
|
|
|
|
|
|
|
|
|
void foldersAboutToBeRemoved(FolderNode *parentFolder,
|
|
|
|
|
const QList<FolderNode*> &staleFolders);
|
|
|
|
|
void foldersRemoved();
|
|
|
|
|
|
|
|
|
|
// files
|
|
|
|
|
void filesAboutToBeAdded(FolderNode *folder,
|
|
|
|
|
const QList<FileNode*> &newFiles);
|
|
|
|
|
void filesAdded();
|
|
|
|
|
|
|
|
|
|
void filesAboutToBeRemoved(FolderNode *folder,
|
|
|
|
|
const QList<FileNode*> &staleFiles);
|
|
|
|
|
void filesRemoved();
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
// let project & session emit signals
|
|
|
|
|
friend class ProjectNode;
|
|
|
|
|
friend class SessionNode;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace ProjectExplorer
|
|
|
|
|
|
|
|
|
|
// HACK: THERE SHOULD BE ONE PLACE TO MAKE THE FILE ENDING->FILE TYPE ASSOCIATION
|
|
|
|
|
ProjectExplorer::FileType typeForFileName(const Core::MimeDatabase *db, const QFileInfo &file);
|
|
|
|
|
|
|
|
|
|
#endif // PROJECTNODES_H
|