[yast-commit] r39114 - /branches/tmp/sh/mod-ui/core/libyui/src/YSelectionWidget.cc
Author: sh-sh-sh Date: Mon Jul 2 17:20:53 2007 New Revision: 39114 URL: http://svn.opensuse.org/viewcvs/yast?rev=39114&view=rev Log: enforce initial selection Modified: branches/tmp/sh/mod-ui/core/libyui/src/YSelectionWidget.cc Modified: branches/tmp/sh/mod-ui/core/libyui/src/YSelectionWidget.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YSelectionWidget.cc?rev=39114&r1=39113&r2=39114&view=diff ============================================================================== --- branches/tmp/sh/mod-ui/core/libyui/src/YSelectionWidget.cc (original) +++ branches/tmp/sh/mod-ui/core/libyui/src/YSelectionWidget.cc Mon Jul 2 17:20:53 2007 @@ -155,26 +155,38 @@ // Enforce single selection (if applicable) // - if ( priv->enforceSingleSelection && item->selected() ) + if ( priv->enforceSingleSelection ) { - YItem * oldSelectedItem = selectedItem(); - - // This looks expensive, but it is not: Even though selectedItem() - // searches the complete item list until it finds a selected item, this - // happens only if a new item is to be inserted that has the "selected" - // flag on. In the normal case, this will only be one item. - // - // Only if the calling application does this systematically wrong and - // sets the "selected" flag for ALL items it inserts this will be more - // expensive. But then, this is a bug in that application that needs to - // be fixed. - - if ( oldSelectedItem && oldSelectedItem != item ) + if ( item->selected() ) { - oldSelectedItem->setSelected( false ); - y2warning( "Enforcing single selection: Deselecting %s", - oldSelectedItem->label().c_str() ); + YItem * oldSelectedItem = selectedItem(); + + // This looks expensive, but it is not: Even though selectedItem() + // searches the complete item list until it finds a selected item, this + // happens only if a new item is to be inserted that has the "selected" + // flag on. In the normal case, this will only be one item. + // + // Only if the calling application does this systematically wrong and + // sets the "selected" flag for ALL items it inserts this will be more + // expensive. But then, this is a bug in that application that needs to + // be fixed. + + + + if ( oldSelectedItem && oldSelectedItem != item ) + { + oldSelectedItem->setSelected( false ); + } } + + + // Make sure there is one item selected initially. + // + // If any other subsequently added items are to be selected, they will + // override this initial selection. + + if ( priv->itemCollection.size() == 1 ) + item->setSelected( true ); } } -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
sh-sh-sh@svn.opensuse.org