Commit c211ecc6 authored by Friedrich W. H. Kossebau's avatar Friedrich W. H. Kossebau
Browse files

kdevplatform/interfaces: use Q_DECLARE_PRIVATE/Q_D to forward constness to d

parent c49fa83c
......@@ -38,7 +38,7 @@ public:
ConfigPage::ConfigPage(IPlugin* plugin, KCoreConfigSkeleton* config, QWidget* parent)
: KTextEditor::ConfigPage(parent)
, d(new ConfigPagePrivate(plugin))
, d_ptr(new ConfigPagePrivate(plugin))
{
setConfigSkeleton(config);
}
......@@ -49,6 +49,8 @@ ConfigPage::~ConfigPage()
void ConfigPage::apply()
{
Q_D(ConfigPage);
// if d->configManager is null, this method must be overridden
Q_ASSERT_X(d->configManager, metaObject()->className(),
"Config page does not use a KConfigSkeleton, but doesn't override apply()");
......@@ -61,6 +63,8 @@ void ConfigPage::apply()
void ConfigPage::defaults()
{
Q_D(ConfigPage);
// if d->configManager is null, this method must be overridden
Q_ASSERT_X(d->configManager, metaObject()->className(),
"Config page does not use a KConfigSkeleton, but doesn't override defaults()");
......@@ -69,6 +73,8 @@ void ConfigPage::defaults()
void ConfigPage::reset()
{
Q_D(ConfigPage);
// if d->configManager is null, this method must be overridden
Q_ASSERT_X(d->configManager, metaObject()->className(),
"Config page does not use a KConfigSkeleton, but doesn't override reset()");
......@@ -77,6 +83,8 @@ void ConfigPage::reset()
void ConfigPage::initConfigManager()
{
Q_D(ConfigPage);
if (d->configManager) {
d->configManager->addWidget(this);
}
......@@ -84,11 +92,15 @@ void ConfigPage::initConfigManager()
KCoreConfigSkeleton* ConfigPage::configSkeleton() const
{
Q_D(const ConfigPage);
return d->configSkeleton;
}
void ConfigPage::setConfigSkeleton(KCoreConfigSkeleton* skel)
{
Q_D(ConfigPage);
if (d->configSkeleton == skel) {
return;
}
......@@ -120,6 +132,8 @@ ConfigPage* ConfigPage::childPage(int number)
IPlugin* ConfigPage::plugin() const
{
Q_D(const ConfigPage);
return d->plugin;
}
......
......@@ -30,6 +30,7 @@ class KCoreConfigSkeleton;
namespace KDevelop {
class IPlugin;
class ConfigPagePrivate;
class KDEVPLATFORMINTERFACES_EXPORT ConfigPage : public KTextEditor::ConfigPage
{
......@@ -104,7 +105,8 @@ public Q_SLOTS:
void reset() override;
private:
const QScopedPointer<class ConfigPagePrivate> d;
const QScopedPointer<class ConfigPagePrivate> d_ptr;
Q_DECLARE_PRIVATE(ConfigPage)
};
}
......
......@@ -40,7 +40,11 @@ class ContextPrivate
};
Context::Context()
: d(nullptr)
: d_ptr(nullptr)
{}
Context::Context(ContextPrivate* d)
: d_ptr(d)
{}
Context::~Context() = default;
......@@ -50,7 +54,7 @@ bool Context::hasType( int aType ) const
return aType == this->type();
}
class FileContextPrivate
class FileContextPrivate : public ContextPrivate
{
public:
explicit FileContextPrivate( const QList<QUrl> &urls )
......@@ -61,7 +65,7 @@ public:
};
FileContext::FileContext( const QList<QUrl> &urls )
: Context(), d( new FileContextPrivate( urls ) )
: Context(new FileContextPrivate(urls))
{}
FileContext::~FileContext() = default;
......@@ -73,10 +77,12 @@ int FileContext::type() const
QList<QUrl> FileContext::urls() const
{
Q_D(const FileContext);
return d->m_urls;
}
class ProjectItemContextPrivate
class ProjectItemContextPrivate : public ContextPrivate
{
public:
explicit ProjectItemContextPrivate( const QList<ProjectBaseItem*> &items )
......@@ -87,7 +93,7 @@ public:
};
ProjectItemContext::ProjectItemContext( const QList<ProjectBaseItem*> &items )
: Context(), d( new ProjectItemContextPrivate( items ) )
: Context(new ProjectItemContextPrivate(items))
{}
ProjectItemContext::~ProjectItemContext() = default;
......@@ -99,10 +105,12 @@ int ProjectItemContext::type() const
QList<ProjectBaseItem*> ProjectItemContext::items() const
{
Q_D(const ProjectItemContext);
return d->m_items;
}
class OpenWithContextPrivate
class OpenWithContextPrivate : public ContextPrivate
{
public:
OpenWithContextPrivate(const QList<QUrl>& urls, const QMimeType& mimeType)
......@@ -115,8 +123,7 @@ public:
};
OpenWithContext::OpenWithContext(const QList<QUrl>& urls, const QMimeType& mimeType)
: Context()
, d(new OpenWithContextPrivate(urls, mimeType))
: Context(new OpenWithContextPrivate(urls, mimeType))
{
}
......@@ -129,11 +136,15 @@ int OpenWithContext::type() const
QList<QUrl> OpenWithContext::urls() const
{
Q_D(const OpenWithContext);
return d->m_urls;
}
QMimeType OpenWithContext::mimeType() const
{
Q_D(const OpenWithContext);
return d->m_mimeType;
}
......
......@@ -42,6 +42,10 @@ template <typename T> class QList;
namespace KDevelop
{
class ProjectBaseItem;
class ContextPrivate;
class FileContextPrivate;
class ProjectItemContextPrivate;
class OpenWithContextPrivate;
/**
Base class for every context.
......@@ -119,10 +123,15 @@ public:
protected:
/**Constructor.*/
Context();
explicit Context(ContextPrivate* d);
private:
const QScopedPointer<class ContextPrivate> d;
const QScopedPointer<class ContextPrivate> d_ptr;
Q_DECLARE_PRIVATE(Context)
Q_DISABLE_COPY(Context)
friend class FileContext;
friend class ProjectItemContext;
friend class OpenWithContext;
};
/**
......@@ -144,7 +153,7 @@ public:
QList<QUrl> urls() const override;
private:
const QScopedPointer<class FileContextPrivate> d;
Q_DECLARE_PRIVATE(FileContext)
Q_DISABLE_COPY(FileContext)
};
......@@ -169,7 +178,7 @@ public:
QList<ProjectBaseItem*> items() const;
private:
const QScopedPointer<class ProjectItemContextPrivate> d;
Q_DECLARE_PRIVATE(ProjectItemContext)
Q_DISABLE_COPY(ProjectItemContext)
};
......@@ -203,7 +212,7 @@ public:
QMimeType mimeType() const;
private:
const QScopedPointer<class OpenWithContextPrivate> d;
Q_DECLARE_PRIVATE(OpenWithContext)
Q_DISABLE_COPY(OpenWithContext)
};
......
......@@ -52,7 +52,7 @@ public:
};
ContextMenuExtension::ContextMenuExtension()
: d(new ContextMenuExtensionPrivate)
: d_ptr(new ContextMenuExtensionPrivate)
{
}
......@@ -60,27 +60,35 @@ ContextMenuExtension::~ContextMenuExtension() = default;
ContextMenuExtension::ContextMenuExtension( const ContextMenuExtension& rhs )
: d( new ContextMenuExtensionPrivate )
: d_ptr(new ContextMenuExtensionPrivate)
{
d->extensions = rhs.d->extensions;
Q_D(ContextMenuExtension);
d->extensions = rhs.d_func()->extensions;
}
ContextMenuExtension& ContextMenuExtension::operator=( const ContextMenuExtension& rhs )
{
Q_D(ContextMenuExtension);
if( this == &rhs )
return *this;
d->extensions = rhs.d->extensions;
d->extensions = rhs.d_func()->extensions;
return *this;
}
QList<QAction*> ContextMenuExtension::actions( const QString& group ) const
{
Q_D(const ContextMenuExtension);
return d->extensions.value( group, QList<QAction*>() );
}
void ContextMenuExtension::addAction( const QString& group, QAction* action )
{
Q_D(ContextMenuExtension);
auto actionGroupIt = d->extensions.find(group);
if (actionGroupIt == d->extensions.end()) {
d->extensions.insert( group, QList<QAction*>() << action );
......
......@@ -32,6 +32,8 @@ class QMenu;
namespace KDevelop
{
class ContextMenuExtensionPrivate;
/**
* For documentation on how to use this class, @see interfaces/context.h
*/
......@@ -102,7 +104,8 @@ public:
static void populateMenu(QMenu* menu, const QList<ContextMenuExtension>& extensions);
private:
const QScopedPointer<class ContextMenuExtensionPrivate> d;
const QScopedPointer<class ContextMenuExtensionPrivate> d_ptr;
Q_DECLARE_PRIVATE(ContextMenuExtension)
};
}
......
......@@ -37,7 +37,7 @@ public:
/* Internal access to the wrapper script object */
static inline QObject *&getWrapper(IDocument *doc)
{
return doc->d->scriptWrapper;
return doc->d_func()->scriptWrapper;
}
};
......@@ -50,17 +50,21 @@ QObject *&getWrapper(IDocument *doc)
}
IDocument::IDocument( KDevelop::ICore* core )
: d(new IDocumentPrivate(core))
: d_ptr(new IDocumentPrivate(core))
{
}
IDocument::~IDocument()
{
Q_D(IDocument);
delete d->scriptWrapper;
}
KDevelop::ICore* IDocument::core()
{
Q_D(IDocument);
return d->m_core;
}
......@@ -111,11 +115,15 @@ QString IDocument::textWord() const
QString IDocument::prettyName() const
{
Q_D(const IDocument);
return d->m_prettyName;
}
void IDocument::setPrettyName(const QString& name)
{
Q_D(IDocument);
d->m_prettyName = name;
}
......
......@@ -40,6 +40,7 @@ class QWidget;
namespace KDevelop {
class ICore;
class IDocumentPrivate;
/**
* A single document being edited by the IDE.
......@@ -210,7 +211,8 @@ protected:
void notifyLoaded();
private:
const QScopedPointer<class IDocumentPrivate> d;
const QScopedPointer<class IDocumentPrivate> d_ptr;
Q_DECLARE_PRIVATE(IDocument)
friend class IDocumentPrivate;
};
......
......@@ -83,8 +83,10 @@ public:
IPlugin::IPlugin( const QString &componentName, QObject *parent )
: QObject(parent)
, KXMLGUIClient()
, d(new IPluginPrivate(this))
, d_ptr(new IPluginPrivate(this))
{
Q_D(IPlugin);
// The following cast is safe, there's no component in KDevPlatform that
// creates plugins except the plugincontroller. The controller passes
// Core::self() as parent to KServiceTypeTrader::createInstanceFromQuery
......@@ -97,7 +99,8 @@ IPlugin::IPlugin( const QString &componentName, QObject *parent )
auto metaData = core()->pluginController()->infoForPluginId(componentName);
setComponentName(componentName, metaData.name());
auto clientAdded = [=] (KXMLGUIClient* client) {
auto clientAdded = [this] (KXMLGUIClient* client) {
Q_D(IPlugin);
d->guiClientAdded(client);
};
const auto mainWindows = KMainWindow::memberList();
......@@ -110,7 +113,10 @@ IPlugin::IPlugin( const QString &componentName, QObject *parent )
this, clientAdded);
}
auto updateState = [=] { d->updateState(); };
auto updateState = [this] {
Q_D(IPlugin);
d->updateState();
};
connect(ICore::self()->projectController(), &IProjectController::projectOpened,
this, updateState);
connect(ICore::self()->projectController(), &IProjectController::projectClosed,
......@@ -125,6 +131,8 @@ void IPlugin::unload()
ICore *IPlugin::core() const
{
Q_D(const IPlugin);
return d->core;
}
......@@ -172,17 +180,23 @@ void KDevelop::IPlugin::createActionsForMainWindow( Sublime::MainWindow* /*windo
bool KDevelop::IPlugin::hasError() const
{
Q_D(const IPlugin);
return !d->m_errorDescription.isEmpty();
}
void KDevelop::IPlugin::setErrorDescription(const QString& description)
{
Q_D(IPlugin);
d->m_errorDescription = description;
}
QString KDevelop::IPlugin::errorDescription() const
{
Q_D(const IPlugin);
return d->m_errorDescription;
}
......
......@@ -48,6 +48,7 @@ class ConfigPage;
class Context;
class ContextMenuExtension;
struct ProjectConfigOptions;
class IPluginPrivate;
/**
* The base class for all KDevelop plugins.
......@@ -269,7 +270,8 @@ protected:
virtual void initializeGuiState();
private:
const QScopedPointer<class IPluginPrivate> d;
const QScopedPointer<class IPluginPrivate> d_ptr;
Q_DECLARE_PRIVATE(IPlugin)
friend class IPluginPrivate;
};
......
......@@ -31,18 +31,22 @@ public:
};
LaunchConfigurationType::LaunchConfigurationType()
: d( new LaunchConfigurationTypePrivate )
: d_ptr(new LaunchConfigurationTypePrivate)
{
}
LaunchConfigurationType::~LaunchConfigurationType()
{
Q_D(LaunchConfigurationType);
qDeleteAll(d->starters);
}
void LaunchConfigurationType::addLauncher( ILauncher* starter )
{
Q_D(LaunchConfigurationType);
if( !d->starters.contains( starter ) )
{
d->starters.append( starter );
......@@ -50,16 +54,22 @@ void LaunchConfigurationType::addLauncher( ILauncher* starter )
}
void LaunchConfigurationType::removeLauncher( ILauncher* starter )
{
Q_D(LaunchConfigurationType);
d->starters.removeAll( starter );
}
QList<ILauncher*> LaunchConfigurationType::launchers() const
{
Q_D(const LaunchConfigurationType);
return d->starters;
}
ILauncher* LaunchConfigurationType::launcherForId(const QString& id) const
{
Q_D(const LaunchConfigurationType);
for (ILauncher* l : qAsConst(d->starters)) {
if( l->id() == id ) {
return l;
......
......@@ -37,6 +37,7 @@ class ILaunchConfiguration;
class ProjectBaseItem;
class ILauncher;
class LaunchConfigurationPageFactory;
class LaunchConfigurationTypePrivate;
/**
* Launch configuration types are used to be able to create
......@@ -145,7 +146,8 @@ Q_SIGNALS:
void signalAddLaunchConfiguration(KDevelop::ILaunchConfiguration* launch);
private:
const QScopedPointer<class LaunchConfigurationTypePrivate> d;
const QScopedPointer<class LaunchConfigurationTypePrivate> d_ptr;
Q_DECLARE_PRIVATE(LaunchConfigurationType)
};
}
......
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