File indexing completed on 2024-05-12 04:38:11

0001 /*
0002     SPDX-FileCopyrightText: 2013 Milian Wolff <mail@milianw.de>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #ifndef KDEVPLATFORM_IPROJECTFILTERPROVIDER_H
0008 #define KDEVPLATFORM_IPROJECTFILTERPROVIDER_H
0009 
0010 #include <project/projectexport.h>
0011 
0012 #include <QObject>
0013 #include <QSharedPointer>
0014 
0015 namespace KDevelop
0016 {
0017 
0018 class IProject;
0019 class IProjectFilter;
0020 
0021 /**
0022  * @short An interface to create project filters.
0023  *
0024  * Plugins implement this interface and return an instance of a custom
0025  * IProjectFilter implementation, which is then doing the actual filtering.
0026  *
0027  * The filter should then allow filtering of files and folders in a
0028  * threadsafe way.
0029  *
0030  * Project managers are supposed to listen to the filterChanged signal
0031  * and update the project filter accordingly, i.e. by creating a new
0032  * filter instance.
0033  *
0034  * This interface was designed such that project filtering can be done in a
0035  * multithreaded project manager without the need for any locks.
0036  *
0037  * @author Milian Wolff
0038  */
0039 class KDEVPLATFORMPROJECT_EXPORT IProjectFilterProvider
0040 {
0041 public:
0042     virtual ~IProjectFilterProvider();
0043 
0044     /**
0045      * Factory function to create threadsafe project filter instances.
0046      *
0047      * @param project The project that the filter should operate on.
0048      *
0049      * @return A threadsafe implementation of the IProjectFilter instance.
0050      */
0051     virtual QSharedPointer<IProjectFilter> createFilter(IProject* project) const = 0;
0052 
0053 Q_SIGNALS:
0054     /**
0055      * Should be emitted whenever the filter rules for the given @p project changed.
0056      *
0057      * Listeners should act on this signal by replacing their current filter
0058      * with a new instance.
0059      */
0060     void filterChanged(KDevelop::IProjectFilterProvider*, KDevelop::IProject* project);
0061 };
0062 
0063 }
0064 
0065 Q_DECLARE_INTERFACE( KDevelop::IProjectFilterProvider, "org.kdevelop.IProjectFilterProvider")
0066 
0067 #endif // KDEVPLATFORM_IPROJECTFILTERPROVIDER_H