]> icculus.org git repositories - duncan/yast2-qt4.git/blob - src/YQRichText.h
Duncan, for you
[duncan/yast2-qt4.git] / src / YQRichText.h
1 /*---------------------------------------------------------------------\
2 |                                                                      |
3 |                      __   __    ____ _____ ____                      |
4 |                      \ \ / /_ _/ ___|_   _|___ \                     |
5 |                       \ V / _` \___ \ | |   __) |                    |
6 |                        | | (_| |___) || |  / __/                     |
7 |                        |_|\__,_|____/ |_| |_____|                    |
8 |                                                                      |
9 |                               core system                            |
10 |                                                        (C) SuSE GmbH |
11 \----------------------------------------------------------------------/
12
13   File:       YQRichText.h
14
15   Author:     Stefan Hundhammer <sh@suse.de>
16
17 /-*/
18
19
20 #ifndef YQRichText_h
21 #define YQRichText_h
22
23 #include <QFrame>
24 #include <QTextBrowser>
25 #include "YRichText.h"
26
27 using std::string;
28
29
30 class YQTextBrowser;
31
32 class YQRichText : public QFrame, public YRichText
33 {
34     Q_OBJECT
35
36 public:
37
38     /**
39      * Constructor.
40      **/
41     YQRichText( YWidget *       parent,
42                 const string &  text,
43                 bool            plainTextMode = false );
44
45     /**
46      * Destructor.
47      **/
48     virtual ~YQRichText();
49
50     /**
51      * Change the text content of the RichText widget.
52      *
53      * Reimplemented from YRichText.
54      **/
55     virtual void setValue( const string & newValue );
56
57     /**
58      * Set this RichText widget's "plain text" mode on or off.
59      *
60      * Reimplemented from YRichText.
61      **/
62     virtual void setPlainTextMode( bool on = true );
63
64     /**
65      * Set this RichText widget's "auto scroll down" mode on or off.
66      *
67      * Reimplemented from YRichText.
68      **/
69     virtual void setAutoScrollDown( bool on = true );
70
71     /**
72      * Preferred width of the widget.
73      *
74      * Reimplemented from YWidget.
75      **/
76     virtual int preferredWidth();
77
78     /**
79      * Preferred height of the widget.
80      *
81      * Reimplemented from YWidget.
82      **/
83     virtual int preferredHeight();
84
85     /**
86      * Set the new size of the widget.
87      *
88      * Reimplemented from YWidget.
89      **/
90     virtual void setSize( int newWidth, int newHeight );
91
92     /**
93      * Set enabled/disabled state.
94      *
95      * Reimplemented from YWidget.
96      **/
97     virtual void setEnabled( bool enabled );
98
99     /**
100      * Accept the keyboard focus.
101      *
102      * Reimplemented from YWidget.
103      **/
104     virtual bool setKeyboardFocus();
105
106     /**
107      * Event filter.
108      *
109      * Reimplemented from QWidget.
110      **/
111     virtual bool eventFilter( QObject * obj, QEvent * ev );
112
113     /**
114      * Returns 'true' if the current text of this RichText widget contains
115      * hyperlinks.
116      **/
117     bool haveHyperLinks();
118
119
120 protected slots:
121
122     /**
123      * Notification that a hyperlink is clicked.
124      **/
125     void linkClicked( const QUrl & url );
126
127
128 protected:
129
130     YQTextBrowser *     _textBrowser;
131 };
132
133
134 /**
135  * Helper class - needed to have the benefits of both QVBox as the base class
136  * for YQRichText so uniform margins can be implemented (outside, not inside
137  * the scroll window as QTextBrowser normally does it) and QTextBrowser's
138  * featurs (enable hyperlinks) without removing the text each time the user
139  * clicks.
140  *
141  * This class is required only to overwrite setSource().
142  **/
143 class YQTextBrowser: public QTextBrowser
144 {
145     Q_OBJECT
146
147
148 public:
149
150     /**
151      * Constructor
152      **/
153     YQTextBrowser( QWidget * parent = 0 ):
154         QTextBrowser( parent ) {}
155
156 public slots:
157
158     /**
159      * Get the document pointed to by a hyperlink.
160      *
161      * Reimplemented from QTextBrowser to avoid having an empty text each time
162      * the user clicks on a hyperlink.
163      **/
164     virtual void setSource( const QUrl & name ) {}
165 };
166
167
168 #endif // YQRichText_h