File indexing completed on 2024-04-21 14:56:00
0001 /* This file is part of the KDE Libraries 0002 * Copyright (C) 1999 Espen Sand (espensa@online.no) 0003 * Copyright (C) 2006 Urs Wolfer <uwolfer at fwo.ch> 0004 * 0005 * This library is free software; you can redistribute it and/or 0006 * modify it under the terms of the GNU Library General Public 0007 * License as published by the Free Software Foundation; either 0008 * version 2 of the License, or (at your option) any later version. 0009 * 0010 * This library is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0013 * Library General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU Library General Public License 0016 * along with this library; see the file COPYING.LIB. If not, write to 0017 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0018 * Boston, MA 02110-1301, USA. 0019 */ 0020 0021 #ifndef KTEXTBROWSER_H 0022 #define KTEXTBROWSER_H 0023 0024 #include <kdelibs4support_export.h> 0025 0026 #include <QTextBrowser> 0027 0028 /** 0029 * @deprecated since 5.0, use QTextBrowser instead 0030 * 0031 * @brief Extended QTextBrowser. 0032 * 0033 * Porting from KTextBrowser to QTextBrowser: 0034 * - setNotifyClick becomes setOpenLinks, isNotifyClick is set to openLinks. 0035 * - use the signal QTextBrowser::anchorClicked for KTextBrowser::urlClick 0036 * 0037 * By default KTextBrowser will 0038 * invoke the system mailer or the system browser when a link is 0039 * activated, or it can emit the signal urlClick() or mailClick() 0040 * when a link is activated. 0041 * 0042 * If the link starts with the text "whatsthis:" a QWhatsThis 0043 * box will appear and then display the rest of the text. 0044 * 0045 * @warning The "whatsthis:" feature is considered deprecated: it is not 0046 * available in KDE Frameworks 5, because KDE Frameworks 5 does 0047 * not provide KTextBrowser anymore. 0048 * 0049 * \image html ktextbrowser.png "KDE Text Browser" 0050 * 0051 * @author Espen Sand (espensa@online.no) 0052 * 0053 * @see QTextBrowser 0054 */ 0055 0056 class KDELIBS4SUPPORT_DEPRECATED_EXPORT KTextBrowser : public QTextBrowser 0057 { 0058 Q_OBJECT 0059 Q_PROPERTY(bool notifyClick READ isNotifyClick WRITE setNotifyClick) 0060 0061 public: 0062 /** 0063 * Creates a new text browser. 0064 * 0065 * @param parent Parent of the widget. 0066 * @param notifyClick @p true causes signals to be emitted. 0067 */ 0068 KDELIBS4SUPPORT_DEPRECATED explicit KTextBrowser(QWidget *parent = nullptr, bool notifyClick = false); 0069 0070 /** 0071 * Destroys the text browser. 0072 */ 0073 ~KTextBrowser() override; 0074 0075 /** 0076 * Decide whether a click on a link should be handled internally 0077 * or if a signal should be emitted. 0078 * 0079 * @param notifyClick @p true causes signals to be emitted. 0080 */ 0081 void setNotifyClick(bool notifyClick); 0082 0083 /** 0084 * Returns whether a click on a link should be handled internally 0085 * or if a signal should be emitted. 0086 */ 0087 bool isNotifyClick() const; 0088 0089 protected: 0090 /** 0091 * Reimplemented to NOT set the source but to do the special handling 0092 * of links being clicked. Do not call this. 0093 * 0094 * If you need to set an initial source url in the text browser, call 0095 * the QTextBrowser method explicitly, like this: 0096 * <code>myTextBrowser->QTextBrowser::setSource(url)</code> 0097 */ 0098 void setSource(const QUrl &name) override; 0099 0100 /** 0101 * Makes sure Key_Escape is ignored 0102 */ 0103 void keyPressEvent(QKeyEvent *event) override; 0104 0105 /** 0106 * Reimplemented to support Qt2 behavior (Ctrl-Wheel = fast scroll) 0107 */ 0108 void wheelEvent(QWheelEvent *event) override; 0109 0110 /** 0111 * Re-implemented for internal reasons. API not affected. 0112 * 0113 * See QLineEdit::createPopupMenu(). 0114 */ 0115 0116 void contextMenuEvent(QContextMenuEvent *event) override; 0117 0118 Q_SIGNALS: 0119 /** 0120 * Emitted when a mail link has been activated and the widget has 0121 * been configured to emit the signal. 0122 * 0123 * @param name The destination name. It is QString() at the moment. 0124 * @param address The destination address. 0125 */ 0126 void mailClick(const QString &name, const QString &address); 0127 0128 /** 0129 * Emitted if mailClick() is not emitted and the widget has been 0130 * configured to emit the signal. 0131 * 0132 * @param url The destination address. 0133 */ 0134 void urlClick(const QString &url); 0135 0136 private: 0137 class Private; 0138 Private *const d; 0139 }; 0140 0141 #endif