libyui-qt-pkg
YQPkgList.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: YQPkgList.h
35 
36  Author: Stefan Hundhammer <shundhammer.de>
37 
38 /-*/
39 
40 
41 #ifndef YQPkgList_h
42 #define YQPkgList_h
43 
44 #include "YQPkgObjList.h"
45 #include <QMenu>
46 #include <QResizeEvent>
47 
48 class YQPkgListItem;
49 
50 
54 class YQPkgList : public YQPkgObjList
55 {
56  Q_OBJECT
57 
58 public:
59 
63  YQPkgList( QWidget * parent );
64 
68  virtual ~YQPkgList();
69 
70 
71  // Column numbers
72 
73  int srpmStatusCol() const { return _srpmStatusCol; }
74 
81  void exportList( const QString filename, bool interactive ) const;
82 
89  virtual QMenu * addAllInListSubMenu( QMenu * menu );
90 
94  static bool haveInstalledPkgs();
95 
109  int globalSetPkgStatus( ZyppStatus newStatus, bool force, bool countOnly );
110 
111 
112 public slots:
113 
119  void addPkgItem ( ZyppSel selectable,
120  ZyppPkg zyppPkg );
121 
126  void addPkgItemDimmed( ZyppSel selectable,
127  ZyppPkg zyppPkg );
128 
132  void addPkgItem ( ZyppSel selectable,
133  ZyppPkg zyppPkg,
134  bool dimmed );
135 
136 
142  virtual void pkgObjClicked( int button,
143  QTreeWidgetItem * item,
144  int col,
145  const QPoint & pos );
146 
152  virtual void updateActions( YQPkgObjListItem * item );
153 
158  virtual QSize sizeHint() const;
159 
163  void askExportList() const;
164 
165 
166  // Direct access to some states for menu actions
167 
168  void setInstallCurrentSourceRpm() { setInstallCurrentSourceRpm( true ); }
169  void setDontInstallCurrentSourceRpm() { setInstallCurrentSourceRpm( false ); }
170 
171  void setInstallListSourceRpms() { setInstallListSourceRpms( true ); }
172  void setDontInstallListSourceRpms() { setInstallListSourceRpms( false ); }
173 
174 
175  // No separate currentItemChanged( ZyppPkg ) signal:
176  // Use YQPkgObjList::currentItemChanged( ZyppObj ) instead
177  // and dynamic_cast to ZyppPkg if required.
178  // This saves duplicating a lot of code.
179 
185  void clear();
186 
191  void resort();
192 
193 
194 protected:
195 
199  void createActions();
200 
206  virtual void createNotInstalledContextMenu();
207 
213  virtual void createInstalledContextMenu();
214 
219 
224  void setInstallCurrentSourceRpm( bool inst, bool selectNextItem = false );
225 
229  void setInstallListSourceRpms( bool inst );
230 
236 
241  void updateOptimalColumnWidthValues(ZyppSel selectable, ZyppPkg zyppPkg);
242 
246  void optimizeColumnWidths();
247 
252  void resizeEvent(QResizeEvent *event);
253 
254 
255  // *** Data members:
256 
257  int _srpmStatusCol;
258  QMenu * _sourceRpmContextMenu;
259  // Optimal (sized-to-content) column widths:
260  int _optimalColWidth_statusIcon;
261  int _optimalColWidth_name;
262  int _optimalColWidth_summary;
263  int _optimalColWidth_version;
264  int _optimalColWidth_instVersion;
265  int _optimalColWidth_size;
266 
267 
268 public:
269 
270  QAction * actionInstallSourceRpm;
271  QAction * actionDontInstallSourceRpm;
272  QAction * actionInstallListSourceRpms;
273  QAction * actionDontInstallListSourceRpms;
274 };
275 
276 
277 
279 {
280 public:
281 
287  ZyppSel selectable,
288  ZyppPkg zyppPkg );
289 
293  virtual ~YQPkgListItem();
294 
298  YQPkgList * pkgList() { return _pkgList; }
299 
303  ZyppPkg zyppPkg() const { return _zyppPkg; }
304 
309  bool installSourceRpm() const;
310 
315 
319  void toggleSourceRpmStatus();
320 
324  bool hasSourceRpm() const;
325 
329  virtual bool operator< ( const QTreeWidgetItem & other ) const;
330 
337  virtual void updateData();
338 
345  virtual QString toolTip( int column );
346 
351  bool isDimmed() const { return _dimmed; }
352 
356  void setDimmed( bool d = true ) { _dimmed = d; }
357 
358 
359  // Columns
360 
361  int srpmStatusCol() const { return _pkgList->srpmStatusCol(); }
362 
363 
364 protected:
365 
369  void setSourceRpmIcon();
370 
371 
372  // Data members
373 
374  YQPkgList * _pkgList;
375  ZyppPkg _zyppPkg;
376  bool _dimmed;
377 };
378 
379 
380 #endif // ifndef YQPkgList_h
void exportList(const QString filename, bool interactive) const
Definition: YQPkgList.cc:591
Abstract base class to display a list of zypp::ResObjects. Handles most generic stuff like setting st...
Definition: YQPkgObjList.h:68
ZyppPkg zyppPkg() const
Definition: YQPkgList.h:303
void addPkgItem(ZyppSel selectable, ZyppPkg zyppPkg)
Definition: YQPkgList.cc:142
int globalSetPkgStatus(ZyppStatus newStatus, bool force, bool countOnly)
Definition: YQPkgList.cc:680
void toggleSourceRpmStatus()
Definition: YQPkgList.cc:866
virtual QSize sizeHint() const
Definition: YQPkgList.cc:234
virtual void createInstalledContextMenu()
Definition: YQPkgList.cc:483
void resetOptimalColumnWidthValues()
Definition: YQPkgList.cc:309
virtual void pkgObjClicked(int button, QTreeWidgetItem *item, int col, const QPoint &pos)
Definition: YQPkgList.cc:197
YQPkgListItem(YQPkgList *pkgList, ZyppSel selectable, ZyppPkg zyppPkg)
Definition: YQPkgList.cc:760
virtual void updateActions(YQPkgObjListItem *item)
Definition: YQPkgList.cc:560
bool isDimmed() const
Definition: YQPkgList.h:351
static bool haveInstalledPkgs()
Definition: YQPkgList.cc:182
bool hasSourceRpm() const
Definition: YQPkgList.cc:792
virtual bool operator<(const QTreeWidgetItem &other) const
Definition: YQPkgList.cc:951
void optimizeColumnWidths()
Definition: YQPkgList.cc:383
void addPkgItemDimmed(ZyppSel selectable, ZyppPkg zyppPkg)
Definition: YQPkgList.cc:149
Definition: YQPkgList.h:278
YQPkgList * pkgList()
Definition: YQPkgList.h:298
void selectNextItem()
Definition: YQPkgObjList.cc:370
Display a list of zypp::Package objects.
Definition: YQPkgList.h:54
virtual void updateData()
Definition: YQPkgList.cc:784
virtual void createNotInstalledContextMenu()
Definition: YQPkgList.cc:465
void setSourceRpmIcon()
Definition: YQPkgList.cc:823
void resort()
Definition: YQPkgList.cc:445
YQPkgList(QWidget *parent)
Definition: YQPkgList.cc:74
void clear()
Definition: YQPkgList.cc:436
void setDimmed(bool d=true)
Definition: YQPkgList.h:356
bool installSourceRpm() const
Definition: YQPkgList.cc:806
ZyppSel selectable() const
Definition: YQPkgObjList.h:454
virtual QString toolTip(int column)
Definition: YQPkgList.cc:873
Definition: YQPkgObjList.h:414
void updateOptimalColumnWidthValues(ZyppSel selectable, ZyppPkg zyppPkg)
Definition: YQPkgList.cc:321
virtual QMenu * addAllInListSubMenu(QMenu *menu)
Definition: YQPkgList.cc:503
void setInstallSourceRpm(bool installSourceRpm)
Definition: YQPkgList.cc:851
void createActions()
Definition: YQPkgList.cc:526
void createSourceRpmContextMenu()
Definition: YQPkgList.cc:241
void askExportList() const
Definition: YQPkgList.cc:580
void resizeEvent(QResizeEvent *event)
Definition: YQPkgList.cc:454
virtual ~YQPkgListItem()
Definition: YQPkgList.cc:777
virtual ~YQPkgList()
Definition: YQPkgList.cc:136