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 << std::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) {
151 NCTableLine *line = myPad()->ModifyLine( index );
157 YTableItem *it = line->origItem();
160 YTableCell *tcell = it->cell(0);
179 return t ? t->getService() : ZyppService();
182 static std::string html_escape(
const std::string& s)
184 std::string escaped = boost::replace_all_copy(s,
"&",
"&");
185 boost::replace_all(escaped,
"<",
"<");
186 boost::replace_all(escaped,
">",
">");
192 zypp::ServiceInfo si = repo_manager->getService(svc);
194 std::string label = _(
"<b>Service URL:</b>" );
195 std::string ret = label + html_escape(si.url().asString());
211 yuiMilestone() <<
"Filling service list" << endl;
213 std::set<std::string> seen_services;
215 std::for_each(ZyppRepositoriesBegin(), ZyppRepositoriesEnd(), [&](
const zypp::Repository& repo)
217 const std::string &service_name(repo.info().service());
218 if (!service_name.empty())
220 if (seen_services.find(service_name) == seen_services.end())
222 seen_services.insert(service_name);
224 std::vector <std::string> oneLine;
225 oneLine.push_back( service_name );
226 addLine( service_name, oneLine);
236 int index = getCurrentItem();
239 yuiMilestone() <<
"Selected service " << service << endl;
240 yuiMilestone() <<
"Collecting packages in selected service" << endl;
242 NCPkgTable *pkgList = packager->PackageList();
246 zypp::PoolQuery query;
247 query.addKind( zypp::ResKind::package );
249 std::for_each(ZyppRepositoriesBegin(), ZyppRepositoriesEnd(), [&](
const zypp::Repository& repo)
251 if (service == repo.info().service())
253 yuiMilestone() <<
"Adding repo filter: " << repo.info().alias() << std::endl;
254 query.addRepo( repo.info().alias() );
258 for( zypp::PoolQuery::Selectable_iterator it = query.selectableBegin();
259 it != query.selectableEnd(); it++)
261 ZyppPkg pkg = tryCastToZyppPkg( (*it)->theObj() );
265 packager->FilterDescription()->setText(
getDescription( service ) );
267 pkgList->setCurrentItem( 0 );
281 NCursesEvent NCPkgServiceTable::wHandleInput( wint_t ch )
283 NCursesEvent ret = NCursesEvent::none;
294 ret = NCursesEvent::handled;
300 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)