From kde-commits Sun Nov 12 01:50:10 2006 From: Tom Albers Date: Sun, 12 Nov 2006 01:50:10 +0000 To: kde-commits Subject: playground/pim/mailody Message-Id: <1163296210.438679.11411.nullmailer () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=116329627618798 SVN commit 604222 by toma: - add a size column - basic support for threading of messages, works quite well, but probably still a lot to do M +1 -2 TODO M +30 -0 src/headerlistview.cpp M +14 -3 src/headerlistview.h M +22 -8 src/imap.cpp M +35 -1 src/mainwindow.cpp M +13 -1 src/messagedata.cpp M +13 -1 src/messagedata.h --- trunk/playground/pim/mailody/TODO #604221:604222 @@ -7,7 +7,7 @@ Notifications: dont show the popup when it is the current mailbox [allee] -make an area clickable to go to that mailbox +make an area clickable to go to that mailbox [allee] ----------------------------------- @@ -30,7 +30,6 @@ go back to last visted header [allee] go to next unread [fdoving] make keys configurable for nex/previous [fdoving] -size column [allee] on resync(slotFetchMailBox()) save uid and reselect that one [allee] select all [allee] --- trunk/playground/pim/mailody/src/headerlistview.cpp #604221:604222 @@ -34,12 +34,17 @@ addColumn( i18n("Subject"), 150 ); addColumn( i18n("Sender"), 150 ); addColumn( i18n("Date"), 150 ); + addColumn( i18n("Size"), 150 ); setColumnWidthMode(0, QListView::Manual); setColumnWidthMode(1, QListView::Manual); + setColumnWidthMode(2, QListView::Manual); + setColumnWidthMode(3, QListView::Manual); setSorting(2); + setColumnAlignment(3, Qt::AlignRight); setAllColumnsShowFocus(true); setSelectionMode(QListView::Extended); setDragEnabled(true); + setRootIsDecorated(true); } QDragObject *HeaderListView::dragObject() @@ -124,9 +129,23 @@ setText(0, msg->subject() ); setText(1, msg->sender() ); setText(2, msg->vDate() ); + setText(3, msg->vSize() ); setDragEnabled(true); } +HeaderListViewItem::HeaderListViewItem( HeaderListViewItem* parent, + MessageData* msg) + : KListViewItem( parent ) +{ + m_msg = msg; + setText(0, msg->subject() ); + setText(1, msg->sender() ); + setText(2, msg->vDate() ); + setText(3, msg->vSize() ); + setDragEnabled(true); +} + + HeaderListViewItem::~HeaderListViewItem() { } @@ -204,6 +223,17 @@ else return -1; } + else if (col == 3) + { + int one = m_msg->size(); + int two = t->msg()->size(); + if (one == two) + return 0; + else if (one > two) + return 1; + else + return -1; + } else return key( col, ascending ).lower() .compare( i->key( col, ascending).lower() ); --- trunk/playground/pim/mailody/src/headerlistview.h #604221:604222 @@ -39,6 +39,7 @@ public: /** Constructor */ explicit HeaderListView( QWidget* ); + /** dragobject */ QDragObject *dragObject(); @@ -78,11 +79,21 @@ * @param md The message which this headerlistviewitem should be * created for */ - HeaderListViewItem( KListView* lv, MessageData* md); + explicit HeaderListViewItem( KListView* lv, MessageData* md); /** - * Destructor - */ + * Constructor + * @param lvi The headerlistviewitem to which this item should be + * a child. + * @param md The message which this headerlistviewitem should be + * created for + */ + explicit HeaderListViewItem( HeaderListViewItem* lvi, + MessageData* msg); + + /** + * Destructor + */ ~HeaderListViewItem(); /** --- trunk/playground/pim/mailody/src/imap.cpp #604221:604222 @@ -395,9 +395,11 @@ QRegExp rx; if (m_currentQueueItem.state() == Queue::GetHeaders) - rx.setPattern("UID (\\d*)" + QRegExp::escape(" BODY[HEADER.FIELDS ") + rx.setPattern("UID (\\d*) RFC822.SIZE (\\d*)" + + QRegExp::escape(" BODY[HEADER.FIELDS ") + "\\(\"?FROM\"? \"?TO\"? \"?CC\"? " - + "\"?SUBJECT\"? \"?DATE\"?\\)\\] " + + "\"?SUBJECT\"? \"?DATE\"? \"?IN-REPLY-TO\"? " + + "\"?MESSAGE-ID\"?\\)\\] " + QRegExp::escape("{") + "(\\d*)" + QRegExp::escape("}")); else rx.setPattern("UID (\\d*)" + QRegExp::escape(" BODY[] ") @@ -409,17 +411,28 @@ while (rx.search(r.stripWhiteSpace()) != -1) { int uid = rx.cap(1).toInt(); - int expectedLength = rx.cap(2).toInt(); + QString size; + int expectedLength; + if (m_currentQueueItem.state() == Queue::GetHeaders) + { + size = "Size: " + rx.cap(2); + expectedLength = rx.cap(3).toInt(); + } + else + expectedLength = rx.cap(2).toInt(); + int i = r.find("}")+1; QString text = r.mid(i, expectedLength); if (m_currentQueueItem.state() == Queue::GetHeaders) { - // kdDebug() << "UID: " << uid - // << " mb: " << m_currentQueueItem.mailbox() - // << "text" << text - // << endl; + text += size; + kdDebug() << "UID: " << uid + << " mb: " << m_currentQueueItem.mailbox() + << "text" << text + << endl; + headersToSend.append(rx.cap(1)); headersToSend.append(m_currentQueueItem.mailbox()); headersToSend.append(text); @@ -613,7 +626,8 @@ // Priority; above the checkmail calls in the queue. m_queue.prepend(Queue(Queue::GetHeaders, mb, "UID FETCH " + part - + " (BODY.PEEK[HEADER.FIELDS (FROM TO CC SUBJECT DATE)])")); + + " (RFC822.SIZE BODY.PEEK[HEADER.FIELDS (FROM TO CC SUBJECT " + "DATE IN-REPLY-TO MESSAGE-ID)])")); } } --- trunk/playground/pim/mailody/src/mainwindow.cpp #604221:604222 @@ -491,6 +491,7 @@ QStringList::ConstIterator it = values.begin(); + QMap threadMap; while (it != values.end()) { int uid = (*it).toInt(); @@ -506,11 +507,44 @@ if (!exists || mbi->fullName() == "All") { MessageData* r = new MessageData(this, "message", uid, mb, headers); - exists = new HeaderListViewItem(m_headerList, r); + HeaderListViewItem* threadTo = threadMap[r->inreplyto()]; + if (!threadTo || r->inreplyto().isEmpty()) + exists = new HeaderListViewItem(m_headerList, r); + else + exists = new HeaderListViewItem(threadTo, r); + threadMap[r->messageID()] = exists; m_headerMap[uid] = exists; } } + // Well, all message are now shown, and if there was a relation + // they are already there. But, maybe some of the items ahve childeren + // now all messages are known. + kdDebug() << "reparanting start " << endl; + + if (m_headerList->childCount() > 200) + kdDebug() << " Aborted, to many items... " << endl; + else + { + int items=0; + int items2=0; + HeaderListViewItem* item = + (HeaderListViewItem*)m_headerList->firstChild(); + while( item ) + { + HeaderListViewItem* i = threadMap[item->msg()->inreplyto()]; + if (i != 0 && !i->msg()->inreplyto().isEmpty()) + { + items++; + m_headerList->takeItem(item); + i->insertItem(item); + } + item = (HeaderListViewItem*)item->nextSibling(); + items2++; + } + kdDebug() << "reparanting end, usefull for " << items + << " of " << items2 << endl; + } // kdDebug() << "Messages shown: " << m_headerList->childCount() << endl; // scroll down as long as we do not store the last selected mail. --- trunk/playground/pim/mailody/src/messagedata.cpp #604221:604222 @@ -93,8 +93,20 @@ QStringList::iterator it; for (it = headerlist.begin(); it != headerlist.end(); ++it) { - if ((*it).startsWith("Subject", false)) + if ((*it).startsWith("Size", false)) { + m_size = (*it).section(' ',1).stripWhiteSpace().toInt(); + } + else if ((*it).startsWith("Message-Id", false)) + { + m_messageID = (*it).section(' ',1).stripWhiteSpace(); + } + else if ((*it).startsWith("In-Reply-To", false)) + { + m_inreplyto = (*it).section(' ',1).stripWhiteSpace(); + } + else if ((*it).startsWith("Subject", false)) + { const char* usedCS; QString t = (*it).section(' ',1).stripWhiteSpace(); m_subject = --- trunk/playground/pim/mailody/src/messagedata.h #604221:604222 @@ -27,8 +27,8 @@ #include #include +#include - class QStrList; class QListViewItem; @@ -97,6 +97,16 @@ /** Returns the to header of the message, all recepients */ QString to() const { return m_to; } + /** Returns the size of message */ + int size() const { return m_size; } + + /** Returns the size of message for the user */ + QString vSize() const { return + KIO::convertSize(KIO::filesize_t(m_size)); } + + /** Returns id of the message where this is a reply to */ + QString inreplyto() const { return m_inreplyto; } + /** Returns the cc header of the message, all recepients */ QString cc() const { return m_cc; } @@ -181,6 +191,8 @@ QString m_sender_full; QString m_company; QString m_cc; + int m_size; + QString m_inreplyto; QStringList* m_cc_addresses; QString m_to; QStringList* m_to_addresses;