Commit 0c8bd021 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Use std::unique_ptr

parent 249f4445
Pipeline #87014 passed with stage
in 42 minutes and 40 seconds
......@@ -32,11 +32,11 @@ static Qt::CheckState boolToCheckState(bool checked) // local
}
}
class Q_DECL_HIDDEN MessageComposer::AttachmentModel::Private
class Q_DECL_HIDDEN MessageComposer::AttachmentModel::AttachmentModelPrivate
{
public:
Private(AttachmentModel *qq);
~Private();
AttachmentModelPrivate(AttachmentModel *qq);
~AttachmentModelPrivate();
AttachmentPart::List parts;
QVector<QTemporaryDir *> tempDirs;
......@@ -49,12 +49,12 @@ public:
bool autoDisplayEnabled = false;
};
AttachmentModel::Private::Private(AttachmentModel *qq)
AttachmentModel::AttachmentModelPrivate::AttachmentModelPrivate(AttachmentModel *qq)
: q(qq)
{
}
AttachmentModel::Private::~Private()
AttachmentModel::AttachmentModelPrivate::~AttachmentModelPrivate()
{
// There should be an automatic way to manage the lifetime of these...
qDeleteAll(tempDirs);
......@@ -62,14 +62,11 @@ AttachmentModel::Private::~Private()
AttachmentModel::AttachmentModel(QObject *parent)
: QAbstractItemModel(parent)
, d(new Private(this))
, d(new AttachmentModelPrivate(this))
{
}
AttachmentModel::~AttachmentModel()
{
delete d;
}
AttachmentModel::~AttachmentModel() = default;
bool AttachmentModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
{
......
......@@ -95,9 +95,9 @@ Q_SIGNALS:
void attachmentCompressRequested(MessageCore::AttachmentPart::Ptr part, bool compress);
private:
class Private;
friend class Private;
Private *const d;
class AttachmentModelPrivate;
friend class AttachmentModelPrivate;
std::unique_ptr<AttachmentModelPrivate> const d;
};
} //
......@@ -43,10 +43,7 @@ RichTextComposerNg::RichTextComposerNg(QWidget *parent)
{
}
RichTextComposerNg::~RichTextComposerNg()
{
delete d;
}
RichTextComposerNg::~RichTextComposerNg() = default;
MessageComposer::RichTextComposerSignatures *RichTextComposerNg::composerSignature() const
{
......
......@@ -54,7 +54,7 @@ protected:
bool processModifyText(QKeyEvent *event) override;
private:
RichTextComposerNgPrivate *const d;
std::unique_ptr<RichTextComposerNgPrivate> const d;
friend class ::RichTextComposerNgTest; // for fixHtmlFontSize
void fixHtmlFontSize(QString &cleanHtml) const;
......
......@@ -31,10 +31,7 @@ RichTextComposerSignatures::RichTextComposerSignatures(MessageComposer::RichText
{
}
RichTextComposerSignatures::~RichTextComposerSignatures()
{
delete d;
}
RichTextComposerSignatures::~RichTextComposerSignatures() = default;
void RichTextComposerSignatures::RichTextComposerSignaturesPrivate::cleanWhitespaceHelper(const QRegExp &regExp,
const QString &newText,
......
......@@ -8,6 +8,7 @@
#include "messagecomposer_export.h"
#include <QObject>
#include <memory>
namespace KIdentityManagement
{
class Signature;
......@@ -33,6 +34,6 @@ public:
private:
class RichTextComposerSignaturesPrivate;
RichTextComposerSignaturesPrivate *const d;
std::unique_ptr<RichTextComposerSignaturesPrivate> const d;
};
}
......@@ -39,10 +39,7 @@ SignatureController::SignatureController(QObject *parent)
{
}
SignatureController::~SignatureController()
{
delete d;
}
SignatureController::~SignatureController() = default;
void SignatureController::setEditor(MessageComposer::RichTextComposerNg *editor)
{
......
......@@ -87,7 +87,7 @@ private Q_SLOTS:
void identityChanged(uint id);
private:
SignatureControllerPrivate *const d;
std::unique_ptr<SignatureControllerPrivate> const d;
};
}
......@@ -28,10 +28,7 @@ ImageScaling::ImageScaling()
{
}
ImageScaling::~ImageScaling()
{
delete d;
}
ImageScaling::~ImageScaling() = default;
bool ImageScaling::loadImageFromData(const QByteArray &data)
{
......
......@@ -8,6 +8,7 @@
#include "messagecomposer_export.h"
#include <QByteArray>
#include <memory>
namespace MessageComposer
{
......@@ -53,7 +54,7 @@ public:
Q_REQUIRED_RESULT QString generateNewName();
private:
ImageScalingPrivate *const d;
std::unique_ptr<ImageScalingPrivate> const d;
};
}
......@@ -115,10 +115,7 @@ ImageScalingWidget::ImageScalingWidget(QWidget *parent)
d->ui->help->setContextMenuPolicy(Qt::NoContextMenu);
}
ImageScalingWidget::~ImageScalingWidget()
{
delete d;
}
ImageScalingWidget::~ImageScalingWidget() = default;
void ImageScalingWidget::slotHelpLinkClicked(const QString &)
{
......
......@@ -50,7 +50,7 @@ private:
void initWriteImageFormat();
void updateEmailsFilterTypeSettings();
void updateSettings();
ImageScalingWidgetPrivate *const d;
std::unique_ptr<ImageScalingWidgetPrivate> const d;
};
}
......@@ -20,10 +20,10 @@
using namespace MessageComposer;
using MessageCore::AttachmentPart;
class Q_DECL_HIDDEN MessageComposer::AttachmentFromPublicKeyJob::Private
class Q_DECL_HIDDEN MessageComposer::AttachmentFromPublicKeyJob::AttachmentFromPublicKeyJobPrivate
{
public:
Private(AttachmentFromPublicKeyJob *qq);
AttachmentFromPublicKeyJobPrivate(AttachmentFromPublicKeyJob *qq);
void exportResult(const GpgME::Error &error, const QByteArray &keyData); // slot
void emitGpgError(const GpgME::Error &error);
......@@ -33,12 +33,12 @@ public:
QByteArray data;
};
AttachmentFromPublicKeyJob::Private::Private(AttachmentFromPublicKeyJob *qq)
AttachmentFromPublicKeyJob::AttachmentFromPublicKeyJobPrivate::AttachmentFromPublicKeyJobPrivate(AttachmentFromPublicKeyJob *qq)
: q(qq)
{
}
void AttachmentFromPublicKeyJob::Private::exportResult(const GpgME::Error &error, const QByteArray &keyData)
void AttachmentFromPublicKeyJob::AttachmentFromPublicKeyJobPrivate::exportResult(const GpgME::Error &error, const QByteArray &keyData)
{
if (error) {
emitGpgError(error);
......@@ -56,7 +56,7 @@ void AttachmentFromPublicKeyJob::Private::exportResult(const GpgME::Error &error
q->emitResult(); // Success.
}
void AttachmentFromPublicKeyJob::Private::emitGpgError(const GpgME::Error &error)
void AttachmentFromPublicKeyJob::AttachmentFromPublicKeyJobPrivate::emitGpgError(const GpgME::Error &error)
{
Q_ASSERT(error);
const QString msg = i18n(
......@@ -71,15 +71,12 @@ void AttachmentFromPublicKeyJob::Private::emitGpgError(const GpgME::Error &error
AttachmentFromPublicKeyJob::AttachmentFromPublicKeyJob(const QString &fingerprint, QObject *parent)
: AttachmentLoadJob(parent)
, d(new Private(this))
, d(new AttachmentFromPublicKeyJobPrivate(this))
{
d->fingerprint = fingerprint;
}
AttachmentFromPublicKeyJob::~AttachmentFromPublicKeyJob()
{
delete d;
}
AttachmentFromPublicKeyJob::~AttachmentFromPublicKeyJob() = default;
QString AttachmentFromPublicKeyJob::fingerprint() const
{
......
......@@ -31,9 +31,9 @@ protected Q_SLOTS:
void doStart() override;
private:
class Private;
friend class Private;
Private *const d;
class AttachmentFromPublicKeyJobPrivate;
friend class AttachmentFromPublicKeyJobPrivate;
std::unique_ptr<AttachmentFromPublicKeyJobPrivate> const d;
};
} //
......@@ -30,10 +30,7 @@ AttachmentVcardFromAddressBookJob::AttachmentVcardFromAddressBookJob(const Akona
{
}
AttachmentVcardFromAddressBookJob::~AttachmentVcardFromAddressBookJob()
{
delete d;
}
AttachmentVcardFromAddressBookJob::~AttachmentVcardFromAddressBookJob() = default;
void AttachmentVcardFromAddressBookJob::addAttachment(const QByteArray &data, const QString &attachmentName)
{
......
......@@ -32,6 +32,6 @@ private Q_SLOTS:
private:
void invalidContact();
void addAttachment(const QByteArray &data, const QString &attachmentName);
AttachmentVcardFromAddressBookJobPrivate *const d;
std::unique_ptr<AttachmentVcardFromAddressBookJobPrivate> const d;
};
}
......@@ -44,10 +44,7 @@ EmailAddressResolveJob::EmailAddressResolveJob(QObject *parent)
{
}
EmailAddressResolveJob::~EmailAddressResolveJob()
{
delete d;
}
EmailAddressResolveJob::~EmailAddressResolveJob() = default;
static inline bool containsAliases(const QString &address)
{
......
......@@ -99,7 +99,7 @@ private Q_SLOTS:
void slotAliasExpansionDone(KJob *);
private:
EmailAddressResolveJobPrivate *const d;
std::unique_ptr<EmailAddressResolveJobPrivate> const d;
};
}
......@@ -36,10 +36,7 @@ InsertTextFileJob::InsertTextFileJob(QTextEdit *editor, const QUrl &url)
{
}
InsertTextFileJob::~InsertTextFileJob()
{
delete d;
}
InsertTextFileJob::~InsertTextFileJob() = default;
void InsertTextFileJob::slotFileData(KIO::Job *job, const QByteArray &data)
{
......
......@@ -42,7 +42,7 @@ private Q_SLOTS:
void slotFileData(KIO::Job *job, const QByteArray &data);
private:
InsertTextFileJobPrivate *const d;
std::unique_ptr<InsertTextFileJobPrivate> 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