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 )
61 NCPkgLocaleTable::NCPkgLocaleTable( YWidget *parent, YTableHeader *tableHeader,
NCPackageSelector *pkg )
62 :NCTable( parent, tableHeader )
69 void NCPkgLocaleTable::fillHeader()
71 std::vector <std::string> header;
74 header.push_back(
"L" + NCPkgStrings::PkgStatus() );
75 header.push_back(
"L" + NCPkgStrings::LangCode() );
76 header.push_back(
"L" + NCPkgStrings::LangName() );
81 void NCPkgLocaleTable::addLine ( zypp::sat::LocaleSupport l,
const std::vector <std::string> & cols, std::string status )
84 YTableItem *tabItem =
new YTableItem();
90 for (
unsigned i = 1; i < cols.size() + 1; ++i ) {
91 tabItem->addCell( cols[ i-1 ]);
100 std::string NCPkgLocaleTable::status( zypp::Locale lang )
104 if ( zypp::getZYpp()->pool().isRequestedLocale( lang ) )
121 void NCPkgLocaleTable::fillLocaleList()
123 std::vector <std::string> oneLine;
125 const zypp::LocaleSet & available_locales( zypp::ResPool::instance().getAvailableLocales() );
126 for_( it, available_locales.begin(), available_locales.end() )
129 zypp::sat::LocaleSupport myLocale( *it );
130 oneLine.push_back( myLocale.locale().code() );
131 oneLine.push_back( myLocale.locale().name() );
132 addLine( myLocale, oneLine, status(*it) );
135 myPad()->setOrder(1);
140 NCTableLine *line = myPad()->ModifyLine( index );
146 YTableItem *it =
dynamic_cast<YTableItem*
> (line->origItem() );
148 YTableCell *tcell = it->cell(0);
154 zypp::sat::LocaleSupport NCPkgLocaleTable::getLocale(
int index )
158 return t->getLocale();
161 void NCPkgLocaleTable::showLocalePackages()
163 int index = getCurrentItem();
164 zypp::sat::LocaleSupport myLocale = getLocale( index );
166 NCPkgTable * packageList = packager->PackageList();
169 yuiMilestone() <<
"Packages supporting locale '" << myLocale.locale() <<
"':" << endl;
170 for_( it, myLocale.selectableBegin(), myLocale.selectableEnd() )
172 ZyppPkg zyppPkg = tryCastToZyppPkg( (*it)->theObj() );
176 std::ostringstream s;
178 s << boost::format( _(
"Translations, dictionaries and other language-related files for <b>%s</b> locale" )) % myLocale.locale().code();
179 packager->FilterDescription()->setText( s.str() );
181 packageList->setCurrentItem( 0 );
186 void NCPkgLocaleTable::toggleStatus()
188 int index = getCurrentItem();
189 zypp::sat::LocaleSupport myLocale = getLocale( index );
191 NCTableLine *line = myPad()->ModifyLine( index );
196 yuiMilestone() <<
"Toggle status of: " << myLocale.locale().code() << endl;
198 if ( zypp::getZYpp()->pool().isRequestedLocale( myLocale.locale() ) )
200 zypp::getZYpp()->pool().eraseRequestedLocale( myLocale.locale() );
204 zypp::getZYpp()->pool().addRequestedLocale( myLocale.locale() );
208 cellChanged( index, 0, status( myLocale.locale() ) );
211 NCursesEvent NCPkgLocaleTable::wHandleInput( wint_t ch )
213 NCursesEvent ret = NCursesEvent::none;
224 ret = NCursesEvent::handled;
225 showLocalePackages();
230 ret = NCursesEvent::handled;
232 showLocalePackages();
237 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.