Commit 18ab4539 authored by hjk's avatar hjk Committed by Tobias Hunger

ProjectExplorer: Hide IProjectPanelFactory implementation details

Change-Id: I3b08a4e2c7fdafd3e05e19b8561ee0d32258b520
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent e83847d7
......@@ -58,12 +58,6 @@ void IProjectPanelFactory::setDisplayName(const QString &name)
m_displayName = name;
}
bool IProjectPanelFactory::prioritySort(IProjectPanelFactory *a, IProjectPanelFactory *b)
{
return (a->priority() == b->priority() && a < b)
|| a->priority() < b->priority();
}
bool IProjectPanelFactory::supportsAllProjects(Project *)
{
return true;
......@@ -71,7 +65,11 @@ bool IProjectPanelFactory::supportsAllProjects(Project *)
void IProjectPanelFactory::registerFactory(IProjectPanelFactory *factory)
{
auto it = std::lower_bound(s_factories.begin(), s_factories.end(), factory, &IProjectPanelFactory::prioritySort);
auto it = std::lower_bound(s_factories.begin(), s_factories.end(), factory,
[](IProjectPanelFactory *a, IProjectPanelFactory *b) {
return (a->priority() == b->priority() && a < b) || a->priority() < b->priority();
});
s_factories.insert(it, factory);
}
......@@ -80,6 +78,12 @@ QList<IProjectPanelFactory *> IProjectPanelFactory::factories()
return s_factories;
}
void IProjectPanelFactory::destroyFactories()
{
qDeleteAll(s_factories);
s_factories.clear();
}
bool IProjectPanelFactory::supports(Project *project)
{
return m_supportsFunction(project);
......
......@@ -41,21 +41,20 @@
namespace ProjectExplorer {
class Project;
class ProjectExplorerPlugin;
class Target;
class PROJECTEXPLORER_EXPORT IProjectPanelFactory
{
public:
IProjectPanelFactory();
// simple properties
QString displayName() const;
void setDisplayName(const QString &name);
int priority() const;
void setPriority(int priority);
// helper to sort by priority
static bool prioritySort(IProjectPanelFactory *a, IProjectPanelFactory *b);
// interface for users of IProjectPanelFactory
bool supports(Project *project);
QWidget *createWidget(ProjectExplorer::Project *project);
......@@ -96,6 +95,9 @@ public:
static QList<IProjectPanelFactory *> factories();
private:
friend class ProjectExplorerPlugin;
static void destroyFactories();
int m_priority;
QString m_displayName;
std::function<bool (Project *)> m_supportsFunction;
......
......@@ -321,7 +321,7 @@ ProjectExplorerPlugin::~ProjectExplorerPlugin()
// Force sequence of deletion:
delete d->m_kitManager; // remove all the profile informations
delete d->m_toolChainManager;
qDeleteAll(IProjectPanelFactory::s_factories);
IProjectPanelFactory::destroyFactories();
delete d;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment