1 /*---------------------------------------------------------------------\
3 | __ __ ____ _____ ____ |
4 | \ \ / /_ _/ ___|_ _|___ \ |
5 | \ V / _` \___ \ | | __) | |
6 | | | (_| |___) || | / __/ |
7 | |_|\__,_|____/ |_| |_____| |
11 \----------------------------------------------------------------------/
13 File: YQPkgTextDialog.h
15 Author: Stefan Hundhammer <sh@suse.de>
20 #ifndef YQPkgTextDialog_h
21 #define YQPkgTextDialog_h
27 #include <zypp/ResObject.h>
36 * @short Dialog that shows a scrolled (HTML) text.
38 class YQPkgTextDialog: public QDialog
47 * Creates a dialog with a text browser and two buttons.
48 * This does not pop up a dialog yet.
49 * Use 'exec()' (inherited from QDialog).
50 * Or, better yet, use the static confirmText() method.
53 YQPkgTextDialog( const QString & text,
55 const QString & acceptButtonLabel,
56 const QString & rejectButtonLabel );
60 * Creates a dialog with a text browser and an "OK" button.
61 * This does not pop up a dialog yet.
62 * Use 'exec()' (inherited from QDialog).
63 * Or, better yet, use the static showText() method.
65 YQPkgTextDialog( const QString & text, QWidget * parent );
70 virtual ~YQPkgTextDialog();
73 * Reimplemented from QWidget:
74 * Reserve a reasonable amount of space.
76 virtual QSize sizeHint() const;
79 * Show a text and wait until the user confirmed with 'OK'.
81 static void showText( QWidget * parent, const QString & text );
84 * Show a text with a headline identifying a selectable (name+summary).
86 static void showText( QWidget * parent,
88 const string & text );
91 * Let the user confirm a text. Returns "true" if the user clicked the
92 * accept button, false if he clicked the reject button.
94 static bool confirmText( QWidget * parent,
96 const QString & acceptButtonLabel,
97 const QString & rejectButtonLabel );
100 * Let the use confirm a text with buttons "Accept" and "Cancel".
101 * Returns "true" if the user clicked "Accept", "false" on "Cancel".
103 static bool confirmText( QWidget * parent, const QString & text );
104 static bool confirmText( QWidget * parent, const char * text );
107 * Let the use confirm a text with a headline identifying a selectable
108 * (name+summary) with buttons "Accept" and "Cancel".
109 * Returns "true" if the user clicked "Accept", "false" on "Cancel".
111 static bool confirmText( QWidget * parent,
113 const string & text );
116 * Simple HTML formatting: Wrap paragraphs in <p>...</p>
117 * Paragraphs are delimited by empty lines.
118 * Return unformatted text if it contains "<!-- DT:Rich -->".
120 static QString htmlParagraphs( const string & rawText );
123 * Returns a uniform heading in HTML format.
125 static QString htmlHeading( const QString & text );
128 * Returns a uniform heading in HTML format for the specified selectable:
131 static QString htmlHeading( ZyppSel selectable );
134 * Escapes characters special to HTML in a ( plain text ) string, such as:
139 * Returns the escaped string.
141 static QString htmlEscape( const QString & plainText );
147 * Set the text contents.
149 void setText( const QString & text );
150 void setText( const string & text );
153 * Show a text with a headline identifying a zypp::ResObject ( name+summary ).
155 void setText( ZyppSel selectable,
156 const string & text );
161 * Create the dialog. Called from all constructors.
163 void buildDialog( const QString & text,
165 const QString & acceptButtonLabel,
166 const QString & rejectButtonLabel = "" );
168 * Grab [Return] press events and close dialog.
169 * Inherited from QObject.
171 bool eventFilter( QObject * obj, QEvent * ev );
176 QPushButton * _acceptButton;
177 QPushButton * _rejectButton;
178 Q3TextBrowser * _textBrowser;
183 #endif // ifndef YQPkgTextDialog_h