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"
64 : QY2ListView( parent )
66 yuiDebug() <<
"Creating repository list" << endl;
76 headers << _(
"Name"); _nameCol = numCol++;
79 setHeaderLabels( headers );
80 header()->setResizeMode( _nameCol, QHeaderView::Stretch );
83 setSelectionMode( QAbstractItemView::ExtendedSelection );
85 connect(
this, SIGNAL( itemSelectionChanged() ),
87 setIconSize(QSize(32,32));
89 setSortingEnabled(
true );
90 sortByColumn( nameCol(), Qt::AscendingOrder );
93 yuiDebug() <<
"Creating repository list done" << endl;
107 yuiDebug() <<
"Filling repository list" << endl;
109 for ( ZyppRepositoryIterator it = ZyppRepositoriesBegin();
110 it != ZyppRepositoriesEnd();
116 yuiDebug() <<
"Inst repository filled" << endl;
123 return zyppPool().knownRepositoriesSize();
140 yuiMilestone() <<
"Collecting packages in selected repositories..." << endl;
149 QTreeWidgetItem * item;
151 QList<QTreeWidgetItem *> items = selectedItems();
152 QListIterator<QTreeWidgetItem *> it(items);
154 while ( it.hasNext() )
161 ZyppRepo currentRepo = repoItem->
zyppRepo();
163 zypp::PoolQuery query;
164 query.addRepo( currentRepo.info().alias() );
165 query.addKind(zypp::ResKind::package);
167 for( zypp::PoolQuery::Selectable_iterator it = query.selectableBegin();
168 it != query.selectableEnd(); it++)
170 emit
filterMatch( *it, tryCastToZyppPkg( (*it)->theObj() ) );
175 yuiDebug() <<
"Packages sent to package list. Elapsed time: "
176 << stopWatch.elapsed() / 1000.0 <<
" sec"
193 QTreeWidgetItem * item = currentItem();
208 : QY2ListViewItem( repoList )
209 , _repoList( repoList )
212 if ( nameCol() >= 0 )
214 string name = repo.info().name();
215 if ( ! name.empty() )
217 setText( nameCol(), fromUTF8( name ));
221 std::string infoToolTip;
222 infoToolTip += (
"<b>" + repo.info().name() +
"</b>");
227 infoToolTip += (
"<p>" + product->summary() +
"</p>");
230 if ( ! repo.info().baseUrlsEmpty() )
232 zypp::RepoInfo::urls_const_iterator it;
233 infoToolTip +=
"<ul>";
235 for ( it = repo.info().baseUrlsBegin();
236 it != repo.info().baseUrlsEnd();
239 infoToolTip += (
"<li>" + (*it).asString() +
"</li>");
241 infoToolTip +=
"</ul>";
243 setToolTip( nameCol(), fromUTF8(infoToolTip) );
246 QString iconName =
"yast-sw_source";
248 if ( ! repo.info().baseUrlsEmpty() )
250 zypp::Url repoUrl = *repo.info().baseUrlsBegin();
254 setText( urlCol(), repoUrl.asString().c_str() );
257 if (QString(repoUrl.asString().c_str()).contains(
"KDE") )
258 iconName =
"pattern-kde";
259 if (QString(repoUrl.asString().c_str()).contains(
"GNOME") )
260 iconName =
"pattern-gnome";
261 if (QString(repoUrl.asString().c_str()).contains(
"KDE") )
262 iconName =
"pattern-kde";
263 if (QString(repoUrl.asString().c_str()).contains(
"update") )
264 iconName =
"yast-update";
265 if (QString(repoUrl.asString().c_str()).contains(
"home:") )
266 iconName =
"yast-users";
269 if ( repo.isSystemRepo() )
270 iconName =
"yast-host";
273 setIcon( 0, QIcon( iconPath.sprintf(
"/usr/share/icons/hicolor/48x48/apps/%s.png", iconName.toUtf8().data()) ));
289 zypp::ResPool::byKind_iterator it = zypp::ResPool::instance().byKindBegin( zypp::ResKind::product );
290 zypp::ResPool::byKind_iterator end = zypp::ResPool::instance().byKindEnd( zypp::ResKind::product );
296 while ( it != end && ! product )
298 if ( it->resolvable()->repoInfo().alias() == zyppRepo.info().alias() )
299 product = zypp::asKind<zypp::Product>( it->resolvable() );
309 if ( it->resolvable()->repoInfo().alias() == zyppRepo.info().alias() )
311 yuiMilestone() <<
"Multiple products in repository "
312 << zyppRepo.info().alias()
322 yuiMilestone() <<
"No product in repository "
323 << zyppRepo.info().alias()
330 YQPkgRepoListItem::operator< (
const QTreeWidgetItem & other )
const
337 #include "YQPkgRepoList.moc"
static int countEnabledRepositories()
YQPkgRepoList(QWidget *parent)
YQPkgRepoListItem * selection() const
YQPkgRepoListItem(YQPkgRepoList *parentList, ZyppRepo repo)
void filterMatch(ZyppSel selectable, ZyppPkg pkg)
virtual ~YQPkgRepoListItem()
static ZyppProduct singleProduct(ZyppRepo repo)
Display a list of zypp::Selection objects.
ZyppRepo zyppRepo() const
void addRepo(ZyppRepo repo)