Author: gs Date: Wed Apr 16 13:12:15 2008 New Revision: 46712 URL: http://svn.opensuse.org/viewcvs/yast?rev=46712&view=rev Log: Filter menu Online Update Added: trunk/ncurses-pkg/src/NCPkgMenuFilter.cc trunk/ncurses-pkg/src/NCPkgMenuFilter.h Added: trunk/ncurses-pkg/src/NCPkgMenuFilter.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/ncurses-pkg/src/NCPkgMenuFilter.c... ============================================================================== --- trunk/ncurses-pkg/src/NCPkgMenuFilter.cc (added) +++ trunk/ncurses-pkg/src/NCPkgMenuFilter.cc Wed Apr 16 13:12:15 2008 @@ -0,0 +1,120 @@ +/*---------------------------------------------------------------------\ +| | +| __ __ ____ _____ ____ | +| \ \ / /_ _/ ___|_ _|___ \ | +| \ V / _` ___ \ | | __) | | +| | | (_| |___) || | / __/ | +| |_|__,_|____/ |_| |_____| | +| | core system | +| (C) SuSE GmbH | +----------------------------------------------------------------------/ + + File: NCPkgMenuFilter.cc + + Author: Gabriele Mohr <gs@suse.de> + +/-*/ +#define YUILogComponent "ncurses-pkg" +#include <YUILog.h> + +#include "NCPkgMenuFilter.h" +#include "NCPkgPatchSearch.h" + +/* + Textdomain "ncurses-pkg" +*/ + +NCPkgMenuFilter::NCPkgMenuFilter (YWidget *parent, string label, NCPackageSelector *pkger) + : NCMenuButton( parent, label) + ,pkg (pkger) +{ + createLayout(); +} + +NCPkgMenuFilter::~NCPkgMenuFilter() +{ + +} + +void NCPkgMenuFilter::createLayout() +{ + // menu items of the filter menu for patches - keep them short + // begin: + installable = new YMenuItem( _( "Installable Patches" ) ); + installed = new YMenuItem( _( "Installed Patches" ) ); + allPatches = new YMenuItem( _( "All Patches" ) ); + recommended = new YMenuItem( _( "Recommended" ) ); + security = new YMenuItem( _( "Security" ) ); + optional = new YMenuItem( _( "Optional" ) ); + // end: + search = new YMenuItem( _( "Search" ) ); + + items.push_back( installable ); + items.push_back( installed ); + items.push_back( allPatches ); + items.push_back( recommended ); + items.push_back( security ); + items.push_back( optional ); + items.push_back( search ); + + addItems( items ); +} + + +bool NCPkgMenuFilter::handleEvent ( const NCursesEvent & event) +{ + if ( !event.selection) + return false; + + NCPkgTable *pkgList = pkg->PackageList(); + int idx = pkgList->getCurrentItem(); + + ZyppObj pkgPtr = pkgList->getDataPointer( idx ); + ZyppSel slbPtr = pkgList->getSelPointer( idx ); + + if ( !pkgPtr || !slbPtr) + { + yuiError() << "package list empty - no package pointer" << endl; + return true; + } + + // Call the appropriate method from NCPackageSelector for + // the selected menu entry. + + if ( event.selection == installable ) + pkg->fillPatchList( "installable" ); // show installed patches + else if ( event.selection == installed ) + pkg->fillPatchList( "installed" ); // show installed patches + else if ( event.selection == allPatches ) + pkg->fillPatchList( "all" ); // show all patches + else if ( event.selection == recommended ) + pkg->fillPatchList( "recommended" ); // patch kind recommended + else if ( event.selection == security ) + pkg->fillPatchList( "security" ); // patch kind security + else if ( event.selection == optional ) + pkg->fillPatchList( "optional" ); // patch kind optional + else if ( event.selection == search ) + { + searchPopup = new NCPkgPatchSearch( wpos( 1, 1 ), pkg ); + + if ( searchPopup ) + { + NCursesEvent retEvent = searchPopup->showSearchPopup(); + + if ( retEvent == NCursesEvent::button ) + { + yuiMilestone() << "Searching for: " << retEvent.result << endl; + pkgList->showInformation( ); + } + else + { + yuiMilestone() << "Search is canceled" << endl; + } + } + } + + pkgList->setKeyboardFocus(); + + + return true; +} Added: trunk/ncurses-pkg/src/NCPkgMenuFilter.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/ncurses-pkg/src/NCPkgMenuFilter.h... ============================================================================== --- trunk/ncurses-pkg/src/NCPkgMenuFilter.h (added) +++ trunk/ncurses-pkg/src/NCPkgMenuFilter.h Wed Apr 16 13:12:15 2008 @@ -0,0 +1,64 @@ +/*---------------------------------------------------------------------\ +| | +| __ __ ____ _____ ____ | +| \ \ / /_ _/ ___|_ _|___ \ | +| \ V / _` ___ \ | | __) | | +| | | (_| |___) || | / __/ | +| |_|__,_|____/ |_| |_____| | +| | +| core system | +| (C) SuSE GmbH | +----------------------------------------------------------------------/ + + File: NCPkgMenuFilter.cc + + Author: Gabriele MOhr <gs@suse.de> + +/-*/ +#ifndef NCPkgMenuFilter_h +#define NCPkgMenuFilter_h + +#include <string> + +#include <YReplacePoint.h> +#include <YWidget.h> +#include "NCurses.h" +#include "NCi18n.h" +#include "NCMenuButton.h" +#include "NCPackageSelector.h" +#include "NCPkgPatchSearch.h" + +#include "NCZypp.h" + +class NCPkgMenuFilter : public NCMenuButton { + + NCPkgMenuFilter & operator=( const NCPkgMenuFilter & ); + NCPkgMenuFilter ( const NCPkgMenuFilter & ); + +private: + NCPackageSelector *pkg; + + NCPkgPatchSearch *searchPopup; + +public: + + YItemCollection items; + + YMenuItem *installable; + YMenuItem *installed; + YMenuItem *allPatches; + YMenuItem *recommended; + YMenuItem *security; + YMenuItem *optional; + YMenuItem *search; + + NCPkgMenuFilter (YWidget *parent, string label, NCPackageSelector *pkger); + virtual ~NCPkgMenuFilter(); + + void createLayout(); + + bool handleEvent (const NCursesEvent & event); + +}; + +#endif -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org