File indexing completed on 2024-05-12 04:38:11
0001 /* 0002 SPDX-FileCopyrightText: 2004 Roberto Raggi <roberto@kdevelop.org> 0003 SPDX-FileCopyrightText: 2006 Matt Rogers <mattr@kde.org> 0004 SPDX-FileCopyrightText: 2006 Hamish Rodda <rodda@kde.org> 0005 SPDX-FileCopyrightText: 2007 Andreas Pakulat <apaku@gmx.de> 0006 SPDX-FileCopyrightText: 2012 Milian Wolff <mail@milianw.de> 0007 0008 SPDX-License-Identifier: LGPL-2.0-or-later 0009 */ 0010 0011 #ifndef KDEVPLATFORM_IPROJECTFILEMANAGER_H 0012 #define KDEVPLATFORM_IPROJECTFILEMANAGER_H 0013 0014 #include <QObject> 0015 0016 #include <project/projectexport.h> 0017 0018 #include <util/path.h> 0019 0020 class KJob; 0021 0022 namespace KDevelop 0023 { 0024 0025 class IProject; 0026 class ProjectBaseItem; 0027 class ProjectFolderItem; 0028 class ProjectFileItem; 0029 0030 /** 0031 * @short An interface to project file management 0032 * 0033 * FileManager is the class you want to implement for integrating 0034 * a project manager in KDevelop. For build systems, implement its 0035 * child class, BuildManager. 0036 * 0037 * These classes \e do \e not cause files, folders etc. to be created 0038 * or removed on disk. They simply read from and write to the file(s) 0039 * which describe the structure (eg. CMakeLists.txt for cmake, Makefile.am for automake, etc). 0040 * 0041 * @author Roberto Raggi, Matt Rogers, Hamish Rodda, Milian Wolff 0042 */ 0043 class KDEVPLATFORMPROJECT_EXPORT IProjectFileManager 0044 { 0045 public: 0046 0047 virtual ~IProjectFileManager(); 0048 /** Features the file manager supports */ 0049 enum Feature 0050 { 0051 None = 0 , ///< This manager supports nothing 0052 Folders = 1 << 0, ///< Folders are supported by the manager 0053 Targets = 1 << 1, ///< Targets are supported by the manager 0054 Files = 1 << 2 ///< Files are supported by the manager 0055 }; 0056 Q_DECLARE_FLAGS( Features, Feature ) 0057 0058 /** 0059 * @return the Features supported by the filemanager 0060 */ 0061 virtual Features features() const = 0; 0062 0063 /** 0064 * This method initialize the model item @arg dom 0065 * @return The list of the sub folders 0066 */ 0067 virtual QList<ProjectFolderItem*> parse(ProjectFolderItem *dom) = 0; 0068 0069 /** 0070 * This method creates the root item from the file @arg fileName 0071 * @return The created item 0072 */ 0073 virtual ProjectFolderItem *import(IProject *project) = 0; 0074 0075 /** 0076 * @brief This method creates an import job for the given @p item 0077 * 0078 * @details The default implementation should be suitable for most needs, 0079 * it'll create an instance of class @ref ImportProjectJob 0080 * 0081 * @return a job that imports the project 0082 */ 0083 virtual KJob* createImportJob(ProjectFolderItem* item); 0084 0085 /** 0086 * Add a folder to the project and create it on disk. 0087 * 0088 * Adds the folder specified by @p folder to @p parent and modifies the 0089 * underlying build system if needed 0090 */ 0091 virtual ProjectFolderItem* addFolder(const Path& folder, ProjectFolderItem* parent) = 0; 0092 0093 /** 0094 * Add a file to a folder and create it on disk. 0095 * 0096 * Adds the file specified by @p file to the folder @p parent and modifies 0097 * the underlying build system if needed. The file is not added to a target 0098 */ 0099 virtual ProjectFileItem* addFile(const Path& file, ProjectFolderItem *parent) = 0; 0100 0101 /** 0102 * Remove files or folders from the project and delete them from disk 0103 * 0104 * Removes the files or folders specified by @p items and 0105 * modifies the underlying build system if needed. 0106 * 0107 * Note: Do not attempt to remove subitems along with their parents 0108 */ 0109 virtual bool removeFilesAndFolders(const QList<ProjectBaseItem*> &items) = 0; 0110 0111 /** 0112 * Move files and folders within a given project 0113 * 0114 * Moves the files or folders specified by @p items to @p newParent and 0115 * modifies the underlying build system as needed 0116 * 0117 * Note: Do not attempt to move subitems along with their parents 0118 */ 0119 virtual bool moveFilesAndFolders(const QList< KDevelop::ProjectBaseItem* > &items, KDevelop::ProjectFolderItem* newParent) = 0; 0120 0121 /** 0122 * Copy files and folders within a given project 0123 * 0124 * Copies the files or folders specified by @p items to @p newParent and 0125 * modifies the underlying build system as needed 0126 * 0127 * Note: Do not attempt to copy subitems along with their parents 0128 */ 0129 virtual bool copyFilesAndFolders(const Path::List &items, KDevelop::ProjectFolderItem* newParent) = 0; 0130 0131 /** 0132 * Rename a file in the project 0133 * 0134 * Renames the file specified by @p oldFile to @p newPath 0135 */ 0136 virtual bool renameFile(ProjectFileItem* file, const Path& newPath) = 0; 0137 0138 /** 0139 * Rename a folder in the project 0140 * 0141 * Renames the folder specified by @p oldFile to @p newPath 0142 */ 0143 virtual bool renameFolder(ProjectFolderItem* oldFolder, const Path& newPath) = 0; 0144 0145 /** 0146 * Reload an item in the project 0147 * 0148 * Reloads the item specified by @p item 0149 */ 0150 virtual bool reload(ProjectFolderItem* item) = 0; 0151 0152 Q_SIGNALS: 0153 void folderAdded(KDevelop::ProjectFolderItem* folder); 0154 void folderRemoved(KDevelop::ProjectFolderItem* folder); 0155 void folderRenamed(const KDevelop::Path& oldFolder, KDevelop::ProjectFolderItem* newFolder); 0156 0157 void fileAdded(KDevelop::ProjectFileItem* file); 0158 void fileRemoved(KDevelop::ProjectFileItem* file); 0159 void fileRenamed(const KDevelop::Path& oldFile, KDevelop::ProjectFileItem* newFile); 0160 }; 0161 0162 Q_DECLARE_OPERATORS_FOR_FLAGS(IProjectFileManager::Features) 0163 } 0164 0165 Q_DECLARE_INTERFACE( KDevelop::IProjectFileManager, "org.kdevelop.IProjectFileManager") 0166 0167 #endif