continue to split class in own files

wilder
Montel Laurent 10 years ago
parent 4c0e7157f9
commit 22fce9dea6
  1. 1
      src/CMakeLists.txt
  2. 89
      src/filter/dialog/filteractionmissingargumentdialog.cpp
  3. 23
      src/filter/dialog/filteractionmissingargumentdialog.h
  4. 124
      src/filter/dialog/filteractionmissingtagdialog.cpp
  5. 51
      src/filter/dialog/filteractionmissingtagdialog.h
  6. 4
      src/filter/filteractions/filteractionaddtag.cpp

@ -66,6 +66,7 @@ set(libmailcommon_filter_dialog
filter/dialog/selectthunderbirdfilterfileswidget.cpp
filter/dialog/filteractionmissingargumentdialog.cpp
filter/dialog/filteractionmissingsoundurldialog.cpp
filter/dialog/filteractionmissingtagdialog.cpp
)

@ -457,92 +457,3 @@ bool FilterActionMissingAccountDialog::allAccountExist(const QStringList &lst)
}
return true;
}
FilterActionMissingTagDialog::FilterActionMissingTagDialog(
const QMap<QUrl, QString> &tagList, const QString &filtername,
const QString &argsStr, QWidget *parent)
: QDialog(parent)
{
setModal(true);
setWindowTitle(i18n("Select Tag"));
QVBoxLayout *mainLayout = new QVBoxLayout(this);
QWidget *mainWidget = new QWidget(this);
mainLayout->addWidget(mainWidget);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
okButton->setDefault(true);
okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
QPushButton *user1Button = new QPushButton;
buttonBox->addButton(user1Button, QDialogButtonBox::ActionRole);
connect(buttonBox, &QDialogButtonBox::accepted, this, &FilterActionMissingTagDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &FilterActionMissingTagDialog::reject);
mainLayout->addWidget(buttonBox);
okButton->setDefault(true);
user1Button->setText(i18n("Add Tag..."));
QVBoxLayout *lay = new QVBoxLayout(mainWidget);
QLabel *label = new QLabel(i18n("Tag was \"%1\".", argsStr));
lay->addWidget(label);
label = new QLabel(this);
label->setText(i18n("Filter tag is missing. "
"Please select a tag to use with filter \"%1\"",
filtername));
label->setWordWrap(true);
lay->addWidget(label);
mTagList = new QListWidget(this);
QMapIterator<QUrl, QString> map(tagList);
while (map.hasNext()) {
map.next();
QListWidgetItem *item = new QListWidgetItem(map.value());
item->setData(UrlData, map.key().toString());
mTagList->addItem(item);
}
connect(user1Button, &QPushButton::clicked, this, &FilterActionMissingTagDialog::slotAddTag);
connect(mTagList, &QListWidget::itemDoubleClicked, this, &FilterActionMissingTagDialog::accept);
lay->addWidget(mTagList);
readConfig();
}
FilterActionMissingTagDialog::~FilterActionMissingTagDialog()
{
writeConfig();
}
void FilterActionMissingTagDialog::readConfig()
{
KConfigGroup group(KernelIf->config(), "FilterActionMissingTagDialog");
const QSize size = group.readEntry("Size", QSize(500, 300));
if (size.isValid()) {
resize(size);
}
}
void FilterActionMissingTagDialog::writeConfig()
{
KConfigGroup group(KernelIf->config(), "FilterActionMissingTagDialog");
group.writeEntry("Size", size());
}
QString FilterActionMissingTagDialog::selectedTag() const
{
if (mTagList->currentItem()) {
return mTagList->currentItem()->data(UrlData).toString();
}
return QString();
}
void FilterActionMissingTagDialog::slotAddTag()
{
QPointer<MailCommon::AddTagDialog> dlg = new MailCommon::AddTagDialog(QList<KActionCollection *>(), this);
if (dlg->exec()) {
QListWidgetItem *item = new QListWidgetItem(dlg->label());
item->setData(UrlData, dlg->tag().url().url());
mTagList->addItem(item);
}
delete dlg;
}

@ -149,28 +149,5 @@ private:
MailCommon::KMFilterAccountList *mAccountList;
};
class FilterActionMissingTagDialog : public QDialog
{
Q_OBJECT
public:
explicit FilterActionMissingTagDialog(const QMap<QUrl, QString> &templateList,
const QString &filtername,
const QString &argsStr,
QWidget *parent = Q_NULLPTR);
~FilterActionMissingTagDialog();
QString selectedTag() const;
private Q_SLOTS:
void slotAddTag();
private:
void readConfig();
void writeConfig();
enum TypeData {
UrlData = Qt::UserRole + 1
};
QListWidget *mTagList;
};
#endif /* FILTERACTIONMISSINGARGUMENTDIALOG_H */

