File indexing completed on 2024-04-28 04:36:30

0001 /*
0002     SPDX-FileCopyrightText: 2001 Matthias Hoelzer-Kluepfel <hoelzer@kde.org>
0003     SPDX-FileCopyrightText: 2001-2002 Bernd Gehrmann <bernd@kdevelop.org>
0004     SPDX-FileCopyrightText: 2002-2003 Roberto Raggi <roberto@kdevelop.org>
0005     SPDX-FileCopyrightText: 2002 Simon Hausmann <hausmann@kde.org>
0006     SPDX-FileCopyrightText: 2003 Jens Dagerbo <jens.dagerbo@swipnet.se>
0007     SPDX-FileCopyrightText: 2003 Mario Scalas <mario.scalas@libero.it>
0008     SPDX-FileCopyrightText: 2003-2004 Alexander Dymo <adymo@kdevelop.org>
0009     SPDX-FileCopyrightText: 2006 Matt Rogers <mattr@kde.org>
0010     SPDX-FileCopyrightText: 2007 Andreas Pakulat <apaku@gmx.de>
0011 
0012     SPDX-License-Identifier: LGPL-2.0-or-later
0013 */
0014 
0015 #ifndef KDEVPLATFORM_IPROJECT_H
0016 #define KDEVPLATFORM_IPROJECT_H
0017 
0018 #include <QObject>
0019 
0020 #include <KSharedConfig>
0021 
0022 #include "interfacesexport.h"
0023 
0024 class KJob;
0025 
0026 template<typename T> class QList;
0027 template<typename T> class QSet;
0028 
0029 
0030 namespace KDevelop
0031 {
0032 
0033 class IPlugin;
0034 class IProjectFileManager;
0035 class IBuildSystemManager;
0036 class Path;
0037 class ProjectBaseItem;
0038 class ProjectFileItem;
0039 class ProjectFolderItem;
0040 class IndexedString;
0041 
0042 /**
0043  * \brief Object which represents a KDevelop project
0044  *
0045  * Provide better descriptions
0046  */
0047 class KDEVPLATFORMINTERFACES_EXPORT IProject : public QObject
0048 {
0049     Q_OBJECT
0050     Q_PROPERTY(QString projectName READ name CONSTANT)
0051 public:
0052     /**
0053      * Constructs a project.
0054      *
0055      * @param parent The parent object for the plugin.
0056      */
0057     explicit IProject(QObject *parent = nullptr);
0058 
0059     /// Destructor.
0060     ~IProject() override;
0061 
0062     /**
0063      * Get the file manager for the project
0064      *
0065      * @return the file manager for the project, if one exists; otherwise null
0066      */
0067     virtual IProjectFileManager* projectFileManager() const = 0;
0068 
0069     /**
0070      * Get the build system manager for the project
0071      *
0072      * @return the build system manager for the project, if one exists; otherwise null
0073      */
0074     virtual IBuildSystemManager* buildSystemManager() const = 0;
0075 
0076     /**
0077      * Get the plugin that manages the project
0078      * This can be used to get other interfaces like IBuildSystemManager
0079      */
0080     virtual IPlugin* managerPlugin() const = 0;
0081 
0082     /**
0083      * Get the version control plugin for this project
0084      * This may return 0 if the project is not under version control
0085      * or version control has been disabled for this project
0086      */
0087     virtual IPlugin* versionControlPlugin() const = 0;
0088 
0089     /**
0090      * With this the top-level project item can be retrieved
0091      */
0092     virtual ProjectFolderItem* projectItem() const = 0;
0093 
0094     /**
0095      * @return all items with the corresponding @p path
0096      */
0097     virtual QList<ProjectBaseItem*> itemsForPath( const IndexedString& path ) const = 0;
0098 
0099     /**
0100      * @return all file items with the corresponding @p file path
0101      */
0102     virtual QList<ProjectFileItem*> filesForPath( const IndexedString& file ) const = 0;
0103 
0104     /**
0105      * @return all folder items with the corresponding @p folder path
0106      */
0107     virtual QList<ProjectFolderItem*> foldersForPath( const IndexedString& folder ) const = 0;
0108 
0109     /**
0110      * @return the path to the project file
0111      */
0112     virtual Path projectFile() const = 0;
0113     /** Get the url of the project file.*/
0114     virtual KSharedConfigPtr projectConfiguration() const = 0;
0115 
0116     virtual void addToFileSet( ProjectFileItem* item ) = 0;
0117     virtual void removeFromFileSet( ProjectFileItem* item ) = 0;
0118     virtual QSet<IndexedString> fileSet() const = 0;
0119 
0120     /** Returns whether the project is ready to be used or not.
0121         A project won't be ready for use when it's being reloaded or still loading
0122     */
0123     virtual bool isReady() const=0;
0124 
0125     /**
0126      * @brief Get the project path
0127      * @return The canonical absolute directory of the project.
0128      */
0129     virtual Path path() const = 0;
0130 
0131     /** Returns the name of the project. */
0132     virtual Q_SCRIPTABLE QString name() const = 0;
0133 
0134     /**
0135      * @brief Check if the project contains an item with the given @p path.
0136      *
0137      * @param path the path to check
0138      *
0139      * @return true if the path @a path is a part of the project.
0140      */
0141     virtual bool inProject(const IndexedString &path) const = 0;
0142 
0143     /**
0144      * @brief Tells the project what job is reloading it
0145      *
0146      * It's useful so that we can tell whether the project manager is busy or not.
0147      */
0148     virtual void setReloadJob(KJob* job) = 0;
0149 
0150 Q_SIGNALS:
0151     /**
0152      * Gets emitted whenever a file was added to the project.
0153      */
0154     void fileAddedToSet( KDevelop::ProjectFileItem* item );
0155     /**
0156      * Gets emitted whenever a file was removed from the project.
0157      */
0158     void fileRemovedFromSet( KDevelop::ProjectFileItem* item );
0159 
0160 public Q_SLOTS:
0161     /** Make the model to reload */
0162     virtual void reloadModel() = 0;
0163 
0164     /** This method is invoked when the project needs to be closed. */
0165     virtual void close() = 0;
0166 };
0167 
0168 }
0169 #endif