libyui-qt-pkg
Loading...
Searching...
No Matches
YQPkgObjList.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: YQPkgObjList.h
21 Author: Stefan Hundhammer <shundhammer.de>
22*/
23
24
25#ifndef YQPkgObjList_h
26#define YQPkgObjList_h
27
28#include <QPixmap>
29#include <QRegExp>
30#include <QMenu>
31#include <QEvent>
32
33#include <map>
34#include <list>
35
36#include <yui/FSize.h>
37#include <yui/qt/QY2ListView.h>
38#include <zypp/Edition.h>
39#include "YQZypp.h"
40
42class QAction;
43class QMenu;
44using std::string;
45using std::list;
46
47
52class YQPkgObjList : public QY2ListView
53{
54 Q_OBJECT
55
56protected:
60 YQPkgObjList( QWidget * parent );
61
65 virtual ~YQPkgObjList();
66
67 // avoiding warning about virtuals
68 using QTreeWidget::currentItemChanged;
69
70public:
71
72 // make it public
73 QTreeWidgetItem * itemFromIndex ( const QModelIndex & index ) const
74 { return QY2ListView::itemFromIndex(index); }
75
76 // Column numbers
77
78 int iconCol() const { return _iconCol; }
79 int statusCol() const { return _statusCol; }
80 int nameCol() const { return _nameCol; }
81 int summaryCol() const { return _summaryCol; }
82 int sizeCol() const { return _sizeCol; }
83 int versionCol() const { return _versionCol; }
84 int instVersionCol() const { return _instVersionCol; }
85 int brokenIconCol() const { return _brokenIconCol; }
86 int satisfiedIconCol() const { return _satisfiedIconCol; }
87
94 bool editable() const { return _editable; }
95
99 void setEditable( bool editable = true ) { _editable = editable; }
100
105 void setCurrentStatus( ZyppStatus newStatus,
106 bool selectNextItem = false,
107 bool ifNewerOnly = false );
108
109
117 void setAllItemStatus( ZyppStatus newStatus, bool force = false );
118
123 virtual QMenu * addAllInListSubMenu( QMenu * menu );
124
131 virtual QPixmap statusIcon( ZyppStatus status,
132 bool enabled = true,
133 bool bySelection = false );
134
138 virtual QString statusText( ZyppStatus status ) const;
139
140
141 class ExcludeRule;
142
147
152 void applyExcludeRules();
153
157 void applyExcludeRules( QTreeWidgetItem * );
158
163 void exclude( YQPkgObjListItem * item, bool exclude );
164
165
166public slots:
167
180 void addPkgObjItem( ZyppSel selectable,
181 ZyppObj zyppObj = 0 );
182
187 void addPassiveItem( const QString & name,
188 const QString & summary = QString(),
189 FSize size = -1 );
190
194 virtual void pkgObjClicked( int button,
195 QTreeWidgetItem * item,
196 int col,
197 const QPoint & pos );
198
203 virtual void clear();
204
211 virtual void updateActions( YQPkgObjListItem * item = 0);
212
217
222 void selectNextItem();
223
228
232 virtual void message( const QString & text );
233
238
244 void maybeSetFocus();
245
246
247 // Direct access to some states for menu actions
248
249 void setCurrentInstall() { setCurrentStatus( S_Install ); }
250 void setCurrentDontInstall() { setCurrentStatus( S_NoInst ); }
251 void setCurrentKeepInstalled() { setCurrentStatus( S_KeepInstalled ); }
252 void setCurrentDelete() { setCurrentStatus( S_Del ); }
253 void setCurrentUpdate() { setCurrentStatus( S_Update, false, true ); }
254 void setCurrentUpdateForce() { setCurrentStatus( S_Update ); }
255 void setCurrentTaboo() { setCurrentStatus( S_Taboo ); }
256 void setCurrentProtected() { setCurrentStatus( S_Protected ); }
257
258 void setListInstall() { setAllItemStatus( S_Install ); }
259 void setListDontInstall() { setAllItemStatus( S_NoInst ); }
260 void setListKeepInstalled() { setAllItemStatus( S_KeepInstalled ); }
261 void setListDelete() { setAllItemStatus( S_Del ); }
262 void setListUpdate() { setAllItemStatus( S_Update ); }
263 void setListUpdateForce() { setAllItemStatus( S_Update, true ); }
264 void setListTaboo() { setAllItemStatus( S_Taboo ); }
265 void setListProtected() { setAllItemStatus( S_Protected ); }
266
267
268protected slots:
269
273 virtual void currentItemChangedInternal( QTreeWidgetItem * item );
274
278 void slotCustomContextMenu(const QPoint& pos);
279
280
281signals:
282
283
288 void currentItemChanged( ZyppSel selectable );
289
294
300
301
302protected:
303
310 virtual void keyPressEvent( QKeyEvent * ev );
311
316 virtual QMenu * installedContextMenu();
317
322 virtual QMenu * notInstalledContextMenu();
323
329 bool shouldKeepFocus( QWidget * widget ) const;
330
334 virtual void createNotInstalledContextMenu();
335
339 virtual void createInstalledContextMenu();
340
345 void createActions();
346
352 QAction * createAction( ZyppStatus status,
353 const QString & key = QString(),
354 bool enabled = false );
355
360 QAction * createAction( const QString & text,
361 const QPixmap & icon = QPixmap(),
362 const QPixmap & insensitiveIcon = QPixmap(),
363 const QString & key = QString(),
364 bool enabled = false );
365
366 // Data members
367
368 int _iconCol;
369 int _statusCol;
370 int _nameCol;
371 int _summaryCol;
372 int _sizeCol;
373 int _versionCol;
374 int _instVersionCol;
375 int _brokenIconCol;
376 int _satisfiedIconCol;
377 bool _editable;
378 bool _debug;
379 int _excludedItemsCount;
380
381 typedef list<ExcludeRule *> ExcludeRuleList;
382
383 ExcludeRuleList _excludeRules;
384
385 QMenu * _installedContextMenu;
386 QMenu * _notInstalledContextMenu;
387
388
389public:
390
391 QAction * actionSetCurrentInstall;
392 QAction * actionSetCurrentDontInstall;
393 QAction * actionSetCurrentKeepInstalled;
394 QAction * actionSetCurrentDelete;
395 QAction * actionSetCurrentUpdate;
396 QAction * actionSetCurrentUpdateForce;
397 QAction * actionSetCurrentTaboo;
398 QAction * actionSetCurrentProtected;
399
400 QAction * actionSetListInstall;
401 QAction * actionSetListDontInstall;
402 QAction * actionSetListKeepInstalled;
403 QAction * actionSetListDelete;
404 QAction * actionSetListUpdate;
405 QAction * actionSetListUpdateForce;
406 QAction * actionSetListTaboo;
407 QAction * actionSetListProtected;
408};
409
410
411
412class YQPkgObjListItem: public QY2ListViewItem
413{
414public:
415
422 YQPkgObjListItem( YQPkgObjList * pkgObjList,
423 ZyppSel selectable,
424 ZyppObj zyppObj = 0 );
425
431 YQPkgObjListItem( YQPkgObjList * pkgObjList );
432
433protected:
437 YQPkgObjListItem( YQPkgObjList * pkgObjList,
438 QY2ListViewItem * parent,
439 ZyppSel selectable,
440 ZyppObj zyppObj = 0 );
441
442public:
443
447 virtual ~YQPkgObjListItem();
448
452 ZyppSel selectable() const { return _selectable; }
453
457 ZyppObj zyppObj() const { return _zyppObj; }
458
464 bool editable() const { return _editable; }
465
469 void setEditable( bool editable = true ) { _editable = editable; }
470
474 virtual ZyppStatus status() const;
475
480 virtual bool bySelection() const;
481
489 virtual void setStatus( ZyppStatus newStatus, bool sendSignals = true );
490
491
495 virtual void setStatusIcon();
496
502 virtual void updateStatus();
503
507 virtual void cycleStatus();
508
512 bool candidateIsNewer() const { return _candidateIsNewer; }
513
517 bool installedIsNewer() const { return _installedIsNewer; }
518
525 bool isSatisfied() const;
526
532 bool isBroken() const;
533
538 void showNotifyTexts( ZyppStatus status );
539
549 static bool showLicenseAgreement( ZyppSel sel );
550
556
560 virtual bool operator< ( const QTreeWidgetItem & other ) const;
561
571 int versionPoints() const;
572
579 virtual void updateData();
580
587 virtual QString toolTip( int column );
588
592 bool isExcluded() const { return _excluded; }
593
599 void setExcluded( bool exclude = true );
600
601
602 // Handle Debug isBroken and isSatisfied flags
603
604 bool debugIsBroken() const { return _debugIsBroken; }
605 bool debugIsSatisfied() const { return _debugIsSatisfied; }
606 void setDebugIsBroken ( bool val = true ) { _debugIsBroken = val; }
607 void setDebugIsSatisfied( bool val = true ) { _debugIsSatisfied = val; }
608 void toggleDebugIsBroken() { _debugIsBroken = ! _debugIsBroken; }
609 void toggleDebugIsSatisfied() { _debugIsSatisfied = ! _debugIsSatisfied; }
610
611
612 // Columns
613
614 int statusCol() const { return _pkgObjList->statusCol(); }
615 int nameCol() const { return _pkgObjList->nameCol(); }
616 int summaryCol() const { return _pkgObjList->summaryCol(); }
617 int sizeCol() const { return _pkgObjList->sizeCol(); }
618 int versionCol() const { return _pkgObjList->versionCol(); }
619 int instVersionCol() const { return _pkgObjList->instVersionCol(); }
620 int brokenIconCol() const { return _pkgObjList->brokenIconCol(); }
621 int satisfiedIconCol() const { return _pkgObjList->satisfiedIconCol(); }
622
623
624protected:
625
630 void init();
631
641 virtual void applyChanges() {}
642
648
653 void setText( int column, const string text );
654
655 public:
660 void setText( int column, const QString & text )
661 { QTreeWidgetItem::setText( column, text ); }
662 protected:
666 void setText( int column, const zypp::Edition & edition );
667
668
669 //
670 // Data members
671 //
672
673 YQPkgObjList * _pkgObjList;
674 ZyppSel _selectable;
675 ZyppObj _zyppObj;
676 bool _editable:1;
677 bool _candidateIsNewer:1;
678 bool _installedIsNewer:1;
679
680 bool _debugIsBroken:1;
681 bool _debugIsSatisfied:1;
682 bool _excluded:1;
683};
684
685
686
688{
689public:
690
700 const QRegExp & regexp,
701 int column = 0 );
702
703
704 // Intentionally omitting virtual destructor:
705 // No allocated objects, no other virtual methods,
706 // no need to have a vtable for each instance of this class.
707 //
708 // virtual ~ExcludeRule();
709
714 void enable( bool enable = true );
715
720 bool isEnabled() const { return _enabled; }
721
725 void setRegexp( const QRegExp & regexp );
726
730 QRegExp regexp() const { return _regexp; };
731
735 void setColumn( int column = 0 );
736
740 int column() const { return _column; }
741
745 YQPkgObjList * parent() const { return _parent; }
746
752 bool match( QTreeWidgetItem * item );
753
754private:
755
756 YQPkgObjList * _parent;
757 QRegExp _regexp;
758 int _column;
759 bool _enabled;
760};
761
762
763#endif // ifndef YQPkgObjList_h
Definition YQPkgObjList.h:413
int versionPoints() const
Definition YQPkgObjList.cc:1522
void solveResolvableCollections()
Definition YQPkgObjList.cc:1100
bool showLicenseAgreement()
Definition YQPkgObjList.cc:1321
virtual void setStatusIcon()
Definition YQPkgObjList.cc:1115
void setText(int column, const QString &text)
Definition YQPkgObjList.h:660
void showNotifyTexts(ZyppStatus status)
Definition YQPkgObjList.cc:1287
bool isBroken() const
Definition YQPkgObjList.cc:1169
virtual ~YQPkgObjListItem()
Definition YQPkgObjList.cc:913
ZyppObj zyppObj() const
Definition YQPkgObjList.h:457
virtual void cycleStatus()
Definition YQPkgObjList.cc:1206
void setEditable(bool editable=true)
Definition YQPkgObjList.h:469
virtual void updateData()
Definition YQPkgObjList.cc:1034
void init()
Definition YQPkgObjList.cc:920
virtual void setStatus(ZyppStatus newStatus, bool sendSignals=true)
Definition YQPkgObjList.cc:1079
virtual QString toolTip(int column)
Definition YQPkgObjList.cc:1407
bool isExcluded() const
Definition YQPkgObjList.h:592
virtual void updateStatus()
Definition YQPkgObjList.cc:1108
virtual bool operator<(const QTreeWidgetItem &other) const
Definition YQPkgObjList.cc:1457
bool editable() const
Definition YQPkgObjList.h:464
bool candidateIsNewer() const
Definition YQPkgObjList.h:512
virtual bool bySelection() const
Definition YQPkgObjList.cc:1068
bool installedIsNewer() const
Definition YQPkgObjList.h:517
virtual ZyppStatus status() const
Definition YQPkgObjList.cc:1055
ZyppSel selectable() const
Definition YQPkgObjList.h:452
void setExcluded(bool exclude=true)
Definition YQPkgObjList.cc:1536
bool isSatisfied() const
Definition YQPkgObjList.cc:1157
void setText(int column, const string text)
Definition YQPkgObjList.cc:1041
virtual void applyChanges()
Definition YQPkgObjList.h:641
YQPkgObjListItem(YQPkgObjList *pkgObjList, ZyppSel selectable, ZyppObj zyppObj=0)
Definition YQPkgObjList.cc:873
Definition YQPkgObjList.h:688
void setRegexp(const QRegExp &regexp)
Definition YQPkgObjList.cc:1567
void enable(bool enable=true)
Definition YQPkgObjList.cc:1554
YQPkgObjList * parent() const
Definition YQPkgObjList.h:745
ExcludeRule(YQPkgObjList *parent, const QRegExp &regexp, int column=0)
Definition YQPkgObjList.cc:1541
bool match(QTreeWidgetItem *item)
Definition YQPkgObjList.cc:1581
int column() const
Definition YQPkgObjList.h:740
void setColumn(int column=0)
Definition YQPkgObjList.cc:1574
QRegExp regexp() const
Definition YQPkgObjList.h:730
bool isEnabled() const
Definition YQPkgObjList.h:720
Abstract base class to display a list of zypp::ResObjects. Handles most generic stuff like setting st...
Definition YQPkgObjList.h:53
virtual void pkgObjClicked(int button, QTreeWidgetItem *item, int col, const QPoint &pos)
Definition YQPkgObjList.cc:158
void applyExcludeRules()
Definition YQPkgObjList.cc:732
void currentItemChanged(ZyppSel selectable)
virtual QMenu * addAllInListSubMenu(QMenu *menu)
Definition YQPkgObjList.cc:504
void exclude(YQPkgObjListItem *item, bool exclude)
Definition YQPkgObjList.cc:828
void setEditable(bool editable=true)
Definition YQPkgObjList.h:99
void selectNextItem()
Definition YQPkgObjList.cc:356
QAction * createAction(ZyppStatus status, const QString &key=QString(), bool enabled=false)
Definition YQPkgObjList.cc:433
void addPassiveItem(const QString &name, const QString &summary=QString(), FSize size=-1)
Definition YQPkgObjList.cc:138
void statusChanged()
void logExcludeStatistics()
Definition YQPkgObjList.cc:753
virtual QPixmap statusIcon(ZyppStatus status, bool enabled=true, bool bySelection=false)
Definition YQPkgObjList.cc:202
void setAllItemStatus(ZyppStatus newStatus, bool force=false)
Definition YQPkgObjList.cc:308
void createActions()
Definition YQPkgObjList.cc:373
bool editable() const
Definition YQPkgObjList.h:94
YQPkgObjList(QWidget *parent)
Definition YQPkgObjList.cc:59
void addExcludeRule(YQPkgObjList::ExcludeRule *rule)
Definition YQPkgObjList.cc:725
virtual void clear()
Definition YQPkgObjList.cc:192
void updatePackages()
void slotCustomContextMenu(const QPoint &pos)
Definition YQPkgObjList.cc:1595
virtual QMenu * notInstalledContextMenu()
Definition YQPkgObjList.cc:525
virtual void createInstalledContextMenu()
Definition YQPkgObjList.cc:489
virtual void createNotInstalledContextMenu()
Definition YQPkgObjList.cc:475
virtual void keyPressEvent(QKeyEvent *ev)
Definition YQPkgObjList.cc:596
virtual void updateActions(YQPkgObjListItem *item=0)
Definition YQPkgObjList.cc:545
void addPkgObjItem(ZyppSel selectable, ZyppObj zyppObj=0)
Definition YQPkgObjList.cc:124
virtual ~YQPkgObjList()
Definition YQPkgObjList.cc:118
void setCurrentStatus(ZyppStatus newStatus, bool selectNextItem=false, bool ifNewerOnly=false)
Definition YQPkgObjList.cc:273
virtual QMenu * installedContextMenu()
Definition YQPkgObjList.cc:535
virtual void currentItemChangedInternal(QTreeWidgetItem *item)
Definition YQPkgObjList.cc:183
virtual QString statusText(ZyppStatus status) const
Definition YQPkgObjList.cc:252
void maybeSetFocus()
Definition YQPkgObjList.cc:845
void sendStatusChanged()
Definition YQPkgObjList.h:227
void sendUpdatePackages()
Definition YQPkgObjList.h:216
bool shouldKeepFocus(QWidget *widget) const
Definition YQPkgObjList.cc:853
virtual void message(const QString &text)
Definition YQPkgObjList.cc:715