• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

mailcommon

  • sources
  • kde-4.12
  • kdepim
  • mailcommon
  • filter
  • dialog
selectthunderbirdfilterfileswidget.cpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 2012-2013 Montel Laurent <montel@kde.org>
3 
4  This program is free software; you can redistribute it and/or modify it
5  under the terms of the GNU General Public License, version 2, as
6  published by the Free Software Foundation.
7 
8  This program is distributed in the hope that it will be useful, but
9  WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License along
14  with this program; if not, write to the Free Software Foundation, Inc.,
15  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 
18 #include "selectthunderbirdfilterfileswidget.h"
19 #include "ui_selectthunderbirdfilterfileswidget.h"
20 #include "mailimporter/filter_thunderbird.h"
21 #include <QAbstractButton>
22 #include <QListWidgetItem>
23 #include <KUrlRequester>
24 
25 SelectThunderbirdFilterFilesWidget::SelectThunderbirdFilterFilesWidget(QWidget *parent) :
26  QWidget(parent),
27  ui(new Ui::SelectThunderbirdFilterFilesWidget)
28 {
29  ui->setupUi(this);
30  connect(ui->buttonGroup,SIGNAL(buttonClicked(QAbstractButton*)),SLOT(slotButtonClicked(QAbstractButton*)));
31  connect(ui->profiles,SIGNAL(currentIndexChanged(int)),SLOT(slotProfileChanged(int)));
32 
33  ui->listFiles->setSelectionMode(QAbstractItemView::MultiSelection);
34  QString defaultProfile;
35  QMap<QString,QString> listProfile = MailImporter::FilterThunderbird::listProfile(defaultProfile);
36  QMap<QString, QString>::const_iterator i = listProfile.constBegin();
37  while (i != listProfile.constEnd()) {
38  QString name = i.key();
39  if (i.value()==defaultProfile){
40  name+=i18n(" (default)");
41  }
42  ui->profiles->addItem(name,i.value());
43  ++i;
44  }
45  ui->fileUrl->setEnabled(true);
46  ui->profiles->setEnabled(false);
47  ui->listFiles->setEnabled(false);
48  slotProfileChanged(0);
49 }
50 
51 SelectThunderbirdFilterFilesWidget::~SelectThunderbirdFilterFilesWidget()
52 {
53  delete ui;
54 }
55 
56 void SelectThunderbirdFilterFilesWidget::slotButtonClicked(QAbstractButton*button)
57 {
58  if (button == ui->selectFile) {
59  ui->fileUrl->setEnabled(true);
60  ui->profiles->setEnabled(false);
61  ui->listFiles->setEnabled(false);
62  } else {
63  ui->fileUrl->setEnabled(false);
64  ui->profiles->setEnabled(true);
65  ui->listFiles->setEnabled(true);
66  }
67 }
68 
69 void SelectThunderbirdFilterFilesWidget::slotProfileChanged(int index)
70 {
71  if (index >= ui->profiles->count()) {
72  return;
73  }
74 
75  QStringList listFilterFiles;
76  const QString path(MailImporter::FilterThunderbird::defaultSettingsPath() + ui->profiles->itemData(index).toString());
77  QDir dir(path);
78  const QStringList subDir = dir.entryList(QDir::AllDirs|QDir::NoDotAndDotDot,QDir::Name);
79  Q_FOREACH( const QString& mailPath, subDir ) {
80  const QString subMailPath(path + QLatin1Char('/') + mailPath);
81  QDir dirMail(subMailPath);
82  const QStringList subDirMail = dirMail.entryList(QDir::AllDirs|QDir::NoDotAndDotDot,QDir::Name);
83  Q_FOREACH( const QString& file, subDirMail ) {
84  const QString filterFile(subMailPath +QLatin1Char('/')+ file + QLatin1String("/msgFilterRules.dat"));
85  if (QFile(filterFile).exists()) {
86  listFilterFiles<<filterFile;
87  }
88  }
89  }
90  ui->listFiles->clear();
91  ui->listFiles->addItems(listFilterFiles);
92 }
93 
94 QStringList SelectThunderbirdFilterFilesWidget::selectedFiles() const
95 {
96  QStringList listFiles;
97  if (ui->selectFile->isChecked()) {
98  listFiles<<ui->fileUrl->url().path();
99  } else {
100  QList<QListWidgetItem *> list = ui->listFiles->selectedItems();
101  Q_FOREACH(QListWidgetItem * item, list) {
102  listFiles<<item->text();
103  }
104  }
105  return listFiles;
106 }
107 
108 void SelectThunderbirdFilterFilesWidget::setStartDir(const KUrl &url)
109 {
110  ui->fileUrl->setFilter(QLatin1String("*.dat"));
111  ui->fileUrl->setStartDir(url);
112 }
113 
114 #include "selectthunderbirdfilterfileswidget.moc"
QWidget
SelectThunderbirdFilterFilesWidget::selectedFiles
QStringList selectedFiles() const
Definition: selectthunderbirdfilterfileswidget.cpp:94
QListWidgetItem
SelectThunderbirdFilterFilesWidget::setStartDir
void setStartDir(const KUrl &)
Definition: selectthunderbirdfilterfileswidget.cpp:108
selectthunderbirdfilterfileswidget.h
SelectThunderbirdFilterFilesWidget::SelectThunderbirdFilterFilesWidget
SelectThunderbirdFilterFilesWidget(QWidget *parent=0)
Definition: selectthunderbirdfilterfileswidget.cpp:25
SelectThunderbirdFilterFilesWidget
Definition: selectthunderbirdfilterfileswidget.h:29
SelectThunderbirdFilterFilesWidget::~SelectThunderbirdFilterFilesWidget
~SelectThunderbirdFilterFilesWidget()
Definition: selectthunderbirdfilterfileswidget.cpp:51
QList
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:55:15 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

mailcommon

Skip menu "mailcommon"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal