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
25 #include <zypp/ResObject.h>
34 * @short Dialog that shows a scrolled (HTML) text.
36 class YQPkgTextDialog: public QDialog
45 * Creates a dialog with a text browser and two buttons.
46 * This does not pop up a dialog yet.
47 * Use 'exec()' (inherited from QDialog).
48 * Or, better yet, use the static confirmText() method.
51 YQPkgTextDialog( const QString & text,
53 const QString & acceptButtonLabel,
54 const QString & rejectButtonLabel );
58 * Creates a dialog with a text browser and an "OK" button.
59 * This does not pop up a dialog yet.
60 * Use 'exec()' (inherited from QDialog).
61 * Or, better yet, use the static showText() method.
63 YQPkgTextDialog( const QString & text, QWidget * parent );
68 virtual ~YQPkgTextDialog();
71 * Reimplemented from QWidget:
72 * Reserve a reasonable amount of space.
74 virtual QSize sizeHint() const;
77 * Show a text and wait until the user confirmed with 'OK'.
79 static void showText( QWidget * parent, const QString & text );
82 * Show a text with a headline identifying a selectable (name+summary).
84 static void showText( QWidget * parent,
86 const string & text );
89 * Let the user confirm a text. Returns "true" if the user clicked the
90 * accept button, false if he clicked the reject button.
92 static bool confirmText( QWidget * parent,
94 const QString & acceptButtonLabel,
95 const QString & rejectButtonLabel );
98 * Let the use confirm a text with buttons "Accept" and "Cancel".
99 * Returns "true" if the user clicked "Accept", "false" on "Cancel".
101 static bool confirmText( QWidget * parent, const QString & text );
102 static bool confirmText( QWidget * parent, const char * text );
105 * Let the use confirm a text with a headline identifying a selectable
106 * (name+summary) with buttons "Accept" and "Cancel".
107 * Returns "true" if the user clicked "Accept", "false" on "Cancel".
109 static bool confirmText( QWidget * parent,
111 const string & text );
114 * Simple HTML formatting: Wrap paragraphs in <p>...</p>
115 * Paragraphs are delimited by empty lines.
116 * Return unformatted text if it contains "<!-- DT:Rich -->".
118 static QString htmlParagraphs( const string & rawText );
121 * Returns a uniform heading in HTML format.
123 static QString htmlHeading( const QString & text );
126 * Returns a uniform heading in HTML format for the specified selectable:
129 static QString htmlHeading( ZyppSel selectable );
132 * Escapes characters special to HTML in a ( plain text ) string, such as:
137 * Returns the escaped string.
139 static QString htmlEscape( const QString & plainText );
145 * Set the text contents.
147 void setText( const QString & text );
148 void setText( const string & text );
151 * Show a text with a headline identifying a zypp::ResObject ( name+summary ).
153 void setText( ZyppSel selectable,
154 const string & text );
159 * Create the dialog. Called from all constructors.
161 void buildDialog( const QString & text,
163 const QString & acceptButtonLabel,
164 const QString & rejectButtonLabel = "" );
166 * Grab [Return] press events and close dialog.
167 * Inherited from QObject.
169 bool eventFilter( QObject * obj, QEvent * ev );
174 QPushButton * _acceptButton;
175 QPushButton * _rejectButton;
176 QTextBrowser * _textBrowser;
181 #endif // ifndef YQPkgTextDialog_h