Author: gs
Date: Tue Oct 30 11:25:19 2007
New Revision: 41632
URL: http://svn.opensuse.org/viewcvs/yast?rev=41632&view=rev
Log:
add map to store table/menu item
Modified:
branches/tmp/sh/mod-ui/ncurses/src/NCMenuButton.cc
branches/tmp/sh/mod-ui/ncurses/src/NCPopupMenu.cc
branches/tmp/sh/mod-ui/ncurses/src/NCPopupMenu.h
Modified: branches/tmp/sh/mod-ui/ncurses/src/NCMenuButton.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/ncurses/src/NCMenuButton.cc?rev=41632&r1=41631&r2=41632&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/ncurses/src/NCMenuButton.cc (original)
+++ branches/tmp/sh/mod-ui/ncurses/src/NCMenuButton.cc Tue Oct 30 11:25:19 2007
@@ -189,7 +189,6 @@
{
wpos at( ScreenPos() + wpos( win->height(), 0 ) );
NCPopupMenu * dialog = new NCPopupMenu( at,
- this,
itemsBegin(),
itemsEnd() );
YUI_CHECK_NEW( dialog );
Modified: branches/tmp/sh/mod-ui/ncurses/src/NCPopupMenu.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/ncurses/src/NCPopupMenu.cc?rev=41632&r1=41631&r2=41632&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/ncurses/src/NCPopupMenu.cc (original)
+++ branches/tmp/sh/mod-ui/ncurses/src/NCPopupMenu.cc Tue Oct 30 11:25:19 2007
@@ -30,25 +30,28 @@
//
// DESCRIPTION :
//
-NCPopupMenu::NCPopupMenu( const wpos at, NCMenuButton * menuButton, YItemIterator begin, YItemIterator end )
+NCPopupMenu::NCPopupMenu( const wpos at, YItemIterator begin, YItemIterator end )
: NCPopupTable( at )
- , menu( menuButton )
- , startIndex( 0 )
+ , itemsMap()
{
vector<string> row( 2 );
createList( row );
YMenuItem * startItem = dynamic_cast (*begin);
YUI_CHECK_PTR( startItem );
- startIndex = startItem->index();
for ( YItemIterator it = begin; it != end; ++it )
{
YMenuItem * item = dynamic_cast (*it);
YUI_CHECK_PTR( item );
+
row[0] = item->label();
row[1] = item->hasChildren() ? "..." : "";
- YItem *tableItem = new YTableItem( row[0], row[1] );
+
+ YTableItem *tableItem = new YTableItem( row[0], row[1] );
+ NCMIL << "Add to map: TableItem: " << tableItem << " Menu item: " << item << endl;
+
addItem( tableItem );
+ itemsMap[tableItem] = item;
}
stripHotkeys();
}
@@ -63,6 +66,7 @@
//
NCPopupMenu::~NCPopupMenu()
{
+ itemsMap.clear();
}
///////////////////////////////////////////////////////////////////
@@ -79,7 +83,11 @@
switch ( ch ) {
case KEY_RIGHT:
{
- YMenuItem * item = menu->findItem( startIndex + getCurrentItem() );
+ NCMIL << "CurrentItem: " << getCurrentItem() << endl;
+ YTableItem * tableItem = dynamic_cast( getCurrentItemPointer() );
+ NCMIL << "TableItem: " << tableItem << endl;
+ YMenuItem * item = itemsMap[ tableItem ];
+ NCMIL << "MenuItem: " << item << endl;
if ( item && item->hasChildren() )
ret = NCursesEvent::button;
break;
@@ -109,18 +117,21 @@
bool again = false;
int selection = ( postevent == NCursesEvent::button ) ? getCurrentItem()
: -1;
- YMenuItem * item = menu->findItem( startIndex + selection );
-
+ NCMIL << "Index: " << selection << endl;
+ YTableItem * tableItem = dynamic_cast( getCurrentItemPointer() );
+ if ( tableItem )
+ NCMIL << "Table item: " << tableItem->label() << endl;
+ YMenuItem * item = itemsMap[ tableItem ];
+
if ( !item )
- return again;
-
+ return true;
+ NCMIL << "Menu item: " << item->label() << endl;
if ( selection != -1 )
{
if ( item->hasChildren() ) {
// post submenu
wpos at( ScreenPos() + wpos( selection, inparent.Sze.W - 1 ) );
NCPopupMenu * dialog = new NCPopupMenu( at,
- menu,
item->childrenBegin(),
item->childrenEnd() );
YUI_CHECK_NEW( dialog );
Modified: branches/tmp/sh/mod-ui/ncurses/src/NCPopupMenu.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/ncurses/src/NCPopupMenu.h?rev=41632&r1=41631&r2=41632&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/ncurses/src/NCPopupMenu.h (original)
+++ branches/tmp/sh/mod-ui/ncurses/src/NCPopupMenu.h Tue Oct 30 11:25:19 2007
@@ -40,8 +40,7 @@
private:
- NCMenuButton * menu;
- int startIndex;
+ std::map itemsMap;
protected:
@@ -51,7 +50,6 @@
public:
NCPopupMenu( const wpos at,
- NCMenuButton * menu,
YItemIterator begin,
YItemIterator end);
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org