diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-09-01 00:37:02 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-09-01 00:37:02 +0000 |
commit | cc29364f06178f8f6b457384f2ec37a042bd9d43 (patch) | |
tree | 7c77a3184c698bbf9d98cef09fb1ba8124daceba /kmail/attachmentstrategy.cpp | |
parent | 4f6c584bacc8c3c694228f36ada3de77a76614a6 (diff) | |
download | tdepim-cc29364f06178f8f6b457384f2ec37a042bd9d43.tar.gz tdepim-cc29364f06178f8f6b457384f2ec37a042bd9d43.zip |
* Massive set of changes to bring in all fixes and enhancements from the Enterprise PIM branch
* Ensured that the Trinity changes were applied on top of those enhancements, and any redundancy removed
* Added journal read support to the CalDAV resource
* Fixed CalDAV resource to use events URL for tasks and journals when separate URL checkbox unchecked
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1170461 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kmail/attachmentstrategy.cpp')
-rw-r--r-- | kmail/attachmentstrategy.cpp | 87 |
1 files changed, 66 insertions, 21 deletions
diff --git a/kmail/attachmentstrategy.cpp b/kmail/attachmentstrategy.cpp index 8d1e59a90..6e147b946 100644 --- a/kmail/attachmentstrategy.cpp +++ b/kmail/attachmentstrategy.cpp @@ -45,6 +45,21 @@ namespace KMail { +static AttachmentStrategy::Display smartDisplay( const partNode *node ) +{ + if ( node->hasContentDispositionInline() ) + // explict "inline" disposition: + return AttachmentStrategy::Inline; + if ( node->isAttachment() ) + // explicit "attachment" disposition: + return AttachmentStrategy::AsIcon; + if ( node->type() == DwMime::kTypeText && + node->msgPart().fileName().stripWhiteSpace().isEmpty() && + node->msgPart().name().stripWhiteSpace().isEmpty() ) + // text/* w/o filename parameter: + return AttachmentStrategy::Inline; + return AttachmentStrategy::AsIcon; +} // // IconicAttachmentStrategy: @@ -60,7 +75,7 @@ namespace KMail { public: const char * name() const { return "iconic"; } const AttachmentStrategy * next() const { return smart(); } - const AttachmentStrategy * prev() const { return hidden(); } + const AttachmentStrategy * prev() const { return headerOnly(); } bool inlineNestedMessages() const { return false; } Display defaultDisplay( const partNode * ) const { return AsIcon; } @@ -86,18 +101,7 @@ namespace KMail { bool inlineNestedMessages() const { return true; } Display defaultDisplay( const partNode * node ) const { - if ( node->hasContentDispositionInline() ) - // explict "inline" disposition: - return Inline; - if ( node->isAttachment() ) - // explicit "attachment" disposition: - return AsIcon; - if ( node->type() == DwMime::kTypeText && - node->msgPart().fileName().stripWhiteSpace().isEmpty() && - node->msgPart().name().stripWhiteSpace().isEmpty() ) - // text/* w/o filename parameter: - return Inline; - return AsIcon; + return smartDisplay( node ); } }; @@ -134,13 +138,45 @@ namespace KMail { public: const char * name() const { return "hidden"; } - const AttachmentStrategy * next() const { return iconic(); } + const AttachmentStrategy * next() const { return headerOnly(); } const AttachmentStrategy * prev() const { return inlined(); } bool inlineNestedMessages() const { return false; } Display defaultDisplay( const partNode * ) const { return None; } }; + class HeaderOnlyAttachmentStrategy : public AttachmentStrategy { + friend class ::KMail::AttachmentStrategy; + protected: + HeaderOnlyAttachmentStrategy() : AttachmentStrategy() {} + virtual ~HeaderOnlyAttachmentStrategy() {} + + public: + const char * name() const { return "headerOnly"; } + const AttachmentStrategy * next() const { return iconic(); } + const AttachmentStrategy * prev() const { return hidden(); } + + bool inlineNestedMessages() const { + return true; + } + + Display defaultDisplay( const partNode *node ) const { + if ( node->isInEncapsulatedMessage() ) { + return smartDisplay( node ); + } + + partNode::AttachmentDisplayInfo info = node->attachmentDisplayInfo(); + if ( info.displayInHeader ) { + // The entire point about this attachment strategy: Hide attachments in the body that are + // already displayed in the attachment quick list + return None; + } else { + return smartDisplay( node ); + } + } + }; + + // // AttachmentStrategy abstract base: @@ -156,10 +192,11 @@ namespace KMail { const AttachmentStrategy * AttachmentStrategy::create( Type type ) { switch ( type ) { - case Iconic: return iconic(); - case Smart: return smart(); - case Inlined: return inlined(); - case Hidden: return hidden(); + case Iconic: return iconic(); + case Smart: return smart(); + case Inlined: return inlined(); + case Hidden: return hidden(); + case HeaderOnly: return headerOnly(); } kdFatal( 5006 ) << "AttachmentStrategy::create(): Unknown attachment startegy ( type == " << (int)type << " ) requested!" << endl; @@ -168,10 +205,11 @@ namespace KMail { const AttachmentStrategy * AttachmentStrategy::create( const TQString & type ) { TQString lowerType = type.lower(); - if ( lowerType == "iconic" ) return iconic(); + if ( lowerType == "iconic" ) return iconic(); //if ( lowerType == "smart" ) return smart(); // not needed, see below - if ( lowerType == "inlined" ) return inlined(); - if ( lowerType == "hidden" ) return hidden(); + if ( lowerType == "inlined" ) return inlined(); + if ( lowerType == "hidden" ) return hidden(); + if ( lowerType == "headeronly" ) return headerOnly(); // don't kdFatal here, b/c the strings are user-provided // (KConfig), so fail gracefully to the default: return smart(); @@ -181,6 +219,7 @@ namespace KMail { static const AttachmentStrategy * smartStrategy = 0; static const AttachmentStrategy * inlinedStrategy = 0; static const AttachmentStrategy * hiddenStrategy = 0; + static const AttachmentStrategy * headerOnlyStrategy = 0; const AttachmentStrategy * AttachmentStrategy::iconic() { if ( !iconicStrategy ) @@ -206,4 +245,10 @@ namespace KMail { return hiddenStrategy; } + const AttachmentStrategy * AttachmentStrategy::headerOnly() { + if ( !headerOnlyStrategy ) + headerOnlyStrategy = new HeaderOnlyAttachmentStrategy(); + return headerOnlyStrategy; + } + } // namespace KMail |