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
26 #include <zypp/ResObject.h>
35 * @short Dialog that shows a scrolled (HTML) text.
37 class YQPkgTextDialog: public QDialog
46 * Creates a dialog with a text browser and two buttons.
47 * This does not pop up a dialog yet.
48 * Use 'exec()' (inherited from QDialog).
49 * Or, better yet, use the static confirmText() method.
52 YQPkgTextDialog( const QString & text,
54 const QString & acceptButtonLabel,
55 const QString & rejectButtonLabel );
59 * Creates a dialog with a text browser and an "OK" button.
60 * This does not pop up a dialog yet.
61 * Use 'exec()' (inherited from QDialog).
62 * Or, better yet, use the static showText() method.
64 YQPkgTextDialog( const QString & text, QWidget * parent );
69 virtual ~YQPkgTextDialog();
72 * Reimplemented from QWidget:
73 * Reserve a reasonable amount of space.
75 virtual QSize sizeHint() const;
78 * Show a text and wait until the user confirmed with 'OK'.
80 static void showText( QWidget * parent, const QString & text );
83 * Show a text with a headline identifying a selectable (name+summary).
85 static void showText( QWidget * parent,
87 const string & text );
90 * Let the user confirm a text. Returns "true" if the user clicked the
91 * accept button, false if he clicked the reject button.
93 static bool confirmText( QWidget * parent,
95 const QString & acceptButtonLabel,
96 const QString & rejectButtonLabel );
99 * Let the use confirm a text with buttons "Accept" and "Cancel".
100 * Returns "true" if the user clicked "Accept", "false" on "Cancel".
102 static bool confirmText( QWidget * parent, const QString & text );
103 static bool confirmText( QWidget * parent, const char * text );
106 * Let the use confirm a text with a headline identifying a selectable
107 * (name+summary) with buttons "Accept" and "Cancel".
108 * Returns "true" if the user clicked "Accept", "false" on "Cancel".
110 static bool confirmText( QWidget * parent,
112 const string & text );
115 * Simple HTML formatting: Wrap paragraphs in <p>...</p>
116 * Paragraphs are delimited by empty lines.
117 * Return unformatted text if it contains "<!-- DT:Rich -->".
119 static QString htmlParagraphs( const string & rawText );
122 * Returns a uniform heading in HTML format.
124 static QString htmlHeading( const QString & text );
127 * Returns a uniform heading in HTML format for the specified selectable:
130 static QString htmlHeading( ZyppSel selectable );
133 * Escapes characters special to HTML in a ( plain text ) string, such as:
138 * Returns the escaped string.
140 static QString htmlEscape( const QString & plainText );
146 * Set the text contents.
148 void setText( const QString & text );
149 void setText( const string & text );
152 * Show a text with a headline identifying a zypp::ResObject ( name+summary ).
154 void setText( ZyppSel selectable,
155 const string & text );
160 * Create the dialog. Called from all constructors.
162 void buildDialog( const QString & text,
164 const QString & acceptButtonLabel,
165 const QString & rejectButtonLabel = "" );
167 * Grab [Return] press events and close dialog.
168 * Inherited from QObject.
170 bool eventFilter( QObject * obj, QEvent * ev );
175 QPushButton * _acceptButton;
176 QPushButton * _rejectButton;
177 QTextBrowser * _textBrowser;
182 #endif // ifndef YQPkgTextDialog_h