1 /*---------------------------------------------------------------------\
3 | __ __ ____ _____ ____ |
4 | \ \ / /_ _/ ___|_ _|___ \ |
5 | \ V / _` \___ \ | | __) | |
6 | | | (_| |___) || | / __/ |
7 | |_|\__,_|____/ |_| |_____| |
11 \----------------------------------------------------------------------/
15 Author: Stefan Hundhammer <sh@suse.de>
17 Textdomain "packages-qt"
22 #define y2log_component "qt-pkg"
23 #include <ycp/y2log.h>
25 #include <zypp/ZYppFactory.h>
26 #include <zypp/Resolver.h>
31 #include "YQPkgSelList.h"
34 YQPkgSelList::YQPkgSelList( QWidget * parent, bool autoFill, bool autoFilter )
35 : YQPkgObjList( parent )
37 y2debug( "Creating selection list" );
41 addColumn( "" ); _statusCol = numCol++;
42 addColumn( _( "Selection" ) ); _summaryCol = numCol++;
43 setAllColumnsShowFocus( true );
46 _satisfiedIconCol = _summaryCol;
47 _brokenIconCol = _summaryCol;
51 connect( this, SIGNAL( currentItemChanged( QTreeWidgetItem * ) ),
52 this, SLOT ( filter() ) );
61 y2debug( "Creating selection list done" );
65 YQPkgSelList::~YQPkgSelList()
72 YQPkgSelList::fillList()
75 y2debug( "Filling selection list" );
78 for ( ZyppPoolIterator it = zyppSelectionsBegin();
79 it != zyppSelectionsEnd();
82 ZyppSelection zyppSelection = tryCastToZyppSelection( (*it)->theObj() );
86 if ( zyppSelection->visible() && ! zyppSelection->isBase() )
88 addPkgSelItem( *it, zyppSelection );
93 y2error( "Found non-Selection selectable" );
97 y2debug( "Selection list filled" );
102 YQPkgSelList::filterIfVisible()
110 YQPkgSelList::filter()
114 if ( selection() ) // The seleted QListViewItem
116 ZyppSelection zyppSelection = selection()->zyppSelection();
120 set<string> wanted = zyppSelection->install_packages();
122 for ( ZyppPoolIterator it = zyppPkgBegin();
126 string name = (*it)->theObj()->name();
128 if ( contains( wanted, name ) )
130 ZyppPkg zyppPkg = tryCastToZyppPkg( (*it)->theObj() );
134 emit filterMatch( *it, zyppPkg );
141 emit filterFinished();
146 YQPkgSelList::addPkgSelItem( ZyppSel selectable,
147 ZyppSelection zyppSelection )
151 y2error( "NULL ZyppSel!" );
155 YQPkgSelListItem * item = new YQPkgSelListItem( this, selectable, zyppSelection );
156 applyExcludeRules( item );
161 YQPkgSelList::selection() const
164 QTreeWidgetItem * item = selectedItem();
169 return dynamic_cast<YQPkgSelListItem *> (item);
180 YQPkgSelListItem::YQPkgSelListItem( YQPkgSelList * pkgSelList,
182 ZyppSelection zyppSelection )
183 : YQPkgObjListItem( pkgSelList, selectable, zyppSelection )
184 , _pkgSelList( pkgSelList )
185 , _zyppSelection( zyppSelection )
187 if ( ! _zyppSelection )
188 _zyppSelection = tryCastToZyppSelection( selectable->theObj() );
190 QString text = fromUTF8( _zyppSelection->summary() );
192 // You don't want to know why we need this.
193 text.replace( QRegExp( "Graphical Basis System" ), "Graphical Base System" );
194 text.replace( QRegExp( "Gnome" ), "GNOME" );
196 setText( summaryCol(), text );
202 YQPkgSelListItem::~YQPkgSelListItem()
209 YQPkgSelListItem::applyChanges()
211 solveResolvableCollections();
216 * Comparison function used for sorting the list.
223 YQPkgSelListItem::compare( QTreeWidgetItem * otherListViewItem,
225 bool ascending ) const
227 YQPkgSelListItem * other = ( YQPkgSelListItem * ) otherListViewItem;
229 if ( ! _zyppSelection || ! other || ! other->zyppSelection() )
232 return _zyppSelection->order().compare( other->zyppSelection()->order() );
237 #include "YQPkgSelList.moc"