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

not necessary to use private class here

parent 3489d74a
Pipeline #87741 passed with stage
in 6 minutes and 57 seconds
......@@ -16,19 +16,9 @@
using namespace NoteShared;
class NoteShared::NotesChangeRecorderPrivate
{
public:
NotesChangeRecorderPrivate()
{
}
Akonadi::ChangeRecorder *mChangeRecorder = nullptr;
};
NotesChangeRecorder::NotesChangeRecorder(QObject *parent)
: QObject(parent)
, d(new NoteShared::NotesChangeRecorderPrivate)
, mChangeRecorder(new Akonadi::ChangeRecorder(this))
{
Akonadi::ItemFetchScope scope;
scope.fetchFullPayload(true); // Need to have full item when adding it to the internal data structure
......@@ -36,18 +26,17 @@ NotesChangeRecorder::NotesChangeRecorder(QObject *parent)
scope.fetchAttribute<NoteShared::NoteDisplayAttribute>();
scope.fetchAttribute<NoteShared::NoteAlarmAttribute>();
d->mChangeRecorder = new Akonadi::ChangeRecorder(this);
d->mChangeRecorder->setItemFetchScope(scope);
d->mChangeRecorder->fetchCollection(true);
d->mChangeRecorder->fetchCollectionStatistics(true);
d->mChangeRecorder->setCollectionMonitored(Akonadi::Collection::root());
d->mChangeRecorder->collectionFetchScope().setIncludeStatistics(true);
d->mChangeRecorder->setMimeTypeMonitored(Akonadi::NoteUtils::noteMimeType());
mChangeRecorder->setItemFetchScope(scope);
mChangeRecorder->fetchCollection(true);
mChangeRecorder->fetchCollectionStatistics(true);
mChangeRecorder->setCollectionMonitored(Akonadi::Collection::root());
mChangeRecorder->collectionFetchScope().setIncludeStatistics(true);
mChangeRecorder->setMimeTypeMonitored(Akonadi::NoteUtils::noteMimeType());
}
NotesChangeRecorder::~NotesChangeRecorder() = default;
Akonadi::ChangeRecorder *NotesChangeRecorder::changeRecorder() const
{
return d->mChangeRecorder;
return mChangeRecorder;
}
......@@ -27,7 +27,7 @@ public:
Akonadi::ChangeRecorder *changeRecorder() const;
private:
std::unique_ptr<NotesChangeRecorderPrivate> const d;
Akonadi::ChangeRecorder *const mChangeRecorder;
};
}
......@@ -23,21 +23,9 @@
using namespace NoteShared;
class NoteShared::NoteAlarmDialogPrivate
{
public:
NoteAlarmDialogPrivate()
{
}
KDateComboBox *m_atDate = nullptr;
KTimeComboBox *m_atTime = nullptr;
QButtonGroup *m_buttons = nullptr;
};
NoteAlarmDialog::NoteAlarmDialog(const QString &caption, QWidget *parent)
: QDialog(parent)
, d(new NoteShared::NoteAlarmDialogPrivate)
{
setWindowTitle(caption);
auto mainLayout = new QVBoxLayout(this);
......@@ -50,13 +38,13 @@ NoteAlarmDialog::NoteAlarmDialog(const QString &caption, QWidget *parent)
auto pageVBoxLayout = new QVBoxLayout(page);
pageVBoxLayout->setContentsMargins(0, 0, 0, 0);
d->m_buttons = new QButtonGroup(this);
m_buttons = new QButtonGroup(this);
auto group = new QGroupBox(i18n("Scheduled Alarm"), page);
pageVBoxLayout->addWidget(group);
auto layout = new QVBoxLayout;
auto none = new QRadioButton(i18n("&No alarm"));
layout->addWidget(none);
d->m_buttons->addButton(none, 0);
m_buttons->addButton(none, 0);
group->setLayout(layout);
......@@ -65,21 +53,21 @@ NoteAlarmDialog::NoteAlarmDialog(const QString &caption, QWidget *parent)
atHBoxLayout->setContentsMargins(0, 0, 0, 0);
auto label_at = new QRadioButton(i18n("Alarm &at:"), at);
atHBoxLayout->addWidget(label_at);
d->m_atDate = new KDateComboBox(at);
atHBoxLayout->addWidget(d->m_atDate);
d->m_atTime = new KTimeComboBox(at);
atHBoxLayout->addWidget(d->m_atTime);
m_atDate = new KDateComboBox(at);
atHBoxLayout->addWidget(m_atDate);
m_atTime = new KTimeComboBox(at);
atHBoxLayout->addWidget(m_atTime);
const QDateTime dateTime = QDateTime::currentDateTime();
d->m_atDate->setMinimumDate(dateTime.date());
d->m_atTime->setMinimumTime(dateTime.time());
atHBoxLayout->setStretchFactor(d->m_atDate, 1);
m_atDate->setMinimumDate(dateTime.date());
m_atTime->setMinimumTime(dateTime.time());
atHBoxLayout->setStretchFactor(m_atDate, 1);
layout->addWidget(at);
d->m_buttons->addButton(label_at, 1);
m_buttons->addButton(label_at, 1);
connect(d->m_buttons, qOverload<QAbstractButton *>(&QButtonGroup::buttonClicked), this, &NoteAlarmDialog::slotButtonChanged);
connect(m_buttons, qOverload<QAbstractButton *>(&QButtonGroup::buttonClicked), this, &NoteAlarmDialog::slotButtonChanged);
connect(okButton, &QPushButton::clicked, this, &NoteAlarmDialog::accept);
d->m_buttons->button(0)->setChecked(true);
slotButtonChanged(d->m_buttons->checkedButton());
m_buttons->button(0)->setChecked(true);
slotButtonChanged(m_buttons->checkedButton());
mainLayout->addWidget(page);
mainLayout->addWidget(buttonBox);
}
......@@ -89,27 +77,27 @@ NoteAlarmDialog::~NoteAlarmDialog() = default;
void NoteAlarmDialog::setAlarm(const QDateTime &dateTime)
{
if (dateTime.isValid()) {
d->m_buttons->button(1)->setChecked(true);
d->m_atDate->setDate(dateTime.date());
d->m_atTime->setTime(dateTime.time());
m_buttons->button(1)->setChecked(true);
m_atDate->setDate(dateTime.date());
m_atTime->setTime(dateTime.time());
} else {
d->m_buttons->button(0)->setChecked(true);
m_buttons->button(0)->setChecked(true);
}
slotButtonChanged(d->m_buttons->checkedButton());
slotButtonChanged(m_buttons->checkedButton());
}
void NoteAlarmDialog::slotButtonChanged(QAbstractButton *button)
{
if (button) {
const int id = d->m_buttons->id(button);
const int id = m_buttons->id(button);
switch (id) {
case 0:
d->m_atDate->setEnabled(false);
d->m_atTime->setEnabled(false);
m_atDate->setEnabled(false);
m_atTime->setEnabled(false);
break;
case 1:
d->m_atDate->setEnabled(true);
d->m_atTime->setEnabled(true);
m_atDate->setEnabled(true);
m_atTime->setEnabled(true);
break;
}
}
......@@ -117,8 +105,8 @@ void NoteAlarmDialog::slotButtonChanged(QAbstractButton *button)
QDateTime NoteAlarmDialog::alarm() const
{
if (d->m_buttons->checkedId() == 1) {
return QDateTime(d->m_atDate->date(), d->m_atTime->time());
if (m_buttons->checkedId() == 1) {
return QDateTime(m_atDate->date(), m_atTime->time());
} else {
return QDateTime();
}
......
......@@ -11,10 +11,11 @@
#include "noteshared_export.h"
#include <QDialog>
#include <memory>
class QDateTime;
class QAbstractButton;
class KDateComboBox;
class KTimeComboBox;
class QButtonGroup;
namespace NoteShared
{
class NoteAlarmDialogPrivate;
......@@ -31,7 +32,9 @@ private:
void slotButtonChanged(QAbstractButton *button);
private:
std::unique_ptr<NoteAlarmDialogPrivate> const d;
KDateComboBox *m_atDate = nullptr;
KTimeComboBox *m_atTime = nullptr;
QButtonGroup *m_buttons = nullptr;
};
}
......@@ -19,21 +19,9 @@
#include <QWhatsThis>
using namespace NoteShared;
class NoteShared::NoteNetworkConfigWidgetPrivate
{
public:
NoteNetworkConfigWidgetPrivate()
{
}
QCheckBox *mTmpChkB = nullptr;
QLineEdit *kcfg_SenderID = nullptr;
QSpinBox *kcfg_Port = nullptr;
};
NoteNetworkConfigWidget::NoteNetworkConfigWidget(QWidget *parent)
: QWidget(parent)
, d(new NoteShared::NoteNetworkConfigWidgetPrivate)
{
auto layout = new QVBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
......@@ -41,9 +29,9 @@ NoteNetworkConfigWidget::NoteNetworkConfigWidget(QWidget *parent)
auto incoming = new QGroupBox(i18n("Incoming Notes"));
auto tmpLayout = new QHBoxLayout;
d->mTmpChkB = new QCheckBox(i18n("Accept incoming notes"));
d->mTmpChkB->setObjectName(QStringLiteral("kcfg_ReceiveNotes"));
tmpLayout->addWidget(d->mTmpChkB);
mTmpChkB = new QCheckBox(i18n("Accept incoming notes"));
mTmpChkB->setObjectName(QStringLiteral("kcfg_ReceiveNotes"));
tmpLayout->addWidget(mTmpChkB);
incoming->setLayout(tmpLayout);
layout->addWidget(incoming);
......@@ -51,12 +39,12 @@ NoteNetworkConfigWidget::NoteNetworkConfigWidget(QWidget *parent)
tmpLayout = new QHBoxLayout;
auto label_SenderID = new QLabel(i18n("&Sender ID:"));
d->kcfg_SenderID = new QLineEdit;
d->kcfg_SenderID->setClearButtonEnabled(true);
d->kcfg_SenderID->setObjectName(QStringLiteral("kcfg_SenderID"));
label_SenderID->setBuddy(d->kcfg_SenderID);
m_kcfg_SenderID = new QLineEdit;
m_kcfg_SenderID->setClearButtonEnabled(true);
m_kcfg_SenderID->setObjectName(QStringLiteral("kcfg_SenderID"));
label_SenderID->setBuddy(m_kcfg_SenderID);
tmpLayout->addWidget(label_SenderID);
tmpLayout->addWidget(d->kcfg_SenderID);
tmpLayout->addWidget(m_kcfg_SenderID);
outgoing->setLayout(tmpLayout);
layout->addWidget(outgoing);
......@@ -66,11 +54,11 @@ NoteNetworkConfigWidget::NoteNetworkConfigWidget(QWidget *parent)
tmpLayout->addWidget(label_Port);
d->kcfg_Port = new QSpinBox;
d->kcfg_Port->setObjectName(QStringLiteral("kcfg_Port"));
d->kcfg_Port->setRange(0, 65535);
label_Port->setBuddy(d->kcfg_Port);
tmpLayout->addWidget(d->kcfg_Port);
kcfg_Port = new QSpinBox;
kcfg_Port->setObjectName(QStringLiteral("kcfg_Port"));
kcfg_Port->setRange(0, 65535);
label_Port->setBuddy(kcfg_Port);
tmpLayout->addWidget(kcfg_Port);
layout->addLayout(tmpLayout);
layout->addStretch();
load();
......@@ -80,17 +68,17 @@ NoteNetworkConfigWidget::~NoteNetworkConfigWidget() = default;
void NoteNetworkConfigWidget::save()
{
NoteShared::NoteSharedGlobalConfig::self()->setReceiveNotes(d->mTmpChkB->isChecked());
NoteShared::NoteSharedGlobalConfig::self()->setSenderID(d->kcfg_SenderID->text());
NoteShared::NoteSharedGlobalConfig::self()->setPort(d->kcfg_Port->value());
NoteShared::NoteSharedGlobalConfig::self()->setReceiveNotes(mTmpChkB->isChecked());
NoteShared::NoteSharedGlobalConfig::self()->setSenderID(m_kcfg_SenderID->text());
NoteShared::NoteSharedGlobalConfig::self()->setPort(kcfg_Port->value());
NoteShared::NoteSharedGlobalConfig::self()->save();
}
void NoteNetworkConfigWidget::load()
{
d->mTmpChkB->setChecked(NoteShared::NoteSharedGlobalConfig::self()->receiveNotes());
d->kcfg_SenderID->setText(NoteShared::NoteSharedGlobalConfig::self()->senderID());
d->kcfg_Port->setValue(NoteShared::NoteSharedGlobalConfig::self()->port());
mTmpChkB->setChecked(NoteShared::NoteSharedGlobalConfig::self()->receiveNotes());
m_kcfg_SenderID->setText(NoteShared::NoteSharedGlobalConfig::self()->senderID());
kcfg_Port->setValue(NoteShared::NoteSharedGlobalConfig::self()->port());
}
NoteNetworkConfig::NoteNetworkConfig(QWidget *parent, const QVariantList &args)
......
......@@ -7,8 +7,9 @@
#include "noteshared_export.h"
#include <KCModule>
#include <memory>
class QCheckBox;
class QLineEdit;
class QSpinBox;
namespace NoteShared
{
class NoteNetworkConfigWidgetPrivate;
......@@ -23,7 +24,9 @@ public:
void load();
private:
std::unique_ptr<NoteNetworkConfigWidgetPrivate> const d;
QCheckBox *mTmpChkB = nullptr;
QLineEdit *m_kcfg_SenderID = nullptr;
QSpinBox *kcfg_Port = nullptr;
};
class NOTESHARED_EXPORT NoteNetworkConfig : public KCModule
......
......@@ -27,23 +27,9 @@
using namespace NoteShared;
class NoteShared::CreateNewNoteJobPrivate
{
public:
CreateNewNoteJobPrivate(QWidget *widget)
: mWidget(widget)
{
}
QString mTitle;
QString mText;
bool mRichText = false;
QWidget *const mWidget;
};
CreateNewNoteJob::CreateNewNoteJob(QObject *parent, QWidget *widget)
: QObject(parent)
, d(new NoteShared::CreateNewNoteJobPrivate(widget))
, mWidget(widget)
{
connect(this, &CreateNewNoteJob::selectNewCollection, this, &CreateNewNoteJob::slotSelectNewCollection);
}
......@@ -57,13 +43,13 @@ void CreateNewNoteJob::slotSelectNewCollection()
void CreateNewNoteJob::setNote(const QString &name, const QString &text)
{
d->mTitle = name;
d->mText = text;
mTitle = name;
mText = text;
}
void CreateNewNoteJob::setRichText(bool richText)
{
d->mRichText = richText;
mRichText = richText;
}
void CreateNewNoteJob::start()
......@@ -81,7 +67,7 @@ void CreateNewNoteJob::createFetchCollectionJob(bool useSettings)
NoteShared::NoteSharedGlobalConfig::self()->setDefaultFolder(id);
}
if (id == -1) {
QPointer<SelectedNotefolderDialog> dlg = new SelectedNotefolderDialog(d->mWidget);
QPointer<SelectedNotefolderDialog> dlg = new SelectedNotefolderDialog(mWidget);
if (dlg->exec()) {
col = dlg->selectedCollection();
} else {
......@@ -141,25 +127,25 @@ void CreateNewNoteJob::slotFetchCollection(KJob *job)
KMime::Message::Ptr newPage = KMime::Message::Ptr(new KMime::Message());
QString title;
if (d->mTitle.isEmpty()) {
if (mTitle.isEmpty()) {
const QDateTime currentDateTime = QDateTime::currentDateTime();
title = NoteShared::NoteSharedGlobalConfig::self()->defaultTitle();
title.replace(QStringLiteral("%t"), QLocale().toString(currentDateTime.time()));
title.replace(QStringLiteral("%d"), QLocale().toString(currentDateTime.date(), QLocale::ShortFormat));
title.replace(QStringLiteral("%l"), QLocale().toString(currentDateTime.date(), QLocale::LongFormat));
} else {
title = d->mTitle;
title = mTitle;
}
QByteArray encoding("utf-8");
newPage->subject(true)->fromUnicodeString(title, encoding);
newPage->contentType(true)->setMimeType(d->mRichText ? "text/html" : "text/plain");
newPage->contentType(true)->setMimeType(mRichText ? "text/html" : "text/plain");
newPage->contentType()->setCharset("utf-8");
newPage->contentTransferEncoding(true)->setEncoding(KMime::Headers::CEquPr);
newPage->date(true)->setDateTime(QDateTime::currentDateTime());
newPage->from(true)->fromUnicodeString(QStringLiteral("knotes@kde4"), encoding);
// Need a non-empty body part so that the serializer regards this as a valid message.
newPage->mainBodyPart()->fromUnicodeString(d->mText.isEmpty() ? QStringLiteral(" ") : d->mText);
newPage->mainBodyPart()->fromUnicodeString(mText.isEmpty() ? QStringLiteral(" ") : mText);
newPage->assemble();
......@@ -183,7 +169,7 @@ void CreateNewNoteJob::slotNoteCreationFinished(KJob *job)
qCWarning(NOTESHARED_LOG) << job->errorString();
NoteShared::NoteSharedGlobalConfig::self()->setDefaultFolder(-1);
NoteShared::NoteSharedGlobalConfig::self()->save();
KMessageBox::error(d->mWidget, i18n("Note was not created."), i18n("Create new note"));
KMessageBox::error(mWidget, i18n("Note was not created."), i18n("Create new note"));
}
deleteLater();
}
......
......@@ -9,8 +9,6 @@
#include "noteshared_export.h"
#include <memory>
class KJob;
namespace NoteShared
......@@ -43,7 +41,10 @@ private:
void createFetchCollectionJob(bool useSettings);
private:
std::unique_ptr<CreateNewNoteJobPrivate> const d;
QString mTitle;
QString mText;
bool mRichText = false;
QWidget *const mWidget;
};
}
......@@ -9,19 +9,9 @@
#include <KMime/KMimeMessage>
using namespace NoteShared;
class NoteShared::NoteListWidgetPrivate
{
public:
NoteListWidgetPrivate()
{
}
Akonadi::Item::List mNotes;
};
NoteListWidget::NoteListWidget(QWidget *parent)
: QListWidget(parent)
, d(new NoteShared::NoteListWidgetPrivate)
{
setSelectionMode(QAbstractItemView::ExtendedSelection);
}
......@@ -31,11 +21,11 @@ NoteListWidget::~NoteListWidget() = default;
void NoteListWidget::addNotes(const Akonadi::Item::List &notes)
{
for (const Akonadi::Item &note : notes) {
if (d->mNotes.contains(note)) {
if (mNotes.contains(note)) {
continue;
}
createItem(note);
d->mNotes.append(note);
mNotes.append(note);
}
}
......@@ -44,7 +34,7 @@ void NoteListWidget::removeNote(const Akonadi::Item &note)
for (int i = 0; i < count(); ++i) {
if (item(i)->data(AkonadiId) == note.id()) {
delete item(i);
d->mNotes.removeAll(note);
mNotes.removeAll(note);
break;
}
}
......@@ -53,8 +43,8 @@ void NoteListWidget::removeNote(const Akonadi::Item &note)
void NoteListWidget::setNotes(const Akonadi::Item::List &notes)
{
clear();
d->mNotes = notes;
for (const Akonadi::Item &note : std::as_const(d->mNotes)) {
mNotes = notes;
for (const Akonadi::Item &note : std::as_const(mNotes)) {
createItem(note);
}
}
......
......@@ -9,11 +9,9 @@
#include <Akonadi/Item>
#include <QListWidget>
#include <memory>
namespace NoteShared
{
class NoteListWidgetPrivate;
class NOTESHARED_EXPORT NoteListWidget : public QListWidget
{
Q_OBJECT
......@@ -36,7 +34,7 @@ private:
enum listViewData { AkonadiId = Qt::UserRole + 1 };
private:
std::unique_ptr<NoteListWidgetPrivate> const d;
Akonadi::Item::List mNotes;
};
}
Markdown is supported
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