summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <[email protected]>2015-09-07 13:30:40 +0200
committerMontel Laurent <[email protected]>2015-09-07 14:01:13 +0200
commitbfbe36c7c71f496952108d28b4c05aa31a036685 (patch)
treea752133dfa79e96bdab319e3af38cc6790dbbcd9
parent24522e217bbdbac1d113f22a9741b38d63f6ed6b (diff)
Use private class
-rw-r--r--libkdepim/widgets/overlaywidget.cpp37
-rw-r--r--libkdepim/widgets/overlaywidget.h3
-rw-r--r--libkdepim/widgets/tagwidgets.cpp24
-rw-r--r--libkdepim/widgets/tagwidgets.h4
-rw-r--r--mailcommon/folder/folderrequester.h5
-rw-r--r--mailcommon/tag/addtagdialog.cpp61
-rw-r--r--mailcommon/tag/addtagdialog.h9
7 files changed, 92 insertions, 51 deletions
diff --git a/libkdepim/widgets/overlaywidget.cpp b/libkdepim/widgets/overlaywidget.cpp
index 104b5ba..2dc561d 100644
--- a/libkdepim/widgets/overlaywidget.cpp
+++ b/libkdepim/widgets/overlaywidget.cpp
@@ -34,8 +34,20 @@
using namespace KPIM;
+class KPIM::OverlayWidgetPrivate
+{
+public:
+ OverlayWidgetPrivate()
+ : mAlignWidget(Q_NULLPTR)
+ {
+
+ }
+
+ QWidget *mAlignWidget;
+};
+
OverlayWidget::OverlayWidget(QWidget *alignWidget, QWidget *parent)
- : QFrame(parent), mAlignWidget(Q_NULLPTR)
+ : QFrame(parent), d(new KPIM::OverlayWidgetPrivate)
{
setAlignWidget(alignWidget);
setLayout(new QHBoxLayout(this));
@@ -43,25 +55,26 @@ OverlayWidget::OverlayWidget(QWidget *alignWidget, QWidget *parent)
OverlayWidget::~OverlayWidget()
{
+ delete d;
}
QWidget *OverlayWidget::alignWidget() const
{
- return mAlignWidget;
+ return d->mAlignWidget;
}
void OverlayWidget::reposition()
{
- if (!mAlignWidget) {
+ if (!d->mAlignWidget) {
return;
}
// p is in the alignWidget's coordinates
QPoint p;
// We are always above the alignWidget, right-aligned with it.
- p.setX(mAlignWidget->width() - width());
+ p.setX(d->mAlignWidget->width() - width());
p.setY(-height());
// Position in the toplevelwidget's coordinates
- QPoint pTopLevel = mAlignWidget->mapTo(topLevelWidget(), p);
+ QPoint pTopLevel = d->mAlignWidget->mapTo(topLevelWidget(), p);
// Position in the widget's parentWidget coordinates
QPoint pParent = parentWidget()->mapFrom(topLevelWidget(), pTopLevel);
// Move 'this' to that position.
@@ -70,18 +83,18 @@ void OverlayWidget::reposition()
void OverlayWidget::setAlignWidget(QWidget *w)
{
- if (w == mAlignWidget) {
+ if (w == d->mAlignWidget) {
return;
}
- if (mAlignWidget) {
- mAlignWidget->removeEventFilter(this);
+ if (d->mAlignWidget) {
+ d->mAlignWidget->removeEventFilter(this);
}
- mAlignWidget = w;
+ d->mAlignWidget = w;
- if (mAlignWidget) {
- mAlignWidget->installEventFilter(this);
+ if (d->mAlignWidget) {
+ d->mAlignWidget->installEventFilter(this);
}
reposition();
@@ -89,7 +102,7 @@ void OverlayWidget::setAlignWidget(QWidget *w)
bool OverlayWidget::eventFilter(QObject *o, QEvent *e)
{
- if (o == mAlignWidget &&
+ if (o == d->mAlignWidget &&
(e->type() == QEvent::Move || e->type() == QEvent::Resize)) {
reposition();
}
diff --git a/libkdepim/widgets/overlaywidget.h b/libkdepim/widgets/overlaywidget.h
index 203ff63..ca5b5e8 100644
--- a/libkdepim/widgets/overlaywidget.h
+++ b/libkdepim/widgets/overlaywidget.h
@@ -47,6 +47,7 @@ namespace KPIM
* Currently the only supported type of alignment is "right aligned, on top of the other widget".
*
*/
+class OverlayWidgetPrivate;
class KDEPIM_EXPORT OverlayWidget : public QFrame
{
Q_OBJECT
@@ -66,7 +67,7 @@ private:
void reposition();
private:
- QWidget *mAlignWidget;
+ OverlayWidgetPrivate *const d;
};
} // namespace
diff --git a/libkdepim/widgets/tagwidgets.cpp b/libkdepim/widgets/tagwidgets.cpp
index 839e90b..4bd4449 100644
--- a/libkdepim/widgets/tagwidgets.cpp
+++ b/libkdepim/widgets/tagwidgets.cpp
@@ -81,15 +81,31 @@ QStringList TagWidget::selection() const
return mCachedTagNames;
}
+class KPIM::TagSelectionDialogPrivate
+{
+public:
+ TagSelectionDialogPrivate()
+ {
+
+ }
+
+ Akonadi::Tag::List mTagList;
+};
TagSelectionDialog::TagSelectionDialog(QWidget *parent)
- : Akonadi::TagSelectionDialog(parent)
+ : Akonadi::TagSelectionDialog(parent),
+ d(new KPIM::TagSelectionDialogPrivate)
{
}
+TagSelectionDialog::~TagSelectionDialog()
+{
+ delete d;
+}
+
void TagSelectionDialog::setSelection(const QStringList &tagNames)
{
- mTagList.clear();
+ d->mTagList.clear();
foreach (const QString &name, tagNames) {
//TODO fetch by GID instead, we don't really want to create tags here
Akonadi::TagCreateJob *tagCreateJob = new Akonadi::TagCreateJob(Akonadi::Tag::genericTag(name), this);
@@ -105,8 +121,8 @@ void TagSelectionDialog::onTagCreated(KJob *job)
return;
}
Akonadi::TagCreateJob *createJob = static_cast<Akonadi::TagCreateJob *>(job);
- mTagList << createJob->tag();
- Akonadi::TagSelectionDialog::setSelection(mTagList);
+ d->mTagList << createJob->tag();
+ Akonadi::TagSelectionDialog::setSelection(d->mTagList);
}
QStringList TagSelectionDialog::selection() const
diff --git a/libkdepim/widgets/tagwidgets.h b/libkdepim/widgets/tagwidgets.h
index 89b2ffe..63dec7d 100644
--- a/libkdepim/widgets/tagwidgets.h
+++ b/libkdepim/widgets/tagwidgets.h
@@ -53,11 +53,13 @@ private:
QStringList mCachedTagNames;
};
+class TagSelectionDialogPrivate;
class KDEPIM_EXPORT TagSelectionDialog : public Akonadi::TagSelectionDialog
{
Q_OBJECT
public:
explicit TagSelectionDialog(QWidget *parent = Q_NULLPTR);
+ ~TagSelectionDialog();
void setSelection(const QStringList &);
QStringList selection() const;
Akonadi::Tag::List tagSelection() const;
@@ -66,7 +68,7 @@ private Q_SLOTS:
void onTagCreated(KJob *);
private:
- Akonadi::Tag::List mTagList;
+ TagSelectionDialogPrivate *const d;
};
}
diff --git a/mailcommon/folder/folderrequester.h b/mailcommon/folder/folderrequester.h
index 726524c..1628e3f 100644
--- a/mailcommon/folder/folderrequester.h
+++ b/mailcommon/folder/folderrequester.h
@@ -121,11 +121,6 @@ protected:
protected:
FolderRequesterPrivate *const d;
- Akonadi::Collection mCollection;
- KLineEdit *mEdit;
- bool mMustBeReadWrite;
- bool mShowOutbox;
- bool mNotCreateNewFolder;
};
}
diff --git a/mailcommon/tag/addtagdialog.cpp b/mailcommon/tag/addtagdialog.cpp
index 0467367..b4c66cd 100644
--- a/mailcommon/tag/addtagdialog.cpp
+++ b/mailcommon/tag/addtagdialog.cpp
@@ -31,65 +31,84 @@
#include <QPushButton>
using namespace MailCommon;
+class MailCommon::AddTagDialogPrivate
+{
+public:
+ AddTagDialogPrivate()
+ : mTagWidget(Q_NULLPTR),
+ mOkButton(Q_NULLPTR)
+ {
+
+ }
+
+ QString mLabel;
+ QString mGid;
+ MailCommon::TagWidget *mTagWidget;
+ QList<MailCommon::Tag::Ptr> mTags;
+ Akonadi::Tag mTag;
+ QPushButton *mOkButton;
+};
AddTagDialog::AddTagDialog(const QList<KActionCollection *> &actions, QWidget *parent)
- : QDialog(parent)
+ : QDialog(parent),
+ d(new MailCommon::AddTagDialogPrivate)
{
setModal(true);
setWindowTitle(i18n("Add Tag"));
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
QVBoxLayout *mainLayout = new QVBoxLayout;
setLayout(mainLayout);
- mOkButton = buttonBox->button(QDialogButtonBox::Ok);
- mOkButton->setDefault(true);
- mOkButton->setShortcut(Qt::CTRL | Qt::Key_Return);
+ d->mOkButton = buttonBox->button(QDialogButtonBox::Ok);
+ d->mOkButton->setDefault(true);
+ d->mOkButton->setShortcut(Qt::CTRL | Qt::Key_Return);
connect(buttonBox, &QDialogButtonBox::accepted, this, &AddTagDialog::slotSave);
connect(buttonBox, &QDialogButtonBox::rejected, this, &AddTagDialog::reject);
- mOkButton->setDefault(true);
+ d->mOkButton->setDefault(true);
- mTagWidget = new MailCommon::TagWidget(actions, this);
+ d->mTagWidget = new MailCommon::TagWidget(actions, this);
- connect(mTagWidget->tagNameLineEdit(), &KLineEdit::textChanged, this, &AddTagDialog::slotTagNameChanged);
- mOkButton->setEnabled(false);
- mainLayout->addWidget(mTagWidget);
+ connect(d->mTagWidget->tagNameLineEdit(), &KLineEdit::textChanged, this, &AddTagDialog::slotTagNameChanged);
+ d->mOkButton->setEnabled(false);
+ mainLayout->addWidget(d->mTagWidget);
mainLayout->addWidget(buttonBox);
}
AddTagDialog::~AddTagDialog()
{
+ delete d;
}
void AddTagDialog::setTags(const QList<MailCommon::Tag::Ptr> &tags)
{
- mTags = tags;
+ d->mTags = tags;
}
void AddTagDialog::slotTagNameChanged(const QString &text)
{
- mOkButton->setEnabled(!text.trimmed().isEmpty());
+ d->mOkButton->setEnabled(!text.trimmed().isEmpty());
}
void AddTagDialog::slotSave()
{
- const QString name(mTagWidget->tagNameLineEdit()->text());
+ const QString name(d->mTagWidget->tagNameLineEdit()->text());
- Q_FOREACH (const MailCommon::Tag::Ptr &tag, mTags) {
+ Q_FOREACH (const MailCommon::Tag::Ptr &tag, d->mTags) {
if (tag->name() == name) {
KMessageBox::error(this, i18n("Tag %1 already exists", name));
- mTagWidget->tagNameLineEdit()->setFocus();
- mTagWidget->tagNameLineEdit()->selectAll();
+ d->mTagWidget->tagNameLineEdit()->setFocus();
+ d->mTagWidget->tagNameLineEdit()->selectAll();
return;
}
}
MailCommon::Tag::Ptr tag(Tag::createDefaultTag(name));
- mTagWidget->recordTagSettings(tag);
- MailCommon::Tag::SaveFlags saveFlags = mTagWidget->saveFlags();
+ d->mTagWidget->recordTagSettings(tag);
+ MailCommon::Tag::SaveFlags saveFlags = d->mTagWidget->saveFlags();
const Akonadi::Tag akonadiTag = tag->saveToAkonadi(saveFlags);
Akonadi::TagCreateJob *createJob = new Akonadi::TagCreateJob(akonadiTag, this);
connect(createJob, &Akonadi::TagCreateJob::result, this, &AddTagDialog::onTagCreated);
- mLabel = name;
+ d->mLabel = name;
}
void AddTagDialog::onTagCreated(KJob *job)
@@ -100,17 +119,17 @@ void AddTagDialog::onTagCreated(KJob *job)
return;
}
Akonadi::TagCreateJob *createJob = static_cast<Akonadi::TagCreateJob *>(job);
- mTag = createJob->tag();
+ d->mTag = createJob->tag();
accept();
}
QString AddTagDialog::label() const
{
- return mLabel;
+ return d->mLabel;
}
Akonadi::Tag AddTagDialog::tag() const
{
- return mTag;
+ return d->mTag;
}
diff --git a/mailcommon/tag/addtagdialog.h b/mailcommon/tag/addtagdialog.h
index 50f1b9c..9311d54 100644
--- a/mailcommon/tag/addtagdialog.h
+++ b/mailcommon/tag/addtagdialog.h
@@ -29,7 +29,7 @@ class KActionCollection;
namespace MailCommon
{
class TagWidget;
-
+class AddTagDialogPrivate;
class MAILCOMMON_EXPORT AddTagDialog : public QDialog
{
Q_OBJECT
@@ -47,12 +47,7 @@ private Q_SLOTS:
void onTagCreated(KJob *job);
private:
- QString mLabel;
- QString mGid;
- MailCommon::TagWidget *mTagWidget;
- QList<MailCommon::Tag::Ptr> mTags;
- Akonadi::Tag mTag;
- QPushButton *mOkButton;
+ AddTagDialogPrivate *const d;
};
}
#endif // ADDTAGDIALOG_H