1 | /* This file is part of the KDE Libraries |
2 | * Copyright (C) 1999 Espen Sand (espensa@online.no) |
3 | * Copyright (C) 2006 Urs Wolfer <uwolfer at fwo.ch> |
4 | * |
5 | * This library is free software; you can redistribute it and/or |
6 | * modify it under the terms of the GNU Library General Public |
7 | * License as published by the Free Software Foundation; either |
8 | * version 2 of the License, or (at your option) any later version. |
9 | * |
10 | * This library is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | * Library General Public License for more details. |
14 | * |
15 | * You should have received a copy of the GNU Library General Public License |
16 | * along with this library; see the file COPYING.LIB. If not, write to |
17 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 | * Boston, MA 02110-1301, USA. |
19 | */ |
20 | |
21 | #ifndef KTEXTBROWSER_H |
22 | #define KTEXTBROWSER_H |
23 | |
24 | #include <kdeui_export.h> |
25 | |
26 | #include <QtGui/QTextBrowser> |
27 | |
28 | |
29 | /** |
30 | * @short Extended QTextBrowser. |
31 | * |
32 | * An extended QTextBrowser. |
33 | * |
34 | * By default it will |
35 | * invoke the system mailer or the system browser when a link is |
36 | * activated, or it can emit the signal urlClick() or mailClick() |
37 | * when a link is activated. |
38 | * |
39 | * If the link starts with the text "whatsthis:" a QWhatsThis |
40 | * box will appear and then display the rest of the text. |
41 | * |
42 | * @warning The "whatsthis:" feature is considered deprecated: it is not |
43 | * available in KDE Frameworks 5, because KDE Frameworks 5 does |
44 | * not provide KTextBrowser anymore. |
45 | * |
46 | * \image html ktextbrowser.png "KDE Text Browser" |
47 | * |
48 | * @author Espen Sand (espensa@online.no) |
49 | */ |
50 | |
51 | class KDEUI_EXPORT KTextBrowser : public QTextBrowser |
52 | { |
53 | Q_OBJECT |
54 | Q_PROPERTY( bool notifyClick READ isNotifyClick WRITE setNotifyClick ) |
55 | |
56 | public: |
57 | /** |
58 | * Creates a new text browser. |
59 | * |
60 | * @param parent Parent of the widget. |
61 | * @param notifyClick @p true causes signals to be emitted. |
62 | */ |
63 | explicit KTextBrowser( QWidget *parent = 0, bool notifyClick = false ); |
64 | |
65 | /** |
66 | * Destroys the text browser. |
67 | */ |
68 | ~KTextBrowser(); |
69 | |
70 | /** |
71 | * Decide whether a click on a link should be handled internally |
72 | * or if a signal should be emitted. |
73 | * |
74 | * @param notifyClick @p true causes signals to be emitted. |
75 | */ |
76 | void setNotifyClick( bool notifyClick ); |
77 | |
78 | /** |
79 | * Returns whether a click on a link should be handled internally |
80 | * or if a signal should be emitted. |
81 | */ |
82 | bool isNotifyClick() const; |
83 | |
84 | protected: |
85 | /** |
86 | * Reimplemented to NOT set the source but to do the special handling |
87 | * of links being clicked. Do not call this. |
88 | * |
89 | * If you need to set an initial source url in the text browser, call |
90 | * the QTextBrowser method explicitly, like this: |
91 | * <code>myTextBrowser->QTextBrowser::setSource(url)</code> |
92 | */ |
93 | void setSource( const QUrl& name ); |
94 | |
95 | /** |
96 | * Makes sure Key_Escape is ignored |
97 | */ |
98 | virtual void keyPressEvent( QKeyEvent *event ); |
99 | |
100 | /** |
101 | * Reimplemented to support Qt2 behavior (Ctrl-Wheel = fast scroll) |
102 | */ |
103 | virtual void wheelEvent( QWheelEvent *event ); |
104 | |
105 | /** |
106 | * Re-implemented for internal reasons. API not affected. |
107 | * |
108 | * See QLineEdit::createPopupMenu(). |
109 | */ |
110 | |
111 | virtual void ( QContextMenuEvent *event ); |
112 | |
113 | Q_SIGNALS: |
114 | /** |
115 | * Emitted when a mail link has been activated and the widget has |
116 | * been configured to emit the signal. |
117 | * |
118 | * @param name The destination name. It is QString() at the moment. |
119 | * @param address The destination address. |
120 | */ |
121 | void mailClick( const QString &name, const QString &address ); |
122 | |
123 | /** |
124 | * Emitted if mailClick() is not emitted and the widget has been |
125 | * configured to emit the signal. |
126 | * |
127 | * @param url The destination address. |
128 | */ |
129 | void urlClick( const QString &url ); |
130 | |
131 | private: |
132 | class Private; |
133 | Private* const d; |
134 | }; |
135 | |
136 | #endif |
137 | |