libyui-ncurses-pkg  2.48.2
 All Classes Functions
NCPkgMenuFilter.cc
1 /****************************************************************************
2 |
3 | Copyright (c) [2002-2011] Novell, Inc.
4 | All Rights Reserved.
5 |
6 | This program is free software; you can redistribute it and/or
7 | modify it under the terms of version 2 of the GNU General Public License as
8 | published by the Free Software Foundation.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program; if not, contact Novell, Inc.
17 |
18 | To contact Novell about this file by physical or electronic mail,
19 | you may find current contact information at www.novell.com
20 |
21 |***************************************************************************/
22 
23 
24 /*---------------------------------------------------------------------\
25 | |
26 | __ __ ____ _____ ____ |
27 | \ \ / /_ _/ ___|_ _|___ \ |
28 | \ V / _` \___ \ | | __) | |
29 | | | (_| |___) || | / __/ |
30 | |_|\__,_|____/ |_| |_____| |
31 | |
32 | core system |
33 | (C) SuSE GmbH |
34 \----------------------------------------------------------------------/
35 
36  File: NCPkgMenuFilter.cc
37 
38  Author: Gabriele Mohr <gs@suse.de>
39 
40 /-*/
41 #define YUILogComponent "ncurses-pkg"
42 #include <YUILog.h>
43 
44 #include "NCPkgMenuFilter.h"
45 #include "NCPkgPatchSearch.h"
46 #include "NCPkgTable.h"
47 #include "NCPackageSelector.h"
48 
49 using std::endl;
50 
51 /*
52  Textdomain "ncurses-pkg"
53 */
54 
55 NCPkgMenuFilter::NCPkgMenuFilter (YWidget *parent, std::string label, NCPackageSelector *pkger)
56  : NCMenuButton( parent, label)
57  ,pkg (pkger)
58 {
59  createLayout();
60 }
61 
62 NCPkgMenuFilter::~NCPkgMenuFilter()
63 {
64 
65 }
66 
67 void NCPkgMenuFilter::createLayout()
68 {
69  // menu items of the filter menu for patches - keep them short
70  // and use unique hotkeys from begin: to end:
71  // begin:
72  needed = new YMenuItem( _( "&Needed Patches" ) );
73  // _( "Re&levant Patches" )
74  unneeded = new YMenuItem( _( "&Installed Patches" ) );
75  // _( "&Satisfied Patches" ) );
76  recommended = new YMenuItem( _( "&Recommended" ) );
77  security = new YMenuItem( _( "&Security" ) );
78  optional = new YMenuItem( _( "&Optional" ) );
79  allPatches = new YMenuItem( _( "&All Patches" ) );
80  // end:
81  search = new YMenuItem( _( "S&earch" ) );
82 
83  items.push_back( needed );
84  items.push_back( unneeded );
85  items.push_back( recommended );
86  items.push_back( security );
87  items.push_back( optional );
88  items.push_back( allPatches );
89  items.push_back( search );
90 
91  addItems( items );
92 }
93 
94 
95 bool NCPkgMenuFilter::handleEvent ( const NCursesEvent & event)
96 {
97  if ( !event.selection)
98  {
99  yuiError() << "Menu selection failed" << endl;
100  return false;
101  }
102 
103  NCPkgTable *pkgList = pkg->PackageList();
104 
105  if ( !pkgList )
106  {
107  yuiError() << "No package list available" << endl;
108  return false;
109  }
110 
111  yuiMilestone() << "Handle event NCPkgMenuFilter" << endl;
112 
113  // Call the appropriate method from NCPackageSelector for
114  // the selected menu entry.
115 
116  if ( event.selection == needed )
117  pkg->fillPatchList( F_Needed ); // show needed patches
118  else if ( event.selection == unneeded )
119  pkg->fillPatchList( F_Unneeded ); // show unneeded patches
120  else if ( event.selection == allPatches )
121  pkg->fillPatchList( F_All ); // show all patches
122  else if ( event.selection == recommended )
123  pkg->fillPatchList( F_Recommended ); // patch kind recommended
124  else if ( event.selection == security )
125  pkg->fillPatchList( F_Security ); // patch kind security
126  else if ( event.selection == optional )
127  pkg->fillPatchList( F_Optional ); // patch kind optional
128  else if ( event.selection == search )
129  {
130  searchPopup = new NCPkgPatchSearch( wpos( 1, 1 ), pkg );
131 
132  if ( searchPopup )
133  {
134  NCursesEvent retEvent = searchPopup->showSearchPopup();
135 
136  if ( retEvent == NCursesEvent::button )
137  {
138  yuiMilestone() << "Searching for: " << retEvent.result << endl;
139  pkgList->showInformation( );
140  }
141  else
142  {
143  yuiMilestone() << "Search is canceled" << endl;
144  }
145  searchPopup->destroy(); // (or call YDialog::deleteTopmostDialog())
146  searchPopup = 0;
147  }
148  }
149 
150  pkgList->setKeyboardFocus();
151 
152  pkgList->showInformation( );
153 
154  return true;
155 }
bool showInformation()
Show the corresponding information (e.g.
Definition: NCPkgTable.cc:762
bool fillPatchList(NCPkgMenuFilter::PatchFilter filter)
Fills the package table with YOU patches matching the filter.
The package table class.
Definition: NCPkgTable.h:175