Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

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

parent 430e7d33
......@@ -37,7 +37,7 @@ public:
CheckerStatus::CheckerStatus() :
d(new CheckerStatusPrivate())
d_ptr(new CheckerStatusPrivate())
{
}
......@@ -45,21 +45,29 @@ CheckerStatus::~CheckerStatus() = default;
QString CheckerStatus::statusName() const
{
Q_D(const CheckerStatus);
return i18nc("@info:progress", "Running %1", d->m_name);
}
void CheckerStatus::setCheckerName(const QString &name)
{
Q_D(CheckerStatus);
d->m_name = name;
}
void CheckerStatus::setMaxItems(int maxItems)
{
Q_D(CheckerStatus);
d->m_maxItems = maxItems;
}
void CheckerStatus::itemChecked()
{
Q_D(CheckerStatus);
if (d->m_checkedItems >= d->m_maxItems)
return;
......@@ -69,12 +77,16 @@ void CheckerStatus::itemChecked()
void CheckerStatus::start()
{
Q_D(CheckerStatus);
d->m_checkedItems = 0;
emit showProgress(this, 0, d->m_maxItems, d->m_checkedItems);
}
void CheckerStatus::stop()
{
Q_D(CheckerStatus);
emit clearMessage(this);
emit showProgress(this, 0, d->m_maxItems, d->m_maxItems);
emit hideProgress(this);
......
......@@ -27,6 +27,8 @@
namespace KDevelop
{
class CheckerStatusPrivate;
/**
* Status / Progress reporter for checker tools. It shows a progress bar as more and more items are checked.
* As part of initialization the max. number of items have to be set, and then when an item is checked that has to be indicated to the class. When stopped the progressbar first filled up to max, then it disappears.
......@@ -87,7 +89,8 @@ Q_SIGNALS:
void showProgress(KDevelop::IStatus*, int minimum, int maximum, int value) override;
private:
const QScopedPointer<class CheckerStatusPrivate> d;
const QScopedPointer<class CheckerStatusPrivate> d_ptr;
Q_DECLARE_PRIVATE(CheckerStatus)
};
}
......
......@@ -553,13 +553,16 @@ Q_DECLARE_TYPEINFO(KDevelop::DocumentControllerPrivate::HistoryEntry, Q_MOVABLE_
DocumentController::DocumentController( QObject *parent )
: IDocumentController( parent )
, d(new DocumentControllerPrivate(this))
, d_ptr(new DocumentControllerPrivate(this))
{
Q_D(DocumentController);
setObjectName(QStringLiteral("DocumentController"));
QDBusConnection::sessionBus().registerObject( QStringLiteral("/org/kdevelop/DocumentController"),
this, QDBusConnection::ExportScriptableSlots );
connect(this, &DocumentController::documentUrlChanged, this, [&] (IDocument* document) { d->changeDocumentUrl(document); });
connect(this, &DocumentController::documentUrlChanged,
this, [this] (IDocument* document) { Q_D(DocumentController); d->changeDocumentUrl(document); });
if(!(Core::self()->setupFlags() & Core::NoUi)) setupActions();
}
......@@ -570,6 +573,8 @@ void DocumentController::initialize()
void DocumentController::cleanup()
{
Q_D(DocumentController);
if (d->fileOpenRecent)
d->fileOpenRecent->saveEntries( KConfigGroup(KSharedConfig::openConfig(), "Recent Files" ) );
......@@ -585,6 +590,8 @@ DocumentController::~DocumentController() = default;
void DocumentController::setupActions()
{
Q_D(DocumentController);
KActionCollection* ac = Core::self()->uiControllerInternal()->defaultMainWindow()->actionCollection();
QAction* action;
......@@ -593,7 +600,8 @@ void DocumentController::setupActions()
action->setIcon(QIcon::fromTheme(QStringLiteral("document-open")));
ac->setDefaultShortcut(action, Qt::CTRL + Qt::Key_O );
action->setText(i18n( "&Open..." ) );
connect( action, &QAction::triggered, this, [&] { d->chooseDocument(); } );
connect(action, &QAction::triggered,
this, [this] { Q_D(DocumentController); d->chooseDocument(); } );
action->setToolTip( i18n( "Open file" ) );
action->setWhatsThis( i18n( "Opens a file for editing." ) );
......@@ -677,6 +685,8 @@ bool DocumentController::openDocumentSimple( QString url, int line, int column )
IDocument* DocumentController::openDocument( const QUrl& inputUrl, const QString& prefName )
{
Q_D(DocumentController);
return d->openDocumentInternal( inputUrl, prefName );
}
......@@ -685,6 +695,8 @@ IDocument* DocumentController::openDocument( const QUrl & inputUrl,
DocumentActivationParams activationParams,
const QString& encoding, IDocument* buddy)
{
Q_D(DocumentController);
return d->openDocumentInternal(inputUrl, QString(), range, encoding, activationParams, buddy);
}
......@@ -694,6 +706,8 @@ bool DocumentController::openDocument(IDocument* doc,
DocumentActivationParams activationParams,
IDocument* buddy)
{
Q_D(DocumentController);
return d->openDocumentInternal( doc, range, activationParams, buddy);
}
......@@ -712,6 +726,8 @@ void DocumentController::fileClose()
bool DocumentController::closeDocument( const QUrl &url )
{
Q_D(DocumentController);
const auto documentIt = d->documents.constFind(url);
if (documentIt == d->documents.constEnd())
return false;
......@@ -725,6 +741,8 @@ bool DocumentController::closeDocument( const QUrl &url )
void DocumentController::notifyDocumentClosed(Sublime::Document* doc_)
{
Q_D(DocumentController);
auto* doc = dynamic_cast<IDocument*>(doc_);
Q_ASSERT(doc);
......@@ -748,6 +766,8 @@ void DocumentController::notifyDocumentClosed(Sublime::Document* doc_)
IDocument * DocumentController::documentForUrl( const QUrl & dirtyUrl ) const
{
Q_D(const DocumentController);
if (dirtyUrl.isEmpty()) {
return nullptr;
}
......@@ -759,6 +779,8 @@ IDocument * DocumentController::documentForUrl( const QUrl & dirtyUrl ) const
QList<IDocument*> DocumentController::openDocuments() const
{
Q_D(const DocumentController);
QList<IDocument*> opened;
for (IDocument* doc : qAsConst(d->documents)) {
auto *sdoc = dynamic_cast<Sublime::Document*>(doc);
......@@ -1008,6 +1030,8 @@ QStringList DocumentController::activeDocumentPaths() const
void DocumentController::registerDocumentForMimetype( const QString& mimetype,
KDevelop::IDocumentFactory* factory )
{
Q_D(DocumentController);
if( !d->factories.contains( mimetype ) )
d->factories[mimetype] = factory;
}
......@@ -1055,11 +1079,15 @@ QUrl DocumentController::nextEmptyDocumentUrl()
IDocumentFactory* DocumentController::factory(const QString& mime) const
{
Q_D(const DocumentController);
return d->factories.value(mime);
}
KTextEditor::Document* DocumentController::globalTextEditorInstance()
{
Q_D(DocumentController);
if(!d->globalTextEditorInstance)
d->globalTextEditorInstance = Core::self()->partControllerInternal()->createTextPart();
return d->globalTextEditorInstance;
......
......@@ -45,6 +45,7 @@ namespace Sublime {
namespace KDevelop {
class MainWindow;
class DocumentControllerPrivate;
/**
* \short Interface to control open documents.
......@@ -171,7 +172,9 @@ private:
void setupActions();
private:
const QScopedPointer<class DocumentControllerPrivate> d;
const QScopedPointer<class DocumentControllerPrivate> d_ptr;
Q_DECLARE_PRIVATE(DocumentController)
friend class DocumentControllerPrivate;
};
......
......@@ -80,21 +80,25 @@ public:
EnvironmentConfigureButton::EnvironmentConfigureButton(QWidget* parent)
: QPushButton(parent),
d(new EnvironmentConfigureButtonPrivate(this))
d_ptr(new EnvironmentConfigureButtonPrivate(this))
{
Q_D(EnvironmentConfigureButton);
setText(QString());
setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
setIcon(QIcon::fromTheme(QStringLiteral("configure")));
setToolTip(i18n("Configure environment variables"));
connect(this, &EnvironmentConfigureButton::clicked,
this, [&] { d->showDialog(); });
this, [this] { Q_D(EnvironmentConfigureButton); d->showDialog(); });
}
EnvironmentConfigureButton::~EnvironmentConfigureButton() = default;
void EnvironmentConfigureButton::setSelectionWidget(EnvironmentSelectionWidget* widget)
{
Q_D(EnvironmentConfigureButton);
connect(this, &EnvironmentConfigureButton::environmentConfigured,
widget, &EnvironmentSelectionWidget::reconfigure);
d->selectionWidget = widget;
......
......@@ -28,6 +28,7 @@ namespace KDevelop
{
class EnvironmentSelectionWidget;
class EnvironmentConfigureButtonPrivate;
/**
* A tool button that shows a dialog to configure the environment settings.
......@@ -52,7 +53,9 @@ Q_SIGNALS:
void environmentConfigured();
private:
const QScopedPointer<class EnvironmentConfigureButtonPrivate> d;
const QScopedPointer<class EnvironmentConfigureButtonPrivate> d_ptr;
Q_DECLARE_PRIVATE(EnvironmentConfigureButton)
friend class EnvironmentConfigureButtonPrivate;
};
......
......@@ -221,7 +221,7 @@ public:
FilteredProblemStore::FilteredProblemStore(QObject *parent)
: ProblemStore(parent)
, d(new FilteredProblemStorePrivate(this))
, d_ptr(new FilteredProblemStorePrivate(this))
{
}
......@@ -231,6 +231,8 @@ FilteredProblemStore::~FilteredProblemStore()
void FilteredProblemStore::addProblem(const IProblem::Ptr &problem)
{
Q_D(FilteredProblemStore);
ProblemStore::addProblem(problem);
if (d->match(problem))
......@@ -239,22 +241,30 @@ void FilteredProblemStore::addProblem(const IProblem::Ptr &problem)
const ProblemStoreNode* FilteredProblemStore::findNode(int row, ProblemStoreNode *parent) const
{
Q_D(const FilteredProblemStore);
return d->m_strategy->findNode(row, parent);
}
int FilteredProblemStore::count(ProblemStoreNode *parent) const
{
Q_D(const FilteredProblemStore);
return d->m_strategy->count(parent);
}
void FilteredProblemStore::clear()
{
Q_D(FilteredProblemStore);
d->m_strategy->clear();
ProblemStore::clear();
}
void FilteredProblemStore::rebuild()
{
Q_D(FilteredProblemStore);
emit beginRebuild();
d->m_strategy->clear();
......@@ -272,6 +282,8 @@ void FilteredProblemStore::rebuild()
void FilteredProblemStore::setGrouping(int grouping)
{
Q_D(FilteredProblemStore);
auto g = GroupingMethod(grouping);
if(g == d->m_grouping)
return;
......@@ -290,6 +302,8 @@ void FilteredProblemStore::setGrouping(int grouping)
int FilteredProblemStore::grouping() const
{
Q_D(const FilteredProblemStore);
return d->m_grouping;
}
......
......@@ -27,6 +27,8 @@
namespace KDevelop
{
class FilteredProblemStorePrivate;
/**
* @brief ProblemStore subclass that can group by severity, and path, and filter by scope, and severity.
*
......@@ -102,7 +104,8 @@ public:
private:
friend class FilteredProblemStorePrivate;
const QScopedPointer<class FilteredProblemStorePrivate> d;
const QScopedPointer<class FilteredProblemStorePrivate> d_ptr;
Q_DECLARE_PRIVATE(FilteredProblemStore)
};
}
......
......@@ -133,7 +133,7 @@ void LanguageControllerPrivate::addLanguageSupport(KDevelop::ILanguageSupport* l
LanguageController::LanguageController(QObject *parent)
: ILanguageController(parent)
, d(new LanguageControllerPrivate(this))
, d_ptr(new LanguageControllerPrivate(this))
{
setObjectName(QStringLiteral("LanguageController"));
}
......@@ -142,6 +142,8 @@ LanguageController::~LanguageController() = default;
void LanguageController::initialize()
{
Q_D(LanguageController);
d->backgroundParser->loadSettings();
d->staticAssistantsManager = new StaticAssistantsManager(this);
......@@ -149,17 +151,21 @@ void LanguageController::initialize()
DUChain::self();
connect(Core::self()->documentController(), &IDocumentController::documentActivated,
this, [&] (IDocument* document) { d->documentActivated(document); });
this, [this] (IDocument* document) { Q_D(LanguageController); d->documentActivated(document); });
}
void LanguageController::cleanup()
{
Q_D(LanguageController);
QMutexLocker lock(&d->dataMutex);
d->m_cleanedUp = true;
}
QList<ILanguageSupport*> LanguageController::activeLanguages()
{
Q_D(LanguageController);
QMutexLocker lock(&d->dataMutex);
return d->activeLanguages;
......@@ -167,6 +173,8 @@ QList<ILanguageSupport*> LanguageController::activeLanguages()
StaticAssistantsManager* LanguageController::staticAssistantsManager() const
{
Q_D(const LanguageController);
return d->staticAssistantsManager;
}
......@@ -177,11 +185,15 @@ ICompletionSettings *LanguageController::completionSettings() const
ProblemModelSet* LanguageController::problemModelSet() const
{
Q_D(const LanguageController);
return d->problemModelSet;
}
QList<ILanguageSupport*> LanguageController::loadedLanguages() const
{
Q_D(const LanguageController);
QMutexLocker lock(&d->dataMutex);
QList<ILanguageSupport*> ret;
......@@ -197,6 +209,8 @@ QList<ILanguageSupport*> LanguageController::loadedLanguages() const
ILanguageSupport* LanguageController::language(const QString &name) const
{
Q_D(const LanguageController);
QMutexLocker lock(&d->dataMutex);
if(d->m_cleanedUp)
......@@ -230,7 +244,7 @@ ILanguageSupport* LanguageController::language(const QString &name) const
if(!supports.isEmpty()) {
auto *languageSupport = supports[0]->extension<ILanguageSupport>();
if(languageSupport) {
d->addLanguageSupport(languageSupport);
const_cast<LanguageControllerPrivate*>(d)->addLanguageSupport(languageSupport);
return languageSupport;
}
}
......@@ -250,6 +264,8 @@ bool isNumeric(const QString& str)
QList<ILanguageSupport*> LanguageController::languagesForUrl(const QUrl &url)
{
Q_D(LanguageController);
QMutexLocker lock(&d->dataMutex);
QList<ILanguageSupport*> languages;
......@@ -318,6 +334,8 @@ QList<ILanguageSupport*> LanguageController::languagesForUrl(const QUrl &url)
QList<ILanguageSupport*> LanguageController::languagesForMimetype(const QString& mimetype)
{
Q_D(LanguageController);
QMutexLocker lock(&d->dataMutex);
QList<ILanguageSupport*> languages;
......@@ -348,6 +366,8 @@ QList<ILanguageSupport*> LanguageController::languagesForMimetype(const QString&
QList<QString> LanguageController::mimetypesForLanguageName(const QString& languageName)
{
Q_D(LanguageController);
QMutexLocker lock(&d->dataMutex);
QList<QString> mimetypes;
......@@ -364,11 +384,15 @@ QList<QString> LanguageController::mimetypesForLanguageName(const QString& langu
BackgroundParser *LanguageController::backgroundParser() const
{
Q_D(const LanguageController);
return d->backgroundParser;
}
void LanguageController::addLanguageSupport(ILanguageSupport* languageSupport, const QStringList& mimetypes)
{
Q_D(LanguageController);
d->addLanguageSupport(languageSupport, mimetypes);
}
......
......@@ -28,6 +28,7 @@
namespace KDevelop {
class ILanguageSupport;
class LanguageControllerPrivate;
class KDEVPLATFORMSHELL_EXPORT LanguageController : public ILanguageController {
Q_OBJECT
......@@ -68,7 +69,8 @@ protected:
void addLanguageSupport(KDevelop::ILanguageSupport* languageSupport, const QStringList& mimetypes);
private:
const QScopedPointer<class LanguageControllerPrivate> d;
const QScopedPointer<class LanguageControllerPrivate> d_ptr;
Q_DECLARE_PRIVATE(LanguageController)
};
}
......
......@@ -56,8 +56,10 @@ QString LaunchConfiguration::LaunchConfigurationTypeEntry()
LaunchConfiguration::LaunchConfiguration(const KConfigGroup& grp, IProject* project, QObject* parent )
: QObject(parent)
, ILaunchConfiguration()
, d(new LaunchConfigurationPrivate(grp, project))
, d_ptr(new LaunchConfigurationPrivate(grp, project))
{
Q_D(LaunchConfiguration);
d->type = Core::self()->runControllerInternal()->launchConfigurationTypeForId(grp.readEntry(LaunchConfigurationTypeEntry(), QString()));
}
......@@ -67,31 +69,43 @@ LaunchConfiguration::~LaunchConfiguration()
KConfigGroup LaunchConfiguration::config()
{
Q_D(LaunchConfiguration);
return d->baseGroup.group("Data");
}
const KConfigGroup LaunchConfiguration::config() const
{
Q_D(const LaunchConfiguration);
return d->baseGroup.group("Data");
}
QString LaunchConfiguration::name() const
{
Q_D(const LaunchConfiguration);
return d->baseGroup.readEntry(LaunchConfigurationNameEntry(), QString());
}
IProject* LaunchConfiguration::project() const
{
Q_D(const LaunchConfiguration);
return d->project;
}
LaunchConfigurationType* LaunchConfiguration::type() const
{
Q_D(const LaunchConfiguration);
return d->type;
}
void LaunchConfiguration::setName(const QString& name)
{
Q_D(LaunchConfiguration);
d->baseGroup.writeEntry(LaunchConfigurationNameEntry(), name);
d->baseGroup.sync();
emit nameChanged( this );
......@@ -99,6 +113,8 @@ void LaunchConfiguration::setName(const QString& name)
void LaunchConfiguration::setType(const QString& typeId)
{
Q_D(LaunchConfiguration);
LaunchConfigurationType* t = Core::self()->runControllerInternal()->launchConfigurationTypeForId( typeId );
// If this ever happens something seriously screwed in the launch config dialog, as that is
// the only place from where this method should be called
......@@ -115,16 +131,22 @@ void LaunchConfiguration::setType(const QString& typeId)
void LaunchConfiguration::save()
{
Q_D(LaunchConfiguration);
d->baseGroup.sync();
}
QString LaunchConfiguration::configGroupName() const
{
Q_D(const LaunchConfiguration);
return d->baseGroup.name();
}
QString LaunchConfiguration::launcherForMode(const QString& mode) const
{
Q_D(const LaunchConfiguration);
QStringList modes = d->baseGroup.readEntry("Configured Launch Modes", QStringList());
int idx = modes.indexOf( mode );
if( idx != -1 )
......@@ -166,6 +188,8 @@ QString LaunchConfiguration::launcherForMode(const QString& mode) const
void LaunchConfiguration::setLauncherForMode(const QString& mode, const QString& id)
{
Q_D(LaunchConfiguration);
QStringList modes = d->baseGroup.readEntry("Configured Launch Modes", QStringList());
int idx = modes.indexOf( mode );
if( idx == -1 )
......
......@@ -33,6 +33,7 @@ namespace KDevelop
class LaunchConfigurationType;
class IProject;
class LaunchConfigurationPrivate;
/**
* @copydoc KDevelop::ILaunchConfiguration
......@@ -93,7 +94,8 @@ Q_SIGNALS:
void typeChanged( LaunchConfigurationType* );
private:
const QScopedPointer<class LaunchConfigurationPrivate> d;
const QScopedPointer<class LaunchConfigurationPrivate> d_ptr;
Q_DECLARE_PRIVATE(LaunchConfiguration)
};
}
......
......@@ -87,6 +87,8 @@ QColor colorForDocument(const QUrl& url, const QPalette& palette, const QColor&
void MainWindow::applyMainWindowSettings(const KConfigGroup& config)
{
Q_D(MainWindow);
if(!d->changingActiveView())
KXmlGuiWindow::applyMainWindowSettings(config);
}
......@@ -137,7 +139,9 @@ MainWindow::MainWindow( Sublime::Controller *parent, Qt::WindowFlags flags )
initializeCorners();
setObjectName( QStringLiteral("MainWindow") );
d = new MainWindowPrivate(this);
d_ptr = new MainWindowPrivate(this);
Q_D(MainWindow);
setStandardToolBarMenuEnabled( true );
d->setupActions();
......@@ -157,16 +161,20 @@ MainWindow::~ MainWindow()
Core::self()->shutdown();
}
delete d;
delete d_ptr;
}
KTextEditorIntegration::MainWindow *MainWindow::kateWrapper() const
{
Q_D(const MainWindow);
return d->kateWrapper();
}
void MainWindow::split(Qt::Orientation orientation)
{
Q_D(MainWindow);
d->split(orientation);
}
......@@ -339,6 +347,8 @@ void MainWindow::shortcutsChanged()
void MainWindow::initialize()
{
Q_D(MainWindow);
KStandardAction::keyBindings(this, SLOT(configureShortcuts()), actionCollection());
setupGUI( KXmlGuiWindow::ToolBar | KXmlGuiWindow::Create | KXmlGuiWindow::Save );
......@@ -417,6 +427,8 @@ bool MainWindow::queryClose()
void MainWindow::documentActivated(const QPointer<KTextEditor::Document>& textDocument)
{
Q_D(MainWindow);
updateCaption();
// update active document connection
......@@ -511,37 +523,51 @@ void MainWindow::updateTabColor(IDocument* doc)
void MainWindow::registerStatus(QObject* status)
{