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" 76 virtual void paint ( QPainter * painter,
const QStyleOptionViewItem & option,
const QModelIndex & index )
const 85 QFont f = painter->font();
86 f.setWeight( QFont::Bold );
88 f.setPixelSize( (
int) ( fm.height() * 1.1 ) );
89 citem->setFont( _view->summaryCol(), f );
91 QItemDelegate::paint( painter, option, index );
103 QColor background = option.palette.color(QPalette::Window);
104 painter->setBackground( background );
106 float percent = (item->totalPackages() > 0)
107 ? (((
float)item->installedPackages()*100) / (
float)item->totalPackages())
110 QColor fillColor = option.palette.color(QPalette::Mid);
112 if ( percent > 100.0 ) percent = 100.0;
113 if ( percent < 0.0 ) percent = 0.0;
114 int x = option.rect.left() + 1;
115 int y = option.rect.top() + 1;
116 int w = option.rect.width() - 2;
117 int h = (int) ( ( (
float) option.rect.height() )/2 );
121 fillWidth = (int) ( w * percent / 100.0 );
125 painter->fillRect( x, y, fillWidth, h, fillColor );
127 QString percentageText = QString(
"%1/%2" )
128 .arg( item->installedPackages() )
129 .arg( item->totalPackages() );
131 painter->setPen( _view->palette().color( QPalette::Base ) );
132 painter->drawText( QRect( x, y,
134 Qt::AlignHCenter, percentageText );
144 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 QTreeWidgetItem * ) ),
215 this, SLOT (
filter() ) );
218 setIconSize(QSize(32,32));
219 header()->resizeSection( iconCol(), 34 );
228 yuiDebug() <<
"Creating pattern list done" << std::endl;
244 yuiDebug() <<
"Filling pattern list" << std::endl;
246 for ( ZyppPoolIterator it = zyppPatternsBegin();
247 it != zyppPatternsEnd();
250 ZyppPattern zyppPattern = tryCastToZyppPattern( (*it)->theObj() );
254 if ( zyppPattern->userVisible() )
259 yuiDebug() <<
"Pattern " << zyppPattern->name()
260 <<
" is not user-visible" << std::endl;
264 yuiError() <<
"Found non-Pattern selectable" << std::endl;
268 yuiDebug() <<
"Pattern list filled" << std::endl;
269 resizeColumnToContents(_iconCol);
270 resizeColumnToContents(_statusCol);
271 resizeColumnToContents(_howmanyCol);
278 if ( categoryName.isEmpty() )
285 yuiDebug() <<
"New pattern category \""<< categoryName <<
"\"" << std::endl;
289 _categories.insert( categoryName, cat );
319 zypp::Pattern::Contents c(zyppPattern->contents());
320 for ( zypp::Pattern::Contents::Selectable_iterator it = c.selectableBegin();
321 it != c.selectableEnd();
324 ZyppPkg zyppPkg = tryCastToZyppPkg( (*it)->theObj() );
327 if ( (*it)->installedSize() > 0 )
334 selection()->setInstalledPackages(installed);
341 resizeColumnToContents(_howmanyCol);
347 ZyppPattern zyppPattern )
351 yuiError() <<
"NULL ZyppSelectable!" << std::endl;
367 resizeColumnToContents(_howmanyCol);
368 resizeColumnToContents(_summaryCol);
370 addTopLevelItem(item);
378 QTreeWidgetItem * item = currentItem();
389 QTreeWidgetItem * listViewItem,
398 if ( button == Qt::LeftButton )
402 categoryItem->setExpanded( ! categoryItem->isExpanded() );
418 QTreeWidgetItemIterator it(
this );
422 QY2ListViewItem * item =
dynamic_cast<QY2ListViewItem *
> (*it);
426 if ( item && item->isSelectable() && ! categoryItem )
428 setSelected( item,
true );
440 ZyppPattern zyppPattern )
442 , _patternList( patternList )
443 , _zyppPattern( zyppPattern )
444 , _total(0), _installed(0)
453 ZyppPattern zyppPattern )
455 , _patternList( patternList )
456 , _zyppPattern( zyppPattern )
457 , _total(0), _installed(0)
467 if ( ! _zyppPattern )
468 _zyppPattern = tryCastToZyppPattern(
selectable()->theObj() );
472 string iconName = _zyppPattern->icon().basename();
473 if ( iconName.empty() )
474 iconName =
"pattern-generic";
476 setIcon( _patternList->iconCol(), YQUI::ui()->loadIcon( iconName ) );
482 setFirstColumnSpanned (
false );
496 if ( ! _editable || ! _pkgObjList->
editable() )
499 ZyppStatus oldStatus =
status();
500 ZyppStatus newStatus = oldStatus;
505 newStatus = S_NoInst;
514 newStatus = S_Install;
518 newStatus = S_NoInst;
525 if ( oldStatus != newStatus )
547 std::string infoToolTip;
548 infoToolTip += (
"<p>" +
zyppPattern()->description() +
"</p>");
550 if ( totalPackages() > 0 )
552 infoToolTip += (
"<p>" + zypp::str::form(
"%d / %d", installedPackages(), totalPackages() ) +
"</p>");
555 setToolTip(_patternList->summaryCol(), fromUTF8(infoToolTip));
570 if ( _zyppPattern && otherPatternListitem && otherPatternListitem->
zyppPattern() )
572 if ( _zyppPattern->order() != otherPatternListitem->
zyppPattern()->order() )
573 return _zyppPattern->order() < otherPatternListitem->
zyppPattern()->order();
575 return _zyppPattern->name() < otherPatternListitem->
zyppPattern()->name();
580 if ( otherCategoryItem )
583 return QTreeWidgetItem::operator<( otherListViewItem );
588 const QString & category )
589 : QY2ListViewItem( patternList )
590 , _patternList( patternList )
592 setText( _patternList->summaryCol(), category );
608 if ( ! _firstPattern )
610 _firstPattern = pattern;
614 if ( _firstPattern->order().compare( pattern->order() ) < 0 )
615 _firstPattern = pattern;
621 YQPkgPatternCategoryItem::setExpanded(
bool open )
623 QTreeWidgetItem::setExpanded( open );
633 YQIconPool::arrowDown() :
634 YQIconPool::arrowRight() );
643 if ( _firstPattern && otherCategoryItem && otherCategoryItem->
firstPattern() )
644 return _firstPattern->order() < otherCategoryItem->
firstPattern()->order();
649 if ( otherPatternListitem )
652 return QTreeWidgetItem::operator<( otherListViewItem );
virtual void selectSomething()
Select the first selectable list entry that is not a pattern category.
void setTreeIcon(void)
Set a suitable tree open/close icon depending on this category's open/close status.
ZyppPattern firstPattern() const
Returns the first pattern.
void init()
Initialize things common to all constructors.
void filterFinished()
Emitted when filtering is finished.
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 ~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 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.
void filter()
Filter according to the view's rules and current selection.
virtual ZyppStatus status() const
Returns the (binary RPM) package status.
YQPkgPatternCategoryItem(YQPkgPatternList *patternList, const QString &category)
Constructor.
Display a list of zypp::Pattern objects.
bool editable() const
Return whether or not items in this list are generally editable, i.e.
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...
YQPkgPatternList(QWidget *parent, bool autoFill=true, bool autoFilter=true)
Constructor.
virtual bool operator<(const QTreeWidgetItem &other) const
sorting function
ZyppPattern zyppPattern() const
Returns the original object within the package manager backend.
ZyppSel selectable() const
Returns the original selectable within the package manager backend.
void currentItemChanged(ZyppSel selectable)
Emitted when a zypp::ui::Selectable is selected.
virtual void cycleStatus()
Cycle the package status to the next valid value.
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.
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 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
YQPkgPatternListItem * selection() const
Returns the currently selected item or 0 if there is none.