summaryrefslogtreecommitdiffabout
path: root/kmicromail
Unidiff
Diffstat (limited to 'kmicromail') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/composemail.cpp24
-rw-r--r--kmicromail/mailistviewitem.cpp77
-rw-r--r--kmicromail/mailistviewitem.h7
-rw-r--r--kmicromail/mainwindow.cpp10
-rw-r--r--kmicromail/opiemail.cpp2
5 files changed, 75 insertions, 45 deletions
diff --git a/kmicromail/composemail.cpp b/kmicromail/composemail.cpp
index ca4f247..c1b58a4 100644
--- a/kmicromail/composemail.cpp
+++ b/kmicromail/composemail.cpp
@@ -1,141 +1,141 @@
1 1
2#include "composemail.h" 2#include "composemail.h"
3 3
4#include <libmailwrapper/smtpwrapper.h> 4#include <libmailwrapper/smtpwrapper.h>
5#include <libmailwrapper/storemail.h> 5#include <libmailwrapper/storemail.h>
6#include <libmailwrapper/abstractmail.h> 6#include <libmailwrapper/abstractmail.h>
7#include <libmailwrapper/mailtypes.h> 7#include <libmailwrapper/mailtypes.h>
8 8
9/* OPIE */ 9/* OPIE */
10//#include <opie2/ofiledialog.h> 10//#include <opie2/ofiledialog.h>
11//#include <opie2/odebug.h> 11//#include <opie2/odebug.h>
12#include <kfiledialog.h> 12#include <kfiledialog.h>
13//#include <qpe/resource.h> 13//#include <qpe/resource.h>
14#include <qpe/config.h> 14#include <qpe/config.h>
15#include <qpe/global.h> 15#include <qpe/global.h>
16//#include <qpe/contact.h> 16//#include <qpe/contact.h>
17 17
18 18
19#include <qcombobox.h> 19#include <qcombobox.h>
20#include <qcheckbox.h> 20#include <qcheckbox.h>
21#include <qtimer.h> 21#include <qtimer.h>
22#include <qmessagebox.h> 22#include <qmessagebox.h>
23#include <qpushbutton.h> 23#include <qpushbutton.h>
24#include <qmultilineedit.h> 24#include <qmultilineedit.h>
25#include <qlabel.h> 25#include <qlabel.h>
26#include <qtabwidget.h> 26#include <qtabwidget.h>
27#include <qlistview.h> 27#include <qlistview.h>
28#include <kabc/addresseedialog.h> 28#include <kabc/addresseedialog.h>
29#include <kabc/stdaddressbook.h> 29#include <kabc/stdaddressbook.h>
30#include <kabc/addressee.h> 30#include <kabc/addressee.h>
31 31
32 32
33 33
34//using namespace Opie::Core; 34//using namespace Opie::Core;
35//using namespace Opie::Ui; 35//using namespace Opie::Ui;
36ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) 36ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags )
37 : ComposeMailUI( parent, name, modal, flags ) 37 : ComposeMailUI( parent, name, modal, flags )
38{ 38{
39 39
40 settings = s; 40 settings = s;
41 m_replyid = ""; 41 m_replyid = "";
42 KABC::Addressee con = KABC::StdAddressBook::self()->whoAmI( ); 42 KABC::Addressee con = KABC::StdAddressBook::self()->whoAmI( );
43 QStringList mails = con.emails(); 43 QStringList mails = con.emails();
44 QString defmail = con.preferredEmail(); 44 QString defmail = con.preferredEmail();
45 if ( mails.count() == 0) 45 if ( mails.count() == 0)
46 QMessageBox::information( parentWidget(), tr( "Hint" ), 46 QMessageBox::information( 0, tr( "Hint" ),
47 tr( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!" ), 47 tr( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ),
48 tr( "Ok" ) ); 48 tr( "Ok" ) );
49 if (defmail.length()!=0) { 49 if (defmail.length()!=0) {
50 fromBox->insertItem(defmail); 50 fromBox->insertItem(defmail);
51 } 51 }
52 QStringList::ConstIterator sit = mails.begin(); 52 QStringList::ConstIterator sit = mails.begin();
53 for (;sit!=mails.end();++sit) { 53 for (;sit!=mails.end();++sit) {
54 if ( (*sit)==defmail) 54 if ( (*sit)==defmail)
55 continue; 55 continue;
56 fromBox->insertItem((*sit)); 56 fromBox->insertItem((*sit));
57 } 57 }
58 senderNameEdit->setText(con.formattedName()); 58 senderNameEdit->setText(con.formattedName());
59 Config cfg( "mail" ); 59 Config cfg( "mail" );
60 cfg.setGroup( "Compose" ); 60 cfg.setGroup( "Compose" );
61 checkBoxLater->setChecked( cfg.readBoolEntry( "sendLater", false ) ); 61 checkBoxLater->setChecked( cfg.readBoolEntry( "sendLater", false ) );
62 62
63 attList->addColumn( tr( "Name" ) ); 63 attList->addColumn( tr( "Name" ) );
64 attList->addColumn( tr( "Size" ) ); 64 attList->addColumn( tr( "Size" ) );
65 65
66 QList<Account> accounts = settings->getAccounts(); 66 QList<Account> accounts = settings->getAccounts();
67 67
68 Account *it; 68 Account *it;
69 for ( it = accounts.first(); it; it = accounts.next() ) { 69 for ( it = accounts.first(); it; it = accounts.next() ) {
70 if ( it->getType()==MAILLIB::A_SMTP ) { 70 if ( it->getType()==MAILLIB::A_SMTP ) {
71 SMTPaccount *smtp = static_cast<SMTPaccount *>(it); 71 SMTPaccount *smtp = static_cast<SMTPaccount *>(it);
72 smtpAccountBox->insertItem( smtp->getAccountName() ); 72 smtpAccountBox->insertItem( smtp->getAccountName() );
73 smtpAccounts.append( smtp ); 73 smtpAccounts.append( smtp );
74 } 74 }
75 } 75 }
76 if ( smtpAccounts.count() > 0 ) {
77 fillValues( smtpAccountBox->currentItem() );
78 } else {
79 QMessageBox::information( parentWidget(), tr( "Problem" ),
80 tr( "Please create an SMTP account first.\nThe SMTP is needed for sending mail." ),
81 tr( "Ok" ) );
82 return;
83 }
84 connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) ); 76 connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) );
85 connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); 77 connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) );
86 connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); 78 connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) );
87 connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); 79 connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) );
88 connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); 80 connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) );
89 connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); 81 connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) );
90 connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); 82 connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) );
91 connect( SaveButton, SIGNAL( clicked() ), SLOT( saveAsDraft()) ); 83 connect( SaveButton, SIGNAL( clicked() ), SLOT( saveAsDraft()) );
92 mMail = 0; 84 mMail = 0;
93 warnAttach = true; 85 warnAttach = true;
86 if ( smtpAccounts.count() > 0 ) {
87 fillValues( smtpAccountBox->currentItem() );
88 } else {
89 QMessageBox::information( 0, tr( "Problem" ),
90 tr( "Please create an SMTP account first.\nThe SMTP is needed for sending mail.\n" ),
91 tr( "Ok" ) );
92 return;
93 }
94} 94}
95void ComposeMail::saveAsDraft() 95void ComposeMail::saveAsDraft()
96{ 96{
97 97
98 Opie::Core::OSmartPointer<Mail> mail= new Mail(); 98 Opie::Core::OSmartPointer<Mail> mail= new Mail();
99 mail->setMail(fromBox->currentText()); 99 mail->setMail(fromBox->currentText());
100 mail->setTo( toLine->text() ); 100 mail->setTo( toLine->text() );
101 mail->setName(senderNameEdit->text()); 101 mail->setName(senderNameEdit->text());
102 mail->setCC( ccLine->text() ); 102 mail->setCC( ccLine->text() );
103 mail->setBCC( bccLine->text() ); 103 mail->setBCC( bccLine->text() );
104 mail->setReply( replyLine->text() ); 104 mail->setReply( replyLine->text() );
105 mail->setSubject( subjectLine->text() ); 105 mail->setSubject( subjectLine->text() );
106 if (!m_replyid.isEmpty()) { 106 if (!m_replyid.isEmpty()) {
107 QStringList ids; 107 QStringList ids;
108 ids.append(m_replyid); 108 ids.append(m_replyid);
109 mail->setInreply(ids); 109 mail->setInreply(ids);
110 } 110 }
111 QString txt = message->text(); 111 QString txt = message->text();
112 if ( !sigMultiLine->text().isEmpty() ) { 112 if ( !sigMultiLine->text().isEmpty() ) {
113 txt.append( "\n--\n" ); 113 txt.append( "\n--\n" );
114 txt.append( sigMultiLine->text() ); 114 txt.append( sigMultiLine->text() );
115 } 115 }
116 mail->setMessage( txt ); 116 mail->setMessage( txt );
117 117
118 /* only use the default drafts folder name! */ 118 /* only use the default drafts folder name! */
119 Storemail wrapper(AbstractMail::draftFolder()); 119 Storemail wrapper(AbstractMail::draftFolder());
120 wrapper.storeMail(mail); 120 wrapper.storeMail(mail);
121 121
122 AttachViewItem *it = (AttachViewItem *) attList->firstChild(); 122 AttachViewItem *it = (AttachViewItem *) attList->firstChild();
123 /* attachments we will ignore! */ 123 /* attachments we will ignore! */
124 if ( it != 0 ) { 124 if ( it != 0 ) {
125 if ( warnAttach ) 125 if ( warnAttach )
126 QMessageBox::warning(0,tr("Store message"), 126 QMessageBox::warning(0,tr("Store message"),
127 tr("<center>Attachments will not be stored in \"Draft\" folder</center>")); 127 tr("<center>Attachments will not be stored in \"Draft\" folder</center>"));
128 warnAttach = false; 128 warnAttach = false;
129 } 129 }
130 setStatus( tr("Mail saved as draft!") ); 130 setStatus( tr("Mail saved as draft!") );
131} 131}
132void ComposeMail::clearStatus() 132void ComposeMail::clearStatus()
133{ 133{
134 topLevelWidget()->setCaption( tr("Compose mail") ); 134 topLevelWidget()->setCaption( tr("Compose mail") );
135} 135}
136void ComposeMail::setStatus( QString status ) 136void ComposeMail::setStatus( QString status )
137{ 137{
138 topLevelWidget()->setCaption( status ); 138 topLevelWidget()->setCaption( status );
139 QTimer::singleShot ( 10000, this, SLOT( clearStatus() ) ) ; 139 QTimer::singleShot ( 10000, this, SLOT( clearStatus() ) ) ;
140} 140}
141void ComposeMail::pickAddress( QLineEdit *line ) 141void ComposeMail::pickAddress( QLineEdit *line )
@@ -275,89 +275,89 @@ void ComposeMail::accept()
275 SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() ); 275 SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() );
276 mail->setMail(fromBox->currentText()); 276 mail->setMail(fromBox->currentText());
277 277
278 if ( !toLine->text().isEmpty() ) { 278 if ( !toLine->text().isEmpty() ) {
279 mail->setTo( toLine->text() ); 279 mail->setTo( toLine->text() );
280 } else { 280 } else {
281 QMessageBox::warning(0,tr("Sending mail"), 281 QMessageBox::warning(0,tr("Sending mail"),
282 tr("No Receiver spezified" ) ); 282 tr("No Receiver spezified" ) );
283 return; 283 return;
284 } 284 }
285 285
286 mail->setName(senderNameEdit->text()); 286 mail->setName(senderNameEdit->text());
287 mail->setCC( ccLine->text() ); 287 mail->setCC( ccLine->text() );
288 mail->setBCC( bccLine->text() ); 288 mail->setBCC( bccLine->text() );
289 mail->setReply( replyLine->text() ); 289 mail->setReply( replyLine->text() );
290 mail->setSubject( subjectLine->text() ); 290 mail->setSubject( subjectLine->text() );
291 if (!m_replyid.isEmpty()) { 291 if (!m_replyid.isEmpty()) {
292 QStringList ids; 292 QStringList ids;
293 ids.append(m_replyid); 293 ids.append(m_replyid);
294 mail->setInreply(ids); 294 mail->setInreply(ids);
295 } 295 }
296 QString txt = message->text(); 296 QString txt = message->text();
297 if ( !sigMultiLine->text().isEmpty() ) { 297 if ( !sigMultiLine->text().isEmpty() ) {
298 txt.append( "\n--\n" ); 298 txt.append( "\n--\n" );
299 txt.append( sigMultiLine->text() ); 299 txt.append( sigMultiLine->text() );
300 } 300 }
301 mail->setMessage( txt ); 301 mail->setMessage( txt );
302 AttachViewItem *it = (AttachViewItem *) attList->firstChild(); 302 AttachViewItem *it = (AttachViewItem *) attList->firstChild();
303 while ( it != 0 ) { 303 while ( it != 0 ) {
304 mail->addAttachment( it->getAttachment() ); 304 mail->addAttachment( it->getAttachment() );
305 it = (AttachViewItem *) it->nextSibling(); 305 it = (AttachViewItem *) it->nextSibling();
306 } 306 }
307 307
308 SMTPwrapper wrapper( smtp ); 308 SMTPwrapper wrapper( smtp );
309 if ( wrapper.sendMail( mail,checkBoxLater->isChecked() ) ) 309 if ( wrapper.sendMail( mail,checkBoxLater->isChecked() ) )
310 setStatus( tr ("Mail sent")); 310 setStatus( tr ("Mail sent"));
311 else { 311 else {
312 setStatus( tr ("Error: Something went wrong. Nothing sent")); 312 setStatus( tr ("Error: Something went wrong. Nothing sent"));
313 return; 313 return;
314 } 314 }
315 315
316 316
317 QDialog::accept(); 317 QDialog::accept();
318} 318}
319 319
320void ComposeMail::reject() 320void ComposeMail::reject()
321{ 321{
322 //qDebug("ComposeMail::reject() "); 322 //qDebug("ComposeMail::reject() ");
323 int yesno = QMessageBox::warning(0,tr("Stop editing message"), 323 int yesno = QMessageBox::warning(0,tr("Store message?"),
324 tr("Store message into drafts?"), 324 tr("Store message into drafts?\n"),
325 tr("Yes"), 325 tr("Yes"),
326 tr("No")); 326 tr("No"));
327 327
328 //qDebug("button %d ", yesno); 328 //qDebug("button %d ", yesno);
329 if (yesno == 0) { 329 if (yesno == 0) {
330 saveAsDraft(); 330 saveAsDraft();
331 } 331 }
332 if (yesno == 2) { 332 if (yesno == 2) {
333 qDebug("return "); 333 qDebug("return ");
334 return; 334 return;
335 } 335 }
336 QDialog::reject(); 336 QDialog::reject();
337} 337}
338 338
339ComposeMail::~ComposeMail() 339ComposeMail::~ComposeMail()
340{ 340{
341} 341}
342 342
343void ComposeMail::reEditMail(const RecMailP&current) 343void ComposeMail::reEditMail(const RecMailP&current)
344{ 344{
345 RecMailP data = current; 345 RecMailP data = current;
346 message->setText(data->Wrapper()->fetchBody(current)->Bodytext()); 346 message->setText(data->Wrapper()->fetchBody(current)->Bodytext());
347 subjectLine->setText( data->getSubject()); 347 subjectLine->setText( data->getSubject());
348 toLine->setText(data->To().join(",")); 348 toLine->setText(data->To().join(","));
349 ccLine->setText(data->CC().join(",")); 349 ccLine->setText(data->CC().join(","));
350 bccLine->setText(data->Bcc().join(",")); 350 bccLine->setText(data->Bcc().join(","));
351 replyLine->setText(data->Replyto()); 351 replyLine->setText(data->Replyto());
352} 352}
353 353
354AttachViewItem::AttachViewItem( QListView *parent, Attachment *att ) 354AttachViewItem::AttachViewItem( QListView *parent, Attachment *att )
355 : QListViewItem( parent ) 355 : QListViewItem( parent )
356{ 356{
357 attachment = att; 357 attachment = att;
358 if ( !attachment->getPixmap().isNull() ) 358 if ( !attachment->getPixmap().isNull() )
359 setPixmap( 0,attachment->getPixmap() ); 359 setPixmap( 0,attachment->getPixmap() );
360 setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() ); 360 setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() );
361 setText( 1, QString::number( att->getSize() ) ); 361 setText( 1, QString::number( att->getSize() ) );
362} 362}
363 363
diff --git a/kmicromail/mailistviewitem.cpp b/kmicromail/mailistviewitem.cpp
index b9b4cd9..1ca0ada 100644
--- a/kmicromail/mailistviewitem.cpp
+++ b/kmicromail/mailistviewitem.cpp
@@ -1,115 +1,142 @@
1#include "mailistviewitem.h" 1#include "mailistviewitem.h"
2#include <libmailwrapper/abstractmail.h> 2#include <libmailwrapper/abstractmail.h>
3#include <qtextstream.h> 3#include <qtextstream.h>
4#include <kiconloader.h> 4#include <kiconloader.h>
5//#include <qpe/resource.h> 5//#include <qpe/resource.h>
6 6
7MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) 7MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item )
8 :QListViewItem(parent,item),mail_data() 8 :QListViewItem(parent,item),mail_data()
9{ 9{
10} 10}
11 11
12void MailListViewItem::showEntry() 12void MailListViewItem::showEntry()
13{ 13{
14 if ( mail_data->getFlags().testBit( FLAG_ANSWERED ) == true) { 14 if ( mail_data->getFlags().testBit( FLAG_ANSWERED ) == true) {
15 setPixmap( 0, SmallIcon ( "kmmsgreplied") ); 15 setPixmap( 0, SmallIcon ( "kmmsgreplied") );
16 } else if ( mail_data->getFlags().testBit( FLAG_SEEN ) == true ) { 16 } else if ( mail_data->getFlags().testBit( FLAG_SEEN ) == true ) {
17 /* I think it looks nicer if there are not such a log of icons but only on mails 17 /* I think it looks nicer if there are not such a log of icons but only on mails
18 replied or new - Alwin*/ 18 replied or new - Alwin*/
19 //setPixmap( 0,SmallIcon ("kmmsgunseen") ); 19 //setPixmap( 0,SmallIcon ("kmmsgunseen") );
20 } else { 20 } else {
21 setPixmap( 0,SmallIcon ( "kmmsgnew") ); 21 setPixmap( 0,SmallIcon ( "kmmsgnew") );
22 } 22 }
23 double s = mail_data->Msgsize(); 23 double s = mail_data->Msgsize();
24 int w; 24 int w = 0;
25 w=0; 25 s/=1024;
26 26 if (s>999.0) {
27 while (s>1024) { 27 s/=1024.0;
28 s/=1024;
29 ++w; 28 ++w;
30 if (w>=2) break;
31 } 29 }
32 30 QString fsort;
33 QString q=""; 31 fsort.sprintf( "%.2f", s );
34 QString fsize=""; 32 QString fsize = QString::number( s, 'f', 2 );
35 switch(w) { 33 // 1.23
36 case 1: 34 // 11.23
37 q="k"; 35 // 111.23
36 // 999.23 maxlen
37 switch(fsize.length() ) {
38 case 4:
39 fsort = "00" + fsize ;
38 break; 40 break;
39 case 2: 41 case 5:
40 q="M"; 42 fsort = "0" + fsize ;
41 break; 43 break;
42 default: 44 default:
43 break; 45 fsort = fsize ;
46 break;
47
44 } 48 }
45 49 if ( w == 0 ) {
46 { 50 setText(3, fsize + "kB" );
47 QTextOStream o(&fsize); 51 mKeyMap.insert(3, "k" + fsort);
48 if (w>0) o.precision(2); else o.precision(0); 52 //setText(3, "kB" + fsort ); // test only
49 o.setf(QTextStream::fixed); 53 } else {
50 o << s << " " << q << "Byte"; 54 //setText(3, fsize + "MB");
55 mKeyMap.insert(4, "M" +fsort );
51 } 56 }
52
53 setText(1,mail_data->getSubject()); 57 setText(1,mail_data->getSubject());
54 setText(2,mail_data->getFrom()); 58 setText(2,mail_data->getFrom());
55 setText(3,fsize); 59
56 QString date = mail_data->getDate(); 60 QString date = mail_data->getDate();
57 61
58 int kom = date.find( ",")+2; 62 int kom = date.find( ",")+2;
59 if ( kom == 1 ) 63 if ( kom == 1 )
60 kom = 0; 64 kom = 0;
61 if ( date.mid(kom,1) == " ") 65 if ( date.mid(kom,1) == " ")
62 ++kom; 66 ++kom;
63 if ( date.mid(kom+1,1) == " " ) 67 if ( date.mid(kom+1,1) == " " )
64 date = "0" + date.mid( kom ); 68 date = "0" + date.mid( kom );
65 else if ( kom ) 69 else if ( kom )
66 date = date.mid( kom ); 70 date = date.mid( kom );
67 if ( kom || date.mid(2,1 ) == " ") { 71 if ( kom || date.mid(2,1 ) == " ") {
68 QString mon = date.mid(3,3); 72 QString mon = date.mid(3,3);
69 QString so = 00; 73 QString so = 00;
70 if ( mon == "Jan" ) 74 if ( mon == "Jan" )
71 so = "01"; 75 so = "01";
72 else if ( mon == "Feb" ) 76 else if ( mon == "Feb" )
73 so = "02"; 77 so = "02";
74 else if ( mon == "Mar" ) 78 else if ( mon == "Mar" )
75 so = "03"; 79 so = "03";
76 else if ( mon == "Apr" ) 80 else if ( mon == "Apr" )
77 so = "04"; 81 so = "04";
78 else if ( mon == "May" ) 82 else if ( mon == "May" )
79 so = "05"; 83 so = "05";
80 else if ( mon == "Jun" ) 84 else if ( mon == "Jun" )
81 so = "06"; 85 so = "06";
82 else if ( mon == "Jul" ) 86 else if ( mon == "Jul" )
83 so = "07"; 87 so = "07";
84 else if ( mon == "Aug" ) 88 else if ( mon == "Aug" )
85 so = "08"; 89 so = "08";
86 else if ( mon == "Sep" ) 90 else if ( mon == "Sep" )
87 so = "09"; 91 so = "09";
88 else if ( mon == "Oct" ) 92 else if ( mon == "Oct" )
89 so = "10"; 93 so = "10";
90 else if ( mon == "Nov" ) 94 else if ( mon == "Nov" )
91 so = "11"; 95 so = "11";
92 else if ( mon == "Dec" ) 96 else if ( mon == "Dec" )
93 so = "12"; 97 so = "12";
94 date = date.mid(7,4)+"-"+so+"-"+date.left(2)+" "+date.mid(12,14); 98 date = date.mid(7,4)+so+date.left(2)+date.mid(12,14);
95 } 99 }
96 // if ( date.left(1) != "1" || date.left(1) != "2" ) 100 // if ( date.left(1) != "1" || date.left(1) != "2" )
97 // date = date.mid(5); 101 // date = date.mid(5);
98 setText(4,date); 102 mKeyMap.insert(4,date);
103 setText(4,mail_data->getDate());
99} 104}
100 105
101void MailListViewItem::storeData(const RecMailP&data) 106void MailListViewItem::storeData(const RecMailP&data)
102{ 107{
103 mail_data = data; 108 mail_data = data;
104} 109}
110void MailListViewItem::setSortKey(int column,const QString &key)
111{
112 mKeyMap.insert(column,key);
113}
114QString MailListViewItem::key(int column, bool) const
115{
116 // to make is fast, we use here special cases
117 if ( column == 3 || column == 4 ) {
118 return *mKeyMap.find(column);
119 }
120 if ( column == 1 ) {
121 if ( text(1).left(4).lower() == "re: " )
122 return text(1).mid(4);
123
124 }
125 return text(column);
126 /*
127 QMap<int,QString>::ConstIterator it = mKeyMap.find(column);
128 if (it == mKeyMap.end()) return text(column);
129 else return *it;
130 */
131}
105 132
106const RecMailP& MailListViewItem::data()const 133const RecMailP& MailListViewItem::data()const
107{ 134{
108 return mail_data; 135 return mail_data;
109} 136}
110 137
111MAILLIB::ATYPE MailListViewItem::wrapperType() 138MAILLIB::ATYPE MailListViewItem::wrapperType()
112{ 139{
113 if (!mail_data->Wrapper()) return MAILLIB::A_UNDEFINED; 140 if (!mail_data->Wrapper()) return MAILLIB::A_UNDEFINED;
114 return mail_data->Wrapper()->getType(); 141 return mail_data->Wrapper()->getType();
115} 142}
diff --git a/kmicromail/mailistviewitem.h b/kmicromail/mailistviewitem.h
index d953d83..cf8040b 100644
--- a/kmicromail/mailistviewitem.h
+++ b/kmicromail/mailistviewitem.h
@@ -1,23 +1,26 @@
1#ifndef __MAILLISTVIEWITEM_H 1#ifndef __MAILLISTVIEWITEM_H
2#define __MAILLISTVIEWITEM_H 2#define __MAILLISTVIEWITEM_H
3 3
4#include <qlistview.h> 4#include <qlistview.h>
5#include <libmailwrapper/mailtypes.h> 5#include <libmailwrapper/mailtypes.h>
6#include <libmailwrapper/maildefines.h> 6#include <libmailwrapper/maildefines.h>
7 7
8class MailListViewItem:public QListViewItem 8class MailListViewItem:public QListViewItem
9{ 9{
10public: 10public:
11 MailListViewItem(QListView * parent, MailListViewItem * after ); 11 MailListViewItem(QListView * parent, MailListViewItem * after );
12 virtual ~MailListViewItem(){} 12 virtual ~MailListViewItem(){}
13 13
14 void storeData(const RecMailP&data); 14 void storeData(const RecMailP&data);
15 const RecMailP&data()const; 15 const RecMailP&data()const;
16 void showEntry(); 16 void showEntry();
17 MAILLIB::ATYPE wrapperType(); 17 MAILLIB::ATYPE wrapperType();
18 18 QString key(int column, bool) const;
19 void setSortKey(int column,const QString &key);
19protected: 20protected:
20 RecMailP mail_data; 21 RecMailP mail_data;
22 private:
23 QMap<int,QString> mKeyMap;
21}; 24};
22 25
23#endif 26#endif
diff --git a/kmicromail/mainwindow.cpp b/kmicromail/mainwindow.cpp
index 78377ea..ddc7b3e 100644
--- a/kmicromail/mainwindow.cpp
+++ b/kmicromail/mainwindow.cpp
@@ -50,178 +50,178 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
50 syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC, 50 syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC,
51 0, 0, this ); 51 0, 0, this );
52 syncFolders->addTo( toolBar ); 52 syncFolders->addTo( toolBar );
53 syncFolders->addTo( mailMenu ); 53 syncFolders->addTo( mailMenu );
54 */ 54 */
55 55
56 showFolders = new QAction( tr( "Show/Hide folders" ), SmallIcon("showfolders") , 56 showFolders = new QAction( tr( "Show/Hide folders" ), SmallIcon("showfolders") ,
57 0, 0, this, 0, true ); 57 0, 0, this, 0, true );
58 showFolders->addTo( toolBar ); 58 showFolders->addTo( toolBar );
59 showFolders->addTo( mailMenu ); 59 showFolders->addTo( mailMenu );
60 showFolders->setOn( true ); 60 showFolders->setOn( true );
61 connect(showFolders, SIGNAL( toggled(bool) ), 61 connect(showFolders, SIGNAL( toggled(bool) ),
62 SLOT( slotShowFolders(bool) ) ); 62 SLOT( slotShowFolders(bool) ) );
63 63
64 /* 64 /*
65 searchMails = new QAction( tr( "Search mails" ), SmallIcon("find") ), 65 searchMails = new QAction( tr( "Search mails" ), SmallIcon("find") ),
66 0, 0, this ); 66 0, 0, this );
67 searchMails->addTo( toolBar ); 67 searchMails->addTo( toolBar );
68 searchMails->addTo( mailMenu ); 68 searchMails->addTo( mailMenu );
69 */ 69 */
70 70
71 deleteMails = new QAction(tr("Delete Mail"), SmallIcon("trash"), 0, 0, this); 71 deleteMails = new QAction(tr("Delete Mail"), SmallIcon("trash"), 0, 0, this);
72 deleteMails->addTo( toolBar ); 72 deleteMails->addTo( toolBar );
73 deleteMails->addTo( mailMenu ); 73 deleteMails->addTo( mailMenu );
74 connect( deleteMails, SIGNAL( activated() ), 74 connect( deleteMails, SIGNAL( activated() ),
75 SLOT( slotDeleteMail() ) ); 75 SLOT( slotDeleteMail() ) );
76 76
77 editSettings = new QAction( tr( "Edit settings" ), SmallIcon("SettingsIcon") , 77 editSettings = new QAction( tr( "Edit settings" ), SmallIcon("SettingsIcon") ,
78 0, 0, this ); 78 0, 0, this );
79 editSettings->addTo( settingsMenu ); 79 editSettings->addTo( settingsMenu );
80 connect( editSettings, SIGNAL( activated() ), 80 connect( editSettings, SIGNAL( activated() ),
81 SLOT( slotEditSettings() ) ); 81 SLOT( slotEditSettings() ) );
82 editAccounts = new QAction( tr( "Configure accounts" ), SmallIcon("editaccounts") , 82 editAccounts = new QAction( tr( "Configure accounts" ), SmallIcon("editaccounts") ,
83 0, 0, this ); 83 0, 0, this );
84 editAccounts->addTo( settingsMenu ); 84 editAccounts->addTo( settingsMenu );
85 85
86 //setCentralWidget( view ); 86 //setCentralWidget( view );
87 87
88 QVBox* wrapperBox = new QVBox( this ); 88 QVBox* wrapperBox = new QVBox( this );
89 setCentralWidget( wrapperBox ); 89 setCentralWidget( wrapperBox );
90 90
91 // QWidget *view = new QWidget( wrapperBox ); 91 // QWidget *view = new QWidget( wrapperBox );
92 KDGanttMinimizeSplitter* split = new KDGanttMinimizeSplitter( Qt::Horizontal, wrapperBox); 92 KDGanttMinimizeSplitter* split = new KDGanttMinimizeSplitter( Qt::Horizontal, wrapperBox);
93 split->setMinimizeDirection( KDGanttMinimizeSplitter::Left); 93 split->setMinimizeDirection( KDGanttMinimizeSplitter::Left);
94 //layout = new QBoxLayout ( split, QBoxLayout::LeftToRight ); 94 //layout = new QBoxLayout ( split, QBoxLayout::LeftToRight );
95 95
96 folderView = new AccountView( split ); 96 folderView = new AccountView( split );
97 folderView->header()->hide(); 97 folderView->header()->hide();
98 folderView->setRootIsDecorated( true ); 98 folderView->setRootIsDecorated( false );
99 folderView->addColumn( tr( "Mailbox" ) ); 99 folderView->addColumn( tr( "Mailbox" ) );
100 100
101 //layout->addWidget( folderView ); 101 //layout->addWidget( folderView );
102 102
103 mailView = new QListView( split ); 103 mailView = new QListView( split );
104 mailView->addColumn( tr( "" ) ); 104 mailView->addColumn( tr( " " ) );
105 mailView->addColumn( tr( "Subject" ),QListView::Manual ); 105 mailView->addColumn( tr( "Subject" ),QListView::Manual );
106 mailView->addColumn( tr( "Sender" ),QListView::Manual ); 106 mailView->addColumn( tr( "Sender" ),QListView::Manual );
107 mailView->addColumn( tr( "Size" ),QListView::Manual); 107 mailView->addColumn( tr( "Size" ),QListView::Manual);
108 mailView->addColumn( tr( "Date" )); 108 mailView->addColumn( tr( "Date" ),QListView::Manual);
109 mailView->setAllColumnsShowFocus(true); 109 mailView->setAllColumnsShowFocus(true);
110 //mailView->setSorting(-1); 110 //mailView->setSorting(-1);
111 111 mailView->setRootIsDecorated( false );
112 statusWidget = new StatusWidget( wrapperBox ); 112 statusWidget = new StatusWidget( wrapperBox );
113 statusWidget->hide(); 113 statusWidget->hide();
114 114
115 //layout->addWidget( mailView ); 115 //layout->addWidget( mailView );
116 //layout->setStretchFactor( folderView, 1 ); 116 //layout->setStretchFactor( folderView, 1 );
117 //layout->setStretchFactor( mailView, 2 ); 117 //layout->setStretchFactor( mailView, 2 );
118 118
119 slotAdjustLayout(); 119 slotAdjustLayout();
120#ifndef DESKTOP_VERSION 120#ifndef DESKTOP_VERSION
121 QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold); 121 QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold);
122 QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold); 122 QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold);
123#endif 123#endif
124 connect( mailView, SIGNAL( doubleClicked (QListViewItem* )),this, 124 connect( mailView, SIGNAL( doubleClicked (QListViewItem* )),this,
125 SLOT( mailLeftClicked(QListViewItem*) ) ); 125 SLOT( mailLeftClicked(QListViewItem*) ) );
126 connect( mailView, SIGNAL( returnPressed (QListViewItem* )),this, 126 connect( mailView, SIGNAL( returnPressed (QListViewItem* )),this,
127 SLOT( mailLeftClicked(QListViewItem*) ) ); 127 SLOT( mailLeftClicked(QListViewItem*) ) );
128 connect( mailView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, 128 connect( mailView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this,
129 SLOT( mailHold(int,QListViewItem*,const QPoint&,int) ) ); 129 SLOT( mailHold(int,QListViewItem*,const QPoint&,int) ) );
130 connect(folderView, SIGNAL(refreshMailview(const QValueList<RecMailP>&)), 130 connect(folderView, SIGNAL(refreshMailview(const QValueList<RecMailP>&)),
131 this,SLOT(refreshMailView(const QValueList<RecMailP>&))); 131 this,SLOT(refreshMailView(const QValueList<RecMailP>&)));
132 connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) ); 132 connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) );
133 connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) ); 133 connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) );
134// connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) ); 134// connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) );
135 connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) ); 135 connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) );
136 mailView->setMultiSelection ( true ); 136 mailView->setMultiSelection ( true );
137 //mailView->setSelectionMode( QListView::Extended ); 137 //mailView->setSelectionMode( QListView::Extended );
138 QValueList<int> list; 138 QValueList<int> list;
139 int fw = 100; 139 int fw = 100;
140 if ( QApplication::desktop()->width() > 320 ) 140 if ( QApplication::desktop()->width() > 320 )
141 fw = 50; 141 fw = 50;
142 list.append( fw ); 142 list.append( fw );
143 list.append( 100 ); 143 list.append( 100 );
144 split->setSizes( list ); 144 split->setSizes( list );
145 QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); 145 QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) );
146 mailView->setShowSortIndicator ( true ); 146 mailView->setShowSortIndicator ( true );
147} 147}
148 148
149MainWindow::~MainWindow() 149MainWindow::~MainWindow()
150{ 150{
151} 151}
152 152
153void MainWindow::appMessage(const QCString &, const QByteArray &) 153void MainWindow::appMessage(const QCString &, const QByteArray &)
154{ 154{
155 qDebug("appMessage implemented by subclass"); 155 qDebug("appMessage implemented by subclass");
156} 156}
157 157
158void MainWindow::slotAdjustLayout() { 158void MainWindow::slotAdjustLayout() {
159 159
160 /* 160 /*
161 QWidget *d = QApplication::desktop(); 161 QWidget *d = QApplication::desktop();
162 162
163 if ( d->width() < d->height() ) { 163 if ( d->width() < d->height() ) {
164 layout->setDirection( QBoxLayout::TopToBottom ); 164 layout->setDirection( QBoxLayout::TopToBottom );
165 } else { 165 } else {
166 layout->setDirection( QBoxLayout::LeftToRight ); 166 layout->setDirection( QBoxLayout::LeftToRight );
167 } 167 }
168 */ 168 */
169} 169}
170 170
171void MainWindow::slotAdjustColumns() 171void MainWindow::slotAdjustColumns()
172{ 172{
173 bool hidden = folderView->isHidden(); 173 bool hidden = folderView->isHidden();
174 if ( hidden ) folderView->show(); 174 if ( hidden ) folderView->show();
175 folderView->setColumnWidth( 0, folderView->visibleWidth() ); 175 folderView->setColumnWidth( 0, folderView->visibleWidth() );
176 if ( hidden ) folderView->hide(); 176 if ( hidden ) folderView->hide();
177 177
178 mailView->setColumnWidth( 0, 10 ); 178 mailView->setColumnWidth( 0, 10 );
179 mailView->setColumnWidth( 1, mailView->visibleWidth() - 130 ); 179 mailView->setColumnWidth( 1, 80 );
180 mailView->setColumnWidth( 2, 80 ); 180 mailView->setColumnWidth( 2, 80 );
181 mailView->setColumnWidth( 3, 50 ); 181 mailView->setColumnWidth( 3, 50 );
182 mailView->setColumnWidth( 4, 50 ); 182 mailView->setColumnWidth( 4, 50 );
183} 183}
184 184
185void MainWindow::slotEditSettings() 185void MainWindow::slotEditSettings()
186{ 186{
187} 187}
188 188
189void MainWindow::slotShowFolders( bool ) 189void MainWindow::slotShowFolders( bool )
190{ 190{
191 qDebug("not implemented: "); 191 qDebug("not implemented: ");
192} 192}
193 193
194void MainWindow::refreshMailView(const QValueList<RecMailP>&) 194void MainWindow::refreshMailView(const QValueList<RecMailP>&)
195{ 195{
196 qDebug("not implemented: "); 196 qDebug("not implemented: ");
197} 197}
198 198
199void MainWindow::mailLeftClicked(QListViewItem * ) 199void MainWindow::mailLeftClicked(QListViewItem * )
200{ 200{
201 qDebug("not implemented: "); 201 qDebug("not implemented: ");
202} 202}
203 203
204void MainWindow::displayMail() 204void MainWindow::displayMail()
205{ 205{
206 qDebug("not implemented: "); 206 qDebug("not implemented: ");
207} 207}
208 208
209void MainWindow::slotDeleteMail() 209void MainWindow::slotDeleteMail()
210{ 210{
211 qDebug("not implemented: "); 211 qDebug("not implemented: ");
212} 212}
213 213
214void MainWindow::mailHold(int, QListViewItem *,const QPoint&,int ) 214void MainWindow::mailHold(int, QListViewItem *,const QPoint&,int )
215{ 215{
216 qDebug("not implemented: "); 216 qDebug("not implemented: ");
217} 217}
218 218
219void MainWindow::slotSendQueued() 219void MainWindow::slotSendQueued()
220{ 220{
221 qDebug("not implemented: "); 221 qDebug("not implemented: ");
222} 222}
223 223
224void MainWindow::slotEditAccounts() 224void MainWindow::slotEditAccounts()
225{ 225{
226 qDebug("not implemented: "); 226 qDebug("not implemented: ");
227} 227}
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp
index b1992ec..bdbd93a 100644
--- a/kmicromail/opiemail.cpp
+++ b/kmicromail/opiemail.cpp
@@ -103,97 +103,97 @@ void OpieMail::slotwriteMail2(const QString& namemail )
103 compose.showMaximized(); 103 compose.showMaximized();
104 compose.exec(); 104 compose.exec();
105 //qDebug("retttich "); 105 //qDebug("retttich ");
106} 106}
107void OpieMail::slotwriteMail(const QString&name,const QString&email) 107void OpieMail::slotwriteMail(const QString&name,const QString&email)
108{ 108{
109 // qDebug("OpieMail::slotwriteMail "); 109 // qDebug("OpieMail::slotwriteMail ");
110 ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp ); 110 ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp );
111 if (!email.isEmpty()) 111 if (!email.isEmpty())
112 { 112 {
113 if (!name.isEmpty()) 113 if (!name.isEmpty())
114 { 114 {
115 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); 115 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">");
116 } 116 }
117 else 117 else
118 { 118 {
119 compose.setTo(email); 119 compose.setTo(email);
120 } 120 }
121 } 121 }
122 compose.slotAdjustColumns(); 122 compose.slotAdjustColumns();
123 compose.showMaximized(); 123 compose.showMaximized();
124 compose.exec(); 124 compose.exec();
125} 125}
126 126
127void OpieMail::slotComposeMail() 127void OpieMail::slotComposeMail()
128{ 128{
129 slotwriteMail2( QString () ); 129 slotwriteMail2( QString () );
130 //slotwriteMail(0l,0l); 130 //slotwriteMail(0l,0l);
131} 131}
132 132
133void OpieMail::slotSendQueued() 133void OpieMail::slotSendQueued()
134{ 134{
135 SMTPaccount *smtp = 0; 135 SMTPaccount *smtp = 0;
136 136
137 QList<Account> list = settings->getAccounts(); 137 QList<Account> list = settings->getAccounts();
138 QList<SMTPaccount> smtpList; 138 QList<SMTPaccount> smtpList;
139 smtpList.setAutoDelete(false); 139 smtpList.setAutoDelete(false);
140 Account *it; 140 Account *it;
141 for ( it = list.first(); it; it = list.next() ) 141 for ( it = list.first(); it; it = list.next() )
142 { 142 {
143 if ( it->getType() == MAILLIB::A_SMTP ) 143 if ( it->getType() == MAILLIB::A_SMTP )
144 { 144 {
145 smtp = static_cast<SMTPaccount *>(it); 145 smtp = static_cast<SMTPaccount *>(it);
146 smtpList.append(smtp); 146 smtpList.append(smtp);
147 } 147 }
148 } 148 }
149 if (smtpList.count()==0) 149 if (smtpList.count()==0)
150 { 150 {
151 QMessageBox::information(0,tr("Info"),tr("Define a smtp account first")); 151 QMessageBox::information(0,tr("Info"),tr("Define a smtp account first!\n"));
152 return; 152 return;
153 } 153 }
154 if (smtpList.count()==1) 154 if (smtpList.count()==1)
155 { 155 {
156 smtp = smtpList.at(0); 156 smtp = smtpList.at(0);
157 } 157 }
158 else 158 else
159 { 159 {
160 smtp = 0; 160 smtp = 0;
161 selectsmtp selsmtp; 161 selectsmtp selsmtp;
162 selsmtp.setSelectionlist(&smtpList); 162 selsmtp.setSelectionlist(&smtpList);
163 selsmtp.showMaximized(); 163 selsmtp.showMaximized();
164 if ( selsmtp.exec() == QDialog::Accepted ) 164 if ( selsmtp.exec() == QDialog::Accepted )
165 { 165 {
166 smtp = selsmtp.selected_smtp(); 166 smtp = selsmtp.selected_smtp();
167 } 167 }
168 } 168 }
169 if (smtp) 169 if (smtp)
170 { 170 {
171 SMTPwrapper * wrap = new SMTPwrapper(smtp); 171 SMTPwrapper * wrap = new SMTPwrapper(smtp);
172 if ( wrap->flushOutbox() ) 172 if ( wrap->flushOutbox() )
173 { 173 {
174 QMessageBox::information(0,tr("Info"),tr("Mail queue flushed")); 174 QMessageBox::information(0,tr("Info"),tr("Mail queue flushed"));
175 } 175 }
176 delete wrap; 176 delete wrap;
177 } 177 }
178} 178}
179 179
180void OpieMail::slotSearchMails() 180void OpieMail::slotSearchMails()
181{ 181{
182 qDebug("OpieMail::slotSearchMails():not implemented "); 182 qDebug("OpieMail::slotSearchMails():not implemented ");
183} 183}
184 184
185void OpieMail::slotEditSettings() 185void OpieMail::slotEditSettings()
186{ 186{
187 SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp ); 187 SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp );
188 settingsDialog.showMaximized(); 188 settingsDialog.showMaximized();
189 settingsDialog.exec(); 189 settingsDialog.exec();
190} 190}
191 191
192void OpieMail::slotEditAccounts() 192void OpieMail::slotEditAccounts()
193{ 193{
194 EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp ); 194 EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp );
195 eaDialog.slotAdjustColumns(); 195 eaDialog.slotAdjustColumns();
196 eaDialog.showMaximized(); 196 eaDialog.showMaximized();
197 eaDialog.exec(); 197 eaDialog.exec();
198 if ( settings ) delete settings; 198 if ( settings ) delete settings;
199 settings = new Settings(); 199 settings = new Settings();