Commit 22b7e053 authored by Laurent Montel's avatar Laurent Montel 😁

Start to create search duplicate emails

parent 976b543c
......@@ -2,6 +2,7 @@ set(kmail_checkbeforesendeditorplugin_SRCS
checkbeforesendplugin.cpp
checkbeforesendinterface.cpp
checkbeforesendconfigurewidget.cpp
checkduplicateemailsdialog.cpp
)
ecm_qt_declare_logging_category(kmail_checkbeforesendeditorplugin_SRCS HEADER checkbeforesendplugin_debug.h IDENTIFIER KMAIL_EDITOR_checkbeforesend_PLUGIN_LOG CATEGORY_NAME log_kmail_checkbeforesendplugin)
......
......@@ -15,3 +15,4 @@ endmacro ()
add_kmail_checkbeforesend_unittest(checkbeforesendplugintest.cpp "../checkbeforesendplugin.cpp;../checkbeforesendinterface.cpp;../checkbeforesendconfigurewidget.cpp")
add_kmail_checkbeforesend_unittest(checkbeforesendinterfacetest.cpp "../checkbeforesendinterface.cpp")
add_kmail_checkbeforesend_unittest(checkbeforesendconfigurewidgettest.cpp "../checkbeforesendconfigurewidget.cpp")
add_kmail_checkbeforesend_unittest(checkduplicateemailsdialogtest.cpp "../checkduplicateemailsdialog.cpp")
......@@ -43,10 +43,18 @@ void CheckBeforeSendConfigureWidgetTest::shouldHaveDefaultValue()
QCheckBox *mCheckPlainTextMail = w.findChild<QCheckBox *>(QStringLiteral("checkplaintext"));
QVERIFY(mCheckPlainTextMail);
QVERIFY(!mCheckPlainTextMail->text().isEmpty());
QVERIFY(!mCheckPlainTextMail->isChecked());
QCheckBox *mCheckMailTransport = w.findChild<QCheckBox *>(QStringLiteral("smtpdefinedinidentity"));
QVERIFY(mCheckMailTransport);
QVERIFY(!mCheckMailTransport->text().isEmpty());
QVERIFY(!mCheckMailTransport->isChecked());
QCheckBox *mCheckDuplicateEmails = w.findChild<QCheckBox *>(QStringLiteral("checkduplicatedemails"));
QVERIFY(mCheckDuplicateEmails);
QVERIFY(!mCheckDuplicateEmails->text().isEmpty());
QVERIFY(!mCheckDuplicateEmails->isChecked());
}
QTEST_MAIN(CheckBeforeSendConfigureWidgetTest)
/*
Copyright (C) 2016 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program 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
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "checkduplicateemailsdialogtest.h"
#include <QTest>
CheckDuplicateEmailsDialogTest::CheckDuplicateEmailsDialogTest(QObject *parent)
: QObject(parent)
{
}
CheckDuplicateEmailsDialogTest::~CheckDuplicateEmailsDialogTest()
{
}
QTEST_MAIN(CheckDuplicateEmailsDialogTest)
/*
Copyright (C) 2016 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program 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
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef CHECKDUPLICATEEMAILSDIALOGTEST_H
#define CHECKDUPLICATEEMAILSDIALOGTEST_H
#include <QObject>
class CheckDuplicateEmailsDialogTest : public QObject
{
Q_OBJECT
public:
explicit CheckDuplicateEmailsDialogTest(QObject *parent = Q_NULLPTR);
~CheckDuplicateEmailsDialogTest();
};
#endif // CHECKDUPLICATEEMAILSDIALOGTEST_H
......@@ -40,6 +40,11 @@ CheckBeforeSendConfigureWidget::CheckBeforeSendConfigureWidget(QWidget *parent)
connect(mCheckMailTransport, &QCheckBox::clicked, this, &CheckBeforeSendConfigureWidget::configureChanged);
mainLayout->addWidget(mCheckMailTransport);
mCheckDuplicateEmails = new QCheckBox(i18n("Check duplicated emails"), this);
mCheckDuplicateEmails->setObjectName(QStringLiteral("checkduplicatedemails"));
connect(mCheckDuplicateEmails, &QCheckBox::clicked, this, &CheckBeforeSendConfigureWidget::configureChanged);
mainLayout->addWidget(mCheckDuplicateEmails);
mainLayout->addStretch(1);
}
......@@ -53,6 +58,7 @@ void CheckBeforeSendConfigureWidget::loadSettings()
KConfigGroup grp(KSharedConfig::openConfig(), "Check Before Send");
mCheckPlainTextMail->setChecked(grp.readEntry("SendPlainText", false));
mCheckMailTransport->setChecked(grp.readEntry("SmtpDefinedInIdentity", false));
mCheckDuplicateEmails->setChecked(grp.readEntry("CheckDuplicatedEmails", false));
}
void CheckBeforeSendConfigureWidget::saveSettings()
......@@ -60,6 +66,7 @@ void CheckBeforeSendConfigureWidget::saveSettings()
KConfigGroup grp(KSharedConfig::openConfig(), "Check Before Send");
grp.writeEntry("SendPlainText", mCheckPlainTextMail->isChecked());
grp.writeEntry("SmtpDefinedInIdentity", mCheckMailTransport->isChecked());
grp.writeEntry("CheckDuplicatedEmails", mCheckDuplicateEmails->isChecked());
}
void CheckBeforeSendConfigureWidget::resetSettings()
......
......@@ -38,6 +38,7 @@ public:
private:
QCheckBox *mCheckPlainTextMail;
QCheckBox *mCheckMailTransport;
QCheckBox *mCheckDuplicateEmails;
};
#endif // CHECKBEFORESENDCONFIGUREWIDGET_H
......@@ -30,7 +30,8 @@ CheckBeforeSendInterface::CheckBeforeSendInterface(QObject *parent)
: MessageComposer::PluginEditorCheckBeforeSendInterface(parent),
mIdentityManager(Q_NULLPTR),
mSendPlainText(false),
mCheckMailTransport(false)
mCheckMailTransport(false),
mCheckDuplicateEmails(false)
{
reloadConfig();
}
......@@ -64,6 +65,9 @@ bool CheckBeforeSendInterface::exec(const MessageComposer::PluginEditorCheckBefo
}
}
}
if (mCheckDuplicateEmails) {
//TODO
}
return true;
}
......@@ -72,4 +76,5 @@ void CheckBeforeSendInterface::reloadConfig()
KConfigGroup grp(KSharedConfig::openConfig(), "Check Before Send");
mSendPlainText = grp.readEntry("SendPlainText", false);
mCheckMailTransport = grp.readEntry("SmtpDefinedInIdentity", false);
mCheckDuplicateEmails = grp.readEntry("CheckDuplicatedEmails", false);
}
......@@ -40,6 +40,7 @@ private:
KIdentityManagement::IdentityManager *mIdentityManager;
bool mSendPlainText;
bool mCheckMailTransport;
bool mCheckDuplicateEmails;
};
#endif // CHECKBEFORESENDINTERFACE_H
/*
Copyright (C) 2016 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program 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
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "checkduplicateemailsdialog.h"
#include <KLocalizedString>
#include <QVBoxLayout>
#include <QDialogButtonBox>
#include <QListWidget>
#include <KConfigGroup>
#include <KSharedConfig>
CheckDuplicateEmailsDialog::CheckDuplicateEmailsDialog(QWidget *parent)
: QDialog(parent)
{
QVBoxLayout *mainLayout = new QVBoxLayout(this);
mListWidget = new QListWidget(this);
mListWidget->setObjectName(QStringLiteral("listwidget"));
mainLayout->addWidget(mListWidget);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel, this);
buttonBox->setObjectName(QStringLiteral("buttonbox"));
connect(buttonBox, &QDialogButtonBox::accepted, this, &CheckDuplicateEmailsDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &CheckDuplicateEmailsDialog::reject);
mainLayout->addWidget(buttonBox);
}
CheckDuplicateEmailsDialog::~CheckDuplicateEmailsDialog()
{
}
void CheckDuplicateEmailsDialog::writeConfig()
{
KConfigGroup group(KSharedConfig::openConfig(), "CheckDuplicateEmailsDialog");
group.writeEntry("Size", size());
}
void CheckDuplicateEmailsDialog::readConfig()
{
KConfigGroup group(KSharedConfig::openConfig(), "CheckDuplicateEmailsDialog");
const QSize sizeDialog = group.readEntry("Size", QSize(500, 300));
if (sizeDialog.isValid()) {
resize(sizeDialog);
}
}
/*
Copyright (C) 2016 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program 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
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef CHECKDUPLICATEEMAILSDIALOG_H
#define CHECKDUPLICATEEMAILSDIALOG_H
#include <QDialog>
class QListWidget;
class CheckDuplicateEmailsDialog : public QDialog
{
Q_OBJECT
public:
explicit CheckDuplicateEmailsDialog(QWidget *parent = Q_NULLPTR);
~CheckDuplicateEmailsDialog();
private:
void readConfig();
void writeConfig();
QListWidget *mListWidget;
};
#endif // CHECKDUPLICATEEMAILSDIALOG_H
......@@ -31,6 +31,8 @@ ConfirmAddressCheckJob::~ConfirmAddressCheckJob()
void ConfirmAddressCheckJob::start()
{
mValidEmails.clear();
mInvalidEmails.clear();
bool foundValidEmail = false;
Q_FOREACH (const QString &email, mAddressList) {
if (email.isEmpty()) {
......
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