Author: sh-sh-sh
Date: Mon Jul 2 18:36:40 2007
New Revision: 39130
URL: http://svn.opensuse.org/viewcvs/yast?rev=39130&view=rev
Log:
fixed MultiSelBox selection
Modified:
branches/tmp/sh/mod-ui/core/libyui/doc/examples/MultiSelectionBox3.ycp
branches/tmp/sh/mod-ui/core/libyui/src/YCPPropertyHandler.cc
branches/tmp/sh/mod-ui/core/libyui/src/YCPPropertyHandler.h
branches/tmp/sh/mod-ui/qt/src/YQMultiSelectionBox.cc
Modified: branches/tmp/sh/mod-ui/core/libyui/doc/examples/MultiSelectionBox3.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/doc/examples/MultiSelectionBox3.ycp?rev=39130&r1=39129&r2=39130&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/doc/examples/MultiSelectionBox3.ycp (original)
+++ branches/tmp/sh/mod-ui/core/libyui/doc/examples/MultiSelectionBox3.ycp Mon Jul 2 18:36:40 2007
@@ -17,6 +17,8 @@
`PushButton( `opt(`default), "&OK")
)
);
+ UI::ChangeWidget(`toppings, `SelectedItems, [`sausage, `onions] );
+
UI::UserInput();
list selected_items = (list) UI::QueryWidget( `id(`toppings), `SelectedItems );
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YCPPropertyHandler.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YCPPropertyHandler.cc?rev=39130&r1=39129&r2=39130&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YCPPropertyHandler.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YCPPropertyHandler.cc Mon Jul 2 18:36:40 2007
@@ -72,7 +72,7 @@
}
else if ( propertyName == YUIProperty_SelectedItems )
{
- // if ( trySetMultiSelectionBoxSelecteditems( widget, val ) ) return true;
+ if ( trySetMultiSelectionBoxSelectedItems( widget, val ) ) return true;
}
y2error( "Can't handle property %s::%s - not changing anything",
@@ -289,7 +289,46 @@
}
+bool
+YCPPropertyHandler::trySetMultiSelectionBoxSelectedItems( YWidget * widget, const YCPValue & val )
+{
+ YMultiSelectionBox * multiSelBox = dynamic_cast (widget);
+
+ if ( ! multiSelBox )
+ return false;
+
+ if ( ! val->isList() )
+ {
+ string msg = "Expected a list of item IDs";
+ YUI_THROW( YUIBadPropertyArgException( YProperty( YUIProperty_SelectedItems,
+ YOtherProperty ),
+ widget, msg ) );
+
+ }
+
+ YCPList itemIdList = val->asList();
+ multiSelBox->deselectAllItems();
+
+ for ( int i=0; i < itemIdList.size(); i++ )
+ {
+ YCPItem * item = findItem( multiSelBox, itemIdList->value( i ) );
+
+ if ( ! item )
+ {
+ y2error( "%s \"%s\" has no item with ID %s",
+ multiSelBox->widgetClass(),
+ multiSelBox->debugLabel().c_str(),
+ itemIdList->value(i)->toString().c_str() );
+ }
+ else
+ {
+ multiSelBox->selectItem( item );
+ }
+ }
+
+ return true;
+}
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YCPPropertyHandler.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YCPPropertyHandler.h?rev=39130&r1=39129&r2=39130&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YCPPropertyHandler.h (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YCPPropertyHandler.h Mon Jul 2 18:36:40 2007
@@ -86,7 +86,7 @@
static bool trySetComboBoxValue ( YWidget * widget, const YCPValue & val );
static bool trySetSelectionWidgetItems ( YWidget * widget, const YCPValue & val );
static bool trySetRadioButtonGroupCurrentButton ( YWidget * widget, const YCPValue & val );
- // static bool trySetMultiSelectionBoxSelecteditems ( YWidget * widget, const YCPValue & val );
+ static bool trySetMultiSelectionBoxSelectedItems ( YWidget * widget, const YCPValue & val );
/**
* All trySet..() functions try to dynamic_cast 'widget' to the expected
Modified: branches/tmp/sh/mod-ui/qt/src/YQMultiSelectionBox.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/qt/src/YQMultiSelectionBox.cc?rev=39130&r1=39129&r2=39130&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/YQMultiSelectionBox.cc (original)
+++ branches/tmp/sh/mod-ui/qt/src/YQMultiSelectionBox.cc Mon Jul 2 18:36:40 2007
@@ -113,7 +113,19 @@
YMultiSelectionBox::deselectAllItems();
_qt_listView->blockSignals( true );
- _qt_listView->clearSelection();
+
+ QListViewItemIterator it( _qt_listView );
+
+ while ( *it )
+ {
+ YQMultiSelectionBoxItem * item = dynamic_cast (*it);
+
+ if ( item )
+ item->setOn( false );
+
+ ++it;
+ }
+
_qt_listView->blockSignals( false );
}
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org