libyui-qt
YQRichText.h
1 /*
2  Copyright (C) 2000-2012 Novell, Inc
3  Copyright (C) 2019 SUSE LLC
4  This library is free software; you can redistribute it and/or modify
5  it under the terms of the GNU Lesser General Public License as
6  published by the Free Software Foundation; either version 2.1 of the
7  License, or (at your option) version 3.0 of the License. This library
8  is distributed in the hope that it will be useful, but WITHOUT ANY
9  WARRANTY; without even the implied warranty of MERCHANTABILITY or
10  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
11  License for more details. You should have received a copy of the GNU
12  Lesser General Public License along with this library; if not, write
13  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
14  Floor, Boston, MA 02110-1301 USA
15 */
16 
17 
18 /*-/
19 
20  File: YQRichText.h
21 
22  Author: Stefan Hundhammer <shundhammer@suse.de>
23 
24 /-*/
25 
26 
27 #ifndef YQRichText_h
28 #define YQRichText_h
29 
30 #include <QFrame>
31 #include <QTextBrowser>
32 #include <yui/YRichText.h>
33 
34 using std::string;
35 
36 
37 class YQTextBrowser;
38 
39 class YQRichText : public QFrame, public YRichText
40 {
41  Q_OBJECT
42 
43 public:
44 
48  YQRichText( YWidget * parent,
49  const std::string & text,
50  bool plainTextMode = false );
51 
55  virtual ~YQRichText();
56 
62  virtual void setValue( const std::string & newValue ) override;
63 
69  virtual void setPlainTextMode( bool on = true );
70 
76  virtual void setAutoScrollDown( bool on = true );
77 
83  virtual int preferredWidth();
84 
90  virtual int preferredHeight();
91 
97  virtual void setSize( int newWidth, int newHeight );
98 
104  virtual void setEnabled( bool enabled );
105 
111  virtual bool setKeyboardFocus();
112 
118  virtual bool eventFilter( QObject * obj, QEvent * ev );
119 
124  bool haveHyperLinks();
125 
131  virtual std::string vScrollValue() const override;
132 
138  virtual void setVScrollValue( const std::string & newValue ) override;
139 
145  virtual std::string hScrollValue() const override;
146 
152  virtual void setHScrollValue( const std::string & newValue ) override;
153 
158  virtual void activateLink( const std::string & url );
159 
160 protected slots:
161 
165  void linkClicked( const QUrl & url );
166 
167 protected:
168 
169  YQTextBrowser * _textBrowser;
170 
171 private:
172 
177  bool *_colors_specified;
178 
182  std::string scrollValue( QScrollBar* scrollBar ) const;
183 
187  void setScrollValue( QScrollBar* scrollBar, const std::string & newValue );
188 
189 };
190 
191 
201 class YQTextBrowser: public QTextBrowser
202 {
203  Q_OBJECT
204 
205 
206 public:
207 
211  YQTextBrowser( QWidget * parent = 0 )
212  : QTextBrowser( parent )
213  {}
214 
215 public slots:
216 
223  virtual void setSource( const QUrl & name );
224 };
225 
226 
227 #endif // YQRichText_h
virtual bool setKeyboardFocus()
Definition: YQRichText.cc:228
YQRichText(YWidget *parent, const std::string &text, bool plainTextMode=false)
Definition: YQRichText.cc:49
virtual std::string vScrollValue() const override
Definition: YQRichText.cc:236
virtual void setHScrollValue(const std::string &newValue) override
Definition: YQRichText.cc:254
Definition: YQRichText.h:39
virtual void setValue(const std::string &newValue) override
Definition: YQRichText.cc:105
virtual bool eventFilter(QObject *obj, QEvent *ev)
Definition: YQRichText.cc:170
bool haveHyperLinks()
Definition: YQRichText.cc:194
YQTextBrowser(QWidget *parent=0)
Definition: YQRichText.h:211
virtual ~YQRichText()
Definition: YQRichText.cc:99
Definition: YQRichText.h:201
virtual void setSize(int newWidth, int newHeight)
Definition: YQRichText.cc:215
virtual int preferredWidth()
Definition: YQRichText.cc:203
virtual void setPlainTextMode(bool on=true)
Definition: YQRichText.cc:137
virtual void setSource(const QUrl &name)
Definition: YQRichText.cc:288
virtual void setAutoScrollDown(bool on=true)
Definition: YQRichText.cc:148
virtual std::string hScrollValue() const override
Definition: YQRichText.cc:248
virtual int preferredHeight()
Definition: YQRichText.cc:209
virtual void setEnabled(bool enabled)
Definition: YQRichText.cc:221
virtual void setVScrollValue(const std::string &newValue) override
Definition: YQRichText.cc:242
virtual void activateLink(const std::string &url)
Definition: YQRichText.cc:157
void linkClicked(const QUrl &url)
Definition: YQRichText.cc:163