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" 65 : QY2ListView( parent )
67 yuiDebug() <<
"Creating repository list" << endl;
77 headers << _(
"Name"); _nameCol = numCol++;
80 setHeaderLabels( headers );
81 header()->setSectionResizeMode( _nameCol, QHeaderView::Stretch );
84 setSelectionMode( QAbstractItemView::ExtendedSelection );
86 connect(
this, SIGNAL( itemSelectionChanged() ),
88 setIconSize(QSize(32,32));
90 setSortingEnabled(
true );
91 sortByColumn( nameCol(), Qt::AscendingOrder );
94 yuiDebug() <<
"Creating repository list done" << endl;
108 yuiDebug() <<
"Filling repository list" << endl;
110 for ( ZyppRepositoryIterator it = ZyppRepositoriesBegin();
111 it != ZyppRepositoriesEnd();
117 yuiDebug() <<
"Inst repository filled" << endl;
124 return zyppPool().knownRepositoriesSize();
141 yuiMilestone() <<
"Collecting packages in selected repositories..." << endl;
150 QTreeWidgetItem * item;
152 QList<QTreeWidgetItem *> items = selectedItems();
153 QListIterator<QTreeWidgetItem *> it(items);
155 while ( it.hasNext() )
162 ZyppRepo currentRepo = repoItem->
zyppRepo();
164 zypp::PoolQuery query;
165 query.addRepo( currentRepo.info().alias() );
166 query.addKind(zypp::ResKind::package);
168 for( zypp::PoolQuery::Selectable_iterator it = query.selectableBegin();
169 it != query.selectableEnd(); it++)
171 emit
filterMatch( *it, tryCastToZyppPkg( (*it)->theObj() ) );
176 yuiDebug() <<
"Packages sent to package list. Elapsed time: " 177 << stopWatch.elapsed() / 1000.0 <<
" sec" 194 QTreeWidgetItem * item = currentItem();
205 : QY2ListViewItem( repoList )
206 , _repoList( repoList )
209 if ( nameCol() >= 0 )
211 string name = repo.info().name();
212 if ( ! name.empty() )
214 setText( nameCol(), fromUTF8( name ));
218 std::string infoToolTip;
219 infoToolTip += (
"<b>" + repo.info().name() +
"</b>");
224 infoToolTip += (
"<p>" + product->summary() +
"</p>");
227 if ( ! repo.info().baseUrlsEmpty() )
229 zypp::RepoInfo::urls_const_iterator it;
230 infoToolTip +=
"<ul>";
232 for ( it = repo.info().baseUrlsBegin();
233 it != repo.info().baseUrlsEnd();
236 infoToolTip += (
"<li>" + (*it).asString() +
"</li>");
238 infoToolTip +=
"</ul>";
240 setToolTip( nameCol(), fromUTF8(infoToolTip) );
243 QString iconName =
"yast-sw_source";
245 if ( ! repo.info().baseUrlsEmpty() )
247 zypp::Url repoUrl = *repo.info().baseUrlsBegin();
251 setText( urlCol(), repoUrl.asString().c_str() );
254 if (QString(repoUrl.asString().c_str()).contains(
"KDE") )
255 iconName =
"pattern-kde";
256 if (QString(repoUrl.asString().c_str()).contains(
"GNOME") )
257 iconName =
"pattern-gnome";
258 if (QString(repoUrl.asString().c_str()).contains(
"update") )
259 iconName =
"yast-update";
260 if (QString(repoUrl.asString().c_str()).contains(
"home:") )
261 iconName =
"yast-users";
264 if ( repo.isSystemRepo() )
265 iconName =
"yast-host";
267 if ( QIcon::hasThemeIcon(iconName) )
269 setIcon( 0, QIcon::fromTheme(iconName) );
272 setIcon( 0, QIcon( iconPath.sprintf(
"/usr/share/icons/hicolor/48x48/apps/%s.png", iconName.toUtf8().data()) ));
288 return item.resolvable()->repoInfo().alias() ==
zyppRepo.info().alias();
293 YQPkgRepoListItem::operator< (
const QTreeWidgetItem & other )
const 300 #include "YQPkgRepoList.moc" 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.