1
/***************************************************************************
2
* This file is part of KDevelop *
3
* Copyright 2010 Milian Wolff <mail@milianw.de> *
5
* This program is free software; you can redistribute it and/or modify *
6
* it under the terms of the GNU Library General Public License as *
7
* published by the Free Software Foundation; either version 2 of the *
8
* License, or (at your option) any later version. *
10
* This program is distributed in the hope that it will be useful, *
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13
* GNU General Public License for more details. *
15
* You should have received a copy of the GNU Library General Public *
16
* License along with this program; if not, write to the *
17
* Free Software Foundation, Inc., *
18
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19
***************************************************************************/
21
#ifndef ABSTRACTGENERICMANAGER_H
22
#define ABSTRACTGENERICMANAGER_H
24
#include "projectexport.h"
26
#include "interfaces/iprojectfilemanager.h"
28
#include <interfaces/iplugin.h>
34
class FileManagerListJob;
37
* This class can be used as a common base for file managers.
39
* It supports remote files using KIO and uses KDirWatch to synchronize with on-disk changes.
41
class KDEVPLATFORMPROJECT_EXPORT AbstractFileManagerPlugin : public IPlugin, public virtual IProjectFileManager
44
Q_INTERFACES( KDevelop::IProjectFileManager )
47
explicit AbstractFileManagerPlugin( const KComponentData& instance, QObject *parent = 0,
48
const QVariantList &args = QVariantList() );
49
virtual ~AbstractFileManagerPlugin();
52
// IProjectFileManager interface
54
virtual Features features() const;
56
virtual ProjectFolderItem* addFolder( const KUrl& folder, ProjectFolderItem *parent );
57
virtual ProjectFileItem* addFile( const KUrl& file, ProjectFolderItem *parent );
58
virtual bool removeFilesAndFolders( QList<ProjectBaseItem*> items);
59
virtual bool renameFolder( ProjectFolderItem *folder, const KUrl& url );
60
virtual bool renameFile( ProjectFileItem *file, const KUrl& url );
62
virtual QList<ProjectFolderItem*> parse( ProjectFolderItem *item );
63
virtual ProjectFolderItem *import( IProject *project );
64
virtual bool reload(ProjectFolderItem* item);
65
virtual KJob* createImportJob(ProjectFolderItem* item);
69
// AbstractFileManagerPlugin interface
72
* Filter interface making it possible to hide files and folders from a project.
74
* The default implementation will show all files.
76
* @return True when @p url should belong to @p project, false otherwise.
78
virtual bool isValid(const KUrl& url, const bool isFolder, IProject* project) const;
81
* Customization hook enabling you to create custom FolderItems if required.
83
* The default implementation will return a simple @c ProjectFolderItem
85
virtual ProjectFolderItem* createFolderItem( KDevelop::IProject* project, const KUrl& url,
86
KDevelop::ProjectBaseItem* parent = 0);
89
* Customization hook enabling you to create custom FileItems if required.
91
* The default implementation will return a simple @c ProjectFileItem
93
virtual ProjectFileItem* createFileItem( KDevelop::IProject* project, const KUrl& url,
94
KDevelop::ProjectBaseItem* parent);
97
* @return the @c KDirWatch for the given @p project.
99
KDirWatch* projectWatcher( KDevelop::IProject* project ) const;
102
void folderAdded(KDevelop::ProjectFolderItem* folder);
103
void folderRemoved(KDevelop::ProjectFolderItem* folder);
104
void folderRenamed(const KUrl& oldFolder, KDevelop::ProjectFolderItem* newFolder);
106
void fileAdded(KDevelop::ProjectFileItem* file);
107
void fileRemoved(KDevelop::ProjectFileItem* file);
108
void fileRenamed(const KUrl& oldFile, KDevelop::ProjectFileItem* newFile);
112
// friend class Private;
115
Q_PRIVATE_SLOT(d, KJob* eventuallyReadFolder( ProjectFolderItem* item,
116
const bool forceRecursion = false ))
117
Q_PRIVATE_SLOT(d, void addJobItems(FileManagerListJob* job,
118
ProjectFolderItem* baseItem,
119
const KIO::UDSEntryList& entries,
120
const bool forceRecursion))
122
Q_PRIVATE_SLOT(d, void deleted(const QString &path))
123
Q_PRIVATE_SLOT(d, void created(const QString &path))
125
Q_PRIVATE_SLOT(d, void projectClosing(KDevelop::IProject* project))
126
Q_PRIVATE_SLOT(d, void jobFinished(KJob* job))
131
#endif // ABSTRACTGENERICMANAGER_H