Conflicts: kmail/editor/kmcomposewin.cpp kmail/editor/potentialphishingemail/potentialphishingemailjob.cpp libksieve/ksieveui/autocreatescripts/sieveactionwidgetlister.cpp libksieve/ksieveui/autocreatescripts/sievescriptlistbox.cpp mailcommon/filter/filteractions/filteractionforward.cpp messageviewer/viewer/mailsourceviewer.cpp messageviewer/widgets/mailsourceviewtextbrowserwidget.hwilder-work
commit
5fc50f5284
14 changed files with 381 additions and 27 deletions
@ -0,0 +1,91 @@ |
||||
/*
|
||||
Copyright (c) 2015 Montel Laurent <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 "potentialphishingdetaildialogtest.h" |
||||
#include "../potentialphishingdetaildialog.h" |
||||
#include <QLabel> |
||||
#include <QListWidget> |
||||
#include <qtest_kde.h> |
||||
|
||||
PotentialPhishingDetailDialogTest::PotentialPhishingDetailDialogTest(QObject *parent) |
||||
: QObject(parent) |
||||
{ |
||||
|
||||
} |
||||
|
||||
PotentialPhishingDetailDialogTest::~PotentialPhishingDetailDialogTest() |
||||
{ |
||||
|
||||
} |
||||
|
||||
void PotentialPhishingDetailDialogTest::shouldHaveDefaultValue() |
||||
{ |
||||
PotentialPhishingDetailDialog dlg; |
||||
QLabel *searchLabel = qFindChild<QLabel *>(&dlg, QLatin1String("label")); |
||||
QVERIFY(searchLabel); |
||||
|
||||
QListWidget *listWidget = qFindChild<QListWidget *>(&dlg, QLatin1String("list_widget")); |
||||
QVERIFY(listWidget); |
||||
QCOMPARE(listWidget->count(), 0); |
||||
} |
||||
|
||||
void PotentialPhishingDetailDialogTest::shouldFillList() |
||||
{ |
||||
PotentialPhishingDetailDialog dlg; |
||||
QListWidget *listWidget = qFindChild<QListWidget *>(&dlg, QLatin1String("list_widget")); |
||||
QStringList lst; |
||||
lst << QLatin1String("bla"); |
||||
lst << QLatin1String("bli"); |
||||
lst << QLatin1String("blo"); |
||||
dlg.fillList(lst); |
||||
QCOMPARE(listWidget->count(), lst.count()); |
||||
} |
||||
|
||||
void PotentialPhishingDetailDialogTest::shouldClearListBeforeToAddNew() |
||||
{ |
||||
PotentialPhishingDetailDialog dlg; |
||||
QListWidget *listWidget = qFindChild<QListWidget *>(&dlg, QLatin1String("list_widget")); |
||||
QStringList lst; |
||||
lst << QLatin1String("bla"); |
||||
lst << QLatin1String("bli"); |
||||
lst << QLatin1String("blo"); |
||||
dlg.fillList(lst); |
||||
QCOMPARE(listWidget->count(), lst.count()); |
||||
lst.clear(); |
||||
lst << QLatin1String("bla"); |
||||
lst << QLatin1String("bli"); |
||||
dlg.fillList(lst); |
||||
QCOMPARE(listWidget->count(), lst.count()); |
||||
} |
||||
|
||||
void PotentialPhishingDetailDialogTest::shouldNotAddDuplicateEntries() |
||||
{ |
||||
PotentialPhishingDetailDialog dlg; |
||||
QListWidget *listWidget = qFindChild<QListWidget *>(&dlg, QLatin1String("list_widget")); |
||||
QStringList lst; |
||||
lst << QLatin1String("bla"); |
||||
lst << QLatin1String("blo"); |
||||
lst << QLatin1String("blo"); |
||||
dlg.fillList(lst); |
||||
QCOMPARE(listWidget->count(), (lst.count()-1)); |
||||
|
||||
} |
||||
|
||||
QTEST_KDEMAIN(PotentialPhishingDetailDialogTest, GUI) |
||||
@ -0,0 +1,39 @@ |
||||
/*
|
||||
Copyright (c) 2015 Montel Laurent <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 POTENTIALPHISHINGDETAILDIALOGTEST_H |
||||
#define POTENTIALPHISHINGDETAILDIALOGTEST_H |
||||
|
||||
#include <QObject> |
||||
|
||||
class PotentialPhishingDetailDialogTest : public QObject |
||||
{ |
||||
Q_OBJECT |
||||
public: |
||||
explicit PotentialPhishingDetailDialogTest(QObject *parent = 0); |
||||
~PotentialPhishingDetailDialogTest(); |
||||
private Q_SLOTS: |
||||
void shouldHaveDefaultValue(); |
||||
void shouldFillList(); |
||||
void shouldClearListBeforeToAddNew(); |
||||
void shouldNotAddDuplicateEntries(); |
||||
}; |
||||
|
||||
#endif // POTENTIALPHISHINGDETAILDIALOGTEST_H
|
||||
@ -0,0 +1,101 @@ |
||||
/*
|
||||
Copyright (c) 2015 Montel Laurent <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 "potentialphishingdetaildialog.h" |
||||
#include <KSharedConfig> |
||||
#include <KLocalizedString> |
||||
#include <qboxlayout.h> |
||||
#include <QLabel> |
||||
#include <QListWidget> |
||||
|
||||
|
||||
PotentialPhishingDetailDialog::PotentialPhishingDetailDialog(QWidget *parent) |
||||
: KDialog(parent) |
||||
{ |
||||
setCaption( i18n( "Details" ) ); |
||||
setButtons( Ok|Cancel ); |
||||
setDefaultButton( Ok ); |
||||
|
||||
setModal( true ); |
||||
QWidget *mainWidget = new QWidget( this ); |
||||
QVBoxLayout *mainLayout = new QVBoxLayout( mainWidget ); |
||||
QLabel *lab = new QLabel(i18n("Select email to put in whitelist:")); |
||||
lab->setObjectName(QLatin1String("label")); |
||||
mainLayout->addWidget(lab); |
||||
|
||||
mListWidget = new QListWidget; |
||||
mListWidget->setObjectName(QLatin1String("list_widget")); |
||||
mainLayout->addWidget(mListWidget); |
||||
|
||||
connect(this, SIGNAL(okClicked()), this, SLOT(slotSave())); |
||||
setMainWidget(mainWidget); |
||||
readConfig(); |
||||
} |
||||
|
||||
PotentialPhishingDetailDialog::~PotentialPhishingDetailDialog() |
||||
{ |
||||
writeConfig(); |
||||
} |
||||
|
||||
void PotentialPhishingDetailDialog::fillList(const QStringList &lst) |
||||
{ |
||||
mListWidget->clear(); |
||||
QStringList emailsAdded; |
||||
Q_FOREACH(const QString & mail, lst) { |
||||
if (!emailsAdded.contains(mail)) { |
||||
QListWidgetItem *item = new QListWidgetItem(mListWidget); |
||||
item->setCheckState(Qt::Unchecked); |
||||
item->setText(mail); |
||||
emailsAdded << mail; |
||||
} |
||||
} |
||||
} |
||||
|
||||
void PotentialPhishingDetailDialog::readConfig() |
||||
{ |
||||
KConfigGroup group( KSharedConfig::openConfig(), "PotentialPhishingDetailDialog" ); |
||||
const QSize sizeDialog = group.readEntry( "Size", QSize(800,600) ); |
||||
if ( sizeDialog.isValid() ) { |
||||
resize( sizeDialog ); |
||||
} |
||||
} |
||||
|
||||
void PotentialPhishingDetailDialog::writeConfig() |
||||
{ |
||||
KConfigGroup group( KSharedConfig::openConfig(), "PotentialPhishingDetailDialog" ); |
||||
group.writeEntry( "Size", size() ); |
||||
} |
||||
|
||||
void PotentialPhishingDetailDialog::slotSave() |
||||
{ |
||||
KConfigGroup group( KSharedConfig::openConfig(), "PotentialPhishing"); |
||||
QStringList potentialPhishing = group.readEntry("whiteList", QStringList()); |
||||
for (int i=0; i < mListWidget->count(); ++i) { |
||||
QListWidgetItem *item = mListWidget->item(i); |
||||
if (item->checkState() == Qt::Checked) { |
||||
QString email = item->text(); |
||||
if (!potentialPhishing.contains(email)) { |
||||
potentialPhishing << email; |
||||
} |
||||
} |
||||
} |
||||
group.writeEntry( "whiteList", potentialPhishing); |
||||
accept(); |
||||
} |
||||
@ -0,0 +1,44 @@ |
||||
/*
|
||||
Copyright (c) 2015 Montel Laurent <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 POTENTIALPHISHINGDETAILDIALOG_H |
||||
#define POTENTIALPHISHINGDETAILDIALOG_H |
||||
|
||||
#include <KDialog> |
||||
class QListWidget; |
||||
class PotentialPhishingDetailDialog : public KDialog |
||||
{ |
||||
Q_OBJECT |
||||
public: |
||||
explicit PotentialPhishingDetailDialog(QWidget *parent=0); |
||||
~PotentialPhishingDetailDialog(); |
||||
|
||||
void fillList(const QStringList &lst); |
||||
|
||||
private slots: |
||||
void slotSave(); |
||||
|
||||
private: |
||||
void readConfig(); |
||||
void writeConfig(); |
||||
QListWidget *mListWidget; |
||||
}; |
||||
|
||||
#endif // POTENTIALPHISHINGDETAILDIALOG_H
|
||||
Loading…
Reference in new issue