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);
91 YQPkgPatchListItem *item = dynamic_cast<YQPkgPatchListItem *>(_view->itemFromIndex(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->setBackground( 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();
377 return dynamic_cast<YQPkgPatchListItem *> (item);
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 )
454 YQPkgPatchListItem * item = dynamic_cast<YQPkgPatchListItem *> (selectedListViewItem);
456 if ( item && item->
selectable()->hasInstalledObj() )
458 yuiWarning() <<
"Deleting patches is not supported" << endl;
473 ZyppPatch zyppPatch )
475 , _patchList( patchList )
476 , _zyppPatch( zyppPatch )
484 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() );
557 const YQPkgPatchListItem * other = dynamic_cast<const YQPkgPatchListItem *> (&otherListViewItem);
560 return ( this->text(_patchList->summaryCol()) < other->text( _patchList->summaryCol()) );
567 : QY2ListViewItem( patchList )
568 , _patchList( patchList )
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::arrowDown() :
660 YQIconPool::arrowRight() );
667 const YQPkgPatchCategoryItem * otherCategoryItem = dynamic_cast<const YQPkgPatchCategoryItem *>(&otherListViewItem);
670 return QTreeWidgetItem::operator<( otherListViewItem );