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
81 QFont f = painter->font();
82 f.setWeight(QFont::Bold);
84 f.setPixelSize( (
int) ( fm.height() * 1.05 ) );
85 citem->setFont(_view->summaryCol(), f);
87 painter->fillRect(option.rect, option.palette.color(QPalette::AlternateBase));
88 QItemDelegate::paint(painter, option, index);
97 QItemDelegate::paint(painter, option, index);
106 yuiDebug() <<
"Creating patch list" << endl;
108 _filterCriteria = RelevantPatches;
114 headers <<
""; _statusCol = numCol++;
116 headers << _(
"Summary" ); _summaryCol = numCol++;
124 _satisfiedIconCol = -42;
125 _brokenIconCol = -42;
127 setHeaderLabels(headers);
130 header()->setResizeMode(_statusCol, QHeaderView::ResizeToContents);
133 header()->setResizeMode(_summaryCol, QHeaderView::Stretch);
139 setAllColumnsShowFocus(
true );
143 this, SLOT (
filter() ) );
146 setSortingEnabled(
true );
150 yuiDebug() <<
"Creating patch list done" << endl;
178 yuiDebug() <<
"New patch category \""<< category <<
"\"" << endl;
182 _categories.insert( category, cat );
203 yuiDebug() <<
"Filling patch list" << endl;
205 for ( ZyppPoolIterator it = zyppPatchesBegin();
206 it != zyppPatchesEnd();
209 ZyppSel selectable = *it;
210 ZyppPatch zyppPatch = tryCastToZyppPatch( selectable->theObj() );
214 bool displayPatch =
false;
216 switch ( _filterCriteria )
218 case RelevantPatches:
221 if ( selectable->hasCandidateObj() &&
222 selectable->candidateObj().isRelevant() )
225 if ( ! selectable->candidateObj().isSatisfied() ||
227 selectable->candidateObj().status().isToBeInstalled() )
230 yuiDebug() <<
"Patch " << zyppPatch->ident()
231 <<
" is already satisfied"
236 yuiDebug() <<
"Patch " << zyppPatch->ident()
237 <<
" is not relevant to the system"
240 case RelevantAndInstalledPatches:
243 if ( ( selectable->hasCandidateObj() ) &&
244 ( ! selectable->candidateObj().isRelevant()
245 || ( selectable->candidateObj().isSatisfied() &&
246 ! selectable->candidateObj().status().isToBeInstalled() ) ) )
259 yuiDebug() <<
"unknown patch filter" << endl;
265 yuiDebug() <<
"Displaying patch " << zyppPatch->name()
266 <<
" - " << zyppPatch->summary()
273 yuiError() <<
"Found non-patch selectable" << endl;
277 yuiDebug() <<
"Patch list filled" << endl;
278 resizeColumnToContents(_statusCol);
288 QY2ListViewItem * item =
new QY2ListViewItem(
this );
291 item->setText( 1, text );
292 item->setBackgroundColor( 0, QColor( 0xE0, 0xE0, 0xF8 ) );
314 zypp::Patch::Contents contents(patch->contents());
315 yuiMilestone() << contents << endl;
317 for ( zypp::Patch::Contents::Selectable_iterator it = contents.selectableBegin();
318 it != contents.selectableEnd();
321 ZyppPkg zyppPkg = tryCastToZyppPkg( (*it)->theObj() );
330 yuiMilestone() <<
"patch is bogus" << endl;
335 yuiWarning() <<
"selection empty" << endl;
343 ZyppPatch zyppPatch )
345 if ( ! selectable || ! zyppPatch )
347 yuiError() <<
"NULL ZyppSel!" << endl;
374 QTreeWidgetItem * item = currentItem();
387 _notInstalledContextMenu =
new QMenu(
this );
388 Q_CHECK_PTR( _notInstalledContextMenu );
390 _notInstalledContextMenu->addAction(actionSetCurrentInstall);
391 _notInstalledContextMenu->addAction(actionSetCurrentDontInstall);
392 _notInstalledContextMenu->addAction(actionSetCurrentTaboo);
401 _installedContextMenu =
new QMenu(
this );
402 Q_CHECK_PTR( _installedContextMenu );
404 _installedContextMenu->addAction(actionSetCurrentKeepInstalled);
406 #if ENABLE_DELETING_PATCHES
407 _installedContextMenu->addAction(actionSetCurrentDelete);
410 _installedContextMenu->addAction(actionSetCurrentUpdate);
411 _installedContextMenu->addAction(actionSetCurrentUpdateForce);
412 _installedContextMenu->addAction(actionSetCurrentProtected);
421 QMenu * submenu =
new QMenu( menu );
422 Q_CHECK_PTR( submenu );
424 submenu->addAction(actionSetListInstall);
425 submenu->addAction(actionSetListDontInstall);
426 submenu->addAction(actionSetListKeepInstalled);
428 #if ENABLE_DELETING_PATCHES
429 submenu->addAction(actionSetListDelete);
432 submenu->addAction(actionSetListUpdate);
433 submenu->addAction(actionSetListUpdateForce);
434 submenu->addAction(actionSetListTaboo);
435 submenu->addAction(actionSetListProtected);
437 QAction *action = menu->addMenu(submenu);
438 action->setText(_(
"&All in This List" ));
449 #if ! ENABLE_DELETING_PATCHES
450 if ( event->ascii() ==
'-' )
452 QTreeWidgetItem * selectedListViewItem = currentItem();
454 if ( selectedListViewItem )
458 if ( item && item->
selectable()->hasInstalledObj() )
460 yuiWarning() <<
"Deleting patches is not supported" << endl;
475 ZyppPatch zyppPatch )
477 , _patchList( patchList )
478 , _zyppPatch( zyppPatch )
486 ZyppPatch zyppPatch )
488 , _patchList( patchList )
489 , _zyppPatch( zyppPatch )
495 void YQPkgPatchListItem::init()
499 if ( summaryCol() > -1 && _zyppPatch->summary().empty() )
500 setText( summaryCol(), _zyppPatch->name() );
524 if ( col == statusCol() )
530 if ( ( col == brokenIconCol() &&
isBroken() ) ||
537 text = fromUTF8(
zyppPatch()->category() );
539 if ( ! text.isEmpty() )
542 text += fromUTF8(
zyppPatch()->downloadSize().asString().c_str() );
562 return ( this->text(_patchList->summaryCol()) < other->text( _patchList->summaryCol()) );
569 : QY2ListViewItem( patchList )
570 , _patchList( patchList )
597 category = category.toLower();
599 if ( category ==
"yast" )
return YQPkgYaSTPatch;
600 if ( category ==
"security" )
return YQPkgSecurityPatch;
601 if ( category ==
"recommended" )
return YQPkgRecommendedPatch;
602 if ( category ==
"optional" )
return YQPkgOptionalPatch;
603 if ( category ==
"document" )
return YQPkgDocumentPatch;
605 yuiWarning() <<
"Unknown patch category \"" << category <<
"\"" << endl;
606 return YQPkgUnknownPatchCategory;
616 case YQPkgYaSTPatch:
return _(
"YaST" );
617 case YQPkgSecurityPatch:
return _(
"security" );
618 case YQPkgRecommendedPatch:
return _(
"recommended" );
619 case YQPkgOptionalPatch:
return _(
"optional" );
620 case YQPkgDocumentPatch:
return _(
"document" );
621 case YQPkgUnknownPatchCategory:
return "";
649 YQPkgPatchCategoryItem::setExpanded(
bool open )
651 QTreeWidgetItem::setExpanded( open );
659 setIcon( _patchList->iconCol(),
661 YQIconPool::treeMinus() :
662 YQIconPool::treePlus() );
672 return QTreeWidgetItem::operator<( otherListViewItem );
677 #include "YQPkgPatchList.moc"
ZyppSel selectable() const
Abstract base class to display a list of zypp::ResObjects. Handles most generic stuff like setting st...
virtual bool operator<(const QTreeWidgetItem &other) const
void setText(int column, const string text)
Display a list of zypp::Patch objects.
virtual void applyChanges()
virtual ~YQPkgPatchCategoryItem()
ZyppPatch zyppPatch() const
virtual ~YQPkgPatchListItem()
YQPkgPatchListItem * selection() const
virtual void keyPressEvent(QKeyEvent *ev)
virtual void cycleStatus()
virtual void setStatus(ZyppStatus newStatus, bool sendSignals=true)
YQPkgPatchCategory category() const
void filterMatch(ZyppSel selectable, ZyppPkg pkg)
YQPkgPatchList(QWidget *parent)
virtual bool operator<(const QTreeWidgetItem &other) const
YQPkgPatchCategoryItem(YQPkgPatchCategory category, YQPkgPatchList *patternList)
virtual void createInstalledContextMenu()
virtual void message(const QString &text)
static QString asString(YQPkgPatchCategory category)
virtual void createNotInstalledContextMenu()
virtual ~YQPkgPatchList()
void currentItemChanged(ZyppSel selectable)
FilterCriteria filterCriteria() const
virtual QMenu * addAllInListSubMenu(QMenu *menu)
static YQPkgPatchCategory patchCategory(QString category)
void addPatchItem(ZyppSel selectable, ZyppPatch zyppPatch)
void addPatch(ZyppPatch patch)
virtual QString toolTip(int column)
virtual bool operator<(const QTreeWidgetItem &other) const
void solveResolvableCollections()
virtual QString toolTip(int column)
virtual void keyPressEvent(QKeyEvent *ev)
virtual ZyppStatus status() const
void setFilterCriteria(FilterCriteria filterCriteria)
YQPkgPatchListItem(YQPkgPatchList *patchList, ZyppSel selectable, ZyppPatch zyppPatch)
YQPkgPatchCategoryItem * category(YQPkgPatchCategory category)
virtual void setStatusIcon()
virtual void cycleStatus()