SVN commit 815012 by toma: Reimplement the cool mailody3 feature where the recipient is shown instead of the sender when the sender is you. iow: don't show your own name for sent items, but show where the message was sent to. M +28 -1 headerproxy.cpp M +1 -0 headerproxy.h --- trunk/kdereview/mailody/src/headerproxy.cpp #815011:815012 @@ -19,6 +19,7 @@ #include "headerproxy.h" #include "messagedata.h" +#include "global.h" #include @@ -59,11 +60,37 @@ bool HeaderProxy::filterAcceptsColumn( int sourceCol, const QModelIndex& ) const { - if ( sourceCol > 3 ) + if ( sourceCol == 4 /* size */ || sourceCol == 2 /* Receiver */ ) return false; return true; } +QVariant HeaderProxy::data ( const QModelIndex & index, int role ) const +{ + if ( index.column() == 1 ) { /* if this is a request for the sender column */ + const QModelIndex sourceIndex = mapToSource( index ); + const QModelIndex col2 = sourceModel()->index( sourceIndex.row(), 2, sourceIndex.parent() ); + + /* fetch the sender */ + QString sender = QSortFilterProxyModel::data( index, Qt::EditRole ).toString(); + + /* check if that is my address */ + if ( Global::myEmail( sender ) ) { + + /* Return the recipient instead of the sender, if sort than raw, else prefixed */ + if ( role == Qt::DisplayRole ) + return i18n("To: %1", sourceModel()->data( col2, Qt::DisplayRole ).toString()); + else + return sourceModel()->data( col2, Qt::EditRole ).toString(); + + } else { /* it's not my address, return the requested value */ + return sourceModel()->data( sourceIndex, role ); + } + + } else /* this is not a request for the sender column, call base */ + return QSortFilterProxyModel::data( index, role ); +} + void HeaderProxy::setHideDeleted( bool hide ) { m_hideDeleted = hide; --- trunk/kdereview/mailody/src/headerproxy.h #815011:815012 @@ -49,6 +49,7 @@ void setSortOnChild( bool sort ); protected: + virtual QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const; virtual bool filterAcceptsRow( int sourceRow, const QModelIndex & sourceParent ) const; virtual bool filterAcceptsColumn( int sourceCol,