Merged revisions 981596 via svnmerge from

svn+ssh://tmcguire@svn.kde.org/home/kde/branches/kdepim/enterprise4/kdepim

................
  r981596 | tmcguire | 2009-06-13 19:30:52 +0200 (Sat, 13 Jun 2009) | 12 lines
  
  Merged revisions 981587 via svnmerge from 
  svn+ssh://tmcguire@svn.kde.org/home/kde/branches/kdepim/enterprise/kdepim
  
  ........
    r981587 | tmcguire | 2009-06-13 19:16:33 +0200 (Sat, 13 Jun 2009) | 5 lines
    
    Provide a "scroll to" menu entry when clicking on an attachment.
    
    Hopefully enough to fix kolab/issue3375.
    MERGE: e4, 4.4
  ........
................

svn path=/trunk/KDE/kdepim/; revision=986495
wilder-work
Thomas McGuire 17 years ago
parent b40365db39
commit 9fe1ce79ff
  1. 3
      kmcommands.h
  2. 32
      kmreaderwin.cpp

@ -925,7 +925,8 @@ public:
ChiasmusEncrypt = 6,
Delete = 7,
Edit = 8,
Copy = 9
Copy = 9,
ScrollTo = 10
};
/**
* Construct a new command

@ -41,6 +41,7 @@
#include <QResizeEvent>
#include <QMouseEvent>
#include <QScrollArea>
#include <QScrollBar>
#include <QSignalMapper>
using KMail::MailSourceViewer;
#include "partNode.h"
@ -2041,6 +2042,26 @@ void KMReaderWin::slotUrlPopup(const QString &aUrl, const QPoint& aPos)
}
}
// Checks if the given node has a parent node that is a DIV which has an ID attribute
// with the value specified here
static bool hasParentDivWithId( const DOM::Node &start, const QString &id )
{
if ( start.isNull() )
return false;
if ( start.nodeName().string() == "div" ) {
for ( unsigned int i = 0; i < start.attributes().length(); i++ ) {
if ( start.attributes().item( i ).nodeName().string() == "id" &&
start.attributes().item( i ).nodeValue().string() == id )
return true;
}
}
if ( !start.parentNode().isNull() )
return hasParentDivWithId( start.parentNode(), id );
else return false;
}
//-----------------------------------------------------------------------------
void KMReaderWin::prepareHandleAttachment( int id, const QString& fileName )
{
@ -2071,6 +2092,14 @@ void KMReaderWin::showAttachmentPopup( int id, const QString & name, const QPoin
connect( action, SIGNAL( triggered(bool) ), attachmentMapper, SLOT( map() ) );
attachmentMapper->setMapping( action, KMHandleAttachmentCommand::View );
const bool attachmentInHeader = hasParentDivWithId( mViewer->nodeUnderMouse(), "attachmentInjectionPoint" );
const bool hasScrollbar = mViewer->view()->verticalScrollBar()->isVisible();
if ( attachmentInHeader && hasScrollbar ) {
action = menu->addAction( i18n( "Scroll To" ) );
connect( action, SIGNAL( triggered(bool) ), attachmentMapper, SLOT( map() ) );
attachmentMapper->setMapping( action, KMHandleAttachmentCommand::ScrollTo );
}
action = menu->addAction(SmallIcon("document-save-as"),i18n("Save As...") );
connect( action, SIGNAL( triggered(bool) ), attachmentMapper, SLOT( map() ) );
attachmentMapper->setMapping( action, KMHandleAttachmentCommand::Save );
@ -2155,6 +2184,9 @@ void KMReaderWin::slotHandleAttachment( int choice )
QMimeData *mimeData = new QMimeData;
mimeData->setUrls( urls );
QApplication::clipboard()->setMimeData( mimeData, QClipboard::Clipboard );
} else if ( choice == KMHandleAttachmentCommand::ScrollTo ) {
// The anchors for this are created in ObjectTreeParser::parseObjectTree()
mViewer->gotoAnchor( QString::fromLatin1( "att%1" ).arg( node->nodeId() ) );
}
else {
KMHandleAttachmentCommand* command = new KMHandleAttachmentCommand(

Loading…
Cancel
Save