24 #define YUILogComponent "ncurses-pkg" 27 #include <zypp/ServiceInfo.h> 28 #include <boost/algorithm/string.hpp> 30 #include "NCPkgFilterService.h" 33 #include "NCLayoutBox.h" 34 #include "NCSpacing.h" 35 #include "NCPackageSelector.h" 55 : YTableCell(
std::string(
" "))
56 , service (servicePtr)
70 NCPkgServiceTable::NCPkgServiceTable( YWidget *parent, YTableHeader *tableHeader,
NCPackageSelector *pkg )
71 :NCTable( parent, tableHeader )
73 , repo_manager(new zypp::RepoManager())
81 bool ret = std::any_of(ZyppRepositoriesBegin(), ZyppRepositoriesEnd(), [](
const zypp::Repository& repo) {
83 return !repo.info().service().empty();
86 yuiMilestone() <<
"Found a libzypp service: " << ret << endl;
99 void NCPkgServiceTable::fillHeader()
101 std::vector <std::string> header;
104 header.push_back(
"L" );
105 header.push_back(
"L" + NCPkgStrings::PkgName() );
122 YTableItem *tabItem =
new YTableItem();
128 for (
const std::string& s: cols )
148 NCTableLine *line = myPad()->ModifyLine( index );
154 YTableItem *it = line->origItem();
157 YTableCell *tcell = it->cell(0);
176 return t ? t->getService() : ZyppService();
179 static std::string html_escape(
const std::string& s)
181 std::string escaped = boost::replace_all_copy(s,
"&",
"&");
182 boost::replace_all(escaped,
"<",
"<");
183 boost::replace_all(escaped,
">",
">");
189 zypp::ServiceInfo si = repo_manager->getService(svc);
191 std::string label = _(
"<b>Service URL:</b>" );
192 std::string ret = label + html_escape(si.url().asString());
208 yuiMilestone() <<
"Filling service list" << endl;
210 std::set<std::string> seen_services;
212 std::for_each(ZyppRepositoriesBegin(), ZyppRepositoriesEnd(), [&](
const zypp::Repository& repo)
214 const std::string &service_name(repo.info().service());
215 if (!service_name.empty())
217 if (seen_services.find(service_name) == seen_services.end())
219 seen_services.insert(service_name);
221 std::vector <std::string> oneLine;
222 oneLine.push_back( service_name );
223 addLine( service_name, oneLine);
233 int index = getCurrentItem();
236 yuiMilestone() <<
"Selected service " << service << endl;
237 yuiMilestone() <<
"Collecting packages in selected service" << endl;
239 NCPkgTable *pkgList = packager->PackageList();
243 zypp::PoolQuery query;
244 query.addKind( zypp::ResKind::package );
246 std::for_each(ZyppRepositoriesBegin(), ZyppRepositoriesEnd(), [&](
const zypp::Repository& repo)
248 if (service == repo.info().service())
250 yuiMilestone() <<
"Adding repo filter: " << repo.info().alias() << endl;
251 query.addRepo( repo.info().alias() );
255 for ( zypp::PoolQuery::Selectable_iterator it = query.selectableBegin();
256 it != query.selectableEnd();
259 ZyppPkg pkg = tryCastToZyppPkg( (*it)->theObj() );
263 packager->FilterDescription()->setText(
getDescription( service ) );
265 pkgList->setCurrentItem( 0 );
279 NCursesEvent NCPkgServiceTable::wHandleInput( wint_t ch )
281 NCursesEvent ret = NCursesEvent::none;
292 ret = NCursesEvent::handled;
297 ret = NCTable::wHandleInput( ch );
bool showInformation()
Show the corresponding information (e.g.
NCPkgServiceTag(ZyppService service)
A helper class to hold a reference to zypp::Service for each service table line (actually it's a dumm...
NCPkgServiceTag * getTag(int index)
Get tag of service table line on current index, (contains service reference)
virtual void addLine(ZyppService r, const std::vector< std::string > &cols)
Add one line (with tag) to the services table.
std::string getDescription(ZyppService r)
static bool any_service()
bool createListEntry(ZyppPkg pkgPtr, ZyppSel slbPtr)
Creates a line in the package table.
bool fillServiceList()
Add items to the service list (assoc.
ZyppService getService(int index)
Get service reference from selected line's tag.
virtual void itemsCleared()
Clears the package list.
void showServicePackages()
Make the Package List show the packages for the currently selected service.
void drawList()
Draws the package list (has to be called after the loop with addLine() calls)