]> icculus.org git repositories - duncan/yast2-qt4.git/blob - src/pkg/YQPkgGenericDetailsView.h
- Don't create layouts with parent. Qt 4.x automatically reparents
[duncan/yast2-qt4.git] / src / pkg / YQPkgGenericDetailsView.h
1 /*---------------------------------------------------------------------\
2 |                                                                      |
3 |                      __   __    ____ _____ ____                      |
4 |                      \ \ / /_ _/ ___|_   _|___ \                     |
5 |                       \ V / _` \___ \ | |   __) |                    |
6 |                        | | (_| |___) || |  / __/                     |
7 |                        |_|\__,_|____/ |_| |_____|                    |
8 |                                                                      |
9 |                               core system                            |
10 |                                                        (C) SuSE GmbH |
11 \----------------------------------------------------------------------/
12
13   File:       YQPkgGenericDetailsView.h
14
15   Author:     Stefan Hundhammer <sh@suse.de>
16
17 /-*/
18
19
20 #ifndef YQPkgGenericDetailsView_h
21 #define YQPkgGenericDetailsView_h
22
23 #include <QTextBrowser>
24 #include <YQZypp.h>
25 #include <zypp/Date.h>
26
27
28 class QTabWidget;
29 using std::string;
30
31
32 /**
33  * @short Abstract base class for details views. Handles generic stuff like
34  * HTML formatting, Qt slots and display only if this view is visible at all
35  * ( it may be hidden if it's part of a QTabWidget ).
36  **/
37 class YQPkgGenericDetailsView : public QTextBrowser
38 {
39     Q_OBJECT
40
41 protected:
42
43     /**
44      * Constructor.
45      **/
46     YQPkgGenericDetailsView( QWidget * parent );
47
48     /**
49      * Destructor.
50      **/
51     virtual ~YQPkgGenericDetailsView();
52
53
54 public:
55
56     /**
57      * Returns the minimum size required for this widget.
58      * Inherited from QWidget.
59      **/
60     virtual QSize minimumSizeHint() const;
61
62     /**
63      * Returns a uniform heading in HTML format for the specified selectable:
64      * name and summary
65      * or name, version and summary, if 'showVersion' is 'true'
66      **/
67     static QString htmlHeading( ZyppSel selectable, bool showVersion = false );
68
69     /**
70      * Escapes characters special to HTML in a ( plain text ) string, such as:
71      * '<'   ->   '&lt;'
72      * '>'   ->   '&gt;'
73      * '&'   ->   '&amp;'
74      *
75      * Returns the escaped string.
76      **/
77     static QString htmlEscape( const QString & plainText );
78
79     /**
80      * Returns a string containing a HTML table with 'contents'.
81      **/
82     static QString table( const QString & contents );
83
84     /**
85      * Returns a string containing a HTML table row with 'contents'.
86      **/
87     static QString row( const QString & contents );
88
89     /**
90      * Returns a string containing a HTML table cell with 'contents'.
91      **/
92     static QString cell( QString contents               );
93     static QString cell( int contents                   );
94     static QString cell( const string & contents        );
95     static QString cell( const zypp::Date & date        );
96
97     /**
98      * Returns a string containing a HTML table cell with 'contents'
99      * for table headers.
100      **/
101     static QString hcell( QString contents );
102
103
104 public slots:
105
106     /**
107      * Show details for the specified package.
108      * Delayed ( optimized ) display if this is embedded into a QTabWidget
109      * parent: In this case, wait until this page becomes visible.
110      **/
111     void showDetailsIfVisible( ZyppSel selectable );
112
113     // slot clear() inherited from QTextEdit
114
115     /**
116      * Show details for the specified package.
117      * Reimplement this in derived classes.
118      **/
119     virtual void showDetails( ZyppSel selectable ) = 0;
120
121     
122 protected slots:
123
124     /**
125      * Show data for the last package.
126      **/
127     void reload( QWidget * newCurrent );
128     virtual void reload() { QTextBrowser::reload(); }
129
130
131 protected:
132     
133     // Data members
134
135     QTabWidget  *       _parentTab;
136     ZyppSel             _selectable;
137 };
138
139
140 #endif // ifndef YQPkgGenericDetailsView_h