Scale identity combobox and send/cancel buttons according to screen DPI.
[kdepim.git] / messageviewer / mailwebview.h
blob0007a7558fce3efe6dff4671789c2030d6d55138
1 /* Copyright 2010 Thomas McGuire <mcguire@kde.org>
3 This program is free software; you can redistribute it and/or
4 modify it under the terms of the GNU General Public License as
5 published by the Free Software Foundation; either version 2 of
6 the License or (at your option) version 3 or any later version
7 accepted by the membership of KDE e.V. (or its successor approved
8 by the membership of KDE e.V.), which shall act as a proxy
9 defined in Section 14 of version 3 of the license.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef MESSAGEVIEWER_MAILWEBVIEW_H
21 #define MESSAGEVIEWER_MAILWEBVIEW_H
23 #include <qglobal.h> // make sure we have Q_OS_WINCE defined
25 #ifdef KDEPIM_NO_WEBKIT
26 # include <QTextBrowser>
27 #else
28 # ifdef Q_OS_WINCE
29 # include <QWebView>
30 # else
31 # include <KWebView>
32 # endif
33 #endif
35 #include <boost/function.hpp>
37 namespace MessageViewer {
39 /// MailWebView extends KWebView so that it can emit the popupMenu() signal
40 #ifdef KDEPIM_NO_WEBKIT
41 class MailWebView : public QTextBrowser // krazy:exclude=qclasses
42 #else
43 # ifdef Q_OS_WINCE
44 class MailWebView : public QWebView
45 # else
46 class MailWebView : public KWebView
47 # endif
48 #endif
50 Q_OBJECT
51 public:
53 explicit MailWebView( QWidget *parent=0 );
54 ~MailWebView();
56 enum FindFlag {
57 FindWrapsAroundDocument = 1,
58 FindBackward = 2,
59 FindCaseSensitively = 4,
60 HighlightAllOccurrences = 8,
62 NumFindFlags
64 Q_DECLARE_FLAGS( FindFlags, FindFlag )
66 bool findText( const QString & test, FindFlags flags );
67 void clearFindSelection();
69 void scrollUp( int pixels );
70 void scrollDown( int pixels );
71 bool isScrolledToBottom() const;
72 bool hasVerticalScrollBar() const;
73 void scrollPageDown( int percent );
74 void scrollPageUp( int percent );
75 void scrollToAnchor( const QString & anchor );
77 QString selectedText() const;
78 bool isAttachmentInjectionPoint( const QPoint & globalPos ) const;
79 void injectAttachments( const boost::function<QString()> & delayedHtml );
80 bool removeAttachmentMarking( const QString & id );
81 void markAttachment( const QString & id, const QString & style );
82 bool replaceInnerHtml( const QString & id, const boost::function<QString()> & delayedHtml );
83 void setElementByIdVisible( const QString & id, bool visible );
84 void setHtml( const QString & html, const QUrl & baseUrl );
85 QString htmlSource() const;
86 void selectAll();
87 void clearSelection();
88 void scrollToRelativePosition( double pos );
89 double relativePosition() const;
91 void setAllowExternalContent( bool allow );
93 QUrl linkOrImageUrlAt( const QPoint & global ) const;
95 void setScrollBarPolicy( Qt::Orientation orientation, Qt::ScrollBarPolicy policy );
96 Qt::ScrollBarPolicy scrollBarPolicy( Qt::Orientation orientation ) const;
98 Q_SIGNALS:
100 /// Emitted when the user right-clicks somewhere
101 /// @param url if an URL was under the cursor, this parameter contains it. Otherwise empty
102 /// @param point position where the click happened, in local coordinates
103 void popupMenu( const QUrl &url, const QPoint &point );
105 void linkHovered( const QString & link, const QString & title=QString(), const QString & textContent=QString() );
106 #ifdef KDEPIM_NO_WEBKIT
107 void linkClicked( const QUrl & link );
108 #endif
110 protected:
111 #ifdef KDEPIM_MOBILE_UI
112 friend class MessageViewItem;
113 #endif
114 /// Reimplemented to catch context menu events and emit popupMenu()
115 virtual bool event( QEvent *event );
120 Q_DECLARE_OPERATORS_FOR_FLAGS( MessageViewer::MailWebView::FindFlags )
122 #endif /* MESSAGEVIEWER_MAILWEBVIEW_H */