diff --git a/plugins/genericprojectmanager/genericmanager.cpp b/plugins/genericprojectmanager/genericmanager.cpp index 136a6802d8..1607f160be 100644 --- a/plugins/genericprojectmanager/genericmanager.cpp +++ b/plugins/genericprojectmanager/genericmanager.cpp @@ -1,113 +1,113 @@ /* This file is part of KDevelop CopyRight 2010 Milian Wolff Copyright 2004 Roberto Raggi This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "genericmanager.h" #include #include #include #include #include #include using namespace KDevelop; K_PLUGIN_FACTORY(GenericSupportFactory, registerPlugin(); ) K_EXPORT_PLUGIN(GenericSupportFactory( KAboutData("kdevgenericmanager", "kdevgenericprojectmanager", ki18n("Generic Project Manager"), "0.2", ki18n("A plugin to support basic project management on a filesystem level"), KAboutData::License_GPL))) GenericProjectManager::GenericProjectManager( QObject* parent, const QVariantList& args ) : AbstractFileManagerPlugin( GenericSupportFactory::componentData(), parent, args ) { } void GenericProjectManager::updateIncludeRules( IProject* project ) { KConfigGroup filtersConfig = project->projectConfiguration()->group("Filters"); QStringList includes = filtersConfig.readEntry("Includes", QStringList("*")); QStringList excludes = filtersConfig.readEntry("Excludes", QStringList() << "*/.*" << "*~"); m_includeRules[project] = qMakePair(includes, excludes); } KJob* GenericProjectManager::createImportJob( ProjectFolderItem* item ) { updateIncludeRules(item->project()); return AbstractFileManagerPlugin::createImportJob( item ); } bool GenericProjectManager::reload( ProjectFolderItem* item ) { updateIncludeRules(item->project()); return AbstractFileManagerPlugin::reload( item ); } bool GenericProjectManager::isValid( const KUrl &url, const bool isFolder, IProject* project ) const { if ( isFolder && url.fileName() == ".kdev4" && url.upUrl() == project->folder() ) { return false; } else if ( url == project->projectFileUrl() ) { return false; } bool ok = isFolder; // we operate on the path of this url relative to the project base // by prepending a slash we can filter hidden files with the pattern "*/.*" // by appending a slash to folders we can filter them with "*/" const QString relativePath = "/" + project->relativeUrl( url ).path( isFolder ? KUrl::AddTrailingSlash : KUrl::RemoveTrailingSlash ); Q_ASSERT( m_includeRules.contains( project ) ); const IncludeRules& rules = m_includeRules.value( project ); QStringList::ConstIterator it; for ( it = rules.first.constBegin(); !ok && it != rules.first.constEnd(); ++it ) { QRegExp rx( *it, Qt::CaseSensitive, QRegExp::Wildcard ); if ( rx.exactMatch( relativePath ) ) { ok = true; break; } } if ( !ok ) { return false; } for ( it = rules.second.constBegin(); it != rules.second.constEnd(); ++it ) { QRegExp rx( *it, Qt::CaseSensitive, QRegExp::Wildcard ); if ( rx.exactMatch( relativePath ) ) { return false; } } return true; } -bool GenericProjectManager::moveFilesAndFolders(QList< ProjectBaseItem* > items, ProjectFolderItem* newParent) +bool GenericProjectManager::moveFilesAndFolders(QList< ProjectBaseItem* > &items, ProjectFolderItem* newParent) { Q_UNUSED(items); Q_UNUSED(newParent); return false; } #include "genericmanager.moc" diff --git a/plugins/genericprojectmanager/genericmanager.h b/plugins/genericprojectmanager/genericmanager.h index 3279a70d09..e6991801fb 100644 --- a/plugins/genericprojectmanager/genericmanager.h +++ b/plugins/genericprojectmanager/genericmanager.h @@ -1,45 +1,45 @@ /* This file is part of KDevelop CopyRight 2010 Milian Wolff Copyright 2004,2005 Roberto Raggi This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KDEVGENERICMANAGER_H #define KDEVGENERICMANAGER_H #include class GenericProjectManager: public KDevelop::AbstractFileManagerPlugin { Q_OBJECT public: explicit GenericProjectManager( QObject* parent = 0, const QVariantList& args = QVariantList() ); virtual KJob* createImportJob( KDevelop::ProjectFolderItem* item ); virtual bool reload( KDevelop::ProjectFolderItem* item ); - virtual bool moveFilesAndFolders ( QList< KDevelop::ProjectBaseItem* > items, KDevelop::ProjectFolderItem *newParent ); + virtual bool moveFilesAndFolders ( QList< KDevelop::ProjectBaseItem* > &items, KDevelop::ProjectFolderItem *newParent ); protected: virtual bool isValid( const KUrl& url, const bool isFolder, KDevelop::IProject* project ) const; private: typedef QPair IncludeRules; void updateIncludeRules( KDevelop::IProject* project ); QMap< KDevelop::IProject*, IncludeRules > m_includeRules; }; #endif // KDEVGENERICIMPORTER_H diff --git a/project/abstractfilemanagerplugin.cpp b/project/abstractfilemanagerplugin.cpp index 6d23a1570a..4753b549bb 100644 --- a/project/abstractfilemanagerplugin.cpp +++ b/project/abstractfilemanagerplugin.cpp @@ -1,538 +1,538 @@ /*************************************************************************** * This file is part of KDevelop * * Copyright 2010 Milian Wolff * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU Library General Public License as * * published by the Free Software Foundation; either version 2 of the * * License, or (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU Library General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "abstractfilemanagerplugin.h" #include "filemanagerlistjob.h" #include "projectmodel.h" #include "helper.h" #include #include #include #include #include #include #include #include #include #include #include #define ifDebug(x) using namespace KDevelop; //BEGIN Helper namespace { /** * Returns the parent folder item for a given item or the project root item if there is no parent. */ ProjectFolderItem* getParentFolder(ProjectBaseItem* item) { if ( item->parent() ) { return static_cast(item->parent()); } else { return item->project()->projectItem(); } } } //END Helper //BEGIN Private struct AbstractFileManagerPlugin::Private { explicit Private(AbstractFileManagerPlugin* qq) : q(qq) { } AbstractFileManagerPlugin* q; /// @p forceRecursion if true, existing folders will be re-read no matter what KJob* eventuallyReadFolder( ProjectFolderItem* item, const bool forceRecursion = false ); void addJobItems(FileManagerListJob* job, ProjectFolderItem* baseItem, const KIO::UDSEntryList& entries, const bool forceRecursion); void deleted(const QString &path); void created(const QString &path); void projectClosing(IProject* project); void jobFinished(KJob* job); /// Stops watching the given folder for changes, only useful for local files. void stopWatcher(ProjectFolderItem* folder); /// Continues watching the given folder for changes. void continueWatcher(ProjectFolderItem* folder); /// Common renaming function. bool rename( ProjectBaseItem* item, const KUrl& destination); void removeFolder(ProjectFolderItem* folder); QMap m_watchers; QMap > m_projectJobs; }; void AbstractFileManagerPlugin::Private::projectClosing(IProject* project) { if ( m_projectJobs.contains(project) ) { // make sure the import job does not live longer than the project // see also addLotsOfFiles test foreach( FileManagerListJob* job, m_projectJobs[project] ) { kDebug(9517) << "killing project job:" << job; job->kill(); } m_projectJobs.remove(project); } delete m_watchers.take(project); } KJob* AbstractFileManagerPlugin::Private::eventuallyReadFolder( ProjectFolderItem* item, const bool forceRecursion ) { FileManagerListJob* listJob = new FileManagerListJob( item, forceRecursion ); m_projectJobs[ item->project() ] << listJob; kDebug(9517) << "adding job" << listJob << item << item->url() << "for project" << item->project(); ICore::self()->runController()->registerJob( listJob ); q->connect( listJob, SIGNAL(finished(KJob*)), q, SLOT(jobFinished(KJob*)) ); q->connect( listJob, SIGNAL(entries(FileManagerListJob*, ProjectFolderItem*, KIO::UDSEntryList, bool)), q, SLOT(addJobItems(FileManagerListJob*, ProjectFolderItem*, KIO::UDSEntryList, bool)) ); return listJob; } void AbstractFileManagerPlugin::Private::jobFinished(KJob* job) { FileManagerListJob* gmlJob = qobject_cast(job); Q_ASSERT(gmlJob); ifDebug(kDebug() << job << gmlJob;) m_projectJobs[ gmlJob->item()->project() ].removeOne( gmlJob ); } void AbstractFileManagerPlugin::Private::addJobItems(FileManagerListJob* job, ProjectFolderItem* baseItem, const KIO::UDSEntryList& entries, const bool forceRecursion) { if ( entries.empty() ) { return; } kDebug(9517) << "reading entries of" << baseItem->url(); // build lists of valid files and folders with relative urls to the project folder KUrl::List files; KUrl::List folders; foreach ( const KIO::UDSEntry& entry, entries ) { QString name = entry.stringValue( KIO::UDSEntry::UDS_NAME ); if (name == "." || name == "..") { continue; } KUrl url = baseItem->url(); url.addPath( name ); if (entry.isDir()) { url.adjustPath(KUrl::AddTrailingSlash); } if ( !q->isValid( url, entry.isDir(), baseItem->project() ) ) { continue; } else { if ( entry.isDir() ) { if( entry.isLink() ) { KUrl linkedUrl = baseItem->url(); linkedUrl.cd(entry.stringValue( KIO::UDSEntry::UDS_LINK_DEST )); // make sure we don't end in an infinite loop if( linkedUrl.isParentOf( baseItem->project()->folder() ) || baseItem->project()->folder().isParentOf( linkedUrl ) || linkedUrl == baseItem->project()->folder() ) { continue; } } folders << url; } else { files << url; } } } ifDebug(kDebug(9517) << "valid folders:" << folders;) ifDebug(kDebug(9517) << "valid files:" << files;) // remove obsolete rows for ( int j = 0; j < baseItem->rowCount(); ++j ) { if ( ProjectFolderItem* f = baseItem->child(j)->folder() ) { // check if this is still a valid folder int index = folders.indexOf( f->url() ); if ( index == -1 ) { // folder got removed or is now invalid removeFolder(f); --j; } else { // this folder already exists in the view folders.removeAt( index ); if ( forceRecursion ) { //no need to add this item, but we still want to recurse into it job->addSubDir( f ); } } } else if ( ProjectFileItem* f = baseItem->child(j)->file() ) { // check if this is still a valid file int index = files.indexOf( f->url() ); if ( index == -1 ) { // file got removed or is now invalid ifDebug(kDebug(9517) << "removing file:" << f << f->url();) baseItem->removeRow( j ); --j; } else { // this file already exists in the view files.removeAt( index ); } } } // add new rows foreach ( const KUrl& url, files ) { ProjectFileItem* file = q->createFileItem( baseItem->project(), url, baseItem ); emit q->fileAdded( file ); } foreach ( const KUrl& url, folders ) { ProjectFolderItem* folder = q->createFolderItem( baseItem->project(), url, baseItem ); emit q->folderAdded( folder ); job->addSubDir( folder ); } } void AbstractFileManagerPlugin::Private::created(const QString &path) { kDebug(9517) << "created:" << path; QFileInfo info(path); KUrl url = KUrl(path); if (info.isDir()) { url.adjustPath(KUrl::AddTrailingSlash); } KUrl parent = url.upUrl(); foreach ( IProject* p, m_watchers.keys() ) { if ( !q->isValid(url, info.isDir(), p) ) { continue; } if ( info.isDir() ) { bool found = false; foreach ( ProjectFolderItem* folder, p->foldersForUrl(url) ) { // exists already in this project, happens e.g. when we restart the dirwatcher // or if we delete and remove folders consecutively https://bugs.kde.org/show_bug.cgi?id=260741 kDebug(9517) << "force reload of" << url << folder; eventuallyReadFolder( folder, true ); found = true; } if ( found ) { continue; } } else if (!p->filesForUrl(url).isEmpty()) { // also gets triggered for kate's backup files continue; } foreach ( ProjectFolderItem* parentItem, p->foldersForUrl(parent) ) { if ( info.isDir() ) { ProjectFolderItem* folder = q->createFolderItem( p, url, parentItem ); emit q->folderAdded( folder ); eventuallyReadFolder( folder ); } else { ProjectFileItem* file = q->createFileItem( p, url, parentItem ); emit q->fileAdded( file ); } } } } void AbstractFileManagerPlugin::Private::deleted(const QString &path) { if ( QFile::exists(path) ) { // stopDirScan... return; } kDebug(9517) << "deleted:" << path; KUrl url = KUrl(path); foreach ( IProject* p, m_watchers.keys() ) { if ( url.equals(p->folder(), KUrl::CompareWithoutTrailingSlash) ) { KMessageBox::error(qApp->activeWindow(), i18n("The base folder of project %1" " got deleted or moved outside of KDevelop.\n" "The project has to be closed.", p->name()), i18n("Project Folder Deleted") ); ICore::self()->projectController()->closeProject(p); continue; } foreach ( ProjectFolderItem* item, p->foldersForUrl(url) ) { removeFolder(item); } foreach ( ProjectFileItem* item, p->filesForUrl(url) ) { emit q->fileRemoved(item); ifDebug(kDebug(9517) << "removing file" << item;) item->parent()->removeRow(item->row()); } } } bool AbstractFileManagerPlugin::Private::rename(ProjectBaseItem* item, const KUrl& destination) { if ( !q->isValid(destination, true, item->project()) ) { int cancel = KMessageBox::warningContinueCancel( qApp->activeWindow(), i18n("You tried to rename '%1' to '%2', but the latter is filtered and will be hidden.\n" "Do you want to continue?", item->text(), destination.fileName()), QString(), KStandardGuiItem::cont(), KStandardGuiItem::cancel(), "GenericManagerRenameToFiltered" ); if ( cancel == KMessageBox::Cancel ) { return false; } } foreach ( ProjectFolderItem* parent, item->project()->foldersForUrl(destination.upUrl()) ) { if ( parent->folder() ) { stopWatcher(parent); const KUrl source = item->url(); bool success = renameUrl( item->project(), source, destination ); if ( success ) { item->setUrl( destination ); item->parent()->takeRow( item->row() ); parent->appendRow( item ); if (item->file()) { emit q->fileRenamed(source, item->file()); } else { Q_ASSERT(item->folder()); emit q->folderRenamed(source, item->folder()); } } continueWatcher(parent); return success; } } return false; } void AbstractFileManagerPlugin::Private::stopWatcher(ProjectFolderItem* folder) { if ( !folder->url().isLocalFile() ) { return; } Q_ASSERT(m_watchers.contains(folder->project())); m_watchers[folder->project()]->stopDirScan(folder->url().toLocalFile()); } void AbstractFileManagerPlugin::Private::continueWatcher(ProjectFolderItem* folder) { if ( !folder->url().isLocalFile() ) { return; } Q_ASSERT(m_watchers.contains(folder->project())); m_watchers[folder->project()]->restartDirScan(folder->url().toLocalFile()); } void AbstractFileManagerPlugin::Private::removeFolder(ProjectFolderItem* folder) { ifDebug(kDebug(9517) << "removing folder:" << folder << folder->url();) foreach(FileManagerListJob* job, m_projectJobs[folder->project()]) { if (job->item() == folder) { kDebug(9517) << "killing list job for removed folder" << job << folder->url(); job->kill(); } } folder->parent()->removeRow( folder->row() ); } //END Private //BEGIN Plugin AbstractFileManagerPlugin::AbstractFileManagerPlugin( const KComponentData& instance, QObject *parent, const QVariantList & /*args*/ ) : IProjectFileManager(), IPlugin( instance, parent ), d(new Private(this)) { KDEV_USE_EXTENSION_INTERFACE( IProjectFileManager ) connect(core()->projectController(), SIGNAL(projectClosing(KDevelop::IProject*)), this, SLOT(projectClosing(KDevelop::IProject*))); } AbstractFileManagerPlugin::~AbstractFileManagerPlugin() { delete d; } IProjectFileManager::Features AbstractFileManagerPlugin::features() const { return Features( Folders | Files ); } QList AbstractFileManagerPlugin::parse( ProjectFolderItem *item ) { // we are async, can't return anything here kDebug(9517) << "note: parse will always return an empty list"; Q_UNUSED(item); return QList(); } ProjectFolderItem *AbstractFileManagerPlugin::import( IProject *project ) { ProjectFolderItem *projectRoot = createFolderItem( project, project->folder(), 0 ); emit folderAdded( projectRoot ); kDebug(9517) << "imported new project" << project->name() << "at" << projectRoot->url(); ///TODO: check if this works for remote files when something gets changed through another KDE app if ( project->folder().isLocalFile() ) { d->m_watchers[project] = new KDirWatch( project ); connect(d->m_watchers[project], SIGNAL(created(QString)), this, SLOT(created(QString))); connect(d->m_watchers[project], SIGNAL(deleted(QString)), this, SLOT(deleted(QString))); d->m_watchers[project]->addDir(project->folder().toLocalFile(), KDirWatch::WatchSubDirs | KDirWatch:: WatchFiles ); } return projectRoot; } KJob* AbstractFileManagerPlugin::createImportJob(ProjectFolderItem* item) { return d->eventuallyReadFolder(item); } bool AbstractFileManagerPlugin::reload( ProjectFolderItem* item ) { kDebug(9517) << "reloading item" << item->url(); d->eventuallyReadFolder( item->folder(), true ); return true; } ProjectFolderItem* AbstractFileManagerPlugin::addFolder( const KUrl& url, ProjectFolderItem * parent ) { kDebug(9517) << "adding folder" << url << "to" << parent->url(); ProjectFolderItem* created = 0; d->stopWatcher(parent); if ( createFolder(url) ) { created = createFolderItem( parent->project(), url, parent ); emit folderAdded(created); } d->continueWatcher(parent); return created; } ProjectFileItem* AbstractFileManagerPlugin::addFile( const KUrl& url, ProjectFolderItem * parent ) { kDebug(9517) << "adding file" << url << "to" << parent->url(); ProjectFileItem* created = 0; d->stopWatcher(parent); if ( createFile(url) ) { created = createFileItem( parent->project(), url, parent ); emit fileAdded(created); } d->continueWatcher(parent); return created; } bool AbstractFileManagerPlugin::renameFolder( ProjectFolderItem * folder, const KUrl& url ) { kDebug(9517) << "trying to rename a folder:" << folder->url() << url; return d->rename(folder, url); } bool AbstractFileManagerPlugin::renameFile( ProjectFileItem * file, const KUrl& url ) { kDebug(9517) << "trying to rename a file:" << file->url() << url; return d->rename(file, url); } -bool AbstractFileManagerPlugin::removeFilesAndFolders(QList items) +bool AbstractFileManagerPlugin::removeFilesAndFolders(QList &items) { bool success = true; foreach(ProjectBaseItem* item, items) { Q_ASSERT(item->folder() || item->file()); ProjectFolderItem* parent = getParentFolder(item); d->stopWatcher(parent); success &= removeUrl(parent->project(), item->url(), true); if ( success ) { if (item->file()) { emit fileRemoved(item->file()); } else { Q_ASSERT(item->folder()); emit folderRemoved(item->folder()); } item->parent()->removeRow( item->row() ); } d->continueWatcher(parent); if ( !success ) break; } return success; } bool AbstractFileManagerPlugin::isValid( const KUrl& /*url*/, const bool /*isFolder*/, IProject* /*project*/ ) const { return true; } ProjectFileItem* AbstractFileManagerPlugin::createFileItem( IProject* project, const KUrl& url, ProjectBaseItem* parent ) { return new ProjectFileItem( project, url, parent ); } ProjectFolderItem* AbstractFileManagerPlugin::createFolderItem( IProject* project, const KUrl& url, ProjectBaseItem* parent ) { return new ProjectFolderItem( project, url, parent ); } KDirWatch* AbstractFileManagerPlugin::projectWatcher( IProject* project ) const { return d->m_watchers.value( project, 0 ); } //END Plugin #include "abstractfilemanagerplugin.moc" diff --git a/project/abstractfilemanagerplugin.h b/project/abstractfilemanagerplugin.h index 3404744aa2..6a475818d6 100644 --- a/project/abstractfilemanagerplugin.h +++ b/project/abstractfilemanagerplugin.h @@ -1,131 +1,131 @@ /*************************************************************************** * This file is part of KDevelop * * Copyright 2010 Milian Wolff * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU Library General Public License as * * published by the Free Software Foundation; either version 2 of the * * License, or (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU Library General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef ABSTRACTGENERICMANAGER_H #define ABSTRACTGENERICMANAGER_H #include "projectexport.h" #include "interfaces/iprojectfilemanager.h" #include class KDirWatch; namespace KDevelop { class FileManagerListJob; /** * This class can be used as a common base for file managers. * * It supports remote files using KIO and uses KDirWatch to synchronize with on-disk changes. */ class KDEVPLATFORMPROJECT_EXPORT AbstractFileManagerPlugin : public IPlugin, public virtual IProjectFileManager { Q_OBJECT Q_INTERFACES( KDevelop::IProjectFileManager ) public: explicit AbstractFileManagerPlugin( const KComponentData& instance, QObject *parent = 0, const QVariantList &args = QVariantList() ); virtual ~AbstractFileManagerPlugin(); // // IProjectFileManager interface // virtual Features features() const; virtual ProjectFolderItem* addFolder( const KUrl& folder, ProjectFolderItem *parent ); virtual ProjectFileItem* addFile( const KUrl& file, ProjectFolderItem *parent ); - virtual bool removeFilesAndFolders( QList items); + virtual bool removeFilesAndFolders( QList &items); virtual bool renameFolder( ProjectFolderItem *folder, const KUrl& url ); virtual bool renameFile( ProjectFileItem *file, const KUrl& url ); virtual QList parse( ProjectFolderItem *item ); virtual ProjectFolderItem *import( IProject *project ); virtual bool reload(ProjectFolderItem* item); virtual KJob* createImportJob(ProjectFolderItem* item); protected: // // AbstractFileManagerPlugin interface // /** * Filter interface making it possible to hide files and folders from a project. * * The default implementation will show all files. * * @return True when @p url should belong to @p project, false otherwise. */ virtual bool isValid(const KUrl& url, const bool isFolder, IProject* project) const; /** * Customization hook enabling you to create custom FolderItems if required. * * The default implementation will return a simple @c ProjectFolderItem */ virtual ProjectFolderItem* createFolderItem( KDevelop::IProject* project, const KUrl& url, KDevelop::ProjectBaseItem* parent = 0); /** * Customization hook enabling you to create custom FileItems if required. * * The default implementation will return a simple @c ProjectFileItem */ virtual ProjectFileItem* createFileItem( KDevelop::IProject* project, const KUrl& url, KDevelop::ProjectBaseItem* parent); /** * @return the @c KDirWatch for the given @p project. */ KDirWatch* projectWatcher( KDevelop::IProject* project ) const; Q_SIGNALS: void folderAdded(KDevelop::ProjectFolderItem* folder); void folderRemoved(KDevelop::ProjectFolderItem* folder); void folderRenamed(const KUrl& oldFolder, KDevelop::ProjectFolderItem* newFolder); void fileAdded(KDevelop::ProjectFileItem* file); void fileRemoved(KDevelop::ProjectFileItem* file); void fileRenamed(const KUrl& oldFile, KDevelop::ProjectFileItem* newFile); private: struct Private; // friend class Private; Private* const d; Q_PRIVATE_SLOT(d, KJob* eventuallyReadFolder( ProjectFolderItem* item, const bool forceRecursion = false )) Q_PRIVATE_SLOT(d, void addJobItems(FileManagerListJob* job, ProjectFolderItem* baseItem, const KIO::UDSEntryList& entries, const bool forceRecursion)) Q_PRIVATE_SLOT(d, void deleted(const QString &path)) Q_PRIVATE_SLOT(d, void created(const QString &path)) Q_PRIVATE_SLOT(d, void projectClosing(KDevelop::IProject* project)) Q_PRIVATE_SLOT(d, void jobFinished(KJob* job)) }; } #endif // ABSTRACTGENERICMANAGER_H diff --git a/project/interfaces/ibuildsystemmanager.h b/project/interfaces/ibuildsystemmanager.h index 08dea7fddd..0b92870209 100644 --- a/project/interfaces/ibuildsystemmanager.h +++ b/project/interfaces/ibuildsystemmanager.h @@ -1,130 +1,130 @@ /* This file is part of KDevelop Copyright 2006 Matt Rogers Copyright 2006 Hamish Rodda Copyright 2007 Andreas Pakulat This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef IBUILDSYSTEMMANAGER_H #define IBUILDSYSTEMMANAGER_H #include #include "iprojectfilemanager.h" #include "../projectexport.h" namespace KDevelop { class IProjectBuilder; class ProjectTargetItem; /** * Manages the build system of the project. * * Use/Implement the IProjectFileManager interface to manage files. * * @author Matt Rogers , Hamish Rodda */ class KDEVPLATFORMPROJECT_EXPORT IBuildSystemManager : public virtual IProjectFileManager { public: virtual ~IBuildSystemManager(); enum BuildFeature { Includes /**< This project supports passing include directives to the compiler */, Defines /**< This project supports passing preprocessor defines to compiler */ }; Q_DECLARE_FLAGS( BuildFeatures, BuildFeature ) /** * Provide access to the builder. This method never returns * null, if it does thats a bug in the plugin. A BuildSystemManager * always has a project builder associated with it. */ virtual IProjectBuilder* builder(ProjectFolderItem*) const = 0; /** * Provide a list of include directories. */ virtual KUrl::List includeDirectories(ProjectBaseItem*) const = 0; /** * Provide a list of preprocessor defines for the project item */ virtual QHash defines(ProjectBaseItem*) const = 0; /** * Create a new target * * Creates the target specified by @p target to the folder @p parent and * modifies the underlying build system if needed */ virtual ProjectTargetItem* createTarget(const QString& target, ProjectFolderItem *parent) = 0; /** * Remove a target * * Removes the target specified by @p target and * modifies the underlying build system if needed. */ virtual bool removeTarget(ProjectTargetItem *target) = 0; /** * Get a list of all the targets in this project * * The list returned by this function should be checked to verify it is not * empty before using it * * @return The list of targets for this project * @todo implement */ virtual QList targets(ProjectFolderItem*) const = 0; /** * Add a file to a target * * Adds the file specified by @p file to the target @p parent and modifies * the underlying build system if needed. */ - virtual bool addFilesToTarget(QList files, ProjectTargetItem *target) = 0; + virtual bool addFilesToTarget(QList &files, ProjectTargetItem *target) = 0; /** * Remove files from targets * * Removes the files from the targets they are paired with (@p targetFiles) * Files are not removed from the folders or the filesystem. */ - virtual bool removeFilesFromTargets( QList files ) = 0; + virtual bool removeFilesFromTargets(QList &files) = 0; /** * Get the toplevel build directory for the project */ virtual KUrl buildDirectory(ProjectBaseItem*) const = 0; }; } Q_DECLARE_OPERATORS_FOR_FLAGS( KDevelop::IBuildSystemManager::BuildFeatures ) Q_DECLARE_INTERFACE( KDevelop::IBuildSystemManager, "org.kdevelop.IBuildSystemManager" ) #endif diff --git a/project/interfaces/iprojectfilemanager.h b/project/interfaces/iprojectfilemanager.h index e49f473cda..592493a430 100644 --- a/project/interfaces/iprojectfilemanager.h +++ b/project/interfaces/iprojectfilemanager.h @@ -1,175 +1,175 @@ /* This file is part of KDevelop Copyright 2004 Roberto Raggi Copyright 2006 Matt Rogers Copyright 2006 Hamish Rodda Copyright 2007 Andreas Pakulat #include #include "../projectexport.h" class KJob; namespace KDevelop { class IProject; class ProjectBaseItem; class ProjectFolderItem; class ProjectFileItem; /** * @short An interface to project file management * * FileManager is the class you want to implement for integrating * a project manager in KDevelop. For build systems, implement its * child class, BuildManager. * * These classes \e do \e not cause files, folders etc. to be created * or removed on disk. They simply read from and write to the file(s) * which describe the structure (eg. CMakeLists.txt for cmake, Makefile.am for automake, etc). * * @author Roberto Raggi, Matt Rogers, Hamish Rodda */ class KDEVPLATFORMPROJECT_EXPORT IProjectFileManager { public: virtual ~IProjectFileManager(); /** Features the file manager supports */ enum Feature { None = 0 , ///< This manager supports nothing Folders = 1 << 0, ///< Folders are supported by the manager Targets = 1 << 1, ///< Targets are supported by the manager Files = 1 << 2 ///< Files are supported by the manager }; Q_DECLARE_FLAGS( Features, Feature ) /** * @return the Features supported by the filemanager */ virtual Features features() const = 0; /** * This method initialize the model item @arg dom * @return The list of the sub folders */ virtual QList parse(ProjectFolderItem *dom) = 0; /** * This method creates the root item from the file @arg fileName * @return The created item */ virtual ProjectFolderItem *import(IProject *project) = 0; /** * This method creates an import job for the given @arg item * * The default implementation should be suitable for most needs, * it'll create an instance of @class ImportProjectJob * * @return a job that imports the project */ virtual KJob* createImportJob(ProjectFolderItem* item); /** * Add a folder to the project and create it on disk. * * Adds the folder specified by @p folder to @p parent and modifies the * underlying build system if needed */ virtual ProjectFolderItem* addFolder(const KUrl& folder, ProjectFolderItem *parent) = 0; /** * Add a file to a folder and create it on disk. * * Adds the file specified by @p file to the folder @p parent and modifies * the underlying build system if needed. The file is not added to a target */ virtual ProjectFileItem* addFile(const KUrl& file, ProjectFolderItem *parent) = 0; /** * Remove files or folders from the project and delete them from disk * * Removes the files or folders specified by @p items and * modifies the underlying build system if needed. * * Note: Do not attempt to remove subitems along with their parents */ - virtual bool removeFilesAndFolders( QList items) = 0; + virtual bool removeFilesAndFolders(QList &items) = 0; /** * Move files and folders within a given project * * Moves the files or folders specified by @p items to @p newParent and * modifies the underlying build system as needed * * Note: Do not attempt to move subitems along with their parents */ - virtual bool moveFilesAndFolders( QList< KDevelop::ProjectBaseItem* > items, KDevelop::ProjectFolderItem* newParent ) = 0; + virtual bool moveFilesAndFolders(QList< KDevelop::ProjectBaseItem* > &items, KDevelop::ProjectFolderItem* newParent) = 0; /** * Rename a file in the project * * Renames the file specified by @p oldFile to @p newFile * */ virtual bool renameFile(ProjectFileItem* oldFile, const KUrl& newFile) = 0; /** * Rename a folder in the project * * Renames the folder specified by @p oldFile to @p newFile */ virtual bool renameFolder(ProjectFolderItem* oldFolder, const KUrl& newFolder ) = 0; /** * Reload an item in the project * * Reloads the item specified by @p item */ virtual bool reload(ProjectFolderItem* item) = 0; Q_SIGNALS: void folderAdded( ProjectFolderItem* folder ); void folderRemoved( ProjectFolderItem* folder ); void folderRenamed( const KUrl& oldFolder, ProjectFolderItem* newFolder ); void fileAdded(ProjectFileItem* file); void fileRemoved(ProjectFileItem* file); void fileRenamed(const KUrl& oldFile, ProjectFileItem* newFile); }; } Q_DECLARE_OPERATORS_FOR_FLAGS( KDevelop::IProjectFileManager::Features ) Q_DECLARE_INTERFACE( KDevelop::IProjectFileManager, "org.kdevelop.IProjectFileManager") #endif diff --git a/shell/kross/xmltokross/dummybsm.h b/shell/kross/xmltokross/dummybsm.h index a4812cb452..1d0325ad4d 100644 --- a/shell/kross/xmltokross/dummybsm.h +++ b/shell/kross/xmltokross/dummybsm.h @@ -1,76 +1,76 @@ /*************************************************************************** * Copyright 2008 Aleix Pol * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU Library General Public License as * * published by the Free Software Foundation; either version 2 of the * * License, or (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU Library General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #ifndef DUMMYBSM_H #define DUMMYBSM_H #include #include #include #include class DummyBSM : public KDevelop::IPlugin, public KDevelop::IBuildSystemManager { Q_OBJECT Q_INTERFACES( KDevelop::IBuildSystemManager ) Q_INTERFACES( KDevelop::IProjectFileManager ) public: explicit DummyBSM(QObject *parent=0, const QVariantList& args=QVariantList(), const KUrl::List& cf=KUrl::List()); QList parse( KDevelop::ProjectFolderItem* dom ) { Q_UNUSED( dom ); return QList(); } KDevelop::ProjectFolderItem* import(KDevelop::IProject *project ); KDevelop::IProjectBuilder* builder(KDevelop::ProjectFolderItem*) const { return 0; } KUrl buildDirectory(KDevelop::ProjectBaseItem*) const { return m_buildDir; } KUrl::List includeDirectories(KDevelop::ProjectBaseItem *) const { qDebug("jojooooooooooojo"); return m_includeDirectories; } QHash defines(KDevelop::ProjectBaseItem *) const { return m_defines; } QList targets() const; QList targets(KDevelop::ProjectFolderItem*) const; KDevelop::ProjectFolderItem* addFolder( const KUrl& /*folder */, KDevelop::ProjectFolderItem* /*parent*/ ) { return 0; } KDevelop::ProjectTargetItem* createTarget( const QString&, KDevelop::ProjectFolderItem* ) { return 0; } KDevelop::ProjectFileItem* addFile( const KUrl&, KDevelop::ProjectFolderItem* ) { return 0; } - bool addFilesToTarget( QList, KDevelop::ProjectTargetItem* ) { return false; } + bool addFilesToTarget( QList&, KDevelop::ProjectTargetItem* ) { return false; } bool removeTarget( KDevelop::ProjectTargetItem* ) { return false; } - bool removeFilesAndFolders(QList< KDevelop::ProjectBaseItem* > ) { return false; } - bool removeFilesFromTargets( QList ) { return false; } + bool removeFilesAndFolders(QList< KDevelop::ProjectBaseItem* >& ) { return false; } + bool removeFilesFromTargets( QList& ) { return false; } bool renameFile(KDevelop::ProjectFileItem*, const KUrl&) { return false; } bool renameFolder(KDevelop::ProjectFolderItem*, const KUrl&) { return false; } - bool moveFilesAndFolders( QList< KDevelop::ProjectBaseItem* >, KDevelop::ProjectFolderItem* ) { return false; }; + bool moveFilesAndFolders( QList< KDevelop::ProjectBaseItem* >&, KDevelop::ProjectFolderItem* ) { return false; }; QHash environment(KDevelop::ProjectBaseItem *) const { return QHash(); } Features features() const { return Targets | Files | Folders; } void setBuildDir(const KUrl& buildDir) { m_buildDir=buildDir; } void setIncludeDirectories(const KUrl::List& id) { m_includeDirectories=id; } void setDefinesDirectories(const QHash& defs) { m_defines=defs; } bool reload(KDevelop::ProjectFolderItem*) { return true; } private: KUrl::List m_controlledFiles; KUrl m_buildDir; KUrl::List m_includeDirectories; QHash m_defines; KDevelop::ProjectTargetItem* m_target; KDevelop::ProjectFolderItem* m_folder; }; #endif