• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.10.5 API Reference
  • KDE Home
  • Contact Us
 

akonadi/contact

  • akonadi
  • contact
textbrowser.cpp
1 /*
2  Copyright (c) 2012 Montel Laurent <montel@kde.org>
3 
4  This library is free software; you can redistribute it and/or modify it
5  under the terms of the GNU Library General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or (at your
7  option) any later version.
8 
9  This library is distributed in the hope that it will be useful, but WITHOUT
10  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12  License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to the
16  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  02110-1301, USA.
18 
19 */
20 
21 #include "textbrowser_p.h"
22 #include <kicontheme.h>
23 #include <ktextbrowser.h>
24 #include <klocalizedstring.h>
25 #include <KUrl>
26 
27 
28 #include <kmime/kmime_util.h>
29 
30 #include <QAction>
31 #include <QApplication>
32 #include <QContextMenuEvent>
33 #include <QMenu>
34 #include <QClipboard>
35 
36 using namespace Akonadi;
37 
38 TextBrowser::TextBrowser( QWidget *parent )
39  : KTextBrowser( parent )
40 {
41 }
42 
43 void TextBrowser::slotCopyEmail()
44 {
45 #ifndef QT_NO_CLIPBOARD
46  QClipboard* clip = QApplication::clipboard();
47  // put the url into the mouse selection and the clipboard
48  const QString address = KMime::decodeRFC2047String( KUrl(mLinkToCopy).path().toUtf8() );
49  clip->setText( address, QClipboard::Clipboard );
50  clip->setText( address, QClipboard::Selection );
51 #endif
52 }
53 
54 #ifndef QT_NO_CONTEXTMENU
55 void TextBrowser::contextMenuEvent( QContextMenuEvent *event )
56 {
57  QMenu *popup = createStandardContextMenu( event->pos() );
58  if ( popup ) { // can be 0 on touch-only platforms
59  QList<QAction*> actions = popup->actions();
60 
61  // inherited from KTextBrowser
62  KIconTheme::assignIconsToContextMenu( KIconTheme::ReadOnlyText, actions );
63 #ifndef QT_NO_CLIPBOARD
64  // hide the 'Copy Link Location' action if not an e-mail address
65  mLinkToCopy = anchorAt( event->pos() );
66  if ( mLinkToCopy.left( 7 ) != QLatin1String( "mailto:" ) ) {
67  actions[ 1 ]->setVisible( false );
68  } else {
69  actions[ 1 ]->setText( i18n( "Copy e-mail address" ) );
70  disconnect(actions[1]);
71  connect(actions[1],SIGNAL(triggered(bool)),this,SLOT(slotCopyEmail()));
72  }
73 #endif
74  popup->exec( event->globalPos() );
75  delete popup;
76  }
77 }
78 #endif
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Sat Jul 13 2013 01:28:43 by doxygen 1.8.3.1 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

akonadi/contact

Skip menu "akonadi/contact"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Related Pages

kdepimlibs-4.10.5 API Reference

Skip menu "kdepimlibs-4.10.5 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal