libyui-qt-pkg
Loading...
Searching...
No Matches
YQPkgList.h
1/*
2 Copyright (c) 2000 - 2010 Novell, Inc.
3 Copyright (c) 2021 SUSE LLC
4
5 This library is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) version 3.0 of the License. This library
9 is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
12 License for more details. You should have received a copy of the GNU
13 Lesser General Public License along with this library; if not, write
14 to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
15 Floor, Boston, MA 02110-1301 USA
16*/
17
18
19/*
20 File: YQPkgList.h
21 Author: Stefan Hundhammer <shundhammer.de>
22*/
23
24
25#ifndef YQPkgList_h
26#define YQPkgList_h
27
28#include "YQPkgObjList.h"
29#include <QMenu>
30#include <QResizeEvent>
31
32class YQPkgListItem;
33
34
38class YQPkgList : public YQPkgObjList
39{
40 Q_OBJECT
41
42public:
43
47 YQPkgList( QWidget * parent );
48
52 virtual ~YQPkgList();
53
54
55 // Column numbers
56
57 int srpmStatusCol() const { return _srpmStatusCol; }
58
65 void exportList( const QString filename, bool interactive ) const;
66
73 virtual QMenu * addAllInListSubMenu( QMenu * menu );
74
78 static bool haveInstalledPkgs();
79
93 int globalSetPkgStatus( ZyppStatus newStatus, bool force, bool countOnly );
94
95
96public slots:
97
103 void addPkgItem ( ZyppSel selectable,
104 ZyppPkg zyppPkg );
105
110 void addPkgItemDimmed( ZyppSel selectable,
111 ZyppPkg zyppPkg );
112
116 void addPkgItem ( ZyppSel selectable,
117 ZyppPkg zyppPkg,
118 bool dimmed );
119
120
126 virtual void pkgObjClicked( int button,
127 QTreeWidgetItem * item,
128 int col,
129 const QPoint & pos );
130
136 virtual void updateActions( YQPkgObjListItem * item );
137
142 virtual QSize sizeHint() const;
143
147 void askExportList() const;
148
149
150 // Direct access to some states for menu actions
151
152 void setInstallCurrentSourceRpm() { setInstallCurrentSourceRpm( true ); }
153 void setDontInstallCurrentSourceRpm() { setInstallCurrentSourceRpm( false ); }
154
155 void setInstallListSourceRpms() { setInstallListSourceRpms( true ); }
156 void setDontInstallListSourceRpms() { setInstallListSourceRpms( false ); }
157
158
159 // No separate currentItemChanged( ZyppPkg ) signal:
160 // Use YQPkgObjList::currentItemChanged( ZyppObj ) instead
161 // and dynamic_cast to ZyppPkg if required.
162 // This saves duplicating a lot of code.
163
169 void clear();
170
175 void resort();
176
177
178protected:
179
183 void createActions();
184
190 virtual void createNotInstalledContextMenu();
191
197 virtual void createInstalledContextMenu();
198
203
208 void setInstallCurrentSourceRpm( bool inst, bool selectNextItem = false );
209
213 void setInstallListSourceRpms( bool inst );
214
220
225 void updateOptimalColumnWidthValues(ZyppSel selectable, ZyppPkg zyppPkg);
226
231
236 void resizeEvent(QResizeEvent *event);
237
238
239 // *** Data members:
240
241 int _srpmStatusCol;
242 QMenu * _sourceRpmContextMenu;
243 // Optimal (sized-to-content) column widths:
244 int _optimalColWidth_statusIcon;
245 int _optimalColWidth_name;
246 int _optimalColWidth_summary;
247 int _optimalColWidth_version;
248 int _optimalColWidth_instVersion;
249 int _optimalColWidth_size;
250
251
252public:
253
254 QAction * actionInstallSourceRpm;
255 QAction * actionDontInstallSourceRpm;
256 QAction * actionInstallListSourceRpms;
257 QAction * actionDontInstallListSourceRpms;
258};
259
260
261
263{
264public:
265
271 ZyppSel selectable,
272 ZyppPkg zyppPkg );
273
277 virtual ~YQPkgListItem();
278
282 YQPkgList * pkgList() { return _pkgList; }
283
287 ZyppPkg zyppPkg() const { return _zyppPkg; }
288
293 bool installSourceRpm() const;
294
299
304
308 bool hasSourceRpm() const;
309
313 virtual bool operator< ( const QTreeWidgetItem & other ) const;
314
321 virtual void updateData();
322
329 virtual QString toolTip( int column );
330
335 bool isDimmed() const { return _dimmed; }
336
340 void setDimmed( bool d = true ) { _dimmed = d; }
341
342
343 // Columns
344
345 int srpmStatusCol() const { return _pkgList->srpmStatusCol(); }
346
347
348protected:
349
353 void setSourceRpmIcon();
354
355
356 // Data members
357
358 YQPkgList * _pkgList;
359 ZyppPkg _zyppPkg;
360 bool _dimmed;
361};
362
363
364#endif // ifndef YQPkgList_h
Definition YQPkgList.h:263
YQPkgList * pkgList()
Definition YQPkgList.h:282
ZyppPkg zyppPkg() const
Definition YQPkgList.h:287
void toggleSourceRpmStatus()
Definition YQPkgList.cc:851
void setInstallSourceRpm(bool installSourceRpm)
Definition YQPkgList.cc:836
bool hasSourceRpm() const
Definition YQPkgList.cc:777
virtual bool operator<(const QTreeWidgetItem &other) const
Definition YQPkgList.cc:936
virtual QString toolTip(int column)
Definition YQPkgList.cc:858
void setSourceRpmIcon()
Definition YQPkgList.cc:808
void setDimmed(bool d=true)
Definition YQPkgList.h:340
bool installSourceRpm() const
Definition YQPkgList.cc:791
virtual void updateData()
Definition YQPkgList.cc:769
bool isDimmed() const
Definition YQPkgList.h:335
virtual ~YQPkgListItem()
Definition YQPkgList.cc:762
Display a list of zypp::Package objects.
Definition YQPkgList.h:39
void addPkgItem(ZyppSel selectable, ZyppPkg zyppPkg)
Definition YQPkgList.cc:127
void addPkgItemDimmed(ZyppSel selectable, ZyppPkg zyppPkg)
Definition YQPkgList.cc:134
void createActions()
Definition YQPkgList.cc:511
virtual void createInstalledContextMenu()
Definition YQPkgList.cc:468
virtual QSize sizeHint() const
Definition YQPkgList.cc:219
void exportList(const QString filename, bool interactive) const
Definition YQPkgList.cc:576
void clear()
Definition YQPkgList.cc:421
void updateOptimalColumnWidthValues(ZyppSel selectable, ZyppPkg zyppPkg)
Definition YQPkgList.cc:306
void resort()
Definition YQPkgList.cc:430
virtual void createNotInstalledContextMenu()
Definition YQPkgList.cc:450
virtual void pkgObjClicked(int button, QTreeWidgetItem *item, int col, const QPoint &pos)
Definition YQPkgList.cc:182
virtual void updateActions(YQPkgObjListItem *item)
Definition YQPkgList.cc:545
void createSourceRpmContextMenu()
Definition YQPkgList.cc:226
void resetOptimalColumnWidthValues()
Definition YQPkgList.cc:294
static bool haveInstalledPkgs()
Definition YQPkgList.cc:167
void resizeEvent(QResizeEvent *event)
Definition YQPkgList.cc:439
void optimizeColumnWidths()
Definition YQPkgList.cc:368
virtual QMenu * addAllInListSubMenu(QMenu *menu)
Definition YQPkgList.cc:488
virtual ~YQPkgList()
Definition YQPkgList.cc:121
int globalSetPkgStatus(ZyppStatus newStatus, bool force, bool countOnly)
Definition YQPkgList.cc:665
void askExportList() const
Definition YQPkgList.cc:565
Definition YQPkgObjList.h:413
ZyppSel selectable() const
Definition YQPkgObjList.h:452
Abstract base class to display a list of zypp::ResObjects. Handles most generic stuff like setting st...
Definition YQPkgObjList.h:53
void selectNextItem()
Definition YQPkgObjList.cc:356