[yast-commit] r47931 - in /trunk/ncurses-pkg/src: NCPkgFilterLocale.cc NCPkgFilterLocale.h
Author: gs Date: Thu May 29 10:11:47 2008 New Revision: 47931 URL: http://svn.opensuse.org/viewcvs/yast?rev=47931&view=rev Log: show and toggle status of language pattern Modified: trunk/ncurses-pkg/src/NCPkgFilterLocale.cc trunk/ncurses-pkg/src/NCPkgFilterLocale.h Modified: trunk/ncurses-pkg/src/NCPkgFilterLocale.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/ncurses-pkg/src/NCPkgFilterLocale.cc?rev=47931&r1=47930&r2=47931&view=diff ============================================================================== --- trunk/ncurses-pkg/src/NCPkgFilterLocale.cc (original) +++ trunk/ncurses-pkg/src/NCPkgFilterLocale.cc Thu May 29 10:11:47 2008 @@ -20,8 +20,8 @@ #include "NCPkgFilterLocale.h" -NCPkgLocaleTag::NCPkgLocaleTag ( zypp::sat::LocaleSupport loc) - : YTableCell(string(" ")) +NCPkgLocaleTag::NCPkgLocaleTag ( zypp::sat::LocaleSupport loc, string status ) + : YTableCell( status ) , locale ( loc ) { @@ -47,13 +47,13 @@ setHeader( header); } -void NCPkgLocaleTable::addLine ( zypp::sat::LocaleSupport l, const vector <string> & cols ) +void NCPkgLocaleTable::addLine ( zypp::sat::LocaleSupport l, const vector <string> & cols, string status ) { //use default ctor, add cell in the next step YTableItem *tabItem = new YTableItem(); //place tag (with repo reference) to the 0th column - tabItem->addCell( new NCPkgLocaleTag ( l ) ); + tabItem->addCell( new NCPkgLocaleTag ( l, status ) ); // and append the rest (name, URL and stuff) for ( unsigned i = 1; i < cols.size() + 1; ++i ) { @@ -66,6 +66,27 @@ } +string NCPkgLocaleTable::status( zypp::Locale lang ) +{ + ZyppStatus status; + + if ( zypp::getZYpp()->pool().isRequestedLocale( lang ) ) + status = S_Install; + else + status = S_NoInst; + + // convert ZyppStatus to string + switch ( status ) + { + case S_NoInst: + return " "; + case S_Install: + return " :-)"; + default: + return "####"; + } +} + void NCPkgLocaleTable::fillLocaleList() { vector <string> oneLine; @@ -77,7 +98,7 @@ zypp::sat::LocaleSupport myLocale( *it ); oneLine.push_back( myLocale.locale().code() ); oneLine.push_back( myLocale.locale().name() ); - addLine( myLocale, oneLine); + addLine( myLocale, oneLine, status(*it) ); } myPad()->setOrder(1); @@ -127,6 +148,31 @@ packageList->showInformation(); } +void NCPkgLocaleTable::toggleStatus() +{ + int index = getCurrentItem(); + zypp::sat::LocaleSupport myLocale = getLocale( index ); + NCPkgLocaleTag * t = getTag ( index ); + NCTableLine *line = myPad()->ModifyLine( index ); + + if ( !t || !line ) + return; + + yuiMilestone() << "Toggle status of: " << myLocale.locale().code() << endl; + + if ( zypp::getZYpp()->pool().isRequestedLocale( myLocale.locale() ) ) + { + zypp::getZYpp()->pool().eraseRequestedLocale( myLocale.locale() ); + } + else + { + zypp::getZYpp()->pool().addRequestedLocale( myLocale.locale() ); + } + packager->showPackageDependencies( true ); + + cellChanged( index, 0, status( myLocale.locale() ) ); +} + NCursesEvent NCPkgLocaleTable::wHandleInput( wint_t ch ) { NCursesEvent ret = NCursesEvent::none; @@ -144,10 +190,17 @@ showLocalePackages(); break; } - + case KEY_SPACE: + case KEY_RETURN: { + ret = NCursesEvent::handled; + toggleStatus(); + showLocalePackages(); + break; + } + default: - ret = NCTable::wHandleInput( ch ) ; - } + ret = NCTable::wHandleInput( ch ) ; + } return ret; } Modified: trunk/ncurses-pkg/src/NCPkgFilterLocale.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/ncurses-pkg/src/NCPkgFilterLocale.h?rev=47931&r1=47930&r2=47931&view=diff ============================================================================== --- trunk/ncurses-pkg/src/NCPkgFilterLocale.h (original) +++ trunk/ncurses-pkg/src/NCPkgFilterLocale.h Thu May 29 10:11:47 2008 @@ -34,7 +34,7 @@ public: - NCPkgLocaleTag ( zypp::sat::LocaleSupport locale); + NCPkgLocaleTag ( zypp::sat::LocaleSupport locale, string status ); ~NCPkgLocaleTag() { }; @@ -57,12 +57,14 @@ virtual ~NCPkgLocaleTable() {}; void fillHeader(); - void addLine ( zypp::sat::LocaleSupport, const vector <string> & cols ); + void addLine ( zypp::sat::LocaleSupport, const vector <string> & cols, string status ); void fillLocaleList(); void showLocalePackages(); NCPkgLocaleTag* getTag (const int & index ); zypp::sat::LocaleSupport getLocale( int index ); + string status( zypp::Locale lang ); + void toggleStatus(); NCursesEvent wHandleInput( wint_t ch ); }; -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
gs@svn.opensuse.org