Async KMail Reader (3/5): Allow storing of BodyPartMemento's in KMReader. This lets selected BodyPartMementos transcend the (temporary) partNode hierarchy in KMReader which is destroyed on every parseMsg()

svn path=/branches/kdepim/enterprise/kdepim/; revision=972556
wilder-work
Marc Mutz 17 years ago
parent 841c8dab40
commit 77fd8e102a
  1. 48
      kmreaderwin.cpp
  2. 19
      kmreaderwin.h

@ -1197,9 +1197,10 @@ void KMReaderWin::setMsg(KMMessage* aMsg, bool force)
kdDebug(5006) << "(" << aMsg->getMsgSerNum() << ", last " << mLastSerNum << ") " << aMsg->subject() << " "
<< aMsg->fromStrip() << ", readyToShow " << (aMsg->readyToShow()) << endl;
//Reset the level quote if the msg has changed.
// Reset message-transient state
if (aMsg && aMsg->getMsgSerNum() != mLastSerNum ){
mLevelQuote = GlobalSettings::self()->collapseQuoteLevelSpin()-1;
clearBodyPartMementos();
}
if ( mPrinting )
mLevelQuote = -1;
@ -2780,6 +2781,51 @@ QString KMReaderWin::renderAttachments(partNode * node, const QColor &bgColor )
return html;
}
using namespace KMail::Interface;
void KMReaderWin::setBodyPartMemento( const partNode * node, const QCString & which, BodyPartMemento * memento )
{
const QCString index = node->path() + ':' + which.lower();
const std::map<QCString,BodyPartMemento*>::iterator it = mBodyPartMementoMap.lower_bound( index );
if ( it != mBodyPartMementoMap.end() && it->first == index ) {
if ( memento && memento == it->second )
return;
delete it->second;
if ( memento )
it->second = memento;
else
mBodyPartMementoMap.erase( it );
} else {
if ( memento )
mBodyPartMementoMap.insert( it, std::make_pair( index, memento ) );
}
if ( Observable * o = memento ? memento->asObservable() : 0 )
o->attach( this );
}
BodyPartMemento * KMReaderWin::bodyPartMemento( const partNode * node, const QCString & which ) const
{
const QCString index = node->path() + ':' + which.lower();
const std::map<QCString,BodyPartMemento*>::const_iterator it = mBodyPartMementoMap.find( index );
if ( it == mBodyPartMementoMap.end() )
return 0;
else
return it->second;
}
void KMReaderWin::clearBodyPartMementos()
{
for ( std::map<QCString,BodyPartMemento*>::const_iterator it = mBodyPartMementoMap.begin(), end = mBodyPartMementoMap.end() ; it != end ; ++it )
delete it->second;
mBodyPartMementoMap.clear();
}
#include "kmreaderwin.moc"

@ -14,6 +14,8 @@
#include "kmmimeparttree.h" // Needed for friend declaration.
#include "interfaces/observer.h"
#include <map>
class QFrame;
class QSplitter;
class QHBox;
@ -42,6 +44,7 @@ class KMMessagePart;
namespace KMail {
namespace Interface {
class Observable;
class BodyPartMemento;
}
class PartMetaData;
class ObjectTreeParser;
@ -302,6 +305,19 @@ public:
/* show or hide the list that points to the attachments */
void setShowAttachmentQuicklist( bool showAttachmentQuicklist = true ) { mShowAttachmentQuicklist = showAttachmentQuicklist; }
/* retrieve BodyPartMemento of id \a which for partNode \a node */
KMail::Interface::BodyPartMemento * bodyPartMemento( const partNode * node, const QCString & which ) const;
/* set/replace BodyPartMemento \a memento of id \a which for
partNode \a node. If there was a BodyPartMemento registered
already, replaces (deletes) that one. */
void setBodyPartMemento( const partNode * node, const QCString & which, KMail::Interface::BodyPartMemento * memento );
private:
/* deletes all BodyPartMementos. Use this when skipping to another
message (as opposed to re-loading the same one again). */
void clearBodyPartMementos();
signals:
/** Emitted after parsing of a message to have it stored
in unencrypted state in it's folder. */
@ -530,12 +546,13 @@ private:
KToggleAction *mToggleFixFontAction;
KURL mUrlClicked;
KMail::HtmlWriter * mHtmlWriter;
std::map<QCString,KMail::Interface::BodyPartMemento*> mBodyPartMementoMap;
// an attachment should be updated
bool mAtmUpdate;
int mChoice;
unsigned long mWaitingForSerNum;
float mSavedRelativePosition;
int mLevelQuote;
int mLevelQuote;
bool mDecrytMessageOverwrite;
bool mShowSignatureDetails;
bool mShowAttachmentQuicklist;

Loading…
Cancel
Save