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" );
40 addColumn( "" ); _statusCol = numCol++;
41 addColumn( _( "Selection" ) ); _summaryCol = numCol++;
42 setAllColumnsShowFocus( true );
44 _satisfiedIconCol = _summaryCol;
45 _brokenIconCol = _summaryCol;
49 connect( this, SIGNAL( selectionChanged( QTreeWidgetItem * ) ),
50 this, SLOT ( filter() ) );
59 y2debug( "Creating selection list done" );
63 YQPkgSelList::~YQPkgSelList()
70 YQPkgSelList::fillList()
73 y2debug( "Filling selection list" );
76 for ( ZyppPoolIterator it = zyppSelectionsBegin();
77 it != zyppSelectionsEnd();
80 ZyppSelection zyppSelection = tryCastToZyppSelection( (*it)->theObj() );
84 if ( zyppSelection->visible() && ! zyppSelection->isBase() )
86 addPkgSelItem( *it, zyppSelection );
91 y2error( "Found non-Selection selectable" );
95 y2debug( "Selection list filled" );
100 YQPkgSelList::filterIfVisible()
108 YQPkgSelList::filter()
112 if ( selection() ) // The seleted QListViewItem
114 ZyppSelection zyppSelection = selection()->zyppSelection();
118 set<string> wanted = zyppSelection->install_packages();
120 for ( ZyppPoolIterator it = zyppPkgBegin();
124 string name = (*it)->theObj()->name();
126 if ( contains( wanted, name ) )
128 ZyppPkg zyppPkg = tryCastToZyppPkg( (*it)->theObj() );
132 emit filterMatch( *it, zyppPkg );
139 emit filterFinished();
144 YQPkgSelList::addPkgSelItem( ZyppSel selectable,
145 ZyppSelection zyppSelection )
149 y2error( "NULL ZyppSel!" );
153 YQPkgSelListItem * item = new YQPkgSelListItem( this, selectable, zyppSelection );
154 applyExcludeRules( item );
159 YQPkgSelList::selection() const
161 QTreeWidgetItem * item = selectedItem();
166 return dynamic_cast<YQPkgSelListItem *> (item);
174 YQPkgSelListItem::YQPkgSelListItem( YQPkgSelList * pkgSelList,
176 ZyppSelection zyppSelection )
177 : YQPkgObjListItem( pkgSelList, selectable, zyppSelection )
178 , _pkgSelList( pkgSelList )
179 , _zyppSelection( zyppSelection )
181 if ( ! _zyppSelection )
182 _zyppSelection = tryCastToZyppSelection( selectable->theObj() );
184 QString text = fromUTF8( _zyppSelection->summary() );
186 // You don't want to know why we need this.
187 text.replace( QRegExp( "Graphical Basis System" ), "Graphical Base System" );
188 text.replace( QRegExp( "Gnome" ), "GNOME" );
190 setText( summaryCol(), text );
196 YQPkgSelListItem::~YQPkgSelListItem()
203 YQPkgSelListItem::applyChanges()
205 solveResolvableCollections();
210 * Comparison function used for sorting the list.
217 YQPkgSelListItem::compare( QTreeWidgetItem * otherListViewItem,
219 bool ascending ) const
221 YQPkgSelListItem * other = ( YQPkgSelListItem * ) otherListViewItem;
223 if ( ! _zyppSelection || ! other || ! other->zyppSelection() )
226 return _zyppSelection->order().compare( other->zyppSelection()->order() );
231 #include "YQPkgSelList.moc"