41 #define YUILogComponent "ncurses-pkg"
44 #include "NCPkgFilterRepo.h"
47 #include "NCLayoutBox.h"
48 #include "NCSpacing.h"
49 #include "NCPackageSelector.h"
69 : YTableCell(std::string(
" "))
84 NCPkgRepoTable::NCPkgRepoTable( YWidget *parent, YTableHeader *tableHeader,
NCPackageSelector *pkg )
85 :NCTable( parent, tableHeader )
101 void NCPkgRepoTable::fillHeader()
103 std::vector <std::string> header;
106 header.push_back(
"L" );
107 header.push_back(
"L" + NCPkgStrings::PkgName() );
124 YTableItem *tabItem =
new YTableItem();
130 for (
unsigned i = 1; i < cols.size() + 1; ++i ) {
131 tabItem->addCell( cols[ i-1 ]);
153 NCTableLine *line = myPad()->ModifyLine( index );
159 YTableItem *it =
dynamic_cast<YTableItem*
> (line->origItem() );
162 YTableCell *tcell = it->cell(0);
191 std::string NCPkgRepoTable::showDescription( ZyppRepo r)
193 std::string ret =
"";
195 if ( r.isSystemRepo())
196 ret = _(
"<b>@System</b>: local RPM database" );
199 std::string label = _(
"<b>Repository URL:</b>" );
201 if ( ! r.info().baseUrlsEmpty() )
202 srcUrl = *(r).info().baseUrlsBegin();
204 ret = label + srcUrl.asString();
221 yuiMilestone() <<
"Filling repository list" << endl;
223 std::vector <std::string> oneLine;
226 for ( ZyppRepositoryIterator it = ZyppRepositoriesBegin();
227 it != ZyppRepositoriesEnd();
239 std::string name = (*it).info().name();
241 oneLine.push_back( name );
248 bool NCPkgRepoTable::showRepoPackages( )
250 int index = getCurrentItem();
251 ZyppRepo repo =
getRepo( index );
253 yuiMilestone() <<
"Selected repository " << repo.info().alias().c_str() << endl;
254 yuiMilestone() <<
"Collecting packages in selected repository" << endl;
256 NCPkgTable *pkgList = packager->PackageList();
261 q.addRepo( repo.info().alias() );
262 q.addKind( zypp::ResKind::package );
264 for( zypp::PoolQuery::Selectable_iterator it = q.selectableBegin();
265 it != q.selectableEnd(); it++)
267 ZyppPkg pkg = tryCastToZyppPkg( (*it)->theObj() );
271 packager->FilterDescription()->setText( showDescription( repo ) );
273 pkgList->setCurrentItem( 0 );
295 zypp::ResPool::byKind_iterator beg = zypp::ResPool::instance().byKindBegin( zypp::ResKind::product);
296 zypp::ResPool::byKind_iterator end = zypp::ResPool::instance().byKindEnd( zypp::ResKind::product);
298 while( beg != end && !product )
301 if ( beg->resolvable()->repoInfo().alias() == repo.info().alias() )
302 product = zypp::asKind<zypp::Product>( beg->resolvable() );
308 if ( beg->resolvable()->repoInfo().alias() == repo.info().alias() )
311 yuiWarning() <<
"Multiple products in repository " <<
312 repo.info().alias().c_str() << endl;
323 yuiMilestone() <<
"No product in repository " <<
324 repo.info().alias().c_str() << endl;
339 NCursesEvent NCPkgRepoTable::wHandleInput( wint_t ch )
341 NCursesEvent ret = NCursesEvent::none;
352 ret = NCursesEvent::handled;
358 ret = NCTable::wHandleInput( ch ) ;
bool showInformation()
Show the corresponding information (e.g.
ZyppProduct findProductForRepo(ZyppRepo repo)
Find single zypp::Product for this repository (null product if multiple products found) ...
ZyppRepo getRepo(int index)
Get repository reference from selected line's tag.
NCPkgRepoTag * getTag(const int &index)
Get tag of repository table line on current index, ( contains repository reference) ...
bool createListEntry(ZyppPkg pkgPtr, ZyppSel slbPtr)
Creates a line in the package table.
NCPkgRepoTag(ZyppRepo repo)
A helper class to hold a reference to zypp::Repository for each repository table line (actually it's ...
bool fillRepoList()
Add items to the repository list (assoc.
virtual void itemsCleared()
Clears the package list.
virtual void addLine(ZyppRepo r, const std::vector< std::string > &cols)
Add one line (with tag) to the repositories table.
void drawList()
Draws the package list (has to be called after the loop with addLine() calls)