Commit cf2f6470 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

USe std::unique_ptr

parent cef7cd1d
Pipeline #87573 passed with stage
in 7 minutes and 17 seconds
......@@ -16,13 +16,13 @@ using namespace Kleo;
namespace Kleo {
class DefaultKeyGenerationJob::Private
class DefaultKeyGenerationJob::DefaultKeyGenerationJobPrivate
{
public:
Private()
DefaultKeyGenerationJobPrivate()
{}
~Private()
~DefaultKeyGenerationJobPrivate()
{
if (job) {
job->deleteLater();
......@@ -37,14 +37,11 @@ public:
DefaultKeyGenerationJob::DefaultKeyGenerationJob(QObject* parent)
: Job(parent)
, d(new DefaultKeyGenerationJob::Private())
, d(new DefaultKeyGenerationJob::DefaultKeyGenerationJobPrivate())
{
}
DefaultKeyGenerationJob::~DefaultKeyGenerationJob()
{
delete d;
}
DefaultKeyGenerationJob::~DefaultKeyGenerationJob() = default;
QString DefaultKeyGenerationJob::auditLogAsHtml() const
{
......
......@@ -9,6 +9,7 @@
#include <qgpgme/job.h>
#include <kleo_export.h>
#include <memory>
namespace GpgME {
class KeyGenerationResult;
......@@ -54,8 +55,8 @@ protected:
bool eventFilter(QObject *watched, QEvent *event) override;
private:
class Private;
Private * const d;
class DefaultKeyGenerationJobPrivate;
std::unique_ptr<DefaultKeyGenerationJobPrivate> const d;
};
}
......
......@@ -22,7 +22,7 @@
#include <QHeaderView>
class Kleo::DNAttributeOrderConfigWidget::Private
class Kleo::DNAttributeOrderConfigWidget::DNAttributeOrderConfigWidgetPrivate
{
public:
enum { UUp = 0, Up = 1, Left = 2, Right = 3, Down = 4, DDown = 5 };
......@@ -50,7 +50,7 @@ static void prepare(QTreeWidget *lv)
#endif
Kleo::DNAttributeOrderConfigWidget::DNAttributeOrderConfigWidget(DNAttributeMapper *mapper, QWidget *parent, Qt::WindowFlags f)
: QWidget(parent, f), d(new Private)
: QWidget(parent, f), d(new DNAttributeOrderConfigWidgetPrivate)
{
Q_ASSERT(mapper);
d->mapper = mapper;
......@@ -122,10 +122,7 @@ Kleo::DNAttributeOrderConfigWidget::DNAttributeOrderConfigWidget(DNAttributeMapp
glay->addLayout(xlay, row, 1);
}
Kleo::DNAttributeOrderConfigWidget::~DNAttributeOrderConfigWidget()
{
delete d;
}
Kleo::DNAttributeOrderConfigWidget::~DNAttributeOrderConfigWidget() = default;
void Kleo::DNAttributeOrderConfigWidget::load()
{
......@@ -199,7 +196,7 @@ void Kleo::DNAttributeOrderConfigWidget::defaults()
void Kleo::DNAttributeOrderConfigWidget::slotAvailableSelectionChanged(QTreeWidgetItem *item)
{
d->navTB[Private::Right]->setEnabled(item);
d->navTB[DNAttributeOrderConfigWidgetPrivate::Right]->setEnabled(item);
}
void Kleo::DNAttributeOrderConfigWidget::slotCurrentOrderSelectionChanged(QTreeWidgetItem *item)
......@@ -210,11 +207,11 @@ void Kleo::DNAttributeOrderConfigWidget::slotCurrentOrderSelectionChanged(QTreeW
void Kleo::DNAttributeOrderConfigWidget::enableDisableButtons(QTreeWidgetItem *item)
{
#ifndef QT_NO_TREEWIDGET
d->navTB[Private::UUp ]->setEnabled(item && d->currentLV->itemAbove(item));
d->navTB[Private::Up ]->setEnabled(item && d->currentLV->itemAbove(item));
d->navTB[Private::Left ]->setEnabled(item);
d->navTB[Private::Down ]->setEnabled(item && d->currentLV->itemBelow(item));
d->navTB[Private::DDown]->setEnabled(item && d->currentLV->itemBelow(item));
d->navTB[DNAttributeOrderConfigWidgetPrivate::UUp ]->setEnabled(item && d->currentLV->itemAbove(item));
d->navTB[DNAttributeOrderConfigWidgetPrivate::Up ]->setEnabled(item && d->currentLV->itemAbove(item));
d->navTB[DNAttributeOrderConfigWidgetPrivate::Left ]->setEnabled(item);
d->navTB[DNAttributeOrderConfigWidgetPrivate::Down ]->setEnabled(item && d->currentLV->itemBelow(item));
d->navTB[DNAttributeOrderConfigWidgetPrivate::DDown]->setEnabled(item && d->currentLV->itemBelow(item));
#endif
}
......@@ -341,7 +338,7 @@ void Kleo::DNAttributeOrderConfigWidget::slotRightButtonClicked()
d->currentLV->insertTopLevelItem(newRightIndex, left);
left->setSelected(true);
enableDisableButtons(left);
d->navTB[Private::Right]->setEnabled(next);
d->navTB[DNAttributeOrderConfigWidgetPrivate::Right]->setEnabled(next);
if (next) {
next->setSelected(true);
}
......
......@@ -57,8 +57,8 @@ private:
void enableDisableButtons(QTreeWidgetItem *);
private:
class Private;
Private *const d;
class DNAttributeOrderConfigWidgetPrivate;
std::unique_ptr<DNAttributeOrderConfigWidgetPrivate> const d;
protected:
virtual void virtual_hook(int, void *);
};
......
......@@ -22,13 +22,13 @@
using namespace Kleo;
class Q_DECL_HIDDEN FileNameRequester::Private
class Q_DECL_HIDDEN FileNameRequester::FileNameRequesterPrivate
{
friend class ::Kleo::FileNameRequester;
FileNameRequester *const q;
public:
explicit Private(FileNameRequester *qq);
~Private();
explicit FileNameRequesterPrivate(FileNameRequester *qq);
~FileNameRequesterPrivate();
private:
void slotButtonClicked();
......@@ -49,7 +49,7 @@ private:
bool existingOnly;
};
FileNameRequester::Private::Private(FileNameRequester *qq)
FileNameRequester::FileNameRequesterPrivate::FileNameRequesterPrivate(FileNameRequester *qq)
: q(qq),
#ifndef QT_NO_DIRMODEL
dirmodel(),
......@@ -87,16 +87,16 @@ FileNameRequester::Private::Private(FileNameRequester *qq)
connect(&lineedit, &KLineEdit::textChanged, q, &FileNameRequester::fileNameChanged);
}
FileNameRequester::Private::~Private() {}
FileNameRequester::FileNameRequesterPrivate::~FileNameRequesterPrivate() {}
FileNameRequester::FileNameRequester(QWidget *p)
: QWidget(p), d(new Private(this))
: QWidget(p), d(new FileNameRequesterPrivate(this))
{
}
FileNameRequester::FileNameRequester(QDir::Filters f, QWidget *p)
: QWidget(p), d(new Private(this))
: QWidget(p), d(new FileNameRequesterPrivate(this))
{
#ifndef QT_NO_DIRMODEL
d->dirmodel.setFilter(f);
......@@ -105,10 +105,7 @@ FileNameRequester::FileNameRequester(QDir::Filters f, QWidget *p)
#endif
}
FileNameRequester::~FileNameRequester()
{
delete d;
}
FileNameRequester::~FileNameRequester() = default;
void FileNameRequester::setFileName(const QString &file)
{
......@@ -158,7 +155,7 @@ QString FileNameRequester::nameFilter() const
return d->nameFilter;
}
void FileNameRequester::Private::slotButtonClicked()
void FileNameRequester::FileNameRequesterPrivate::slotButtonClicked()
{
const QString fileName = q->requestFileName();
if (!fileName.isEmpty()) {
......
......@@ -50,8 +50,8 @@ private:
virtual QString requestFileName();
private:
class Private;
Private *d;
class FileNameRequesterPrivate;
std::unique_ptr<FileNameRequesterPrivate> const d;
};
}
......
......@@ -67,10 +67,10 @@ static QStringList preferencesStrings()
<< i18n("Ask Whenever Encryption is Possible");
}
class Q_DECL_HIDDEN Kleo::KeyApprovalDialog::Private
class Q_DECL_HIDDEN Kleo::KeyApprovalDialog::KeyApprovalDialogPrivate
{
public:
Private() {}
KeyApprovalDialogPrivate() {}
Kleo::KeyRequester *selfRequester = nullptr;
QStringList addresses;
......@@ -83,7 +83,7 @@ Kleo::KeyApprovalDialog::KeyApprovalDialog(const std::vector<Item> &recipients,
const std::vector<GpgME::Key> &sender,
QWidget *parent)
: QDialog(parent),
d(new Private())
d(new KeyApprovalDialogPrivate())
{
setWindowTitle(i18nc("@title:window", "Encryption Key Approval"));
auto mainLayout = new QVBoxLayout(this);
......@@ -159,10 +159,7 @@ Kleo::KeyApprovalDialog::KeyApprovalDialog(const std::vector<Item> &recipients,
qMin(size.height(), 7 * desk.height() / 8)));
}
Kleo::KeyApprovalDialog::~KeyApprovalDialog()
{
delete d;
}
Kleo::KeyApprovalDialog::~KeyApprovalDialog() = default;
std::vector<GpgME::Key> Kleo::KeyApprovalDialog::senderKeys() const
{
......
......@@ -58,8 +58,8 @@ private Q_SLOTS:
void slotPrefsChanged();
private:
class Private;
Private *const d;
class KeyApprovalDialogPrivate;
std::unique_ptr<KeyApprovalDialogPrivate> const d;
};
} // namespace Kleo
......
......@@ -26,10 +26,10 @@
static const int updateDelayMilliSecs = 500;
class Q_DECL_HIDDEN Kleo::KeyListView::Private
class Q_DECL_HIDDEN Kleo::KeyListView::KeyListViewPrivate
{
public:
Private() : updateTimer(nullptr) {}
KeyListViewPrivate() : updateTimer(nullptr) {}
std::vector<GpgME::Key> keyBuffer;
QTimer *updateTimer = nullptr;
......@@ -61,7 +61,7 @@ Kleo::KeyListView::KeyListView(const ColumnStrategy *columnStrategy, const Displ
: QTreeWidget(parent),
mColumnStrategy(columnStrategy),
mDisplayStrategy(displayStrategy),
mHierarchical(false), d(new Private())
mHierarchical(false), d(new KeyListViewPrivate())
{
setWindowFlags(f);
setContextMenuPolicy(Qt::CustomContextMenu);
......@@ -101,7 +101,6 @@ Kleo::KeyListView::~KeyListView()
clear();
Q_ASSERT(d->itemMap.size() == 0);
// need to delete the tooltip ourselves, as ~QToolTip isn't virtual :o
delete d;
delete mColumnStrategy; mColumnStrategy = nullptr;
delete mDisplayStrategy; mDisplayStrategy = nullptr;
}
......
......@@ -195,8 +195,8 @@ private:
const DisplayStrategy *mDisplayStrategy = nullptr;
bool mHierarchical = false;
class Private;
Private *const d;
class KeyListViewPrivate;
std::unique_ptr<KeyListViewPrivate> const d;
};
}
......@@ -465,10 +465,7 @@ KeySelectionCombo::KeySelectionCombo(bool secretOnly, QWidget* parent)
QTimer::singleShot(0, this, &KeySelectionCombo::init);
}
KeySelectionCombo::~KeySelectionCombo()
{
delete d;
}
KeySelectionCombo::~KeySelectionCombo() = default;
void KeySelectionCombo::init()
{
......
......@@ -66,7 +66,7 @@ protected:
virtual void init();
private:
KeySelectionComboPrivate * const d;
std::unique_ptr<KeySelectionComboPrivate> 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