]> icculus.org git repositories - duncan/yast2-qt4.git/blob - src/pkg/YQPkgVersionsView.h
- Don't create layouts with parent. Qt 4.x automatically reparents
[duncan/yast2-qt4.git] / src / pkg / YQPkgVersionsView.h
1 /*---------------------------------------------------------------------\
2 |                                                                      |
3 |                      __   __    ____ _____ ____                      |
4 |                      \ \ / /_ _/ ___|_   _|___ \                     |
5 |                       \ V / _` \___ \ | |   __) |                    |
6 |                        | | (_| |___) || |  / __/                     |
7 |                        |_|\__,_|____/ |_| |_____|                    |
8 |                                                                      |
9 |                               core system                            |
10 |                                                        (C) SuSE GmbH |
11 \----------------------------------------------------------------------/
12
13   File:       YQPkgVersionsView.h
14
15   Author:     Stefan Hundhammer <sh@suse.de>
16
17 /-*/
18
19
20 #ifndef YQPkgVersionsView_h
21 #define YQPkgVersionsView_h
22
23 #include "QY2ListView.h"
24 #include "YQZypp.h"
25
26 class QTabWidget;
27
28
29 /**
30  * @short Package version selector: Display a list of available versions from
31  * all the different installation sources and let the user change the candidate
32  * version for installation / update.
33  **/
34 class YQPkgVersionsView : public QY2ListView
35 {
36     Q_OBJECT
37
38 public:
39
40     /**
41      * Constructor.
42      *
43      * 'userCanSwitchVersions' specifies whether or not the user is allowed to
44      * switch between package versions - e.g. in patch mode, he can't.
45      **/
46     YQPkgVersionsView( QWidget * parent, bool userCanSwitchVersions );
47
48     /**
49      * Destructor
50      **/
51     virtual ~YQPkgVersionsView();
52
53     /**
54      * Returns the minimum size required for this widget.
55      * Inherited from QWidget.
56      **/
57     virtual QSize minimumSizeHint() const;
58
59
60     // Column numbers
61
62     int versionCol()    const   { return _versionCol;   }
63     int archCol()       const   { return _archCol;      }
64     int productCol()    const   { return _productCol;   }
65     int urlCol()        const   { return _urlCol;       }
66     int repoCol()       const   { return _repoCol;      }
67     int nameCol()       const   { return _nameCol;      }
68     int summaryCol()    const   { return _summaryCol;   }
69     int statusCol()     const   { return _statusCol;    }
70
71
72 public slots:
73
74     /**
75      * Show details for the specified package.
76      * Delayed ( optimized ) display if this is embedded into a QTabWidget
77      * parent: In this case, wait until this page becomes visible.
78      **/
79     void showDetailsIfVisible( ZyppSel selectable );
80
81     // slot clear() inherited from QListView
82
83
84     /**
85      * Show data for the last package.
86      **/
87     void reload( QWidget * newCurrent );
88
89
90 signals:
91
92     /**
93      * Emitted when the user changes the
94      **/
95     void candidateChanged( ZyppObj newCandidate );
96
97
98 protected slots:
99
100     /**
101      * Check for changed candidates
102      **/
103     void checkForChangedCandidate();
104
105
106 protected:
107
108     /**
109      * Show details for the specified package.
110      **/
111     void showDetails( ZyppSel selectable );
112
113
114     // Data members
115
116     QTabWidget  *       _parentTab;
117     ZyppSel             _selectable;
118     bool                _userCanSwitch;
119
120     int                 _versionCol;
121     int                 _archCol;
122     int                 _productCol;
123     int                 _urlCol;
124     int                 _repoCol;
125     int                 _nameCol;
126     int                 _summaryCol;
127     int                 _statusCol;
128 };
129
130
131 class YQPkgVersion: public QY2CheckListItem
132 {
133 public:
134
135     /**
136      * Constructor. Creates a YQPkgVersion item that corresponds to the package
137      * manager object that 'pkg' refers to.
138      **/
139     YQPkgVersion( YQPkgVersionsView *   pkgVersionList,
140                   QY2CheckListItem *    parent,
141                   ZyppSel               selectable,
142                   ZyppObj               zyppObj,
143                   bool                  enabled = true );
144
145     /**
146      * Destructor
147      **/
148     virtual ~YQPkgVersion();
149
150     /**
151      * Returns the original ZYPP object
152      **/
153     ZyppObj zyppObj() const { return _zyppObj; }
154
155     /**
156      * Returns the original ZYPP selectable
157      **/
158     ZyppSel selectable() const { return _selectable; }
159
160     /**
161      * sorting function
162      */
163     virtual bool operator< ( const QTreeWidgetItem & other ) const;
164
165     /**
166      * Returns a tool tip text for a specific column of this item.
167      * 'column' is -1 if the mouse pointer is in the tree indentation area.
168      *
169      * Reimplemented from QY2CheckListItem.
170      **/
171     virtual QString toolTip( int column );
172
173
174     // Columns
175
176     int versionCol()            const   { return _pkgVersionList->versionCol(); }
177     int productCol()            const   { return _pkgVersionList->productCol(); }
178     int urlCol()                const   { return _pkgVersionList->urlCol();     }
179     int repoCol()               const   { return _pkgVersionList->repoCol();    }
180     int statusCol()             const   { return _pkgVersionList->statusCol();  }
181     int archCol()               const   { return _pkgVersionList->archCol();    }
182
183
184 protected:
185
186     // Data members
187
188     YQPkgVersionsView * _pkgVersionList;
189     ZyppSel             _selectable;
190     ZyppObj             _zyppObj;
191 };
192
193
194 #endif // ifndef YQPkgVersionsView_h