@ -0,0 +1,124 @@
/*
Copyright (C) 2016 Laurent Montel <montel@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "filteractionmissingtagdialog.h"
#include <KLocalizedString>
#include "tag/addtagdialog.h"
#include "kernel/mailkernel.h"
#include <KConfigGroup>
#include <QDialogButtonBox>
#include <QLabel>
#include <QListWidget>
#include <QPushButton>
#include <QVBoxLayout>
#include <QPointer>
using namespace MailCommon;
FilterActionMissingTagDialog::FilterActionMissingTagDialog(
const QMap<QUrl, QString> &tagList, const QString &filtername,
const QString &argsStr, QWidget *parent)
: QDialog(parent)
{
setModal(true);
setWindowTitle(i18n("Select Tag"));
QVBoxLayout *mainLayout = new QVBoxLayout(this);
QWidget *mainWidget = new QWidget(this);
mainLayout->addWidget(mainWidget);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
okButton->setDefault(true);
okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
QPushButton *user1Button = new QPushButton;
buttonBox->addButton(user1Button, QDialogButtonBox::ActionRole);
connect(buttonBox, &QDialogButtonBox::accepted, this, &FilterActionMissingTagDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &FilterActionMissingTagDialog::reject);
mainLayout->addWidget(buttonBox);
okButton->setDefault(true);
user1Button->setText(i18n("Add Tag..."));
QVBoxLayout *lay = new QVBoxLayout(mainWidget);
QLabel *label = new QLabel(i18n("Tag was \"%1\".", argsStr));
lay->addWidget(label);
label = new QLabel(this);
label->setText(i18n("Filter tag is missing. "
"Please select a tag to use with filter \"%1\"",
filtername));
label->setWordWrap(true);
lay->addWidget(label);
mTagList = new QListWidget(this);
QMapIterator<QUrl, QString> map(tagList);
while (map.hasNext()) {
map.next();
QListWidgetItem *item = new QListWidgetItem(map.value());
item->setData(UrlData, map.key().toString());
mTagList->addItem(item);
}
connect(user1Button, &QPushButton::clicked, this, &FilterActionMissingTagDialog::slotAddTag);
connect(mTagList, &QListWidget::itemDoubleClicked, this, &FilterActionMissingTagDialog::accept);
lay->addWidget(mTagList);
readConfig();
}
FilterActionMissingTagDialog::~FilterActionMissingTagDialog()
{
writeConfig();
}
void FilterActionMissingTagDialog::readConfig()
{
KConfigGroup group(KernelIf->config(), "FilterActionMissingTagDialog");
const QSize size = group.readEntry("Size", QSize(500, 300));
if (size.isValid()) {
resize(size);
}
}
void FilterActionMissingTagDialog::writeConfig()
{
KConfigGroup group(KernelIf->config(), "FilterActionMissingTagDialog");
group.writeEntry("Size", size());
}
QString FilterActionMissingTagDialog::selectedTag() const
{
if (mTagList->currentItem()) {
return mTagList->currentItem()->data(UrlData).toString();
}
return QString();
}
void FilterActionMissingTagDialog::slotAddTag()
{
QPointer<MailCommon::AddTagDialog> dlg = new MailCommon::AddTagDialog(QList<KActionCollection *>(), this);
if (dlg->exec()) {
QListWidgetItem *item = new QListWidgetItem(dlg->label());
item->setData(UrlData, dlg->tag().url().url());
mTagList->addItem(item);
}
delete dlg;
}

@ -0,0 +1,51 @@
/*
Copyright (C) 2016 Laurent Montel <montel@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef FILTERACTIONMISSINGTAGDIALOG_H
#define FILTERACTIONMISSINGTAGDIALOG_H
#include <QDialog>
class QListWidget;
namespace MailCommon {
class FilterActionMissingTagDialog : public QDialog
{
Q_OBJECT
public:
explicit FilterActionMissingTagDialog(const QMap<QUrl, QString> &templateList,
const QString &filtername,
const QString &argsStr,
QWidget *parent = Q_NULLPTR);
~FilterActionMissingTagDialog();
QString selectedTag() const;
private Q_SLOTS:
void slotAddTag();
private:
void readConfig();
void writeConfig();
enum TypeData {
UrlData = Qt::UserRole + 1
};
QListWidget *mTagList;
};
}
#endif // FILTERACTIONMISSINGTAGDIALOG_H

@ -19,7 +19,7 @@
#include "filteractionaddtag.h"
#include "filter/filtermanager.h"
#include "filter/dialog/filteractionmissingargumentdialog.h"
#include "filter/dialog/filteractionmissingtagdialog.h"
#include "PimCommon/MinimumComboBox"
#include <QTextDocument>
@ -108,7 +108,7 @@ bool FilterActionAddTag::argsFromStringInteractive(const QString &argsStr, const
}
const bool index = mList.contains(QUrl(mParameter));
if (!index) {
QPointer<FilterActionMissingTagDialog> dlg = new FilterActionMissingTagDialog(mList, filterName, argsStr);
QPointer<MailCommon::FilterActionMissingTagDialog> dlg = new MailCommon::FilterActionMissingTagDialog(mList, filterName, argsStr);
if (dlg->exec()) {
mParameter = dlg->selectedTag();
needUpdate = true;

Loading…
Cancel
Save