diff --git a/kmmimeparttree.cpp b/kmmimeparttree.cpp index 0a5ad906d..bb318038c 100644 --- a/kmmimeparttree.cpp +++ b/kmmimeparttree.cpp @@ -298,16 +298,10 @@ void KMMimePartTree::startHandleAttachmentCommand( int action ) return; partNode *node = static_cast( selected.first() )->node(); - QString name = mReaderWin->tempFileUrlFromPartNode( node ).path(); - KMHandleAttachmentCommand *command = new KMHandleAttachmentCommand( - node, mReaderWin->message(), node->nodeId(), name, - KMHandleAttachmentCommand::AttachmentAction( action ), - KService::Ptr(), this ); - connect( command, SIGNAL( showAttachment( int, const QString& ) ), - mReaderWin, SLOT( slotAtmView( int, const QString& ) ) ); - command->start(); + mReaderWin->prepareHandleAttachment( node->nodeId(), name ); + mReaderWin->slotHandleAttachment( action ); } void KMMimePartTree::slotCopy() diff --git a/kmreaderwin.cpp b/kmreaderwin.cpp index 757c8692c..c14ee2141 100644 --- a/kmreaderwin.cpp +++ b/kmreaderwin.cpp @@ -1960,10 +1960,16 @@ void KMReaderWin::slotUrlPopup(const QString &aUrl, const QPoint& aPos) } //----------------------------------------------------------------------------- -void KMReaderWin::showAttachmentPopup( int id, const QString & name, const QPoint &p ) +void KMReaderWin::prepareHandleAttachment( int id, const QString& fileName ) { mAtmCurrent = id; - mAtmCurrentName = name; + mAtmCurrentName = fileName; +} + +//----------------------------------------------------------------------------- +void KMReaderWin::showAttachmentPopup( int id, const QString & name, const QPoint &p ) +{ + prepareHandleAttachment( id, name ); KMenu *menu = new KMenu(); QAction *action; @@ -2663,7 +2669,7 @@ void KMReaderWin::slotEditAttachment(partNode * node) command->start(); } -KMail::CSSHelper* KMReaderWin::cssHelper() +KMail::CSSHelper* KMReaderWin::cssHelper() const { return mCSSHelper; } diff --git a/kmreaderwin.h b/kmreaderwin.h index 129595efc..2bcff5340 100644 --- a/kmreaderwin.h +++ b/kmreaderwin.h @@ -282,6 +282,13 @@ public: emit popupMenu( *message(), url, p ); } + /** + * Sets the current attachment ID and the current attachment temporary filename + * to the given values. + * Call this so that slotHandleAttachment() knows which attachment to handle. + */ + void prepareHandleAttachment( int id, const QString& fileName ); + void showAttachmentPopup( int id, const QString & name, const QPoint & p ); /** Set the serial number of the message this reader window is currently @@ -308,6 +315,8 @@ public: /* show or hide the list that points to the attachments */ void setShowAttachmentQuicklist( bool showAttachmentQuicklist = true ) { mShowAttachmentQuicklist = showAttachmentQuicklist; } + KMail::CSSHelper* cssHelper() const; + signals: /** Emitted after parsing of a message to have it stored in unencrypted state in it's folder. */ @@ -386,7 +395,15 @@ public slots: void slotDeleteAttachment( partNode* node ); void slotEditAttachment( partNode* node ); - KMail::CSSHelper* cssHelper(); + + /** + * Does an action for the current attachment. + * The action is defined by the KMHandleAttachmentCommand::AttachmentAction + * enum. + * prepareHandleAttachment() needs to be called before calling this to set the + * correct attachment ID. + */ + void slotHandleAttachment( int action ); protected slots: void slotCycleHeaderStyles(); @@ -406,7 +423,6 @@ protected slots: /** Some attachment operations. */ void slotAtmView( int id, const QString& name ); void slotDelayedResize(); - void slotHandleAttachment( int ); /** Print message. Called on as a response of finished() signal of mPartHtmlWriter after rendering is finished.