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();
200 return dynamic_cast<YQPkgRepoListItem *> (item);
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
291 const YQPkgRepoListItem * otherItem = dynamic_cast<const YQPkgRepoListItem *>(&other);