Author: kmachalkova Date: Thu Apr 24 18:19:09 2008 New Revision: 47041 URL: http://svn.opensuse.org/viewcvs/yast?rev=47041&view=rev Log: new class, renamed class Added: trunk/ncurses-pkg/src/NCPkgFilterLocale.cc trunk/ncurses-pkg/src/NCPkgFilterLocale.h trunk/ncurses-pkg/src/NCPkgFilterPattern.cc - copied, changed from r47021, trunk/ncurses-pkg/src/NCPkgFilterContainer.cc trunk/ncurses-pkg/src/NCPkgFilterPattern.h - copied, changed from r47021, trunk/ncurses-pkg/src/NCPkgFilterContainer.h Modified: trunk/ncurses-pkg/src/Makefile.am Modified: trunk/ncurses-pkg/src/Makefile.am URL: http://svn.opensuse.org/viewcvs/yast/trunk/ncurses-pkg/src/Makefile.am?rev=4... ============================================================================== --- trunk/ncurses-pkg/src/Makefile.am (original) +++ trunk/ncurses-pkg/src/Makefile.am Thu Apr 24 18:19:09 2008 @@ -36,7 +36,8 @@ NCPkgFilterRepo.h \ NCPkgFilterSearch.h \ NCPkgSearchSettings.h \ - NCPkgFilterContainer.h \ + NCPkgFilterPattern.h \ + NCPkgFilterLocale.h \ NCPkgFilterRPMGroups.h \ NCPkgStrings.h \ NCZypp.h @@ -64,7 +65,8 @@ NCPkgFilterRepo.cc \ NCPkgFilterSearch.cc \ NCPkgSearchSettings.cc \ - NCPkgFilterContainer.cc \ + NCPkgFilterPattern.cc \ + NCPkgFilterLocale.cc \ NCPkgFilterRPMGroups.cc \ NCPkgStrings.cc Added: trunk/ncurses-pkg/src/NCPkgFilterLocale.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/ncurses-pkg/src/NCPkgFilterLocale... ============================================================================== --- trunk/ncurses-pkg/src/NCPkgFilterLocale.cc (added) +++ trunk/ncurses-pkg/src/NCPkgFilterLocale.cc Thu Apr 24 18:19:09 2008 @@ -0,0 +1,152 @@ +/*---------------------------------------------------------------------\ +| | +| __ __ ____ _____ ____ | +| \ \ / /_ _/ ___|_ _|___ \ | +| \ V / _` ___ \ | | __) | | +| | | (_| |___) || | / __/ | +| |_|__,_|____/ |_| |_____| | +| | +| core system | +| (C) SuSE GmbH | +----------------------------------------------------------------------/ + + File: NCPkgFilterLocale.cc + + Author: Bubli <kmachalkova@suse.cz> + +/-*/ +#define YUILogComponent "ncurses-pkg" +#include <YUILog.h> + +#include "NCPkgFilterLocale.h" + +NCPkgLocaleTag::NCPkgLocaleTag ( zypp::sat::LocaleSupport loc) + : YTableCell(string(" ")) + , locale ( loc ) +{ + +} + +NCPkgLocaleTable::NCPkgLocaleTable( YWidget *parent, YTableHeader *tableHeader, NCPackageSelector *pkg ) + :NCTable( parent, tableHeader ) + ,packager(pkg) +{ + fillHeader(); + fillLocaleList(); +} + +void NCPkgLocaleTable::fillHeader() +{ + vector <string> header; + + header.reserve(4); + header.push_back( "L" + NCPkgStrings::PkgStatus() ); + header.push_back( "L" + NCPkgStrings::LangCode() ); + header.push_back( "L" + NCPkgStrings::LangName() ); + + setHeader( header); +} + +void NCPkgLocaleTable::addLine ( zypp::sat::LocaleSupport l, const vector <string> & cols ) +{ + //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 ) ); + + // and append the rest (name, URL and stuff) + for ( unsigned i = 1; i < cols.size() + 1; ++i ) { + tabItem->addCell( cols[ i-1 ]); + } + + // this is NCTable::addItem( tabItem ); + //it actually appends the line to the table + addItem( tabItem ); + +} + +void NCPkgLocaleTable::fillLocaleList() +{ + vector <string> oneLine; + + const zypp::LocaleSet & available_locales( zypp::ResPool::instance().getAvailableLocales() ); + for_( it, available_locales.begin(), available_locales.end() ) + { + oneLine.clear(); + zypp::sat::LocaleSupport myLocale( *it ); + oneLine.push_back( myLocale.locale().code() ); + oneLine.push_back( myLocale.locale().name() ); + addLine( myLocale, oneLine); + } +} + +NCPkgLocaleTag* NCPkgLocaleTable::getTag (const int & index ) +{ + NCTableLine *line = myPad()->ModifyLine( index ); + if ( !line ) + { + return 0; + } + + YTableItem *it = dynamic_cast<YTableItem*> (line->origItem() ); + + YTableCell *tcell = it->cell(0); + NCPkgLocaleTag *tag = static_cast<NCPkgLocaleTag *>( tcell ); + + return tag; +} + +zypp::sat::LocaleSupport NCPkgLocaleTable::getLocale( int index ) +{ + NCPkgLocaleTag *t = getTag( index ); + + return t->getLocale(); +} + +void NCPkgLocaleTable::showLocalePackages() +{ + int index = getCurrentItem(); + zypp::sat::LocaleSupport myLocale = getLocale( index ); + + NCPkgTable * packageList = packager->PackageList(); + packageList->itemsCleared(); + + yuiMilestone() << "Packages supporting locale '" << myLocale.locale() << "':" << endl; + for_( it, myLocale.selectableBegin(), myLocale.selectableEnd() ) + { + //yuiMilestone() << (*it).name() << endl;i + ZyppPkg zyppPkg = tryCastToZyppPkg( (*it)->theObj() ); + packageList->createListEntry( zyppPkg, *it ); + } + + packageList->setCurrentItem( 0 ); + packageList->drawList(); + packageList->showInformation(); +} + +NCursesEvent NCPkgLocaleTable::wHandleInput( wint_t ch ) +{ + NCursesEvent ret = NCursesEvent::none; + handleInput( ch ); + + switch ( ch ) + { + case KEY_UP: + case KEY_DOWN: + case KEY_NPAGE: + case KEY_PPAGE: + case KEY_END: + case KEY_HOME: { + ret = NCursesEvent::handled; + showLocalePackages(); + break; + } + + default: + ret = NCTable::wHandleInput( ch ) ; + } + + return ret; +} + Added: trunk/ncurses-pkg/src/NCPkgFilterLocale.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/ncurses-pkg/src/NCPkgFilterLocale... ============================================================================== --- trunk/ncurses-pkg/src/NCPkgFilterLocale.h (added) +++ trunk/ncurses-pkg/src/NCPkgFilterLocale.h Thu Apr 24 18:19:09 2008 @@ -0,0 +1,69 @@ +/*---------------------------------------------------------------------\ +| | +| __ __ ____ _____ ____ | +| \ \ / /_ _/ ___|_ _|___ \ | +| \ V / _` ___ \ | | __) | | +| | | (_| |___) || | / __/ | +| |_|__,_|____/ |_| |_____| | +| | +| core system | +| (C) SuSE GmbH | +----------------------------------------------------------------------/ + + File: NCPkgPopupRepo.h + + Author: Bubli <kmachalkova@suse.cz> + +/-*/ + +#ifndef NCPkgFilterLocale_h +#define NCPkgFilterLocale_h + +#include <vector> +#include "NCTable.h" +#include "NCPackageSelector.h" +#include "NCZypp.h" +#include <zypp/sat/LocaleSupport.h> + +class NCPkgLocaleTag : public YTableCell +{ + +private: + + zypp::sat::LocaleSupport locale; + +public: + + NCPkgLocaleTag ( zypp::sat::LocaleSupport locale); + + ~NCPkgLocaleTag() { }; + + zypp::sat::LocaleSupport getLocale() const { return locale; } + +}; + +class NCPkgLocaleTable : public NCTable +{ +private: + + NCPkgLocaleTable & operator=( const NCPkgLocaleTable & ); + NCPkgLocaleTable ( const NCPkgLocaleTable & ); + + NCPackageSelector *packager; +public: + + NCPkgLocaleTable ( YWidget *parent, YTableHeader *tableHeader, NCPackageSelector *pkg); + + virtual ~NCPkgLocaleTable() {}; + + void fillHeader(); + void addLine ( zypp::sat::LocaleSupport, const vector <string> & cols ); + void fillLocaleList(); + void showLocalePackages(); + + NCPkgLocaleTag* getTag (const int & index ); + zypp::sat::LocaleSupport getLocale( int index ); + NCursesEvent wHandleInput( wint_t ch ); +}; + +#endif Copied: trunk/ncurses-pkg/src/NCPkgFilterPattern.cc (from r47021, trunk/ncurses-pkg/src/NCPkgFilterContainer.cc) URL: http://svn.opensuse.org/viewcvs/yast/trunk/ncurses-pkg/src/NCPkgFilterPatter... ============================================================================== --- trunk/ncurses-pkg/src/NCPkgFilterContainer.cc (original) +++ trunk/ncurses-pkg/src/NCPkgFilterPattern.cc Thu Apr 24 18:19:09 2008 @@ -10,7 +10,7 @@ | (C) SuSE GmbH | ----------------------------------------------------------------------/ - File: NCPkgFilterContainer.cc + File: NCPkgFilterPattern.cc Author: Gabriele Strattner <gs@suse.de> Maintainer: Michael Andres <ma@suse.de> @@ -19,7 +19,7 @@ #define YUILogComponent "ncurses-pkg" #include <YUILog.h> -#include "NCPkgFilterContainer.h" +#include "NCPkgFilterPattern.h" #include "YDialog.h" #include "NCLayoutBox.h" @@ -28,6 +28,7 @@ #include "NCPkgTable.h" #include "NCPkgStatusStrategy.h" #include <zypp/ui/PatternContents.h> +#include <zypp/sat/LocaleSupport.h> #include "NCZypp.h" #include "NCi18n.h" @@ -45,12 +46,12 @@ /////////////////////////////////////////////////////////////////// // // -// METHOD NAME : NCPkgFilterContainer::NCPkgFilterContainer +// METHOD NAME : NCPkgFilterPattern::NCPkgFilterPattern // METHOD TYPE : Constructor // // DESCRIPTION : // -NCPkgFilterContainer::NCPkgFilterContainer( YWidget *parent, YTableHeader *header, NCPackageSelector * pkg, SelType type ) +NCPkgFilterPattern::NCPkgFilterPattern( YWidget *parent, YTableHeader *header, NCPackageSelector * pkg, SelType type ) : NCPkgTable( parent, header ) , packager( pkg ) , type( type ) @@ -76,12 +77,12 @@ /////////////////////////////////////////////////////////////////// // // -// METHOD NAME : NCPkgFilterContainer::~NCPkgFilterContainer +// METHOD NAME : NCPkgFilterPattern::~NCPkgFilterPattern // METHOD TYPE : Destructor // // DESCRIPTION : // -NCPkgFilterContainer::~NCPkgFilterContainer() +NCPkgFilterPattern::~NCPkgFilterPattern() { } @@ -89,12 +90,12 @@ /////////////////////////////////////////////////////////////////// // // -// METHOD NAME : NCPkgFilterContainer::createLayout +// METHOD NAME : NCPkgFilterPattern::createLayout // METHOD TYPE : void // // DESCRIPTION : // -void NCPkgFilterContainer::createLayout( YWidget *parent, const string & label ) +void NCPkgFilterPattern::createLayout( YWidget *parent, const string & label ) { YTableHeader * tableHeader = new YTableHeader(); @@ -127,7 +128,7 @@ // NCursesEvent & showSelectionPopup () // // -void NCPkgFilterContainer::showContainerPackages( ) +void NCPkgFilterPattern::showContainerPackages( ) { int index = getCurrentItem(); ZyppObj objPtr = getDataPointer( index ); @@ -225,7 +226,7 @@ // returns the currently selected list item (may be "really" selected // or not) // -string NCPkgFilterContainer::getCurrentLine( ) +string NCPkgFilterPattern::getCurrentLine( ) { //if ( !sel ) // return ""; @@ -236,7 +237,7 @@ return ( selPtr?selPtr->summary(LOCALE):"" ); } -string NCPkgFilterContainer::showDescription( ZyppObj objPtr ) +string NCPkgFilterPattern::showDescription( ZyppObj objPtr ) { switch (type) { @@ -265,7 +266,7 @@ // // DESCRIPTION : // -NCursesEvent NCPkgFilterContainer::wHandleInput( wint_t ch ) +NCursesEvent NCPkgFilterPattern::wHandleInput( wint_t ch ) { NCursesEvent ret = NCursesEvent::none; @@ -326,12 +327,12 @@ /////////////////////////////////////////////////////////////////// // // -// METHOD NAME : NCPkgFilterContainer::fillContainerList +// METHOD NAME : NCPkgFilterPattern::fillContainerList // METHOD TYPE : bool // // DESCRIPTION : // -bool NCPkgFilterContainer::fillContainerList( SelType type ) +bool NCPkgFilterPattern::fillContainerList( SelType type ) { // if ( !sel ) // return false; @@ -356,30 +357,23 @@ yuiMilestone() << resPtr->kind () <<": " << resPtr->name() << ", initial status: " << (*i)->status() << endl; +// pkgLine.push_back( resPtr->summary(LOCALE) ); // the description slbList.push_back (*i); } } slbList.sort( orderPattern ); break; } - #if 0 case S_Language: { - for (i = zyppLangBegin (); i != zyppLangEnd (); ++i ) - { - ZyppObj resPtr = (*i)->theObj(); - - ZyppLang langPtr = tryCastToZyppLang (resPtr); - - yuiMilestone() << resPtr->kind () <<": " << resPtr->name() - << ", initial status: " << (*i)->status() << endl; - slbList.push_back (*i); - - } - slbList.sort( orderLang ); + const zypp::LocaleSet & available_locales( zypp::ResPool::instance().getAvailableLocales() ); + for_( it, available_locales.begin(), available_locales.end() ) + { + zypp::sat::LocaleSupport myLocale( *it ); + yuiMilestone() << myLocale.locale().name() << " " << myLocale.locale().code() << endl; + } break; } - #endif default: yuiError() << "Container type not handled: " << type << endl; } Copied: trunk/ncurses-pkg/src/NCPkgFilterPattern.h (from r47021, trunk/ncurses-pkg/src/NCPkgFilterContainer.h) URL: http://svn.opensuse.org/viewcvs/yast/trunk/ncurses-pkg/src/NCPkgFilterPatter... ============================================================================== --- trunk/ncurses-pkg/src/NCPkgFilterContainer.h (original) +++ trunk/ncurses-pkg/src/NCPkgFilterPattern.h Thu Apr 24 18:19:09 2008 @@ -10,14 +10,14 @@ | (C) SuSE GmbH | ----------------------------------------------------------------------/ - File: NCPkgFilterContainer.h + File: NCPkgFilterPattern.h Author: Gabriele Strattner <gs@suse.de> Maintainer: Michael Andres <ma@suse.de> /-*/ -#ifndef NCPkgFilterContainer_h -#define NCPkgFilterContainer_h +#ifndef NCPkgFilterPattern_h +#define NCPkgFilterPattern_h #include <iosfwd> @@ -31,14 +31,14 @@ /////////////////////////////////////////////////////////////////// // -// CLASS NAME : NCPkgFilterContainer +// CLASS NAME : NCPkgFilterPattern // // DESCRIPTION : // -class NCPkgFilterContainer : public NCPkgTable { +class NCPkgFilterPattern : public NCPkgTable { - NCPkgFilterContainer & operator=( const NCPkgFilterContainer & ); - NCPkgFilterContainer ( const NCPkgFilterContainer & ); + NCPkgFilterPattern & operator=( const NCPkgFilterPattern & ); + NCPkgFilterPattern ( const NCPkgFilterPattern & ); private: @@ -58,8 +58,8 @@ S_Unknown }; - NCPkgFilterContainer( YWidget *parent, YTableHeader *header, NCPackageSelector * pkg, SelType type ); - virtual ~NCPkgFilterContainer(); + NCPkgFilterPattern( YWidget *parent, YTableHeader *header, NCPackageSelector * pkg, SelType type ); + virtual ~NCPkgFilterPattern(); void createLayout( YWidget *parent, const string & label ); @@ -85,4 +85,4 @@ /////////////////////////////////////////////////////////////////// -#endif // NCPkgFilterContainer_h +#endif // NCPkgFilterPattern_h -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org