42 #define YUILogComponent "qt-pkg"
45 #include <zypp/ZYppFactory.h>
46 #include <zypp/Resolver.h>
48 #include <QHeaderView>
51 #include <QItemDelegate>
55 #include "YQPackageSelector.h"
56 #include "YQPkgPatternList.h"
57 #include "YQIconPool.h"
58 #include "YQApplication.h"
71 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.1 ) );
84 citem->setFont(_view->summaryCol(), f);
86 QItemDelegate::paint(painter, option, index);
100 QColor background = option.palette.color(QPalette::Window);
101 painter->setBackground( background );
103 float percent = (item->totalPackages() > 0)
104 ? (((
float)item->installedPackages()*100) / (
float)item->totalPackages())
107 QColor fillColor = option.palette.color(QPalette::Mid);
109 if ( percent > 100.0 ) percent = 100.0;
110 if ( percent < 0.0 ) percent = 0.0;
111 int x = option.rect.left() + 1;
112 int y = option.rect.top() + 1;
113 int w = option.rect.width() - 2;
114 int h = (int) ( ( (
float) option.rect.height() )/2 );
118 fillWidth = (int) ( w * percent / 100.0 );
123 painter->fillRect( x, y, fillWidth, h,
126 QString percentageText;
127 percentageText.sprintf(
"%d/%d", item->installedPackages(), item->totalPackages());
129 painter->setPen( _view->palette().color( QPalette::Base ) );
130 painter->drawText( QRect( x, y,
132 Qt::AlignHCenter, percentageText );
143 QItemDelegate::paint(painter, option, index);
155 yuiDebug() <<
"Creating pattern list" << std::endl;
160 headers <<
""; _statusCol = numCol++;
169 headers <<
""; _iconCol = numCol++;
170 headers << _(
"Pattern" ); _summaryCol = numCol++;
174 setColumnCount( numCol );
175 setHeaderLabels(headers);
187 _satisfiedIconCol = -42;
188 _brokenIconCol = -42;
193 setSortingEnabled(
true );
194 sortByColumn( summaryCol(), Qt::AscendingOrder );
196 setAllColumnsShowFocus(
true );
198 header()->setSectionResizeMode( statusCol(), QHeaderView::Fixed );
199 header()->setSectionResizeMode( summaryCol(), QHeaderView::Stretch );
200 header()->setSectionResizeMode( howmanyCol(), QHeaderView::Fixed );
202 header()->resizeSection( statusCol(), 25 );
203 setColumnWidth( statusCol(), 25 );
204 setColumnWidth( summaryCol(), 100 );
205 setColumnWidth( howmanyCol(), 15 );
214 this, SLOT (
filter() ) );
217 setIconSize(QSize(32,32));
218 header()->resizeSection( iconCol(), 34 );
226 yuiDebug() <<
"Creating pattern list done" << std::endl;
242 yuiDebug() <<
"Filling pattern list" << std::endl;
244 for ( ZyppPoolIterator it = zyppPatternsBegin();
245 it != zyppPatternsEnd();
248 ZyppPattern zyppPattern = tryCastToZyppPattern( (*it)->theObj() );
252 if ( zyppPattern->userVisible() )
257 yuiDebug() <<
"Pattern " << zyppPattern->name()
258 <<
" is not user-visible" << std::endl;
262 yuiError() <<
"Found non-Pattern selectable" << std::endl;
266 yuiDebug() <<
"Pattern list filled" << std::endl;
267 resizeColumnToContents(_iconCol);
268 resizeColumnToContents(_statusCol);
269 resizeColumnToContents(_howmanyCol);
276 if ( categoryName.isEmpty() )
283 yuiDebug() <<
"New pattern category \""<< categoryName <<
"\"" << std::endl;
287 _categories.insert( categoryName, cat );
317 zypp::Pattern::Contents c(zyppPattern->contents());
318 for ( zypp::Pattern::Contents::Selectable_iterator it = c.selectableBegin();
319 it != c.selectableEnd();
322 ZyppPkg zyppPkg = tryCastToZyppPkg( (*it)->theObj() );
325 if ( (*it)->installedSize() > 0 )
332 selection()->setInstalledPackages(installed);
339 resizeColumnToContents(_howmanyCol);
345 ZyppPattern zyppPattern )
349 yuiError() <<
"NULL ZyppSelectable!" << std::endl;
365 resizeColumnToContents(_howmanyCol);
366 resizeColumnToContents(_summaryCol);
368 addTopLevelItem(item);
376 QTreeWidgetItem * item = currentItem();
387 QTreeWidgetItem * listViewItem,
396 if ( button == Qt::LeftButton )
400 categoryItem->setExpanded( ! categoryItem->isExpanded() );
416 QTreeWidgetItemIterator it(
this );
420 QY2ListViewItem * item =
dynamic_cast<QY2ListViewItem *
> (*it);
424 if ( item && item->isSelectable() && ! categoryItem )
426 setSelected( item,
true );
437 ZyppPattern zyppPattern )
439 , _patternList( patternList )
440 , _zyppPattern( zyppPattern )
441 , _total(0), _installed(0)
450 ZyppPattern zyppPattern )
452 , _patternList( patternList )
453 , _zyppPattern( zyppPattern )
454 , _total(0), _installed(0)
464 if ( ! _zyppPattern )
465 _zyppPattern = tryCastToZyppPattern(
selectable()->theObj() );
469 string icon = _zyppPattern->icon().asString();
471 if ( (icon == zypp::Pathname(
"yast-system").asString()) ||
473 icon =
"pattern-generic";
478 setIcon(_patternList->iconCol(), QIcon(QString(iconpath.c_str())));
484 setFirstColumnSpanned (
false );
498 if ( ! _editable || ! _pkgObjList->
editable() )
501 ZyppStatus oldStatus =
status();
502 ZyppStatus newStatus = oldStatus;
507 newStatus = S_NoInst;
516 newStatus = S_Install;
520 newStatus = S_NoInst;
527 if ( oldStatus != newStatus )
549 std::string infoToolTip;
550 infoToolTip += (
"<p>" +
zyppPattern()->description() +
"</p>");
552 if ( totalPackages() > 0 )
554 infoToolTip += (
"<p>" + zypp::str::form(
"%d / %d", installedPackages(), totalPackages() ) +
"</p>");
557 setToolTip(_patternList->summaryCol(), fromUTF8(infoToolTip));
574 if ( _zyppPattern && otherPatternListitem && otherPatternListitem->
zyppPattern() )
576 if ( _zyppPattern->order() != otherPatternListitem->
zyppPattern()->order() )
577 return _zyppPattern->order() < otherPatternListitem->
zyppPattern()->order();
579 return _zyppPattern->name() < otherPatternListitem->
zyppPattern()->name();
584 if ( otherCategoryItem )
587 return QTreeWidgetItem::operator<( otherListViewItem );
591 const QString & category )
592 : QY2ListViewItem( patternList )
593 , _patternList( patternList )
595 setText( _patternList->summaryCol(), category );
610 if ( ! _firstPattern )
612 _firstPattern = pattern;
616 if ( _firstPattern->order().compare( pattern->order() ) < 0 )
617 _firstPattern = pattern;
623 YQPkgPatternCategoryItem::setExpanded(
bool open )
625 QTreeWidgetItem::setExpanded( open );
635 YQIconPool::treeMinus() :
636 YQIconPool::treePlus() );
645 if ( _firstPattern && otherCategoryItem && otherCategoryItem->
firstPattern() )
646 return _firstPattern->order() < otherCategoryItem->
firstPattern()->order();
651 if ( otherPatternListitem )
654 return QTreeWidgetItem::operator<( otherListViewItem );
659 #include "YQPkgPatternList.moc"
virtual void selectSomething()
Select the first selectable list entry that is not a pattern category.
ZyppSel selectable() const
Returns the original selectable within the package manager backend.
void setTreeIcon(void)
Set a suitable tree open/close icon depending on this category's open/close status.
void init()
Initialize things common to all constructors.
void filterFinished()
Emitted when filtering is finished.
ZyppPattern firstPattern() const
Returns the first pattern.
Abstract base class to display a list of zypp::ResObjects.
virtual void applyChanges()
Propagate status changes in this list to other lists: Have the solver transact all patterns...
virtual bool operator<(const QTreeWidgetItem &other) const
sorting function
virtual ~YQPkgPatternCategoryItem()
Destructor.
YQPkgPatternCategoryItem * category(const QString &categoryName)
Returns the category item with the specified name.
void fillList()
Fill the pattern list.
bool showLicenseAgreement()
Display this item's license agreement (if there is any) that corresponds to its current status (S_Ins...
YQPkgPatternListItem(YQPkgPatternList *patternList, ZyppSel selectable, ZyppPattern zyppPattern)
Constructor for root items.
virtual void clear()
Reimplemented from QY2ListView: Emit currentItemChanged() signal after clearing the list...
virtual bool operator<(const QTreeWidgetItem &other) const
sorting function
virtual void setStatus(ZyppStatus newStatus, bool sendSignals=true)
Set the (binary RPM) package status.
virtual ~YQPkgPatternListItem()
Destructor.
void filterMatch(ZyppSel selectable, ZyppPkg pkg)
Emitted during filtering for each pkg that matches the filter.
virtual void pkgObjClicked(int button, QTreeWidgetItem *item, int col, const QPoint &pos)
Dispatcher slot for mouse click: cycle status depending on column.
virtual ~YQPkgPatternList()
Destructor.
void filterIfVisible()
Same as filter(), but only if this widget is currently visible.
void sendStatusChanged()
Emit a statusChanged() signal for the specified zypp::ResObject.
bool editable() const
Return whether or not items in this list are generally editable, i.e.
void filter()
Filter according to the view's rules and current selection.
static std::string iconPath(const std::string &name, int size)
returns the full path for an icon of a given size
YQPkgPatternCategoryItem(YQPkgPatternList *patternList, const QString &category)
Constructor.
Display a list of zypp::Pattern objects.
void filterStart()
Emitted when the filtering starts.
void applyExcludeRules()
Apply all exclude rules of this list to all items, including those that are currently excluded...
YQPkgPatternListItem * selection() const
Returns the currently selected item or 0 if there is none.
YQPkgPatternList(QWidget *parent, bool autoFill=true, bool autoFilter=true)
Constructor.
void currentItemChanged(ZyppSel selectable)
Emitted when a zypp::ui::Selectable is selected.
ZyppPattern zyppPattern() const
Returns the original object within the package manager backend.
virtual void cycleStatus()
Cycle the package status to the next valid value.
void solveResolvableCollections()
Do a "small" solver run for all "resolvable collections", i.e., for selections, patterns, languages, patches.
void showNotifyTexts(ZyppStatus status)
Display this item's notify text (if there is any) that corresponds to the specified status (S_Install...
void addPattern(ZyppPattern pattern)
Add a pattern to this category.
virtual ZyppStatus status() const
Returns the (binary RPM) package status.
virtual void pkgObjClicked(int button, QTreeWidgetItem *item, int col, const QPoint &pos)
Dispatcher slot for mouse click: cycle status depending on column.
virtual void setStatusIcon()
Set a status icon according to the package's status.
void addPatternItem(ZyppSel selectable, ZyppPattern pattern)
Add a pattern to the list.
void resetToolTip()
resets the tooltip with the current available information