author | alwin <alwin> | 2004-10-26 01:08:58 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-10-26 01:08:58 (UTC) |
commit | cd3245ade209b4672ab5c51003aa66b5908c67a1 (patch) (side-by-side diff) | |
tree | dfd4246557ff5d8804204387660de7e0afbd4032 /noncore | |
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 | 25 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailstatics.h | 4 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailtypes.cpp | 28 | ||||
-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 | 17 | ||||
-rw-r--r-- | noncore/net/mail/viewmail.cpp | 6 |
10 files changed, 81 insertions, 46 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 @@ -384,7 +384,7 @@ QStringList Genericwrapper::parseInreplies(mailimf_in_reply_to * in_replies) void Genericwrapper::parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to) { - int r; + int r,toffset; mailmessage_list * env_list = 0; r = mailsession_get_messages_list(session,&env_list); if (r != MAIL_NO_ERROR) { @@ -437,13 +437,13 @@ void Genericwrapper::parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > & mail->setCC( parseAddressList( single_fields.fld_cc->cc_addr_list ) ); if (single_fields.fld_bcc) mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) ); - if (single_fields.fld_orig_date) - mail->setDate( parseDateTime( single_fields.fld_orig_date->dt_date_time ) ); - // crashes when accessing pop3 account? + if (single_fields.fld_orig_date) { + QDateTime d = parseDateTime( single_fields.fld_orig_date->dt_date_time,toffset); + mail->setDate( d,toffset ); + } if (single_fields.fld_message_id && single_fields.fld_message_id->mid_value) { mail->setMsgid(QString(single_fields.fld_message_id->mid_value)); } - if (single_fields.fld_reply_to) { QStringList t = parseAddressList(single_fields.fld_reply_to->rt_addr_list); if (t.count()>0) { 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 @@ -372,7 +372,7 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) clistcell *current,*c,*cf; mailimap_msg_att_dynamic*flist; mailimap_flag_fetch*cflag; - int size; + int size,toffset; QBitArray mFlags(7); QStringList addresslist; @@ -424,7 +424,8 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) } if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { mailimap_envelope * head = item->att_data.att_static->att_data.att_env; - m->setDate(parseDateTime(head->env_date)); + QDateTime d = parseDateTime(head->env_date,toffset); + m->setDate(d,toffset); m->setSubject(convert_String((const char*)head->env_subject)); if (head->env_from!=NULL) { addresslist = address_list_to_stringlist(head->env_from->frm_list); 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 @@ #include "mailstatics.h" #include <libetpan/libetpan.h> -#include <qpe/timestring.h> +//#include <qpe/timestring.h> -QString MailStatics::parseDateTime(const mailimf_date_time *date ) +QDateTime MailStatics::parseDateTime(const mailimf_date_time *date,int&offset ) { - if (!date) return ""; + offset = 0; + if (!date) { + return QDateTime(); + } QDateTime da(QDate(date->dt_year,date->dt_month,date->dt_day),QTime(date->dt_hour,date->dt_min,date->dt_sec)); - QString timestring = TimeString::numberDateString(QDate(date->dt_year,date->dt_month,date->dt_day))+" "; - timestring+=TimeString::timeString(QTime(date->dt_hour,date->dt_min,date->dt_sec))+" "; - timestring.sprintf(timestring+" %+05i",date->dt_zone); - return timestring; + offset = date->dt_zone; + return da; } -QString MailStatics::parseDateTime(const char*date) +QDateTime MailStatics::parseDateTime(const char*date,int&offset) { - mailimf_date_time * date_time; - QString d = ""; + mailimf_date_time * date_time=0; + QDateTime d; size_t cur_tok = 0; if (!date) return d; int r = mailimf_date_time_parse(date,strlen(date),&cur_tok,&date_time); if (r==MAILIMF_NO_ERROR) { - d = parseDateTime(date_time); + d = parseDateTime(date_time,offset); } if (date_time) { mailimf_date_time_free(date_time); } return d; -}
\ 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 @@ -9,8 +9,8 @@ struct mailimf_date_time; class MailStatics { protected: - static QString parseDateTime(const mailimf_date_time * date); - static QString parseDateTime(const char*date); + static QDateTime parseDateTime(const mailimf_date_time * date,int&offset); + static QDateTime parseDateTime(const char*date,int&offset); MailStatics(){}; virtual ~MailStatics(){}; public: 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,22 +1,23 @@ #include "mailtypes.h" #include <opie2/odebug.h> +#include <qpe/timestring.h> #include <stdlib.h> using namespace Opie::Core; RecMail::RecMail() - :Opie::Core::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_size(0),msg_flags(7) + :Opie::Core::ORefCount(),subject(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_size(0),msg_flags(7),maildate(),date("") { init(); } RecMail::RecMail(const RecMail&old) - :Opie::Core::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7) + :Opie::Core::ORefCount(),subject(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7),maildate(),date("") { init(); copy_old(old); - odebug << "Copy constructor RecMail" << oendl; + odebug << "Copy constructor RecMail" << oendl; } RecMail::~RecMail() @@ -27,6 +28,7 @@ RecMail::~RecMail() void RecMail::copy_old(const RecMail&old) { subject = old.subject; + maildate = old.maildate; date = old.date; mbox = old.mbox; msg_id = old.msg_id; @@ -53,6 +55,17 @@ void RecMail::init() wrapper = 0; } +void RecMail::setDate( const QDateTime&a,int offset) +{ + QString timestring = TimeString::numberDateString(a.date())+" "; + timestring+=TimeString::timeString(a.time()); + if (offset > 0) { + timestring.sprintf(timestring+" %+05i",offset); + } + date = timestring; + maildate = a; +} + void RecMail::setWrapper(AbstractMail*awrapper) { wrapper = awrapper; @@ -134,7 +147,7 @@ RecPart::RecPart(const RecPart&old) m_size = old.m_size; m_Parameters = old.m_Parameters; m_poslist = old.m_poslist; - odebug << "RecPart copy constructor" << oendl; + odebug << "RecPart copy constructor" << oendl; } RecPart::~RecPart() @@ -258,7 +271,7 @@ RecBody::RecBody(const RecBody&old) m_BodyText = old.m_BodyText; m_PartsList = old.m_PartsList; m_description = old.m_description; - odebug << "Recbody copy constructor" << oendl; + odebug << "Recbody copy constructor" << oendl; } RecBody::~RecBody() @@ -323,14 +336,14 @@ encodedString::encodedString(const encodedString&old) { init(); copy_old(old); - odebug << "encodedeString: copy constructor!" << oendl; + odebug << "encodedeString: copy constructor!" << oendl; } encodedString& encodedString::operator=(const encodedString&old) { init(); copy_old(old); - odebug << "encodedString: assign operator!" << oendl; + odebug << "encodedString: assign operator!" << oendl; return *this; } @@ -396,4 +409,3 @@ folderStat&folderStat::operator=(const folderStat&old) message_recent = old.message_recent; return *this; } - 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 @@ -15,6 +15,7 @@ #include <qstringlist.h> #include <qmap.h> #include <qvaluelist.h> +#include <qdatetime.h> class AbstractMail; /* a class to describe mails in a mailbox */ @@ -38,8 +39,6 @@ public: const unsigned int getNumber()const{return msg_number;} void setNumber(unsigned int number){msg_number=number;} - const QString&getDate()const{ return date; } - void setDate( const QString&a ) { date = a; } const QString&getFrom()const{ return from; } void setFrom( const QString&a ) { from = a; } const QString&getSubject()const { return subject; } @@ -71,14 +70,20 @@ public: void setWrapper(AbstractMail*wrapper); AbstractMail* Wrapper(); + const QDateTime&getDate()const{ return maildate; } + const QString&getStringDate()const{return date;} + void setDate( const QDateTime&a,int offset=0 ); + protected: - QString subject,date,from,mbox,msg_id,replyto; + QString subject,from,mbox,msg_id,replyto; unsigned int msg_number,msg_size; QBitArray msg_flags; QStringList to,cc,bcc,in_reply_to,references; AbstractMail*wrapper; void init(); void copy_old(const RecMail&old); + QDateTime maildate; + QString date; }; typedef Opie::Core::OSmartPointer<RecMail> RecMailP; 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 @@ -2,6 +2,7 @@ #include <libmailwrapper/abstractmail.h> #include <qtextstream.h> #include <qpe/resource.h> +#include <qpe/timestring.h> MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) :QListViewItem(parent,item),mail_data() @@ -13,7 +14,7 @@ void MailListViewItem::showEntry() if ( mail_data->getFlags().testBit( FLAG_ANSWERED ) == true) { setPixmap( 0, Resource::loadPixmap( "mail/kmmsgreplied") ); } else if ( mail_data->getFlags().testBit( FLAG_SEEN ) == true ) { - /* I think it looks nicer if there are not such a log of icons but only on mails + /* I think it looks nicer if there are not such a lot of icons but only on mails replied or new - Alwin*/ //setPixmap( 0, Resource::loadPixmap( "mail/kmmsgunseen") ); } else { @@ -48,11 +49,24 @@ void MailListViewItem::showEntry() o.setf(QTextStream::fixed); o << s << " " << q << "Byte"; } - setText(1,mail_data->getSubject()); setText(2,mail_data->getFrom()); setText(3,fsize); - setText(4,mail_data->getDate()); + setText(4,mail_data->getStringDate()); +} + +QString MailListViewItem::key(int col,bool) const +{ + QString temp; + if (col == 4) { + temp.sprintf( "%08d",QDateTime().secsTo(mail_data->getDate())); + return temp; + } + if (col == 3) { + temp.sprintf( "%020d",mail_data->Msgsize()); + return temp; + } + return text(col); } void MailListViewItem::storeData(const RecMailP&data) 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 @@ -16,6 +16,7 @@ public: void showEntry(); MAILLIB::ATYPE wrapperType(); + virtual QString key(int col,bool) const; protected: RecMailP mail_data; }; 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 @@ -103,7 +103,8 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) mailView->addColumn( tr( "Size" ),QListView::Manual); mailView->addColumn( tr( "Date" )); mailView->setAllColumnsShowFocus(true); - mailView->setSorting(-1); + mailView->setShowSortIndicator(true); + mailView->setSorting(4,false); statusWidget = new StatusWidget( wrapperBox ); statusWidget->hide(); @@ -143,7 +144,7 @@ MainWindow::~MainWindow() void MainWindow::appMessage(const QCString &, const QByteArray &) { - odebug << "appMessage not reached" << oendl; + odebug << "appMessage not reached" << oendl; } void MainWindow::slotAdjustLayout() { @@ -177,32 +178,32 @@ void MainWindow::slotEditSettings() void MainWindow::slotShowFolders( bool ) { - odebug << "slotShowFolders not reached" << oendl; + odebug << "slotShowFolders not reached" << oendl; } void MainWindow::refreshMailView(const QValueList<RecMailP>&) { - odebug << "refreshMailView not reached" << oendl; + odebug << "refreshMailView not reached" << oendl; } void MainWindow::mailLeftClicked(int, QListViewItem *,const QPoint&,int ) { - odebug << "mailLeftClicked not reached" << oendl; + odebug << "mailLeftClicked not reached" << oendl; } void MainWindow::displayMail() { - odebug << "displayMail not reached" << oendl; + odebug << "displayMail not reached" << oendl; } void MainWindow::slotDeleteMail() { - odebug << "deleteMail not reached" << oendl; + odebug << "deleteMail not reached" << oendl; } void MainWindow::mailHold(int, QListViewItem *,const QPoint&,int ) { - odebug << "mailHold not reached" << oendl; + odebug << "mailHold not reached" << oendl; } void MainWindow::slotSendQueued() 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 @@ -144,7 +144,7 @@ void ViewMail::setBody(const RecBodyP&body ) part_plist_t::ConstIterator it = body->Parts()[i]->Parameters().begin(); for (;it!=body->Parts()[i]->Parameters().end();++it) { - odebug << it.key() << oendl; + odebug << it.key() << oendl; if (it.key().lower()=="name") { filename=it.data(); @@ -247,7 +247,7 @@ void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int } break ; - case 2: + case 2: { QString tmpfile = "/tmp/opiemail-image"; encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); @@ -289,7 +289,7 @@ void ViewMail::setMail(const RecMailP&mail ) m_mail[0] = mail->getFrom(); m_mail[1] = mail->getSubject(); - m_mail[3] = mail->getDate(); + m_mail[3] = mail->getStringDate(); m_mail[4] = mail->Msgid(); m_mail2[0] = mail->To(); |