author | alwin <alwin> | 2004-10-26 01:08:58 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-10-26 01:08:58 (UTC) |
commit | cd3245ade209b4672ab5c51003aa66b5908c67a1 (patch) (unidiff) | |
tree | dfd4246557ff5d8804204387660de7e0afbd4032 | |
parent | 9e97864f04686ca8fc672de950cbbef4ff6a5ec6 (diff) | |
download | opie-cd3245ade209b4672ab5c51003aa66b5908c67a1.zip opie-cd3245ade209b4672ab5c51003aa66b5908c67a1.tar.gz opie-cd3245ade209b4672ab5c51003aa66b5908c67a1.tar.bz2 |
Resolved a feature request:
unique display of date-time of a mail
maillist now sorted for mail-date as default, user can switch sort order
to all other items (subject, author, size)
-rw-r--r-- | noncore/net/mail/libmailwrapper/genericwrapper.cpp | 10 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.cpp | 5 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailstatics.cpp | 23 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailstatics.h | 4 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailtypes.cpp | 18 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailtypes.h | 11 | ||||
-rw-r--r-- | noncore/net/mail/mailistviewitem.cpp | 20 | ||||
-rw-r--r-- | noncore/net/mail/mailistviewitem.h | 1 | ||||
-rw-r--r-- | noncore/net/mail/mainwindow.cpp | 3 | ||||
-rw-r--r-- | noncore/net/mail/viewmail.cpp | 2 |
10 files changed, 66 insertions, 31 deletions
diff --git a/noncore/net/mail/libmailwrapper/genericwrapper.cpp b/noncore/net/mail/libmailwrapper/genericwrapper.cpp index 703235d..0ac842d 100644 --- a/noncore/net/mail/libmailwrapper/genericwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/genericwrapper.cpp | |||
@@ -375,25 +375,25 @@ QStringList Genericwrapper::parseInreplies(mailimf_in_reply_to * in_replies) | |||
375 | while (h.length()>0 && h[h.length()-1]=='>') { | 375 | while (h.length()>0 && h[h.length()-1]=='>') { |
376 | h.remove(h.length()-1,1); | 376 | h.remove(h.length()-1,1); |
377 | } | 377 | } |
378 | if (h.length()>0) { | 378 | if (h.length()>0) { |
379 | res.append(h); | 379 | res.append(h); |
380 | } | 380 | } |
381 | } | 381 | } |
382 | return res; | 382 | return res; |
383 | } | 383 | } |
384 | 384 | ||
385 | void Genericwrapper::parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to) | 385 | void Genericwrapper::parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to) |
386 | { | 386 | { |
387 | int r; | 387 | int r,toffset; |
388 | mailmessage_list * env_list = 0; | 388 | mailmessage_list * env_list = 0; |
389 | r = mailsession_get_messages_list(session,&env_list); | 389 | r = mailsession_get_messages_list(session,&env_list); |
390 | if (r != MAIL_NO_ERROR) { | 390 | if (r != MAIL_NO_ERROR) { |
391 | odebug << "Error message list" << oendl; | 391 | odebug << "Error message list" << oendl; |
392 | return; | 392 | return; |
393 | } | 393 | } |
394 | r = mailsession_get_envelopes_list(session, env_list); | 394 | r = mailsession_get_envelopes_list(session, env_list); |
395 | if (r != MAIL_NO_ERROR) { | 395 | if (r != MAIL_NO_ERROR) { |
396 | odebug << "Error filling message list" << oendl; | 396 | odebug << "Error filling message list" << oendl; |
397 | if (env_list) { | 397 | if (env_list) { |
398 | mailmessage_list_free(env_list); | 398 | mailmessage_list_free(env_list); |
399 | } | 399 | } |
@@ -428,31 +428,31 @@ void Genericwrapper::parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > & | |||
428 | if (single_fields.fld_from) | 428 | if (single_fields.fld_from) |
429 | mail->setFrom(parseMailboxList(single_fields.fld_from->frm_mb_list)); | 429 | mail->setFrom(parseMailboxList(single_fields.fld_from->frm_mb_list)); |
430 | if (!mbox_as_to) { | 430 | if (!mbox_as_to) { |
431 | if (single_fields.fld_to) | 431 | if (single_fields.fld_to) |
432 | mail->setTo( parseAddressList( single_fields.fld_to->to_addr_list ) ); | 432 | mail->setTo( parseAddressList( single_fields.fld_to->to_addr_list ) ); |
433 | } else { | 433 | } else { |
434 | mail->setTo(mailbox); | 434 | mail->setTo(mailbox); |
435 | } | 435 | } |
436 | if (single_fields.fld_cc) | 436 | if (single_fields.fld_cc) |
437 | mail->setCC( parseAddressList( single_fields.fld_cc->cc_addr_list ) ); | 437 | mail->setCC( parseAddressList( single_fields.fld_cc->cc_addr_list ) ); |
438 | if (single_fields.fld_bcc) | 438 | if (single_fields.fld_bcc) |
439 | mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) ); | 439 | mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) ); |
440 | if (single_fields.fld_orig_date) | 440 | if (single_fields.fld_orig_date) { |
441 | mail->setDate( parseDateTime( single_fields.fld_orig_date->dt_date_time ) ); | 441 | QDateTime d = parseDateTime( single_fields.fld_orig_date->dt_date_time,toffset); |
442 | // crashes when accessing pop3 account? | 442 | mail->setDate( d,toffset ); |
443 | } | ||
443 | if (single_fields.fld_message_id && single_fields.fld_message_id->mid_value) { | 444 | if (single_fields.fld_message_id && single_fields.fld_message_id->mid_value) { |
444 | mail->setMsgid(QString(single_fields.fld_message_id->mid_value)); | 445 | mail->setMsgid(QString(single_fields.fld_message_id->mid_value)); |
445 | } | 446 | } |
446 | |||
447 | if (single_fields.fld_reply_to) { | 447 | if (single_fields.fld_reply_to) { |
448 | QStringList t = parseAddressList(single_fields.fld_reply_to->rt_addr_list); | 448 | QStringList t = parseAddressList(single_fields.fld_reply_to->rt_addr_list); |
449 | if (t.count()>0) { | 449 | if (t.count()>0) { |
450 | mail->setReplyto(t[0]); | 450 | mail->setReplyto(t[0]); |
451 | } | 451 | } |
452 | } | 452 | } |
453 | #if 0 | 453 | #if 0 |
454 | refs = single_fields.fld_references; | 454 | refs = single_fields.fld_references; |
455 | if (refs && refs->mid_list && clist_count(refs->mid_list)) { | 455 | if (refs && refs->mid_list && clist_count(refs->mid_list)) { |
456 | char * text = (char*)refs->mid_list->first->data; | 456 | char * text = (char*)refs->mid_list->first->data; |
457 | mail->setReplyto(QString(text)); | 457 | mail->setReplyto(QString(text)); |
458 | } | 458 | } |
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp index 56efa0b..8e5212b 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp | |||
@@ -363,25 +363,25 @@ QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders() | |||
363 | } | 363 | } |
364 | if (result) mailimap_list_result_free( result ); | 364 | if (result) mailimap_list_result_free( result ); |
365 | return folders; | 365 | return folders; |
366 | } | 366 | } |
367 | 367 | ||
368 | RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | 368 | RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) |
369 | { | 369 | { |
370 | RecMail * m = 0; | 370 | RecMail * m = 0; |
371 | mailimap_msg_att_item *item=0; | 371 | mailimap_msg_att_item *item=0; |
372 | clistcell *current,*c,*cf; | 372 | clistcell *current,*c,*cf; |
373 | mailimap_msg_att_dynamic*flist; | 373 | mailimap_msg_att_dynamic*flist; |
374 | mailimap_flag_fetch*cflag; | 374 | mailimap_flag_fetch*cflag; |
375 | int size; | 375 | int size,toffset; |
376 | QBitArray mFlags(7); | 376 | QBitArray mFlags(7); |
377 | QStringList addresslist; | 377 | QStringList addresslist; |
378 | 378 | ||
379 | if (!m_att) { | 379 | if (!m_att) { |
380 | return m; | 380 | return m; |
381 | } | 381 | } |
382 | size = 0; | 382 | size = 0; |
383 | m = new RecMail(); | 383 | m = new RecMail(); |
384 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { | 384 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { |
385 | current = c; | 385 | current = c; |
386 | item = (mailimap_msg_att_item*)current->data; | 386 | item = (mailimap_msg_att_item*)current->data; |
387 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { | 387 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { |
@@ -415,25 +415,26 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | |||
415 | break; | 415 | break; |
416 | default: | 416 | default: |
417 | break; | 417 | break; |
418 | } | 418 | } |
419 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { | 419 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { |
420 | mFlags.setBit(FLAG_RECENT); | 420 | mFlags.setBit(FLAG_RECENT); |
421 | } | 421 | } |
422 | } | 422 | } |
423 | continue; | 423 | continue; |
424 | } | 424 | } |
425 | if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { | 425 | if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { |
426 | mailimap_envelope * head = item->att_data.att_static->att_data.att_env; | 426 | mailimap_envelope * head = item->att_data.att_static->att_data.att_env; |
427 | m->setDate(parseDateTime(head->env_date)); | 427 | QDateTime d = parseDateTime(head->env_date,toffset); |
428 | m->setDate(d,toffset); | ||
428 | m->setSubject(convert_String((const char*)head->env_subject)); | 429 | m->setSubject(convert_String((const char*)head->env_subject)); |
429 | if (head->env_from!=NULL) { | 430 | if (head->env_from!=NULL) { |
430 | addresslist = address_list_to_stringlist(head->env_from->frm_list); | 431 | addresslist = address_list_to_stringlist(head->env_from->frm_list); |
431 | if (addresslist.count()) { | 432 | if (addresslist.count()) { |
432 | m->setFrom(addresslist.first()); | 433 | m->setFrom(addresslist.first()); |
433 | } | 434 | } |
434 | } | 435 | } |
435 | if (head->env_to!=NULL) { | 436 | if (head->env_to!=NULL) { |
436 | addresslist = address_list_to_stringlist(head->env_to->to_list); | 437 | addresslist = address_list_to_stringlist(head->env_to->to_list); |
437 | m->setTo(addresslist); | 438 | m->setTo(addresslist); |
438 | } | 439 | } |
439 | if (head->env_cc!=NULL) { | 440 | if (head->env_cc!=NULL) { |
diff --git a/noncore/net/mail/libmailwrapper/mailstatics.cpp b/noncore/net/mail/libmailwrapper/mailstatics.cpp index 4878dc9..033ec28 100644 --- a/noncore/net/mail/libmailwrapper/mailstatics.cpp +++ b/noncore/net/mail/libmailwrapper/mailstatics.cpp | |||
@@ -1,29 +1,30 @@ | |||
1 | #include "mailstatics.h" | 1 | #include "mailstatics.h" |
2 | #include <libetpan/libetpan.h> | 2 | #include <libetpan/libetpan.h> |
3 | #include <qpe/timestring.h> | 3 | //#include <qpe/timestring.h> |
4 | 4 | ||
5 | QString MailStatics::parseDateTime(const mailimf_date_time *date ) | 5 | QDateTime MailStatics::parseDateTime(const mailimf_date_time *date,int&offset ) |
6 | { | 6 | { |
7 | if (!date) return ""; | 7 | offset = 0; |
8 | if (!date) { | ||
9 | return QDateTime(); | ||
10 | } | ||
8 | QDateTime da(QDate(date->dt_year,date->dt_month,date->dt_day),QTime(date->dt_hour,date->dt_min,date->dt_sec)); | 11 | QDateTime da(QDate(date->dt_year,date->dt_month,date->dt_day),QTime(date->dt_hour,date->dt_min,date->dt_sec)); |
9 | QString timestring = TimeString::numberDateString(QDate(date->dt_year,date->dt_month,date->dt_day))+" "; | 12 | offset = date->dt_zone; |
10 | timestring+=TimeString::timeString(QTime(date->dt_hour,date->dt_min,date->dt_sec))+" "; | 13 | return da; |
11 | timestring.sprintf(timestring+" %+05i",date->dt_zone); | ||
12 | return timestring; | ||
13 | } | 14 | } |
14 | 15 | ||
15 | QString MailStatics::parseDateTime(const char*date) | 16 | QDateTime MailStatics::parseDateTime(const char*date,int&offset) |
16 | { | 17 | { |
17 | mailimf_date_time * date_time; | 18 | mailimf_date_time * date_time=0; |
18 | QString d = ""; | 19 | QDateTime d; |
19 | size_t cur_tok = 0; | 20 | size_t cur_tok = 0; |
20 | if (!date) return d; | 21 | if (!date) return d; |
21 | int r = mailimf_date_time_parse(date,strlen(date),&cur_tok,&date_time); | 22 | int r = mailimf_date_time_parse(date,strlen(date),&cur_tok,&date_time); |
22 | if (r==MAILIMF_NO_ERROR) { | 23 | if (r==MAILIMF_NO_ERROR) { |
23 | d = parseDateTime(date_time); | 24 | d = parseDateTime(date_time,offset); |
24 | } | 25 | } |
25 | if (date_time) { | 26 | if (date_time) { |
26 | mailimf_date_time_free(date_time); | 27 | mailimf_date_time_free(date_time); |
27 | } | 28 | } |
28 | return d; | 29 | return d; |
29 | } \ No newline at end of file | 30 | } \ No newline at end of file |
diff --git a/noncore/net/mail/libmailwrapper/mailstatics.h b/noncore/net/mail/libmailwrapper/mailstatics.h index 841d14d..c714ead 100644 --- a/noncore/net/mail/libmailwrapper/mailstatics.h +++ b/noncore/net/mail/libmailwrapper/mailstatics.h | |||
@@ -1,19 +1,19 @@ | |||
1 | #ifndef __MAIL_STATICS_H | 1 | #ifndef __MAIL_STATICS_H |
2 | #define __MAIL_STATICS_H | 2 | #define __MAIL_STATICS_H |
3 | 3 | ||
4 | #include <qdatetime.h> | 4 | #include <qdatetime.h> |
5 | #include <qstring.h> | 5 | #include <qstring.h> |
6 | 6 | ||
7 | struct mailimf_date_time; | 7 | struct mailimf_date_time; |
8 | 8 | ||
9 | class MailStatics | 9 | class MailStatics |
10 | { | 10 | { |
11 | protected: | 11 | protected: |
12 | static QString parseDateTime(const mailimf_date_time * date); | 12 | static QDateTime parseDateTime(const mailimf_date_time * date,int&offset); |
13 | static QString parseDateTime(const char*date); | 13 | static QDateTime parseDateTime(const char*date,int&offset); |
14 | MailStatics(){}; | 14 | MailStatics(){}; |
15 | virtual ~MailStatics(){}; | 15 | virtual ~MailStatics(){}; |
16 | public: | 16 | public: |
17 | }; | 17 | }; |
18 | 18 | ||
19 | #endif | 19 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/mailtypes.cpp b/noncore/net/mail/libmailwrapper/mailtypes.cpp index d4395a2..b009b75 100644 --- a/noncore/net/mail/libmailwrapper/mailtypes.cpp +++ b/noncore/net/mail/libmailwrapper/mailtypes.cpp | |||
@@ -1,41 +1,43 @@ | |||
1 | #include "mailtypes.h" | 1 | #include "mailtypes.h" |
2 | 2 | ||
3 | #include <opie2/odebug.h> | 3 | #include <opie2/odebug.h> |
4 | #include <qpe/timestring.h> | ||
4 | 5 | ||
5 | #include <stdlib.h> | 6 | #include <stdlib.h> |
6 | 7 | ||
7 | using namespace Opie::Core; | 8 | using namespace Opie::Core; |
8 | RecMail::RecMail() | 9 | RecMail::RecMail() |
9 | :Opie::Core::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_size(0),msg_flags(7) | 10 | :Opie::Core::ORefCount(),subject(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_size(0),msg_flags(7),maildate(),date("") |
10 | { | 11 | { |
11 | init(); | 12 | init(); |
12 | } | 13 | } |
13 | 14 | ||
14 | RecMail::RecMail(const RecMail&old) | 15 | RecMail::RecMail(const RecMail&old) |
15 | :Opie::Core::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7) | 16 | :Opie::Core::ORefCount(),subject(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7),maildate(),date("") |
16 | { | 17 | { |
17 | init(); | 18 | init(); |
18 | copy_old(old); | 19 | copy_old(old); |
19 | odebug << "Copy constructor RecMail" << oendl; | 20 | odebug << "Copy constructor RecMail" << oendl; |
20 | } | 21 | } |
21 | 22 | ||
22 | RecMail::~RecMail() | 23 | RecMail::~RecMail() |
23 | { | 24 | { |
24 | wrapper = 0; | 25 | wrapper = 0; |
25 | } | 26 | } |
26 | 27 | ||
27 | void RecMail::copy_old(const RecMail&old) | 28 | void RecMail::copy_old(const RecMail&old) |
28 | { | 29 | { |
29 | subject = old.subject; | 30 | subject = old.subject; |
31 | maildate = old.maildate; | ||
30 | date = old.date; | 32 | date = old.date; |
31 | mbox = old.mbox; | 33 | mbox = old.mbox; |
32 | msg_id = old.msg_id; | 34 | msg_id = old.msg_id; |
33 | msg_size = old.msg_size; | 35 | msg_size = old.msg_size; |
34 | msg_number = old.msg_number; | 36 | msg_number = old.msg_number; |
35 | from = old.from; | 37 | from = old.from; |
36 | msg_flags = old.msg_flags; | 38 | msg_flags = old.msg_flags; |
37 | to = old.to; | 39 | to = old.to; |
38 | cc = old.cc; | 40 | cc = old.cc; |
39 | bcc = old.bcc; | 41 | bcc = old.bcc; |
40 | wrapper = old.wrapper; | 42 | wrapper = old.wrapper; |
41 | in_reply_to = old.in_reply_to; | 43 | in_reply_to = old.in_reply_to; |
@@ -44,24 +46,35 @@ void RecMail::copy_old(const RecMail&old) | |||
44 | } | 46 | } |
45 | 47 | ||
46 | void RecMail::init() | 48 | void RecMail::init() |
47 | { | 49 | { |
48 | to.clear(); | 50 | to.clear(); |
49 | cc.clear(); | 51 | cc.clear(); |
50 | bcc.clear(); | 52 | bcc.clear(); |
51 | in_reply_to.clear(); | 53 | in_reply_to.clear(); |
52 | references.clear(); | 54 | references.clear(); |
53 | wrapper = 0; | 55 | wrapper = 0; |
54 | } | 56 | } |
55 | 57 | ||
58 | void RecMail::setDate( const QDateTime&a,int offset) | ||
59 | { | ||
60 | QString timestring = TimeString::numberDateString(a.date())+" "; | ||
61 | timestring+=TimeString::timeString(a.time()); | ||
62 | if (offset > 0) { | ||
63 | timestring.sprintf(timestring+" %+05i",offset); | ||
64 | } | ||
65 | date = timestring; | ||
66 | maildate = a; | ||
67 | } | ||
68 | |||
56 | void RecMail::setWrapper(AbstractMail*awrapper) | 69 | void RecMail::setWrapper(AbstractMail*awrapper) |
57 | { | 70 | { |
58 | wrapper = awrapper; | 71 | wrapper = awrapper; |
59 | } | 72 | } |
60 | 73 | ||
61 | AbstractMail* RecMail::Wrapper() | 74 | AbstractMail* RecMail::Wrapper() |
62 | { | 75 | { |
63 | return wrapper; | 76 | return wrapper; |
64 | } | 77 | } |
65 | 78 | ||
66 | void RecMail::setTo(const QStringList&list) | 79 | void RecMail::setTo(const QStringList&list) |
67 | { | 80 | { |
@@ -387,13 +400,12 @@ void encodedString::setContent(char*nContent,int nSize) | |||
387 | { | 400 | { |
388 | content = nContent; | 401 | content = nContent; |
389 | size = nSize; | 402 | size = nSize; |
390 | } | 403 | } |
391 | 404 | ||
392 | folderStat&folderStat::operator=(const folderStat&old) | 405 | folderStat&folderStat::operator=(const folderStat&old) |
393 | { | 406 | { |
394 | message_count = old.message_count; | 407 | message_count = old.message_count; |
395 | message_unseen = old.message_unseen; | 408 | message_unseen = old.message_unseen; |
396 | message_recent = old.message_recent; | 409 | message_recent = old.message_recent; |
397 | return *this; | 410 | return *this; |
398 | } | 411 | } |
399 | |||
diff --git a/noncore/net/mail/libmailwrapper/mailtypes.h b/noncore/net/mail/libmailwrapper/mailtypes.h index c317880..272514c 100644 --- a/noncore/net/mail/libmailwrapper/mailtypes.h +++ b/noncore/net/mail/libmailwrapper/mailtypes.h | |||
@@ -6,49 +6,48 @@ | |||
6 | #define FLAG_DELETED 2 | 6 | #define FLAG_DELETED 2 |
7 | #define FLAG_SEEN 3 | 7 | #define FLAG_SEEN 3 |
8 | #define FLAG_DRAFT 4 | 8 | #define FLAG_DRAFT 4 |
9 | #define FLAG_RECENT 5 | 9 | #define FLAG_RECENT 5 |
10 | 10 | ||
11 | #include <opie2/osmartpointer.h> | 11 | #include <opie2/osmartpointer.h> |
12 | 12 | ||
13 | #include <qbitarray.h> | 13 | #include <qbitarray.h> |
14 | #include <qstring.h> | 14 | #include <qstring.h> |
15 | #include <qstringlist.h> | 15 | #include <qstringlist.h> |
16 | #include <qmap.h> | 16 | #include <qmap.h> |
17 | #include <qvaluelist.h> | 17 | #include <qvaluelist.h> |
18 | #include <qdatetime.h> | ||
18 | 19 | ||
19 | class AbstractMail; | 20 | class AbstractMail; |
20 | /* a class to describe mails in a mailbox */ | 21 | /* a class to describe mails in a mailbox */ |
21 | /* Attention! | 22 | /* Attention! |
22 | From programmers point of view it would make sense to | 23 | From programmers point of view it would make sense to |
23 | store the mail body into this class, too. | 24 | store the mail body into this class, too. |
24 | But: not from the point of view of the device. | 25 | But: not from the point of view of the device. |
25 | Mailbodies can be real large. So we request them when | 26 | Mailbodies can be real large. So we request them when |
26 | needed from the mail-wrapper class direct from the server itself | 27 | needed from the mail-wrapper class direct from the server itself |
27 | (imap) or from a file-based cache (pop3?) | 28 | (imap) or from a file-based cache (pop3?) |
28 | So there is no interface "const QString&body()" but you should | 29 | So there is no interface "const QString&body()" but you should |
29 | make a request to the mailwrapper with this class as parameter to | 30 | make a request to the mailwrapper with this class as parameter to |
30 | get the body. Same words for the attachments. | 31 | get the body. Same words for the attachments. |
31 | */ | 32 | */ |
32 | class RecMail:public Opie::Core::ORefCount | 33 | class RecMail:public Opie::Core::ORefCount |
33 | { | 34 | { |
34 | public: | 35 | public: |
35 | RecMail(); | 36 | RecMail(); |
36 | RecMail(const RecMail&old); | 37 | RecMail(const RecMail&old); |
37 | virtual ~RecMail(); | 38 | virtual ~RecMail(); |
38 | 39 | ||
39 | const unsigned int getNumber()const{return msg_number;} | 40 | const unsigned int getNumber()const{return msg_number;} |
40 | void setNumber(unsigned int number){msg_number=number;} | 41 | void setNumber(unsigned int number){msg_number=number;} |
41 | const QString&getDate()const{ return date; } | ||
42 | void setDate( const QString&a ) { date = a; } | ||
43 | const QString&getFrom()const{ return from; } | 42 | const QString&getFrom()const{ return from; } |
44 | void setFrom( const QString&a ) { from = a; } | 43 | void setFrom( const QString&a ) { from = a; } |
45 | const QString&getSubject()const { return subject; } | 44 | const QString&getSubject()const { return subject; } |
46 | void setSubject( const QString&s ) { subject = s; } | 45 | void setSubject( const QString&s ) { subject = s; } |
47 | const QString&getMbox()const{return mbox;} | 46 | const QString&getMbox()const{return mbox;} |
48 | void setMbox(const QString&box){mbox = box;} | 47 | void setMbox(const QString&box){mbox = box;} |
49 | void setMsgid(const QString&id){msg_id=id;} | 48 | void setMsgid(const QString&id){msg_id=id;} |
50 | const QString&Msgid()const{return msg_id;} | 49 | const QString&Msgid()const{return msg_id;} |
51 | void setReplyto(const QString&reply){replyto=reply;} | 50 | void setReplyto(const QString&reply){replyto=reply;} |
52 | const QString&Replyto()const{return replyto;} | 51 | const QString&Replyto()const{return replyto;} |
53 | void setMsgsize(unsigned int size){msg_size = size;} | 52 | void setMsgsize(unsigned int size){msg_size = size;} |
54 | const unsigned int Msgsize()const{return msg_size;} | 53 | const unsigned int Msgsize()const{return msg_size;} |
@@ -62,32 +61,38 @@ public: | |||
62 | const QStringList&Bcc()const; | 61 | const QStringList&Bcc()const; |
63 | void setInreply(const QStringList&list); | 62 | void setInreply(const QStringList&list); |
64 | const QStringList&Inreply()const; | 63 | const QStringList&Inreply()const; |
65 | void setReferences(const QStringList&list); | 64 | void setReferences(const QStringList&list); |
66 | const QStringList&References()const; | 65 | const QStringList&References()const; |
67 | 66 | ||
68 | const QBitArray&getFlags()const{return msg_flags;} | 67 | const QBitArray&getFlags()const{return msg_flags;} |
69 | void setFlags(const QBitArray&flags){msg_flags = flags;} | 68 | void setFlags(const QBitArray&flags){msg_flags = flags;} |
70 | 69 | ||
71 | void setWrapper(AbstractMail*wrapper); | 70 | void setWrapper(AbstractMail*wrapper); |
72 | AbstractMail* Wrapper(); | 71 | AbstractMail* Wrapper(); |
73 | 72 | ||
73 | const QDateTime&getDate()const{ return maildate; } | ||
74 | const QString&getStringDate()const{return date;} | ||
75 | void setDate( const QDateTime&a,int offset=0 ); | ||
76 | |||
74 | protected: | 77 | protected: |
75 | QString subject,date,from,mbox,msg_id,replyto; | 78 | QString subject,from,mbox,msg_id,replyto; |
76 | unsigned int msg_number,msg_size; | 79 | unsigned int msg_number,msg_size; |
77 | QBitArray msg_flags; | 80 | QBitArray msg_flags; |
78 | QStringList to,cc,bcc,in_reply_to,references; | 81 | QStringList to,cc,bcc,in_reply_to,references; |
79 | AbstractMail*wrapper; | 82 | AbstractMail*wrapper; |
80 | void init(); | 83 | void init(); |
81 | void copy_old(const RecMail&old); | 84 | void copy_old(const RecMail&old); |
85 | QDateTime maildate; | ||
86 | QString date; | ||
82 | }; | 87 | }; |
83 | 88 | ||
84 | typedef Opie::Core::OSmartPointer<RecMail> RecMailP; | 89 | typedef Opie::Core::OSmartPointer<RecMail> RecMailP; |
85 | typedef QMap<QString,QString> part_plist_t; | 90 | typedef QMap<QString,QString> part_plist_t; |
86 | 91 | ||
87 | class RecPart:public Opie::Core::ORefCount | 92 | class RecPart:public Opie::Core::ORefCount |
88 | { | 93 | { |
89 | protected: | 94 | protected: |
90 | QString m_type,m_subtype,m_identifier,m_encoding,m_description; | 95 | QString m_type,m_subtype,m_identifier,m_encoding,m_description; |
91 | unsigned int m_lines,m_size; | 96 | unsigned int m_lines,m_size; |
92 | part_plist_t m_Parameters; | 97 | part_plist_t m_Parameters; |
93 | /* describes the position in the mail */ | 98 | /* describes the position in the mail */ |
diff --git a/noncore/net/mail/mailistviewitem.cpp b/noncore/net/mail/mailistviewitem.cpp index 0b926da..d3a0723 100644 --- a/noncore/net/mail/mailistviewitem.cpp +++ b/noncore/net/mail/mailistviewitem.cpp | |||
@@ -1,28 +1,29 @@ | |||
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 <qpe/resource.h> | 4 | #include <qpe/resource.h> |
5 | #include <qpe/timestring.h> | ||
5 | 6 | ||
6 | MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) | 7 | MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) |
7 | :QListViewItem(parent,item),mail_data() | 8 | :QListViewItem(parent,item),mail_data() |
8 | { | 9 | { |
9 | } | 10 | } |
10 | 11 | ||
11 | void MailListViewItem::showEntry() | 12 | void MailListViewItem::showEntry() |
12 | { | 13 | { |
13 | if ( mail_data->getFlags().testBit( FLAG_ANSWERED ) == true) { | 14 | if ( mail_data->getFlags().testBit( FLAG_ANSWERED ) == true) { |
14 | setPixmap( 0, Resource::loadPixmap( "mail/kmmsgreplied") ); | 15 | setPixmap( 0, Resource::loadPixmap( "mail/kmmsgreplied") ); |
15 | } else if ( mail_data->getFlags().testBit( FLAG_SEEN ) == true ) { | 16 | } else if ( mail_data->getFlags().testBit( FLAG_SEEN ) == true ) { |
16 | /* 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 lot of icons but only on mails |
17 | replied or new - Alwin*/ | 18 | replied or new - Alwin*/ |
18 | //setPixmap( 0, Resource::loadPixmap( "mail/kmmsgunseen") ); | 19 | //setPixmap( 0, Resource::loadPixmap( "mail/kmmsgunseen") ); |
19 | } else { | 20 | } else { |
20 | setPixmap( 0, Resource::loadPixmap( "mail/kmmsgnew") ); | 21 | setPixmap( 0, Resource::loadPixmap( "mail/kmmsgnew") ); |
21 | } | 22 | } |
22 | double s = mail_data->Msgsize(); | 23 | double s = mail_data->Msgsize(); |
23 | int w; | 24 | int w; |
24 | w=0; | 25 | w=0; |
25 | 26 | ||
26 | while (s>1024) { | 27 | while (s>1024) { |
27 | s/=1024; | 28 | s/=1024; |
28 | ++w; | 29 | ++w; |
@@ -39,29 +40,42 @@ void MailListViewItem::showEntry() | |||
39 | q="M"; | 40 | q="M"; |
40 | break; | 41 | break; |
41 | default: | 42 | default: |
42 | break; | 43 | break; |
43 | } | 44 | } |
44 | 45 | ||
45 | { | 46 | { |
46 | QTextOStream o(&fsize); | 47 | QTextOStream o(&fsize); |
47 | if (w>0) o.precision(2); else o.precision(0); | 48 | if (w>0) o.precision(2); else o.precision(0); |
48 | o.setf(QTextStream::fixed); | 49 | o.setf(QTextStream::fixed); |
49 | o << s << " " << q << "Byte"; | 50 | o << s << " " << q << "Byte"; |
50 | } | 51 | } |
51 | |||
52 | setText(1,mail_data->getSubject()); | 52 | setText(1,mail_data->getSubject()); |
53 | setText(2,mail_data->getFrom()); | 53 | setText(2,mail_data->getFrom()); |
54 | setText(3,fsize); | 54 | setText(3,fsize); |
55 | setText(4,mail_data->getDate()); | 55 | setText(4,mail_data->getStringDate()); |
56 | } | ||
57 | |||
58 | QString MailListViewItem::key(int col,bool) const | ||
59 | { | ||
60 | QString temp; | ||
61 | if (col == 4) { | ||
62 | temp.sprintf( "%08d",QDateTime().secsTo(mail_data->getDate())); | ||
63 | return temp; | ||
64 | } | ||
65 | if (col == 3) { | ||
66 | temp.sprintf( "%020d",mail_data->Msgsize()); | ||
67 | return temp; | ||
68 | } | ||
69 | return text(col); | ||
56 | } | 70 | } |
57 | 71 | ||
58 | void MailListViewItem::storeData(const RecMailP&data) | 72 | void MailListViewItem::storeData(const RecMailP&data) |
59 | { | 73 | { |
60 | mail_data = data; | 74 | mail_data = data; |
61 | } | 75 | } |
62 | 76 | ||
63 | const RecMailP& MailListViewItem::data()const | 77 | const RecMailP& MailListViewItem::data()const |
64 | { | 78 | { |
65 | return mail_data; | 79 | return mail_data; |
66 | } | 80 | } |
67 | 81 | ||
diff --git a/noncore/net/mail/mailistviewitem.h b/noncore/net/mail/mailistviewitem.h index d953d83..ce64ca9 100644 --- a/noncore/net/mail/mailistviewitem.h +++ b/noncore/net/mail/mailistviewitem.h | |||
@@ -7,17 +7,18 @@ | |||
7 | 7 | ||
8 | class MailListViewItem:public QListViewItem | 8 | class MailListViewItem:public QListViewItem |
9 | { | 9 | { |
10 | public: | 10 | public: |
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 | ||
19 | virtual QString key(int col,bool) const; | ||
19 | protected: | 20 | protected: |
20 | RecMailP mail_data; | 21 | RecMailP mail_data; |
21 | }; | 22 | }; |
22 | 23 | ||
23 | #endif | 24 | #endif |
diff --git a/noncore/net/mail/mainwindow.cpp b/noncore/net/mail/mainwindow.cpp index 6252fc2..c115b32 100644 --- a/noncore/net/mail/mainwindow.cpp +++ b/noncore/net/mail/mainwindow.cpp | |||
@@ -94,25 +94,26 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) | |||
94 | folderView->setRootIsDecorated( true ); | 94 | folderView->setRootIsDecorated( true ); |
95 | folderView->addColumn( tr( "Mailbox" ) ); | 95 | folderView->addColumn( tr( "Mailbox" ) ); |
96 | 96 | ||
97 | layout->addWidget( folderView ); | 97 | layout->addWidget( folderView ); |
98 | 98 | ||
99 | mailView = new QListView( view ); | 99 | mailView = new QListView( view ); |
100 | mailView->addColumn( "" ); | 100 | mailView->addColumn( "" ); |
101 | mailView->addColumn( tr( "Subject" ),QListView::Manual ); | 101 | mailView->addColumn( tr( "Subject" ),QListView::Manual ); |
102 | mailView->addColumn( tr( "Sender" ),QListView::Manual ); | 102 | mailView->addColumn( tr( "Sender" ),QListView::Manual ); |
103 | mailView->addColumn( tr( "Size" ),QListView::Manual); | 103 | mailView->addColumn( tr( "Size" ),QListView::Manual); |
104 | mailView->addColumn( tr( "Date" )); | 104 | mailView->addColumn( tr( "Date" )); |
105 | mailView->setAllColumnsShowFocus(true); | 105 | mailView->setAllColumnsShowFocus(true); |
106 | mailView->setSorting(-1); | 106 | mailView->setShowSortIndicator(true); |
107 | mailView->setSorting(4,false); | ||
107 | 108 | ||
108 | statusWidget = new StatusWidget( wrapperBox ); | 109 | statusWidget = new StatusWidget( wrapperBox ); |
109 | statusWidget->hide(); | 110 | statusWidget->hide(); |
110 | 111 | ||
111 | layout->addWidget( mailView ); | 112 | layout->addWidget( mailView ); |
112 | layout->setStretchFactor( folderView, 1 ); | 113 | layout->setStretchFactor( folderView, 1 ); |
113 | layout->setStretchFactor( mailView, 2 ); | 114 | layout->setStretchFactor( mailView, 2 ); |
114 | 115 | ||
115 | slotAdjustLayout(); | 116 | slotAdjustLayout(); |
116 | 117 | ||
117 | QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold); | 118 | QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold); |
118 | QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold); | 119 | QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold); |
diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp index ce694d5..d5f9b7f 100644 --- a/noncore/net/mail/viewmail.cpp +++ b/noncore/net/mail/viewmail.cpp | |||
@@ -280,25 +280,25 @@ void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int | |||
280 | } | 280 | } |
281 | delete menu; | 281 | delete menu; |
282 | } | 282 | } |
283 | 283 | ||
284 | 284 | ||
285 | void ViewMail::setMail(const RecMailP&mail ) | 285 | void ViewMail::setMail(const RecMailP&mail ) |
286 | { | 286 | { |
287 | 287 | ||
288 | m_recMail = mail; | 288 | m_recMail = mail; |
289 | 289 | ||
290 | m_mail[0] = mail->getFrom(); | 290 | m_mail[0] = mail->getFrom(); |
291 | m_mail[1] = mail->getSubject(); | 291 | m_mail[1] = mail->getSubject(); |
292 | m_mail[3] = mail->getDate(); | 292 | m_mail[3] = mail->getStringDate(); |
293 | m_mail[4] = mail->Msgid(); | 293 | m_mail[4] = mail->Msgid(); |
294 | 294 | ||
295 | m_mail2[0] = mail->To(); | 295 | m_mail2[0] = mail->To(); |
296 | m_mail2[1] = mail->CC(); | 296 | m_mail2[1] = mail->CC(); |
297 | m_mail2[2] = mail->Bcc(); | 297 | m_mail2[2] = mail->Bcc(); |
298 | 298 | ||
299 | setText(); | 299 | setText(); |
300 | } | 300 | } |
301 | 301 | ||
302 | 302 | ||
303 | 303 | ||
304 | ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) | 304 | ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) |