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