43 #include <QElapsedTimer> 44 #include <QHeaderView> 46 #define YUILogComponent "qt-pkg" 48 #include <zypp/RepoManager.h> 49 #include <zypp/PoolQuery.h> 51 #include <QTreeWidget> 52 #include "YQPkgRepoList.h" 53 #include "YQPkgFilters.h" 66 : QY2ListView( parent )
68 yuiDebug() <<
"Creating repository list" << endl;
78 headers << _(
"Name"); _nameCol = numCol++;
81 setHeaderLabels( headers );
82 header()->setSectionResizeMode( _nameCol, QHeaderView::Stretch );
85 setSelectionMode( QAbstractItemView::ExtendedSelection );
87 connect(
this, SIGNAL( itemSelectionChanged() ),
89 setIconSize(QSize(32,32));
91 setSortingEnabled(
true );
92 sortByColumn( nameCol(), Qt::AscendingOrder );
95 yuiDebug() <<
"Creating repository list done" << endl;
109 yuiDebug() <<
"Filling repository list" << endl;
111 for ( ZyppRepositoryIterator it = ZyppRepositoriesBegin();
112 it != ZyppRepositoriesEnd();
118 yuiDebug() <<
"Inst repository filled" << endl;
125 return zyppPool().knownRepositoriesSize();
142 yuiMilestone() <<
"Collecting packages in selected repositories..." << endl;
143 QElapsedTimer stopWatch;
151 QTreeWidgetItem * item;
153 QList<QTreeWidgetItem *> items = selectedItems();
154 QListIterator<QTreeWidgetItem *> it(items);
156 while ( it.hasNext() )
163 ZyppRepo currentRepo = repoItem->
zyppRepo();
165 zypp::PoolQuery query;
166 query.addRepo( currentRepo.info().alias() );
167 query.addKind(zypp::ResKind::package);
169 for( zypp::PoolQuery::Selectable_iterator it = query.selectableBegin();
170 it != query.selectableEnd(); it++)
172 emit
filterMatch( *it, tryCastToZyppPkg( (*it)->theObj() ) );
177 yuiDebug() <<
"Packages sent to package list. Elapsed time: " 178 << stopWatch.elapsed() / 1000.0 <<
" sec" 195 QTreeWidgetItem * item = currentItem();
206 : QY2ListViewItem( repoList )
207 , _repoList( repoList )
210 if ( nameCol() >= 0 )
212 string name = repo.info().name();
213 if ( ! name.empty() )
215 setText( nameCol(), fromUTF8( name ));
219 std::string infoToolTip;
220 infoToolTip += (
"<b>" + repo.info().name() +
"</b>");
225 infoToolTip += (
"<p>" + product->summary() +
"</p>");
228 if ( ! repo.info().baseUrlsEmpty() )
230 zypp::RepoInfo::urls_const_iterator it;
231 infoToolTip +=
"<ul>";
233 for ( it = repo.info().baseUrlsBegin();
234 it != repo.info().baseUrlsEnd();
237 infoToolTip += (
"<li>" + (*it).asString() +
"</li>");
239 infoToolTip +=
"</ul>";
241 setToolTip( nameCol(), fromUTF8(infoToolTip) );
244 QString iconName =
"applications-internet";
246 if ( ! repo.info().baseUrlsEmpty() )
248 zypp::Url repoUrl = *repo.info().baseUrlsBegin();
252 setText( urlCol(), repoUrl.asString().c_str() );
255 if (QString(repoUrl.asString().c_str()).contains(
"KDE") )
257 if (QString(repoUrl.asString().c_str()).contains(
"GNOME") )
259 if (QString(repoUrl.asString().c_str()).contains(
"update") )
260 iconName =
"applications-utilities";
261 if (QString(repoUrl.asString().c_str()).contains(
"home:") )
262 iconName =
"preferences-desktop";
265 if ( repo.isSystemRepo() )
266 iconName =
"preferences-system";
268 setIcon( 0, YQUI::ui()->loadIcon( iconName.toStdString() ) );
284 return item.resolvable()->repoInfo().alias() ==
zyppRepo.info().alias();
289 YQPkgRepoListItem::operator< (
const QTreeWidgetItem & other )
const void fillList()
Fill the list.
void filter()
Filter according to the view's rules and current selection.
static int countEnabledRepositories()
Returns the number of enabled repositories.
YQPkgRepoListItem * selection() const
Returns the currently selected item or 0 if there is none.
ZyppRepo zyppRepo() const
Returns the ZYPP repository this item corresponds to.
YQPkgRepoList(QWidget *parent)
Constructor.
void filterStart()
Emitted when the filtering starts.
virtual ~YQPkgRepoList()
Destructor.
YQPkgRepoListItem(YQPkgRepoList *parentList, ZyppRepo repo)
Constructor.
void filterFinished()
Emitted when filtering is finished.
void filterMatch(ZyppSel selectable, ZyppPkg pkg)
Emitted during filtering for each pkg that matches the filter and the candidate package comes from th...
virtual ~YQPkgRepoListItem()
Destructor.
static ZyppProduct singleProduct(ZyppRepo repo)
Returns the product on a source if it has one single product or 0 if there are no or multiple product...
Display a list of libzypp repositories.
static ZyppProduct singleProductFilter(std::function< bool(const zypp::PoolItem &item)> filter)
Returns the product if the filter finds a single product or null product if there are no or multiple ...
void addRepo(ZyppRepo repo)
Add a repository to the list.
void filterIfVisible()
Same as filter(), but only if this widget is currently visible.