Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit c2faf1f5 authored by Laurent Montel's avatar Laurent Montel 😁

Fix icedove import filter

parent 4fb53bb4
......@@ -45,7 +45,7 @@ IcedoveImportData::~IcedoveImportData()
QString IcedoveImportData::defaultProfile()
{
if (mDefaultProfile.isEmpty()) {
mDefaultProfile = MailImporter::FilterThunderbird::defaultProfile(mImportWizard);
mDefaultProfile = MailImporter::FilterThunderbird::defaultProfile(mPath, mImportWizard);
}
return mDefaultProfile;
}
......
......@@ -45,7 +45,7 @@ ThunderbirdImportData::~ThunderbirdImportData()
QString ThunderbirdImportData::defaultProfile()
{
if (mDefaultProfile.isEmpty()) {
mDefaultProfile = MailImporter::FilterThunderbird::defaultProfile(mImportWizard);
mDefaultProfile = MailImporter::FilterThunderbird::defaultProfile(mPath, mImportWizard);
}
return mDefaultProfile;
}
......
......@@ -24,7 +24,7 @@
using namespace MailCommon;
SelectThunderbirdFilterFilesDialog::SelectThunderbirdFilterFilesDialog(QWidget *parent)
SelectThunderbirdFilterFilesDialog::SelectThunderbirdFilterFilesDialog(const QString &defaultSettingPath, QWidget *parent)
:KDialog(parent)
{
setCaption( i18n( "Select thunderbird filter files" ) );
......@@ -37,7 +37,7 @@ SelectThunderbirdFilterFilesDialog::SelectThunderbirdFilterFilesDialog(QWidget *
mainLayout->setMargin( KDialog::marginHint() );
setMainWidget( mainWidget );
mSelectFilterFilesWidget = new SelectThunderbirdFilterFilesWidget(mainWidget);
mSelectFilterFilesWidget = new SelectThunderbirdFilterFilesWidget(defaultSettingPath, mainWidget);
connect(mSelectFilterFilesWidget, SIGNAL(enableOkButton(bool)), this, SLOT(enableButtonOk(bool)));
mainLayout->addWidget(mSelectFilterFilesWidget);
readConfig();
......
......@@ -26,7 +26,7 @@ namespace MailCommon {
class SelectThunderbirdFilterFilesDialog : public KDialog
{
public:
explicit SelectThunderbirdFilterFilesDialog(QWidget *parent);
explicit SelectThunderbirdFilterFilesDialog(const QString &defaultSettingPath, QWidget *parent);
~SelectThunderbirdFilterFilesDialog();
QStringList selectedFiles() const;
......
......@@ -21,7 +21,7 @@
#include <QAbstractButton>
#include <QListWidgetItem>
SelectThunderbirdFilterFilesWidget::SelectThunderbirdFilterFilesWidget(QWidget *parent) :
SelectThunderbirdFilterFilesWidget::SelectThunderbirdFilterFilesWidget(const QString &defaultSettingPath, QWidget *parent) :
QWidget(parent),
ui(new Ui::SelectThunderbirdFilterFilesWidget)
{
......@@ -31,7 +31,7 @@ SelectThunderbirdFilterFilesWidget::SelectThunderbirdFilterFilesWidget(QWidget *
ui->listFiles->setSelectionMode(QAbstractItemView::MultiSelection);
QString defaultProfile;
QMap<QString,QString> listProfile = MailImporter::FilterThunderbird::listProfile(defaultProfile);
QMap<QString,QString> listProfile = MailImporter::FilterThunderbird::listProfile(defaultProfile, defaultSettingPath);
QMap<QString, QString>::const_iterator i = listProfile.constBegin();
while (i != listProfile.constEnd()) {
QString name = i.key();
......
......@@ -31,7 +31,7 @@ class SelectThunderbirdFilterFilesWidget : public QWidget
Q_OBJECT
public:
explicit SelectThunderbirdFilterFilesWidget(QWidget *parent = 0);
explicit SelectThunderbirdFilterFilesWidget(const QString &defaultSettingPath,QWidget *parent = 0);
~SelectThunderbirdFilterFilesWidget();
QStringList selectedFiles() const;
......
......@@ -54,7 +54,12 @@ void FilterImporterThunderbird::readStream(QTextStream &stream)
appendFilter(filter);
}
QString FilterImporterThunderbird::defaultFiltersSettingsPath()
QString FilterImporterThunderbird::defaultIcedoveFiltersSettingsPath()
{
return QString::fromLatin1( "%1/.icedove/" ).arg( QDir::homePath() );
}
QString FilterImporterThunderbird::defaultThunderbirdFiltersSettingsPath()
{
return QString::fromLatin1( "%1/.thunderbird/" ).arg( QDir::homePath() );
}
......
......@@ -34,8 +34,9 @@ public:
explicit FilterImporterThunderbird( QFile *file, bool interactive = true );
FilterImporterThunderbird( QString string, bool interactive = true );
~FilterImporterThunderbird();
static QString defaultFiltersSettingsPath();
static QString defaultThunderbirdFiltersSettingsPath();
static QString defaultIcedoveFiltersSettingsPath();
private:
void readStream(QTextStream &stream);
static QString cleanArgument( const QString &line, const QString &removeStr );
......
......@@ -38,6 +38,7 @@
#include "filterimporter/filterimporterprocmail_p.h"
#include "filterimporter/filterimporterbalsa_p.h"
#include "filterimporter/filterimporterclawsmail_p.h"
#include "dialog/selectthunderbirdfilterfilesdialog.h"
#include <messageviewer/utils/autoqpointer.h>
......@@ -175,7 +176,7 @@ QList<MailFilter *> FilterImporterExporter::importFilters(
break;
case ThunderBirdFilter:
title = i18n( "Import Thunderbird Filters" );
defaultPath = MailCommon::FilterImporterThunderbird::defaultFiltersSettingsPath();
defaultPath = MailCommon::FilterImporterThunderbird::defaultThunderbirdFiltersSettingsPath();
break;
case EvolutionFilter:
title = i18n( "Import Evolution Filters" );
......@@ -197,6 +198,10 @@ QList<MailFilter *> FilterImporterExporter::importFilters(
title = i18n( "Import Claws Mail Filters" );
defaultPath = MailCommon::FilterImporterClawsMails::defaultFiltersSettingsPath();
break;
case IcedoveFilter:
title = i18n( "Import Icedove Filters" );
defaultPath = MailCommon::FilterImporterThunderbird::defaultIcedoveFiltersSettingsPath();
break;
}
fileName = KFileDialog::getOpenFileName(
......@@ -226,11 +231,14 @@ QList<MailFilter *> FilterImporterExporter::importFilters(
imported = readFiltersFromConfig( config, emptyFilter );
break;
}
case IcedoveFilter:
case ThunderBirdFilter:
{
if (fileName.isEmpty()) {
SelectThunderbirdFilterFilesDialog * selectThunderBirdFileDialog = new SelectThunderbirdFilterFilesDialog(d->mParent);
selectThunderBirdFileDialog->setStartDir(KUrl(MailCommon::FilterImporterThunderbird::defaultFiltersSettingsPath()));
const QString defaultPath = ( type == ThunderBirdFilter ) ? MailCommon::FilterImporterThunderbird::defaultThunderbirdFiltersSettingsPath() : MailCommon::FilterImporterThunderbird::defaultIcedoveFiltersSettingsPath();
SelectThunderbirdFilterFilesDialog * selectThunderBirdFileDialog = new SelectThunderbirdFilterFilesDialog(defaultPath, d->mParent);
selectThunderBirdFileDialog->setStartDir(KUrl(defaultPath));
if (selectThunderBirdFileDialog->exec()) {
Q_FOREACH(const QString& url, selectThunderBirdFileDialog->selectedFiles()) {
QFile fileThunderbird(url);
......
......@@ -60,7 +60,8 @@ public:
SylpheedFilter = 3,
ProcmailFilter = 4,
BalsaFilter = 5,
ClawsMailFilter = 6
ClawsMailFilter = 6,
IcedoveFilter = 7
};
/**
......
......@@ -131,6 +131,10 @@ KMFilterDialog::KMFilterDialog( const QList<KActionCollection*> &actionCollectio
act->setData( QVariant::fromValue(MailCommon::FilterImporterExporter::ClawsMailFilter) );
menu->addAction( act );
act = new QAction( i18n( "Icedove Mail filters" ), this );
act->setData( QVariant::fromValue(MailCommon::FilterImporterExporter::IcedoveFilter) );
menu->addAction( act );
connect( menu, SIGNAL(triggered(QAction*)), SLOT(slotImportFilter(QAction*)) );
button( KDialog::User1 )->setMenu( menu );
......
......@@ -52,10 +52,10 @@ QString FilterThunderbird::defaultSettingsPath()
}
QString FilterThunderbird::defaultProfile(QWidget * parent)
QString FilterThunderbird::defaultProfile(const QString defaultSettingPath, QWidget * parent)
{
QString currentProfile;
QMap<QString,QString> listProfile = FilterThunderbird::listProfile(currentProfile);
QMap<QString,QString> listProfile = FilterThunderbird::listProfile(currentProfile, defaultSettingPath);
if(listProfile.isEmpty()) {
return QString();
} else if(listProfile.count() == 1) {
......@@ -70,9 +70,9 @@ QString FilterThunderbird::defaultProfile(QWidget * parent)
return currentProfile;
}
QMap<QString,QString> FilterThunderbird::listProfile(QString&currentProfile)
QMap<QString,QString> FilterThunderbird::listProfile(QString&currentProfile, const QString &defaultSettingPath)
{
const QString thunderbirdPath = defaultSettingsPath() + QLatin1String( "/profiles.ini" );
const QString thunderbirdPath = defaultSettingPath + QLatin1String( "/profiles.ini" );
QMap<QString,QString> lstProfile;
QFile profiles( thunderbirdPath );
if ( profiles.exists() ) {
......
......@@ -36,8 +36,8 @@ public:
void importMails( const QString & maildir );
static QString defaultSettingsPath();
static QString defaultProfile(QWidget *parent = 0);
static QMap<QString, QString> listProfile(QString&currentProfile);
static QString defaultProfile(const QString defaultSettingPath, QWidget *parent = 0);
static QMap<QString, QString> listProfile(QString&currentProfile, const QString &defaultSettingPath);
protected:
virtual QString defaultInstallFolder() const;
......
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