Commit 059ed5d1 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Use std::unique_ptr

parent 94a636f5
Pipeline #86959 passed with stage
in 31 minutes and 36 seconds
......@@ -116,7 +116,6 @@ AccountConfigOrderDialog::AccountConfigOrderDialog(MailCommon::MailCommonSetting
AccountConfigOrderDialog::~AccountConfigOrderDialog()
{
writeConfig();
delete d;
}
void AccountConfigOrderDialog::slotEnableAccountOrder(bool state)
......
......@@ -35,7 +35,7 @@ private:
void writeConfig();
void readConfig();
void init();
AccountConfigOrderDialogPrivate *const d;
std::unique_ptr<AccountConfigOrderDialogPrivate> const d;
};
}
......@@ -94,7 +94,6 @@ EntityCollectionOrderProxyModel::~EntityCollectionOrderProxyModel()
if (d->manualSortingActive) {
saveOrder();
}
delete d;
}
void EntityCollectionOrderProxyModel::slotSpecialCollectionsChanged()
......
......@@ -46,7 +46,7 @@ public Q_SLOTS:
private:
class EntityCollectionOrderProxyModelPrivate;
EntityCollectionOrderProxyModelPrivate *const d;
std::unique_ptr<EntityCollectionOrderProxyModelPrivate> const d;
};
}
......@@ -51,11 +51,7 @@ FolderCollectionMonitor::FolderCollectionMonitor(Akonadi::Session *session, QObj
d->mMonitor->itemFetchScope().fetchAttribute<Akonadi::EntityAnnotationsAttribute>(true);
}
FolderCollectionMonitor::~FolderCollectionMonitor()
{
qDebug() << "FolderCollectionMonitor::~FolderCollectionMonitor() " << this;
delete d;
}
FolderCollectionMonitor::~FolderCollectionMonitor() = default;
Akonadi::ChangeRecorder *FolderCollectionMonitor::monitor() const
{
......
......@@ -47,7 +47,7 @@ protected:
private:
void slotDeleteJob(KJob *job);
FolderCollectionMonitorPrivate *const d;
std::unique_ptr<FolderCollectionMonitorPrivate> const d;
};
}
......@@ -81,10 +81,7 @@ void FolderRequester::slotOpenDialog()
}
//-----------------------------------------------------------------------------
FolderRequester::~FolderRequester()
{
delete d;
}
FolderRequester::~FolderRequester() = default;
Akonadi::Collection FolderRequester::collection() const
{
......
......@@ -97,7 +97,7 @@ protected:
void setCollectionFullPath(const Akonadi::Collection &col);
protected:
FolderRequesterPrivate *const d;
std::unique_ptr<FolderRequesterPrivate> const d;
};
}
......@@ -118,7 +118,6 @@ FolderSelectionDialog::FolderSelectionDialog(QWidget *parent, SelectionFolderOpt
FolderSelectionDialog::~FolderSelectionDialog()
{
writeConfig();
delete d;
}
void FolderSelectionDialog::slotFolderTreeWidgetContextMenuRequested(const QPoint &pos)
......
......@@ -70,7 +70,7 @@ protected:
private:
class FolderSelectionDialogPrivate;
FolderSelectionDialogPrivate *const d;
std::unique_ptr<FolderSelectionDialogPrivate> const d;
};
}
......@@ -18,7 +18,7 @@ using namespace MailCommon;
/**
* @internal
*/
class Q_DECL_HIDDEN MDNStateAttribute::Private
class Q_DECL_HIDDEN MDNStateAttribute::MDNStateAttributePrivate
{
public:
MDNSentState dataToState(const QByteArray &data)
......@@ -100,21 +100,18 @@ public:
};
MDNStateAttribute::MDNStateAttribute(MDNSentState state)
: d(new Private)
: d(new MDNStateAttributePrivate)
{
d->mSentState = d->stateToData(state);
}
MDNStateAttribute::MDNStateAttribute(const QByteArray &stateData)
: d(new Private)
: d(new MDNStateAttributePrivate)
{
d->mSentState = stateData;
}
MDNStateAttribute::~MDNStateAttribute()
{
delete d;
}
MDNStateAttribute::~MDNStateAttribute() = default;
MDNStateAttribute *MDNStateAttribute::clone() const
{
......
......@@ -12,6 +12,7 @@
#include "mailcommon_export.h"
#include <Akonadi/Attribute>
#include <memory>
namespace MailCommon
{
......@@ -96,8 +97,8 @@ public:
private:
//@cond PRIVATE
class Private;
Private *const d;
class MDNStateAttributePrivate;
std::unique_ptr<MDNStateAttributePrivate> const d;
//@endcond
};
}
......
......@@ -26,10 +26,10 @@
using namespace MailCommon;
class Q_DECL_HIDDEN SnippetsManager::Private
class Q_DECL_HIDDEN SnippetsManager::SnippetsManagerPrivate
{
public:
Private(SnippetsManager *qq, QWidget *parentWidget)
SnippetsManagerPrivate(SnippetsManager *qq, QWidget *parentWidget)
: q(qq)
, mParent(parentWidget)
{
......@@ -92,7 +92,7 @@ public:
bool mDirty = false;
};
QModelIndex SnippetsManager::Private::currentGroupIndex() const
QModelIndex SnippetsManager::SnippetsManagerPrivate::currentGroupIndex() const
{
if (mSelectionModel->selectedIndexes().isEmpty()) {
return QModelIndex();
......@@ -106,7 +106,7 @@ QModelIndex SnippetsManager::Private::currentGroupIndex() const
}
}
void SnippetsManager::Private::selectionChanged()
void SnippetsManager::SnippetsManagerPrivate::selectionChanged()
{
const bool itemSelected = !mSelectionModel->selectedIndexes().isEmpty();
......@@ -135,12 +135,12 @@ void SnippetsManager::Private::selectionChanged()
}
}
void SnippetsManager::Private::addSnippet()
void SnippetsManager::SnippetsManagerPrivate::addSnippet()
{
createSnippet();
}
void SnippetsManager::Private::createSnippet(const QString &text)
void SnippetsManager::SnippetsManagerPrivate::createSnippet(const QString &text)
{
const bool noGroupAvailable = (mModel->rowCount() == 0);
......@@ -196,17 +196,17 @@ void SnippetsManager::Private::createSnippet(const QString &text)
delete dlg;
}
void SnippetsManager::Private::slotAddNewDndSnippset(const QString &text)
void SnippetsManager::SnippetsManagerPrivate::slotAddNewDndSnippset(const QString &text)
{
createSnippet(text);
}
void SnippetsManager::Private::dndDone()
void SnippetsManager::SnippetsManagerPrivate::dndDone()
{
mDirty = true;
}
void SnippetsManager::Private::editSnippet()
void SnippetsManager::SnippetsManagerPrivate::editSnippet()
{
QModelIndex index = mSelectionModel->selectedIndexes().first();
if (!index.isValid() || index.data(SnippetsModel::IsGroupRole).toBool()) {
......@@ -266,7 +266,7 @@ void SnippetsManager::Private::editSnippet()
delete dlg;
}
void SnippetsManager::Private::deleteSnippet()
void SnippetsManager::SnippetsManagerPrivate::deleteSnippet()
{
const QModelIndex index = mSelectionModel->selectedIndexes().first();
......@@ -290,7 +290,7 @@ void SnippetsManager::Private::deleteSnippet()
save();
}
void SnippetsManager::Private::addSnippetGroup()
void SnippetsManager::SnippetsManagerPrivate::addSnippetGroup()
{
QPointer<SnippetDialog> dlg = new SnippetDialog(mActionCollection, true, mParent);
dlg->setWindowTitle(i18nc("@title:window", "Add Group"));
......@@ -310,7 +310,7 @@ void SnippetsManager::Private::addSnippetGroup()
delete dlg;
}
void SnippetsManager::Private::editSnippetGroup()
void SnippetsManager::SnippetsManagerPrivate::editSnippetGroup()
{
const QModelIndex groupIndex = currentGroupIndex();
if (!groupIndex.isValid() || !groupIndex.data(SnippetsModel::IsGroupRole).toBool()) {
......@@ -335,7 +335,7 @@ void SnippetsManager::Private::editSnippetGroup()
delete dlg;
}
void SnippetsManager::Private::deleteSnippetGroup()
void SnippetsManager::SnippetsManagerPrivate::deleteSnippetGroup()
{
const QModelIndex groupIndex = currentGroupIndex();
if (!groupIndex.isValid()) {
......@@ -370,7 +370,7 @@ void SnippetsManager::Private::deleteSnippetGroup()
save();
}
void SnippetsManager::Private::insertSelectedSnippet()
void SnippetsManager::SnippetsManagerPrivate::insertSelectedSnippet()
{
if (!mSelectionModel->hasSelection()) {
return;
......@@ -390,7 +390,7 @@ void SnippetsManager::Private::insertSelectedSnippet()
Q_EMIT q->insertSnippetInfo({subject, text, to, cc, bcc, attachment});
}
void SnippetsManager::Private::insertActionSnippet()
void SnippetsManager::SnippetsManagerPrivate::insertActionSnippet()
{
auto action = qobject_cast<QAction *>(q->sender());
if (!action) {
......@@ -406,7 +406,7 @@ void SnippetsManager::Private::insertActionSnippet()
Q_EMIT q->insertSnippetInfo({subject, text, to, cc, bcc, attachment});
}
void SnippetsManager::Private::initializeActionCollection()
void SnippetsManager::SnippetsManagerPrivate::initializeActionCollection()
{
if (mActionCollection) {
const QVector<SnippetsInfo> infos = mModel->snippetsInfo();
......@@ -416,14 +416,14 @@ void SnippetsManager::Private::initializeActionCollection()
}
}
void SnippetsManager::Private::initializeAction(const QString &newName,
const QKeySequence &keySequence,
const QString &text,
const QString &subject,
const QString &to,
const QString &cc,
const QString &bcc,
const QString &attachment)
void SnippetsManager::SnippetsManagerPrivate::initializeAction(const QString &newName,
const QKeySequence &keySequence,
const QString &text,
const QString &subject,
const QString &to,
const QString &cc,
const QString &bcc,
const QString &attachment)
{
const QString actionName = i18nc("@action", "Snippet %1", newName);
const QString normalizedName = QString(actionName).replace(QLatin1Char(' '), QLatin1Char('_'));
......@@ -442,15 +442,15 @@ void SnippetsManager::Private::initializeAction(const QString &newName,
mActionCollection->setDefaultShortcut(action, keySequence);
}
void SnippetsManager::Private::updateActionCollection(const QString &oldName,
const QString &newName,
const QKeySequence &keySequence,
const QString &text,
const QString &subject,
const QString &to,
const QString &cc,
const QString &bcc,
const QString &attachment)
void SnippetsManager::SnippetsManagerPrivate::updateActionCollection(const QString &oldName,
const QString &newName,
const QKeySequence &keySequence,
const QString &text,
const QString &subject,
const QString &to,
const QString &cc,
const QString &bcc,
const QString &attachment)
{
// remove previous action in case that the name changed
if (!oldName.isEmpty() && mActionCollection) {
......@@ -468,7 +468,7 @@ void SnippetsManager::Private::updateActionCollection(const QString &oldName,
}
}
QString SnippetsManager::Private::replaceVariables(const QString &text)
QString SnippetsManager::SnippetsManagerPrivate::replaceVariables(const QString &text)
{
QString result = text;
QString variableName;
......@@ -514,7 +514,7 @@ QString SnippetsManager::Private::replaceVariables(const QString &text)
return result;
}
void SnippetsManager::Private::save()
void SnippetsManager::SnippetsManagerPrivate::save()
{
if (!mDirty) {
return;
......@@ -526,7 +526,7 @@ void SnippetsManager::Private::save()
SnippetsManager::SnippetsManager(KActionCollection *actionCollection, QObject *parent, QWidget *parentWidget)
: QObject(parent)
, d(new Private(this, parentWidget))
, d(new SnippetsManagerPrivate(this, parentWidget))
{
d->mModel = SnippetsModel::instance();
connect(d->mModel,
......@@ -607,7 +607,6 @@ SnippetsManager::SnippetsManager(KActionCollection *actionCollection, QObject *p
SnippetsManager::~SnippetsManager()
{
d->save();
delete d;
}
QAbstractItemModel *SnippetsManager::model() const
......
......@@ -12,7 +12,7 @@
#include "mailcommon_export.h"
#include <QObject>
#include <memory>
class KActionCollection;
class QAbstractItemModel;
......@@ -126,8 +126,8 @@ Q_SIGNALS:
private:
//@cond PRIVATE
class Private;
Private *const d;
class SnippetsManagerPrivate;
std::unique_ptr<SnippetsManagerPrivate> const d;
//@endcond
};
}
......
......@@ -92,10 +92,7 @@ SnippetWidget::SnippetWidget(QWidget *parent)
});
}
SnippetWidget::~SnippetWidget()
{
delete d;
}
SnippetWidget::~SnippetWidget() = default;
void SnippetWidget::setName(const QString &name)
{
......
......@@ -72,7 +72,7 @@ Q_SIGNALS:
void groupChanged(int index);
private:
SnippetWidgetPrivate *const d;
std::unique_ptr<SnippetWidgetPrivate> const d;
};
}
......@@ -57,10 +57,7 @@ AddTagDialog::AddTagDialog(const QList<KActionCollection *> &actions, QWidget *p
mainLayout->addWidget(buttonBox);
}
AddTagDialog::~AddTagDialog()
{
delete d;
}
AddTagDialog::~AddTagDialog() = default;
void AddTagDialog::setTags(const QVector<MailCommon::Tag::Ptr> &tags)
{
......
......@@ -33,6 +33,6 @@ private:
void slotSave();
void slotTagNameChanged(const QString &text);
void onTagCreated(KJob *job);
AddTagDialogPrivate *const d;
std::unique_ptr<AddTagDialogPrivate> const d;
};
}
......@@ -31,10 +31,7 @@ ResourceReadConfigFile::ResourceReadConfigFile(const QString &resourceName)
d->mConfig = new KConfig(resourceName + QStringLiteral("rc"));
}
ResourceReadConfigFile::~ResourceReadConfigFile()
{
delete d;
}
ResourceReadConfigFile::~ResourceReadConfigFile() = default;
KConfigGroup ResourceReadConfigFile::group(const QString &name) const
{
......
......@@ -9,6 +9,7 @@
#include "mailcommon_export.h"
#include <KConfigGroup>
#include <QString>
#include <memory>
namespace MailCommon
{
......@@ -22,7 +23,7 @@ public:
KConfigGroup group(const QString &name) const;
private:
ResourceReadConfigFilePrivate *const d;
std::unique_ptr<ResourceReadConfigFilePrivate> const d;
};
}
Supports Markdown
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