libyui-qt-pkg  2.45.13.1
YQPkgGenericDetailsView.h
1 /**************************************************************************
2 Copyright (C) 2000 - 2010 Novell, Inc.
3 All Rights Reserved.
4 
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 
19 **************************************************************************/
20 
21 
22 /*---------------------------------------------------------------------\
23 | |
24 | __ __ ____ _____ ____ |
25 | \ \ / /_ _/ ___|_ _|___ \ |
26 | \ V / _` \___ \ | | __) | |
27 | | | (_| |___) || | / __/ |
28 | |_|\__,_|____/ |_| |_____| |
29 | |
30 | core system |
31 | (C) SuSE GmbH |
32 \----------------------------------------------------------------------/
33 
34  File: YQPkgGenericDetailsView.h
35 
36  Author: Stefan Hundhammer <sh@suse.de>
37 
38 /-*/
39 
40 
41 #ifndef YQPkgGenericDetailsView_h
42 #define YQPkgGenericDetailsView_h
43 
44 #include <QTextBrowser>
45 #include <YQZypp.h>
46 #include <zypp/Date.h>
47 
48 
49 class QTabWidget;
50 using std::string;
51 
52 
53 /**
54  * @short Abstract base class for details views. Handles generic stuff like
55  * HTML formatting, Qt slots and display only if this view is visible at all
56  * ( it may be hidden if it's part of a QTabWidget ).
57  **/
58 class YQPkgGenericDetailsView : public QTextBrowser
59 {
60  Q_OBJECT
61 
62 protected:
63 
64  /**
65  * Constructor.
66  **/
67  YQPkgGenericDetailsView( QWidget * parent );
68 
69  /**
70  * Destructor.
71  **/
72  virtual ~YQPkgGenericDetailsView();
73 
74 
75 public:
76 
77  /**
78  * Returns the minimum size required for this widget.
79  * Inherited from QWidget.
80  **/
81  virtual QSize minimumSizeHint() const;
82 
83  /**
84  * starts the html tag and set the style
85  */
86  static QString htmlStart();
87  static QString htmlEnd();
88 
89  /**
90  * Returns a uniform heading in HTML format for the specified selectable:
91  * name and summary
92  * or name, version and summary, if 'showVersion' is 'true'
93  **/
94  static QString htmlHeading( ZyppSel selectable, bool showVersion = false );
95 
96  /**
97  * Escapes characters special to HTML in a ( plain text ) string, such as:
98  * '<' -> '&lt;'
99  * '>' -> '&gt;'
100  * '&' -> '&amp;'
101  *
102  * Returns the escaped string.
103  **/
104  static QString htmlEscape( const QString & plainText );
105 
106  /**
107  * Returns a string containing a HTML table with 'contents'.
108  **/
109  static QString table( const QString & contents );
110 
111  /**
112  * Returns a string containing a HTML table row with 'contents'.
113  **/
114  static QString row( const QString & contents );
115 
116  /**
117  * Returns a string containing a HTML table cell with 'contents'.
118  **/
119  static QString cell( QString contents );
120  static QString cell( int contents );
121  static QString cell( const string & contents );
122  static QString cell( const zypp::Date & date );
123 
124  /**
125  * Returns a string containing a HTML table cell with 'contents'
126  * for table headers.
127  **/
128  static QString hcell( QString contents );
129 
130 
131 public slots:
132 
133  /**
134  * Show details for the specified package.
135  * Delayed ( optimized ) display if this is embedded into a QTabWidget
136  * parent: In this case, wait until this page becomes visible.
137  **/
138  void showDetailsIfVisible( ZyppSel selectable );
139 
140  // slot clear() inherited from QTextEdit
141 
142  /**
143  * Show details for the specified package.
144  * Reimplement this in derived classes.
145  **/
146  virtual void showDetails( ZyppSel selectable ) = 0;
147 
148 
149 
150 protected slots:
151 
152  /**
153  * Show data for the last package.
154  **/
155  void reloadTab( int newCurrent );
156  virtual void reload() { QTextBrowser::reload(); }
157 
158 
159 protected:
160 
161  // Data members
162 
163  QTabWidget * _parentTab;
164  ZyppSel _selectable;
165 };
166 
167 
168 #endif // ifndef YQPkgGenericDetailsView_h
static QString hcell(QString contents)
Returns a string containing a HTML table cell with &#39;contents&#39; for table headers.
static QString htmlHeading(ZyppSel selectable, bool showVersion=false)
Returns a uniform heading in HTML format for the specified selectable: name and summary or name...
Abstract base class for details views.
void reloadTab(int newCurrent)
Show data for the last package.
static QString cell(QString contents)
Returns a string containing a HTML table cell with &#39;contents&#39;.
virtual void showDetails(ZyppSel selectable)=0
Show details for the specified package.
static QString htmlEscape(const QString &plainText)
Escapes characters special to HTML in a ( plain text ) string, such as: &#39;<&#39; -> &#39;<&#39; &#39;>&#39; -> &#39;>&#39; &#39;&&#39; -> ...
void showDetailsIfVisible(ZyppSel selectable)
Show details for the specified package.
virtual QSize minimumSizeHint() const
Returns the minimum size required for this widget.
static QString table(const QString &contents)
Returns a string containing a HTML table with &#39;contents&#39;.
virtual ~YQPkgGenericDetailsView()
Destructor.
static QString row(const QString &contents)
Returns a string containing a HTML table row with &#39;contents&#39;.
static QString htmlStart()
starts the html tag and set the style
YQPkgGenericDetailsView(QWidget *parent)
Constructor.