42 #define YUILogComponent "qt-pkg" 46 #include <QItemDelegate> 50 #include <QHeaderView> 51 #include <zypp/base/Logger.h> 57 #include "YQPkgPatchList.h" 58 #include "YQPkgTextDialog.h" 59 #include "YQIconPool.h" 72 virtual void paint ( QPainter * painter,
const QStyleOptionViewItem & option,
const QModelIndex & index )
const 80 QFont f = painter->font();
81 f.setWeight(QFont::Bold);
83 f.setPixelSize( (
int) ( fm.height() * 1.05 ) );
84 citem->setFont(_view->summaryCol(), f);
86 QItemDelegate::paint(painter, option, index);
95 QItemDelegate::paint(painter, option, index);
104 yuiDebug() <<
"Creating patch list" << endl;
106 _filterCriteria = RelevantPatches;
112 headers <<
""; _statusCol = numCol++;
114 headers << _(
"Summary" ); _summaryCol = numCol++;
122 _satisfiedIconCol = -42;
123 _brokenIconCol = -42;
125 setHeaderLabels(headers);
128 header()->setSectionResizeMode(_statusCol, QHeaderView::ResizeToContents);
131 header()->setSectionResizeMode(_summaryCol, QHeaderView::Stretch);
137 setAllColumnsShowFocus(
true );
141 this, SLOT (
filter() ) );
144 setSortingEnabled(
true );
148 yuiDebug() <<
"Creating patch list done" << endl;
176 yuiDebug() <<
"New patch category \""<< category <<
"\"" << endl;
180 _categories.insert( category, cat );
201 yuiDebug() <<
"Filling patch list" << endl;
203 for ( ZyppPoolIterator it = zyppPatchesBegin();
204 it != zyppPatchesEnd();
207 ZyppSel selectable = *it;
208 ZyppPatch zyppPatch = tryCastToZyppPatch( selectable->theObj() );
212 bool displayPatch =
false;
214 switch ( _filterCriteria )
216 case RelevantPatches:
219 if ( selectable->hasCandidateObj() &&
220 selectable->candidateObj().isRelevant() )
223 if ( ! selectable->candidateObj().isSatisfied() ||
225 selectable->candidateObj().status().isToBeInstalled() )
228 yuiDebug() <<
"Patch " << zyppPatch->ident()
229 <<
" is already satisfied" 234 yuiDebug() <<
"Patch " << zyppPatch->ident()
235 <<
" is not relevant to the system" 238 case RelevantAndInstalledPatches:
241 if ( ( selectable->hasCandidateObj() ) &&
242 ( ! selectable->candidateObj().isRelevant()
243 || ( selectable->candidateObj().isSatisfied() &&
244 ! selectable->candidateObj().status().isToBeInstalled() ) ) )
257 yuiDebug() <<
"unknown patch filter" << endl;
263 yuiDebug() <<
"Displaying patch " << zyppPatch->name()
264 <<
" - " << zyppPatch->summary()
271 yuiError() <<
"Found non-patch selectable" << endl;
275 yuiDebug() <<
"Patch list filled" << endl;
276 resizeColumnToContents(_statusCol);
286 QY2ListViewItem * item =
new QY2ListViewItem(
this );
289 item->setText( 1, text );
290 item->setBackgroundColor( 0, QColor( 0xE0, 0xE0, 0xF8 ) );
312 zypp::Patch::Contents contents(patch->contents());
313 yuiMilestone() << contents << endl;
315 for ( zypp::Patch::Contents::Selectable_iterator it = contents.selectableBegin();
316 it != contents.selectableEnd();
319 ZyppPkg zyppPkg = tryCastToZyppPkg( (*it)->theObj() );
328 yuiMilestone() <<
"patch is bogus" << endl;
333 yuiWarning() <<
"selection empty" << endl;
341 ZyppPatch zyppPatch )
343 if ( ! selectable || ! zyppPatch )
345 yuiError() <<
"NULL ZyppSel!" << endl;
372 QTreeWidgetItem * item = currentItem();
385 _notInstalledContextMenu =
new QMenu(
this );
386 Q_CHECK_PTR( _notInstalledContextMenu );
388 _notInstalledContextMenu->addAction(actionSetCurrentInstall);
389 _notInstalledContextMenu->addAction(actionSetCurrentDontInstall);
390 _notInstalledContextMenu->addAction(actionSetCurrentTaboo);
399 _installedContextMenu =
new QMenu(
this );
400 Q_CHECK_PTR( _installedContextMenu );
402 _installedContextMenu->addAction(actionSetCurrentKeepInstalled);
404 #if ENABLE_DELETING_PATCHES 405 _installedContextMenu->addAction(actionSetCurrentDelete);
408 _installedContextMenu->addAction(actionSetCurrentUpdate);
409 _installedContextMenu->addAction(actionSetCurrentUpdateForce);
410 _installedContextMenu->addAction(actionSetCurrentProtected);
419 QMenu * submenu =
new QMenu( menu );
420 Q_CHECK_PTR( submenu );
422 submenu->addAction(actionSetListInstall);
423 submenu->addAction(actionSetListDontInstall);
424 submenu->addAction(actionSetListKeepInstalled);
426 #if ENABLE_DELETING_PATCHES 427 submenu->addAction(actionSetListDelete);
430 submenu->addAction(actionSetListUpdate);
431 submenu->addAction(actionSetListUpdateForce);
432 submenu->addAction(actionSetListTaboo);
433 submenu->addAction(actionSetListProtected);
435 QAction *action = menu->addMenu(submenu);
436 action->setText(_(
"&All in This List" ));
447 #if ! ENABLE_DELETING_PATCHES 448 if ( event->ascii() ==
'-' )
450 QTreeWidgetItem * selectedListViewItem = currentItem();
452 if ( selectedListViewItem )
456 if ( item && item->
selectable()->hasInstalledObj() )
458 yuiWarning() <<
"Deleting patches is not supported" << endl;
473 ZyppPatch zyppPatch )
475 , _patchList( patchList )
476 , _zyppPatch( zyppPatch )
486 , _patchList( patchList )
487 , _zyppPatch( zyppPatch )
493 void YQPkgPatchListItem::init()
497 if ( summaryCol() > -1 && _zyppPatch->summary().empty() )
498 setText( summaryCol(), _zyppPatch->name() );
522 if ( col == statusCol() )
528 if ( ( col == brokenIconCol() &&
isBroken() ) ||
535 text = fromUTF8(
zyppPatch()->category() );
537 if ( ! text.isEmpty() )
540 text += fromUTF8(
zyppPatch()->downloadSize().asString().c_str() );
560 return ( this->text(_patchList->summaryCol()) < other->text( _patchList->summaryCol()) );
567 : QY2ListViewItem( patchList )
568 , _patchList( patchList )
595 category = category.toLower();
597 if ( category ==
"yast" )
return YQPkgYaSTPatch;
598 if ( category ==
"security" )
return YQPkgSecurityPatch;
599 if ( category ==
"recommended" )
return YQPkgRecommendedPatch;
600 if ( category ==
"optional" )
return YQPkgOptionalPatch;
601 if ( category ==
"document" )
return YQPkgDocumentPatch;
603 yuiWarning() <<
"Unknown patch category \"" << category <<
"\"" << endl;
604 return YQPkgUnknownPatchCategory;
614 case YQPkgYaSTPatch:
return _(
"YaST" );
615 case YQPkgSecurityPatch:
return _(
"security" );
616 case YQPkgRecommendedPatch:
return _(
"recommended" );
617 case YQPkgOptionalPatch:
return _(
"optional" );
618 case YQPkgDocumentPatch:
return _(
"document" );
619 case YQPkgUnknownPatchCategory:
return "";
647 YQPkgPatchCategoryItem::setExpanded(
bool open )
649 QTreeWidgetItem::setExpanded( open );
657 setIcon( _patchList->iconCol(),
659 YQIconPool::treeMinus() :
660 YQIconPool::treePlus() );
670 return QTreeWidgetItem::operator<( otherListViewItem );
675 #include "YQPkgPatchList.moc" ZyppSel selectable() const
Returns the original selectable within the package manager backend.
Abstract base class to display a list of zypp::ResObjects.
virtual bool operator<(const QTreeWidgetItem &other) const
sorting function
void setText(int column, const string text)
Set a column text via STL string.
Display a list of zypp::Patch objects.
void filterIfVisible()
Same as filter(), but only if this widget is currently visible.
virtual void polish()
Delayed initialization after the dialog is fully created.
virtual void applyChanges()
Propagate status changes in this list to other lists: Have the solver transact all patches...
void filter()
Filter according to the view's rules and current selection.
virtual ~YQPkgPatchCategoryItem()
Destructor.
ZyppPatch zyppPatch() const
Returns the original zyppPatch object.
virtual ~YQPkgPatchListItem()
Destructor.
virtual void clear()
Reimplemented from QY2ListView: Emit currentItemChanged() signal after clearing the list...
void fillList()
Fill the patch list according to filterCriteria().
YQPkgPatchListItem * selection() const
Returns the currently selected item or 0 if there is none.
virtual void keyPressEvent(QKeyEvent *ev)
Event handler for keyboard input.
virtual void cycleStatus()
Cycle the package status to the next valid value.
virtual void setStatus(ZyppStatus newStatus, bool sendSignals=true)
Set the (binary RPM) package status.
YQPkgPatchCategory category() const
Category (and order ) for this item.
void filterMatch(ZyppSel selectable, ZyppPkg pkg)
Emitted during filtering for each pkg that matches the filter.
YQPkgPatchList(QWidget *parent)
Constructor.
virtual bool operator<(const QTreeWidgetItem &other) const
sorting function
YQPkgPatchCategoryItem(YQPkgPatchCategory category, YQPkgPatchList *patternList)
Constructor.
virtual void createInstalledContextMenu()
Create the context menu for installed items.
virtual void message(const QString &text)
Display a one-line message in the list.
static QString asString(YQPkgPatchCategory category)
Converts a patch category to a user-readable (translated) string.
void applyExcludeRules()
Apply all exclude rules of this list to all items, including those that are currently excluded...
virtual void createNotInstalledContextMenu()
Create the context menu for items that are not installed.
void setTreeIcon(void)
Set a suitable tree open/close icon depending on this category's open/close status.
virtual ~YQPkgPatchList()
Destructor.
bool isBroken() const
Check if this item is "broken": If it is installed, but any of its dependencies are no longer satisfi...
void currentItemChanged(ZyppSel selectable)
Emitted when a zypp::ui::Selectable is selected.
FilterCriteria filterCriteria() const
Returns the current filter criteria.
virtual QMenu * addAllInListSubMenu(QMenu *menu)
Add a submenu "All in this list..." to 'menu'.
void filterFinished()
Emitted when filtering is finished.
bool isSatisfied() const
Check if this item is satisfied, even though it is not installed.
int categoryCol() const
Returns the column for the patch category.
void filterStart()
Emitted when the filtering starts.
static YQPkgPatchCategory patchCategory(QString category)
Maps a string patch category to the corresponding enum.
void addPatchItem(ZyppSel selectable, ZyppPatch zyppPatch)
Add a patch to the list.
void addPatch(ZyppPatch patch)
Add a pattern to this category.
virtual QString toolTip(int column)
Returns a tool tip text for a specific column of this item.
virtual bool operator<(const QTreeWidgetItem &other) const
sorting function
void solveResolvableCollections()
Do a "small" solver run for all "resolvable collections", i.e., for selections, patterns, languages, patches.
virtual QString toolTip(int column)
Returns a tool tip text for a specific column of this item.
virtual void keyPressEvent(QKeyEvent *ev)
Event handler for keyboard input.
virtual ZyppStatus status() const
Returns the (binary RPM) package status.
void setFilterCriteria(FilterCriteria filterCriteria)
Set the filter criteria for fillList().
YQPkgPatchListItem(YQPkgPatchList *patchList, ZyppSel selectable, ZyppPatch zyppPatch)
Constructor.
YQPkgPatchCategoryItem * category(YQPkgPatchCategory category)
returns or creates a category item for a defined category
virtual void setStatusIcon()
Set a status icon according to the package's status.
virtual void cycleStatus()
Cycle the package status to the next valid value.