Commit 0297580b authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Use unique_ptr

parent 740920c4
Pipeline #87592 passed with stage
in 31 minutes and 22 seconds
......@@ -28,15 +28,15 @@ using namespace MailCommon;
//
//=============================================================================
class Q_DECL_HIDDEN FilterActionWidget::Private
class Q_DECL_HIDDEN FilterActionWidget::FilterActionWidgetPrivate
{
public:
Private(FilterActionWidget *qq)
FilterActionWidgetPrivate(FilterActionWidget *qq)
: q(qq)
{
}
~Private()
~FilterActionWidgetPrivate()
{
qDeleteAll(mActionList);
mActionList.clear();
......@@ -57,7 +57,7 @@ public:
QGridLayout *mLayout = nullptr;
};
void FilterActionWidget::Private::setFilterAction(QWidget *widget)
void FilterActionWidget::FilterActionWidgetPrivate::setFilterAction(QWidget *widget)
{
if (mLayout->itemAtPosition(1, 2)) {
delete mLayout->itemAtPosition(1, 2)->widget();
......@@ -70,26 +70,26 @@ void FilterActionWidget::Private::setFilterAction(QWidget *widget)
}
}
void FilterActionWidget::Private::slotAddWidget()
void FilterActionWidget::FilterActionWidgetPrivate::slotAddWidget()
{
Q_EMIT q->addFilterWidget(q);
Q_EMIT q->filterModified();
}
void FilterActionWidget::Private::slotRemoveWidget()
void FilterActionWidget::FilterActionWidgetPrivate::slotRemoveWidget()
{
Q_EMIT q->removeFilterWidget(q);
Q_EMIT q->filterModified();
}
void FilterActionWidget::Private::slotFilterTypeChanged(int index)
void FilterActionWidget::FilterActionWidgetPrivate::slotFilterTypeChanged(int index)
{
setFilterAction(index < mActionList.count() ? mActionList.at(index)->createParamWidget(q) : nullptr);
}
FilterActionWidget::FilterActionWidget(QWidget *parent)
: QWidget(parent)
, d(new Private(this))
, d(new FilterActionWidgetPrivate(this))
{
auto mainLayout = new QHBoxLayout(this);
mainLayout->setContentsMargins({});
......@@ -170,10 +170,7 @@ FilterActionWidget::FilterActionWidget(QWidget *parent)
d->mLayout->addWidget(d->mRemove, 1, 4);
}
FilterActionWidget::~FilterActionWidget()
{
delete d;
}
FilterActionWidget::~FilterActionWidget() = default;
void FilterActionWidget::updateAddRemoveButton(bool addButtonEnabled, bool removeButtonEnabled)
{
......@@ -240,10 +237,10 @@ FilterAction *FilterActionWidget::action() const
//
//=============================================================================
class Q_DECL_HIDDEN FilterActionWidgetLister::Private
class FilterActionWidgetLister::FilterActionWidgetListerPrivate
{
public:
Private(FilterActionWidgetLister *qq)
FilterActionWidgetListerPrivate(FilterActionWidgetLister *qq)
: q(qq)
{
}
......@@ -254,7 +251,7 @@ public:
QVector<MailCommon::FilterAction *> *mActionList = nullptr;
};
void FilterActionWidgetLister::Private::regenerateActionListFromWidgets()
void FilterActionWidgetLister::FilterActionWidgetListerPrivate::regenerateActionListFromWidgets()
{
if (!mActionList) {
return;
......@@ -274,14 +271,11 @@ void FilterActionWidgetLister::Private::regenerateActionListFromWidgets()
FilterActionWidgetLister::FilterActionWidgetLister(QWidget *parent)
: KWidgetLister(false, 1, MailFilter::filterActionsMaximumSize(), parent)
, d(new Private(this))
, d(new FilterActionWidgetListerPrivate(this))
{
}
FilterActionWidgetLister::~FilterActionWidgetLister()
{
delete d;
}
FilterActionWidgetLister::~FilterActionWidgetLister() = default;
void FilterActionWidgetLister::setActionList(QVector<FilterAction *> *list)
{
......
......@@ -83,8 +83,8 @@ Q_SIGNALS:
private:
//@cond PRIVATE
class Private;
Private *const d;
class FilterActionWidgetPrivate;
std::unique_ptr<FilterActionWidgetPrivate> const d;
//@endcond
};
......@@ -149,8 +149,8 @@ protected:
private:
//@cond PRIVATE
class Private;
Private *const d;
class FilterActionWidgetListerPrivate;
std::unique_ptr<FilterActionWidgetListerPrivate> const d;
//@endcond
void connectWidget(QWidget *widget, FilterAction *filterAction);
};
......
......@@ -96,10 +96,10 @@ void FilterImporterExporter::writeFiltersToConfig(const QVector<MailFilter *> &f
config->sync();
}
class Q_DECL_HIDDEN FilterImporterExporter::Private
class Q_DECL_HIDDEN FilterImporterExporter::FilterImporterExporterPrivate
{
public:
Private(QWidget *parent)
FilterImporterExporterPrivate(QWidget *parent)
: mParent(parent)
{
}
......@@ -108,7 +108,7 @@ public:
QWidget *const mParent;
};
void FilterImporterExporter::Private::warningInfoAboutInvalidFilter(const QStringList &emptyFilters) const
void FilterImporterExporter::FilterImporterExporterPrivate::warningInfoAboutInvalidFilter(const QStringList &emptyFilters) const
{
if (!emptyFilters.isEmpty()) {
KMessageBox::informationList(mParent,
......@@ -121,14 +121,11 @@ void FilterImporterExporter::Private::warningInfoAboutInvalidFilter(const QStrin
}
FilterImporterExporter::FilterImporterExporter(QWidget *parent)
: d(new Private(parent))
: d(new FilterImporterExporterPrivate(parent))
{
}
FilterImporterExporter::~FilterImporterExporter()
{
delete d;
}
FilterImporterExporter::~FilterImporterExporter() = default;
QVector<MailFilter *> FilterImporterExporter::importFilters(bool &canceled, FilterImporterExporter::FilterType type, const QString &filename)
{
......
......@@ -14,7 +14,7 @@
#include <QStringList>
#include <QVector>
#include <memory>
class QWidget;
namespace MailCommon
......@@ -83,8 +83,8 @@ private:
//@cond PRIVATE
Q_DISABLE_COPY(FilterImporterExporter)
class Private;
Private *const d;
class FilterImporterExporterPrivate;
std::unique_ptr<FilterImporterExporterPrivate> const d;
//@endcond
};
}
......
......@@ -16,10 +16,10 @@
using namespace MailCommon;
class Q_DECL_HIDDEN FilterLog::Private
class Q_DECL_HIDDEN FilterLog::FilterLogPrivate
{
public:
Private(FilterLog *qq)
FilterLogPrivate(FilterLog *qq)
: q(qq)
, mMaxLogSize(512 * 1024)
, mAllowedTypes(FilterLog::Meta | FilterLog::PatternDescription | FilterLog::RuleResult | FilterLog::PatternResult | FilterLog::AppliedAction)
......@@ -38,7 +38,7 @@ public:
void checkLogSize();
};
void FilterLog::Private::checkLogSize()
void FilterLog::FilterLogPrivate::checkLogSize()
{
if (mCurrentLogSize > mMaxLogSize && mMaxLogSize > -1) {
qCDebug(MAILCOMMON_LOG) << "Filter log: memory limit reached, starting to discard old items, size =" << QString::number(mCurrentLogSize);
......@@ -60,25 +60,22 @@ void FilterLog::Private::checkLogSize()
}
}
FilterLog *FilterLog::Private::mSelf = nullptr;
FilterLog *FilterLog::FilterLogPrivate::mSelf = nullptr;
FilterLog::FilterLog()
: d(new Private(this))
: d(new FilterLogPrivate(this))
{
}
FilterLog::~FilterLog()
{
delete d;
}
FilterLog::~FilterLog() = default;
FilterLog *FilterLog::instance()
{
if (!FilterLog::Private::mSelf) {
FilterLog::Private::mSelf = new FilterLog();
if (!FilterLog::FilterLogPrivate::mSelf) {
FilterLog::FilterLogPrivate::mSelf = new FilterLog();
}
return FilterLog::Private::mSelf;
return FilterLog::FilterLogPrivate::mSelf;
}
bool FilterLog::isLogging() const
......
......@@ -10,7 +10,7 @@
#include <QObject>
#include <QStringList>
#include <memory>
namespace MailCommon
{
/**
......@@ -143,8 +143,8 @@ private:
//@cond PRIVATE
FilterLog();
class Private;
Private *const d;
class FilterLogPrivate;
std::unique_ptr<FilterLogPrivate> const d;
//@endcond
};
}
......
......@@ -128,10 +128,7 @@ FolderTreeWidget::FolderTreeWidget(QWidget *parent,
}
}
FolderTreeWidget::~FolderTreeWidget()
{
delete d;
}
FolderTreeWidget::~FolderTreeWidget() = default;
void FolderTreeWidget::slotFilterFixedString(const QString &text)
{
......
......@@ -14,7 +14,7 @@
#include <QAbstractItemView>
#include <QWidget>
#include <memory>
namespace Akonadi
{
class StatisticsProxyModel;
......@@ -121,7 +121,7 @@ protected Q_SLOTS:
private:
bool eventFilter(QObject *o, QEvent *e) override;
class FolderTreeWidgetPrivate;
FolderTreeWidgetPrivate *const d;
std::unique_ptr<FolderTreeWidgetPrivate> const d;
};
}
......@@ -25,10 +25,10 @@
namespace MailCommon
{
class FolderTreeWidgetProxyModel::Private
class FolderTreeWidgetProxyModel::FolderTreeWidgetProxyModelPrivate
{
public:
Private(FolderTreeWidgetProxyModel *qq)
FolderTreeWidgetProxyModelPrivate(FolderTreeWidgetProxyModel *qq)
: q(qq)
{
}
......@@ -72,7 +72,7 @@ public:
FolderTreeWidgetProxyModel::FolderTreeWidgetProxyModel(QObject *parent, FolderTreeWidgetProxyModelOptions option)
: Akonadi::EntityRightsFilterModel(parent)
, d(new Private(this))
, d(new FolderTreeWidgetProxyModelPrivate(this))
{
setDynamicSortFilter(true);
setFilterCaseSensitivity(Qt::CaseInsensitive);
......@@ -89,10 +89,7 @@ FolderTreeWidgetProxyModel::FolderTreeWidgetProxyModel(QObject *parent, FolderTr
readConfig();
}
FolderTreeWidgetProxyModel::~FolderTreeWidgetProxyModel()
{
delete d;
}
FolderTreeWidgetProxyModel::~FolderTreeWidgetProxyModel() = default;
void FolderTreeWidgetProxyModel::setWarningThreshold(qreal threshold)
{
......
......@@ -10,6 +10,7 @@
#include <Akonadi/Collection>
#include <Akonadi/EntityRightsFilterModel>
#include <memory>
namespace MailCommon
{
......@@ -56,8 +57,8 @@ protected:
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
private:
class Private;
Private *const d;
class FolderTreeWidgetProxyModelPrivate;
std::unique_ptr<FolderTreeWidgetProxyModelPrivate> const d;
};
}
......@@ -98,10 +98,7 @@ SendMdnHandler::SendMdnHandler(IKernel *kernel, QObject *parent)
});
}
SendMdnHandler::~SendMdnHandler()
{
delete d;
}
SendMdnHandler::~SendMdnHandler() = default;
void SendMdnHandler::setItem(const Akonadi::Item &item)
{
......
......@@ -46,7 +46,7 @@ public:
private:
//@cond PRIVATE
class Private;
Private *const d;
std::unique_ptr<Private> const d;
//@endcond
};
}
......
......@@ -148,10 +148,7 @@ TagWidget::TagWidget(const QList<KActionCollection *> &actionCollections, QWidge
connect(d->mInToolbarCheck, &QCheckBox::stateChanged, this, &TagWidget::slotEmitChangeCheck);
}
TagWidget::~TagWidget()
{
delete d;
}
TagWidget::~TagWidget() = default;
void TagWidget::slotEmitChangeCheck()
{
......
......@@ -57,7 +57,7 @@ Q_SIGNALS:
private:
void slotEmitChangeCheck();
TagWidgetPrivate *const d;
std::unique_ptr<TagWidgetPrivate> 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