Fix clipping/eliding of multi-line task descriptions.
[kdepim.git] / kmailcvt / filter_plain.cxx
blobdf9194bbd5d21ebc9faaf3cf8d833556e68f403b
1 /***************************************************************************
2 FilterPlain.cxx - Plain mail import
3 -------------------
4 begin : Fri Jun 14 2002
5 copyright : (C) 2002 by Laurence Anderson
6 email : l.d.anderson@warwick.ac.uk
7 ***************************************************************************/
9 /***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
18 #include <klocale.h>
19 #include <kfiledialog.h>
21 #include "filter_plain.hxx"
24 FilterPlain::FilterPlain() :
25 Filter(i18n("Import Plain Text Emails"),
26 "Laurence Anderson <p>( Filter accelerated by Danny Kukawka )</p>",
27 i18n("<p>Select the directory containing the emails on your system. "
28 "The emails are placed in a folder with the same name as the "
29 "directory they were in, prefixed by PLAIN-</p>"
30 "<p>This filter will import all .msg, .eml and .txt emails.</p>"))
33 FilterPlain::~FilterPlain()
37 void FilterPlain::import(FilterInfo *info)
39 // Select directory containing plain text emails
40 const QString mailDir = KFileDialog::getExistingDirectory(QDir::homePath(),info->parent());
41 if (mailDir.isEmpty()) { // No directory selected
42 info->alert(i18n("No directory selected."));
43 return;
45 QDir dir (mailDir);
46 const QStringList files = dir.entryList(QStringList("*.[eE][mM][lL]")<<"*.[tT][xX][tT]"<<"*.[mM][sS][gG]", QDir::Files, QDir::Name);
48 // Count total number of files to be processed
49 info->addLog(i18n("Counting files..."));
50 int totalFiles = files.count();
51 int currentFile = 0;
53 info->addLog(i18n("Importing new mail files..."));
54 for ( QStringList::ConstIterator mailFile = files.constBegin(); mailFile != files.constEnd(); ++mailFile ) {
55 info->setFrom(*mailFile);
56 info->setTo(dir.dirName());
57 info->setCurrent(0);
59 /* comment by Danny Kukawka:
60 * addMessage() == old function, need more time and check for duplicates
61 * addMessage_fastImport == new function, faster and no check for duplicates
63 if(info->removeDupMsg) {
64 if(! addMessage( info, "PLAIN-" + dir.dirName(), dir.filePath(*mailFile) )) {
65 info->addLog( i18n("Could not import %1", *mailFile ) );
67 } else {
68 if( ! addMessage_fastImport( info, "PLAIN-" + dir.dirName(), dir.filePath(*mailFile) )) {
69 info->addLog( i18n("Could not import %1", *mailFile ) );
73 info->setCurrent(100);
74 info->setOverall(100 * ++currentFile/ totalFiles);
75 if ( info->shouldTerminate() ) break;
78 info->addLog( i18n("Finished importing emails from %1", mailDir ));
79 if (count_duplicates > 0) {
80 info->addLog( i18np("1 duplicate message not imported", "%1 duplicate messages not imported", count_duplicates));
82 if (info->shouldTerminate()) info->addLog( i18n("Finished import, canceled by user."));
84 count_duplicates = 0;