Author: kmachalkova Date: Mon Jan 7 11:27:26 2008 New Revision: 43293 URL: http://svn.opensuse.org/viewcvs/yast?rev=43293&view=rev Log: Fixed adding and indexing combo-box items (#346862 related) Modified: trunk/ncurses/src/NCComboBox.cc Modified: trunk/ncurses/src/NCComboBox.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/ncurses/src/NCComboBox.cc?rev=43293&r1=43292&r2=43293&view=diff ============================================================================== --- trunk/ncurses/src/NCComboBox.cc (original) +++ trunk/ncurses/src/NCComboBox.cc Mon Jan 7 11:27:26 2008 @@ -200,8 +200,9 @@ YComboBox::addItem( item ); deflist.push_back( item->label() ); - if ( item->selected() || index == -1 ) + if ( item->selected() ) { + index = item->index(); setText( item->label() ); } } @@ -220,13 +221,8 @@ YItem * newItem = new YItem( label, selected ); YUI_CHECK_NEW( newItem ); - YComboBox::addItem( newItem ); + addItem(newItem); - deflist.push_back( label ); - if ( selected || index == -1 ) - { - setText( label ); - } } /////////////////////////////////////////////////////////////////// @@ -302,7 +298,6 @@ modified = false; fldstart = 0; curpos = mayedit ? buffer.length() : 0; - index = -1; setDefsze(); tUpdate(); Redraw(); @@ -319,17 +314,16 @@ string NCComboBox::text() { if ( modified ) - return NCstring( buffer ).Str(); - - if ( index != -1 ) { - int idx = 0; - list<string>::const_iterator entry; - for ( entry = deflist.begin(); entry != deflist.end(); ++entry, ++idx ) { - if ( idx == index ) { - return *entry; - } - } - } + return NCstring( buffer ).Str(); + //if ( index != -1 ) { + // int idx = 0; + // list<string>::const_iterator entry; + // for ( entry = deflist.begin(); entry != deflist.end(); ++entry, ++idx ) { + // if ( idx == index ) { + // return *entry; + // } + // } + //} return privText.Str(); } @@ -640,7 +634,7 @@ wpos at( ScreenPos() + wpos( win->height(), -1 ) ); NCPopupList * dialog = new NCPopupList( at, "", deflist, index ); YUI_CHECK_NEW( dialog ); - int idx = dialog->post(); + int idx = dialog->post(); if ( idx != -1 ) setCurrentItem( idx ); YDialog::deleteTopmostDialog(); -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org