libyui-qt
2.43.5
|
00001 /* 00002 Copyright (C) 2000-2012 Novell, Inc 00003 This library is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU Lesser General Public License as 00005 published by the Free Software Foundation; either version 2.1 of the 00006 License, or (at your option) version 3.0 of the License. This library 00007 is distributed in the hope that it will be useful, but WITHOUT ANY 00008 WARRANTY; without even the implied warranty of MERCHANTABILITY or 00009 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 00010 License for more details. You should have received a copy of the GNU 00011 Lesser General Public License along with this library; if not, write 00012 to the Free Software Foundation, Inc., 51 Franklin Street, Fifth 00013 Floor, Boston, MA 02110-1301 USA 00014 */ 00015 00016 00017 /*-/ 00018 00019 File: YQRichText.h 00020 00021 Author: Stefan Hundhammer <sh@suse.de> 00022 00023 /-*/ 00024 00025 00026 #ifndef YQRichText_h 00027 #define YQRichText_h 00028 00029 #include <QFrame> 00030 #include <QTextBrowser> 00031 #include <yui/YRichText.h> 00032 00033 using std::string; 00034 00035 00036 class YQTextBrowser; 00037 00038 class YQRichText : public QFrame, public YRichText 00039 { 00040 Q_OBJECT 00041 00042 public: 00043 00044 /** 00045 * Constructor. 00046 **/ 00047 YQRichText( YWidget * parent, 00048 const std::string & text, 00049 bool plainTextMode = false ); 00050 00051 /** 00052 * Destructor. 00053 **/ 00054 virtual ~YQRichText(); 00055 00056 /** 00057 * Change the text content of the RichText widget. 00058 * 00059 * Reimplemented from YRichText. 00060 **/ 00061 virtual void setValue( const std::string & newValue ); 00062 00063 /** 00064 * Set this RichText widget's "plain text" mode on or off. 00065 * 00066 * Reimplemented from YRichText. 00067 **/ 00068 virtual void setPlainTextMode( bool on = true ); 00069 00070 /** 00071 * Set this RichText widget's "auto scroll down" mode on or off. 00072 * 00073 * Reimplemented from YRichText. 00074 **/ 00075 virtual void setAutoScrollDown( bool on = true ); 00076 00077 /** 00078 * Preferred width of the widget. 00079 * 00080 * Reimplemented from YWidget. 00081 **/ 00082 virtual int preferredWidth(); 00083 00084 /** 00085 * Preferred height of the widget. 00086 * 00087 * Reimplemented from YWidget. 00088 **/ 00089 virtual int preferredHeight(); 00090 00091 /** 00092 * Set the new size of the widget. 00093 * 00094 * Reimplemented from YWidget. 00095 **/ 00096 virtual void setSize( int newWidth, int newHeight ); 00097 00098 /** 00099 * Set enabled/disabled state. 00100 * 00101 * Reimplemented from YWidget. 00102 **/ 00103 virtual void setEnabled( bool enabled ); 00104 00105 /** 00106 * Accept the keyboard focus. 00107 * 00108 * Reimplemented from YWidget. 00109 **/ 00110 virtual bool setKeyboardFocus(); 00111 00112 /** 00113 * Event filter. 00114 * 00115 * Reimplemented from QWidget. 00116 **/ 00117 virtual bool eventFilter( QObject * obj, QEvent * ev ); 00118 00119 /** 00120 * Returns 'true' if the current text of this RichText widget contains 00121 * hyperlinks. 00122 **/ 00123 bool haveHyperLinks(); 00124 00125 00126 protected slots: 00127 00128 /** 00129 * Notification that a hyperlink is clicked. 00130 **/ 00131 void linkClicked( const QUrl & url ); 00132 00133 00134 protected: 00135 00136 YQTextBrowser * _textBrowser; 00137 00138 private: 00139 /** 00140 * to avoid big suprises, we remember if the stylesheet specified a 00141 * color before we replace color= with class= 00142 **/ 00143 bool *_colors_specified; 00144 }; 00145 00146 00147 /** 00148 * Helper class - needed to have the benefits of both QVBox as the base class 00149 * for YQRichText so uniform margins can be implemented (outside, not inside 00150 * the scroll window as QTextBrowser normally does it) and QTextBrowser's 00151 * featurs (enable hyperlinks) without removing the text each time the user 00152 * clicks. 00153 * 00154 * This class is required only to overwrite setSource(). 00155 **/ 00156 class YQTextBrowser: public QTextBrowser 00157 { 00158 Q_OBJECT 00159 00160 00161 public: 00162 00163 /** 00164 * Constructor 00165 **/ 00166 YQTextBrowser( QWidget * parent = 0 ): 00167 QTextBrowser( parent ) {} 00168 00169 public slots: 00170 00171 /** 00172 * Get the document pointed to by a hyperlink. 00173 * 00174 * Reimplemented from QTextBrowser to avoid having an empty text each time 00175 * the user clicks on a hyperlink. 00176 **/ 00177 virtual void setSource( const QUrl & name ); 00178 }; 00179 00180 00181 #endif // YQRichText_h