41 #define YUILogComponent "ncurses-pkg" 44 #include <boost/format.hpp> 46 #include "NCPkgFilterLocale.h" 54 NCPkgLocaleTag::NCPkgLocaleTag ( zypp::sat::LocaleSupport loc, std::string status )
55 : YTableCell( status )
62 NCPkgLocaleTable::NCPkgLocaleTable( YWidget *parent, YTableHeader *tableHeader,
NCPackageSelector *pkg )
63 :NCTable( parent, tableHeader )
71 void NCPkgLocaleTable::fillHeader()
73 std::vector <std::string> header;
76 header.push_back(
"L" + NCPkgStrings::PkgStatus() );
77 header.push_back(
"L" + NCPkgStrings::LangCode() );
78 header.push_back(
"L" + NCPkgStrings::LangName() );
84 void NCPkgLocaleTable::addLine ( zypp::sat::LocaleSupport l,
const std::vector <std::string> & cols, std::string status )
87 YTableItem *tabItem =
new YTableItem();
93 for (
const std::string& s: cols )
103 std::string NCPkgLocaleTable::status( zypp::Locale lang )
107 if ( zypp::getZYpp()->pool().isRequestedLocale( lang ) )
125 void NCPkgLocaleTable::fillLocaleList()
127 std::vector <std::string> oneLine;
129 const zypp::LocaleSet & available_locales( zypp::ResPool::instance().getAvailableLocales() );
130 for_( it, available_locales.begin(), available_locales.end() )
133 zypp::sat::LocaleSupport myLocale( *it );
134 oneLine.push_back( myLocale.locale().code() );
135 oneLine.push_back( myLocale.locale().name() );
136 addLine( myLocale, oneLine, status(*it) );
139 myPad()->setOrder(1);
145 NCTableLine *line = myPad()->ModifyLine( index );
151 YTableItem *it =
dynamic_cast<YTableItem*
> (line->origItem() );
153 YTableCell *tcell = it->cell(0);
160 zypp::sat::LocaleSupport NCPkgLocaleTable::getLocale(
int index )
164 return t->getLocale();
168 void NCPkgLocaleTable::showLocalePackages()
170 int index = getCurrentItem();
171 zypp::sat::LocaleSupport myLocale = getLocale( index );
173 NCPkgTable * packageList = packager->PackageList();
176 yuiMilestone() <<
"Packages supporting locale '" << myLocale.locale() <<
"':" << endl;
177 for_( it, myLocale.selectableBegin(), myLocale.selectableEnd() )
179 ZyppPkg zyppPkg = tryCastToZyppPkg( (*it)->theObj() );
183 std::ostringstream s;
185 s << boost::format( _(
"Translations, dictionaries and other language-related files for <b>%s</b> locale" )) % myLocale.locale().code();
186 packager->FilterDescription()->setText( s.str() );
188 packageList->setCurrentItem( 0 );
194 void NCPkgLocaleTable::cycleStatus()
196 int index = getCurrentItem();
197 zypp::sat::LocaleSupport myLocale = getLocale( index );
199 NCTableLine *line = myPad()->ModifyLine( index );
204 yuiMilestone() <<
"Toggle status of: " << myLocale.locale().code() << endl;
206 if ( zypp::getZYpp()->pool().isRequestedLocale( myLocale.locale() ) )
208 zypp::getZYpp()->pool().eraseRequestedLocale( myLocale.locale() );
212 zypp::getZYpp()->pool().addRequestedLocale( myLocale.locale() );
216 cellChanged( index, 0, status( myLocale.locale() ) );
220 NCursesEvent NCPkgLocaleTable::wHandleInput( wint_t ch )
222 NCursesEvent ret = NCursesEvent::none;
233 ret = NCursesEvent::handled;
234 showLocalePackages();
239 ret = NCursesEvent::handled;
241 showLocalePackages();
245 ret = NCTable::wHandleInput( ch );
bool showInformation()
Show the corresponding information (e.g.
bool createListEntry(ZyppPkg pkgPtr, ZyppSel slbPtr)
Creates a line in the package table.
virtual void itemsCleared()
Clears the package list.
void drawList()
Draws the package list (has to be called after the loop with addLine() calls)
bool showPackageDependencies(bool doit)
Checks and shows the dependencies.