Author: sh-sh-sh
Date: Wed Oct 10 21:48:49 2007
New Revision: 41353
URL: http://svn.opensuse.org/viewcvs/yast?rev=41353&view=rev
Log:
Ported MenuButton
Added:
branches/tmp/sh/mod-ui/core/libyui/src/YCPMenuItem.h
branches/tmp/sh/mod-ui/core/libyui/src/YCPMenuItemParser.cc
branches/tmp/sh/mod-ui/core/libyui/src/YCPMenuItemParser.h
branches/tmp/sh/mod-ui/core/libyui/src/YCPMenuItemWriter.cc
branches/tmp/sh/mod-ui/core/libyui/src/YCPMenuItemWriter.h
branches/tmp/sh/mod-ui/core/libyui/src/YMenuItem.h
Modified:
branches/tmp/sh/mod-ui/core/libyui/src/ChangeLog
branches/tmp/sh/mod-ui/core/libyui/src/Makefile.am
branches/tmp/sh/mod-ui/core/libyui/src/YCPDialogParser.cc
branches/tmp/sh/mod-ui/core/libyui/src/YCPDialogParser.h
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/core/libyui/src/YEvent.cc
branches/tmp/sh/mod-ui/core/libyui/src/YEvent.h
branches/tmp/sh/mod-ui/core/libyui/src/YMenuButton.cc
branches/tmp/sh/mod-ui/core/libyui/src/YMenuButton.h
branches/tmp/sh/mod-ui/core/libyui/src/YTree.cc
branches/tmp/sh/mod-ui/core/libyui/src/YTreeItem.h
branches/tmp/sh/mod-ui/core/libyui/src/YUI.h
branches/tmp/sh/mod-ui/qt/src/YQComboBox.cc
branches/tmp/sh/mod-ui/qt/src/YQMenuButton.cc
branches/tmp/sh/mod-ui/qt/src/YQMenuButton.h
branches/tmp/sh/mod-ui/qt/src/YQSelectionBox.cc
branches/tmp/sh/mod-ui/qt/src/YQTable.cc
branches/tmp/sh/mod-ui/qt/src/YQTree.cc
branches/tmp/sh/mod-ui/qt/src/YQUI.h
branches/tmp/sh/mod-ui/qt/src/YQUI_widgets.cc
branches/tmp/sh/mod-ui/qt/src/YQWidgetFactory.cc
Modified: branches/tmp/sh/mod-ui/core/libyui/src/ChangeLog
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/ChangeLog?rev=41353&r1=41352&r2=41353&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/ChangeLog (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/ChangeLog Wed Oct 10 21:48:49 2007
@@ -347,7 +347,7 @@
* Ported Table
- now based on SelectionWidget
- much streamlined with the other selection widgets
- - QueryWidget(table) can now return the complete item term
+ - QueryWidget can now return the complete item term
as well as individual cells
Look at YQTable for a sample implementation.
@@ -369,3 +369,14 @@
* Ported LogView
+
+2007-10-10 22:00 sh@suse.de
+
+* Ported MenuButton
+ - Now derived from YSelectionWidget
+ - Added support for replacing (all!) items
+ - QueryWidget can now return the complete item term
+ - Added support for icons in menu entries
+ - Added YMenuEvent( YMenuEntry * ) constructor
+
+ Look at YQMenuButton for a sample implementation.
Modified: branches/tmp/sh/mod-ui/core/libyui/src/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/Makefile.am?rev=41353&r1=41352&r2=41353&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/Makefile.am (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/Makefile.am Wed Oct 10 21:48:49 2007
@@ -16,10 +16,12 @@
YCPDialogParser.cc \
YCPItemParser.cc \
YCPItemWriter.cc \
- YCPTreeItemParser.cc \
- YCPTreeItemWriter.cc \
+ YCPMenuItemParser.cc \
+ YCPMenuItemWriter.cc \
YCPTableItemParser.cc \
YCPTableItemWriter.cc \
+ YCPTreeItemParser.cc \
+ YCPTreeItemWriter.cc \
YCPPropertyHandler.cc \
YCPValueWidgetID.cc \
YItem.cc \
@@ -98,17 +100,21 @@
YCPItem.h \
YCPItemParser.h \
YCPItemWriter.h \
- YCPTreeItem.h \
- YCPTreeItemParser.h \
- YCPTreeItemWriter.h \
+ YCPMenuItem.h \
+ YCPMenuItemParser.h \
+ YCPMenuItemWriter.h \
YCPTableItemParser.h \
YCPTableItemWriter.h \
YCPTableItem.h \
+ YCPTreeItem.h \
+ YCPTreeItemParser.h \
+ YCPTreeItemWriter.h \
YCPPropertyHandler.h \
YCPValueWidgetID.h \
YCP_UI_Exception.h \
YChildrenManager.h \
YItem.h \
+ YMenuItem.h \
YTreeItem.h \
YTableItem.h \
YOptionalWidgetFactory.h \
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YCPDialogParser.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YCPDialogParser.cc?rev=41353&r1=41352&r2=41353&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YCPDialogParser.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YCPDialogParser.cc Wed Oct 10 21:48:49 2007
@@ -33,6 +33,7 @@
#include "YWidget.h"
#include "YCPValueWidgetID.h"
#include "YCPItemParser.h"
+#include "YCPMenuItemParser.h"
#include "YCPTreeItemParser.h"
#include "YCPTableItemParser.h"
#include "YCP_UI_Exception.h"
@@ -1302,9 +1303,11 @@
YCPDialogParser::parseMenuButton( YWidget * parent, YWidgetOpt & opt,
const YCPTerm & term, const YCPList & optList, int argnr )
{
- if ( term->size() - argnr != 2
- || ! term->value(argnr )->isString()
- || ! term->value(argnr+1)->isList() )
+ int numargs = term->size() - argnr;
+
+ if ( numargs < 1 || numargs > 2
+ || ! term->value( argnr )->isString()
+ || ( numargs >= 2 && ! term->value( argnr+1 )->isList() ) )
{
y2error( "Invalid arguments for the MenuButton widget: "
"expected \"label\", [ `item(), `item(), ... ], not %s",
@@ -1314,111 +1317,20 @@
rejectAllOptions( term,optList );
- YMenuButton *menu_button = dynamic_cast
- ( YUI::ui()->createMenuButton( parent, opt, term->value( argnr )->asString() ) );
-
- if ( ! menu_button ||
- parseMenuItemList( term->value( argnr+1 )->asList(), menu_button ) == -1 )
- {
- return 0;
- }
-
- menu_button->resolveShortcutConflicts();
- menu_button->createMenu(); // actually create the specific UI's menu hierarchy
-
- return menu_button;
-}
-
+ string label = term->value( argnr )->asString()->value();
+ YMenuButton * menuButton = YUI::widgetFactory()->createMenuButton( parent, label );
-int
-YCPDialogParser::parseMenuItemList( const YCPList & itemList,
- YMenuButton * menu_button,
- YMenu * parent_menu ) // 0 if top level
-{
- for ( int i=0; i < itemList->size(); i++ )
+ if ( numargs >= 2 )
{
- YCPValue item = itemList->value(i);
-
- if ( item->isTerm() && item->asTerm()->name() == YUISymbol_item )
- {
- // found `item()
-
- YCPTerm iterm = item->asTerm();
-
- if ( iterm->size() != 2 ||
- ! iterm->value(0)->isTerm() || // `id( ... )
- ! iterm->value(1)->isString() ) // "menu item label"
- {
- y2error( "MenuButton: Invalid menu item - expected `item( `id( ... ), \"label\" ), not %s",
- iterm->toString().c_str() );
-
- return -1;
- }
-
-
- // check for item `id() (mandatory)
-
- YCPValue item_id = YCPNull();
-
- if ( checkId ( iterm->value(0), true ) )
- {
- item_id = parseIdTerm( iterm->value(0) );
- }
- else // no `id()
- {
- y2error( "MenuButton: Invalid menu item - no `id() specified: %s",
- item->toString().c_str() );
-
- return -1;
- }
-
-
- // extract item label ( mandatory ) and create the item
-
- YCPString item_label = iterm->value(1)->asString();
- menu_button->addMenuItem( item_label, item_id, parent_menu );
- // y2debug( "Inserted menu entry '%s'", item_label->value().c_str() );
- }
- else if ( item->isTerm() && item->asTerm()->name() == YUISymbol_menu )
- {
- // found `menu()
-
- YCPTerm iterm = item->asTerm();
-
- if ( iterm->size() != 2 ||
- ! iterm->value(0)->isString() && // "submenu label"
- ! iterm->value(1)->isList() ) // [ `item( ... ), `item( ... ) ] )
- {
- y2error( "MenuButton: Invalid submenu specification: "
- "expected `menu( \"submenu label\", [ `item(), `item(), ... ] ), not %s",
- item->toString().c_str() );
-
- return -1;
- }
-
- YCPString sub_menu_label = iterm->value(0)->asString();
- YMenu * sub_menu = menu_button->addSubMenu( sub_menu_label, parent_menu );
- // y2debug( "Inserted sub menu '%s'", sub_menu_label->value().c_str() );
-
- if ( parseMenuItemList( iterm->value(1)->asList(), menu_button, sub_menu ) == -1 )
- {
- return -1;
- }
- }
- else
- {
- y2error( "MenuButton: Invalid menu item - use either `item() or `menu(), not %s",
- item->toString().c_str() );
- return -1;
- }
+ YCPList itemList = term->value( argnr+1 )->asList();
+ menuButton->addItems( YCPMenuItemParser::parseMenuItemList( itemList ) );
}
- return 0;
+ return menuButton;
}
-
/**
* @widget CheckBox
* @short Clickable on/off toggle button
@@ -1802,6 +1714,7 @@
const YCPTerm & term, const YCPList & optList, int argnr )
{
int numargs = term->size() - argnr;
+
if ( numargs < 1 || numargs > 2
|| ! term->value( argnr )->isString()
|| ( numargs >= 2 && ! term->value( argnr+1 )->isList() ) )
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YCPDialogParser.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YCPDialogParser.h?rev=41353&r1=41352&r2=41353&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YCPDialogParser.h (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YCPDialogParser.h Wed Oct 10 21:48:49 2007
@@ -91,11 +91,6 @@
static YCPValue parseIdTerm( const YCPValue & v );
/**
- * Parse a menu list (for menu buttons)
- **/
- static int parseMenuItemList( const YCPList & itemList, YMenuButton *menu_button, YMenu *parentMenu = 0 );
-
- /**
* Parse a list of numeric values and return it as a vector<float>.
* Throws exceptions upon syntax errors.
**/
Added: branches/tmp/sh/mod-ui/core/libyui/src/YCPMenuItem.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YCPMenuItem.h?rev=41353&view=auto
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YCPMenuItem.h (added)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YCPMenuItem.h Wed Oct 10 21:48:49 2007
@@ -0,0 +1,120 @@
+/*---------------------------------------------------------------------\
+| |
+| __ __ ____ _____ ____ |
+| \ \ / /_ _/ ___|_ _|___ \ |
+| \ V / _` \___ \ | | __) | |
+| | | (_| |___) || | / __/ |
+| |_|\__,_|____/ |_| |_____| |
+| |
+| core system |
+| (C) SuSE GmbH |
+\----------------------------------------------------------------------/
+
+ File: YCPMenuItem.h
+
+ Author: Stefan Hundhammer
+
+/-*/
+
+#ifndef YCPMenuItem_h
+#define YCPMenuItem_h
+
+
+#include
+#include
+#include "YMenuItem.h"
+
+
+/**
+ * Menu item class with YCPValue IDs.
+ *
+ * Similar to YCPItem (and even more similar to YCPTreeItem, but with YMenuItem
+ * as base class. There should be an elegant way to do this with templates, but
+ * the different constructor arguments make this difficult.
+ **/
+class YCPMenuItem: public YMenuItem
+{
+public:
+
+ /**
+ * Constructors
+ **/
+ YCPMenuItem( const YCPString & label,
+ const YCPValue & id )
+ : YMenuItem( label->value() )
+ , _id( id )
+ {}
+
+ YCPMenuItem( const YCPString & label,
+ const YCPValue & id,
+ const YCPString & iconName )
+ : YMenuItem( label->value(), iconName->value() )
+ , _id( id )
+ {}
+
+ YCPMenuItem( YCPMenuItem * parent,
+ const YCPString & label,
+ const YCPValue & id )
+ : YMenuItem( parent, label->value() )
+ , _id( id )
+ {}
+
+ YCPMenuItem( YCPMenuItem * parent,
+ const YCPString & label,
+ const YCPValue & id,
+ const YCPString & iconName )
+ : YMenuItem( parent, label->value(), iconName->value() )
+ , _id( id )
+ {}
+
+ /**
+ * Destructor.
+ **/
+ virtual ~YCPMenuItem()
+ {}
+
+ /**
+ * Return 'true' if this item has an ID.
+ **/
+ bool hasId() const { return ! _id.isNull() && ! _id->isVoid(); }
+
+ /**
+ * Return this item's ID.
+ **/
+ YCPValue id() const { return _id; }
+
+ /**
+ * Set a new ID.
+ **/
+ void setId( const YCPValue & newId ) { _id = newId; }
+
+ /**
+ * Return this item's label as a YCPString.
+ **/
+ YCPString label() const { return YCPString( YMenuItem::label() ); }
+
+ /**
+ * Set this item's label with a YCPString.
+ **/
+ void setLabel( const YCPString & newLabel )
+ { YMenuItem::setLabel( newLabel->value() ); }
+
+ /**
+ * Return this item's icon name as a YCPString.
+ **/
+ YCPString iconName() const { return YCPString( YMenuItem::iconName() ); }
+
+ /**
+ * Set this item's icon name with a YCPString.
+ **/
+ void setIconName( const YCPString & newIconName )
+ { YMenuItem::setIconName( newIconName->value() ); }
+
+
+private:
+
+ YCPValue _id;
+};
+
+
+#endif // YCPMenuItem_h
Added: branches/tmp/sh/mod-ui/core/libyui/src/YCPMenuItemParser.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YCPMenuItemParser.cc?rev=41353&view=auto
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YCPMenuItemParser.cc (added)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YCPMenuItemParser.cc Wed Oct 10 21:48:49 2007
@@ -0,0 +1,180 @@
+/*---------------------------------------------------------------------\
+| |
+| __ __ ____ _____ ____ |
+| \ \ / /_ _/ ___|_ _|___ \ |
+| \ V / _` \___ \ | | __) | |
+| | | (_| |___) || | / __/ |
+| |_|\__,_|____/ |_| |_____| |
+| |
+| core system |
+| (C) SuSE GmbH |
+\----------------------------------------------------------------------/
+
+ File: YCPMenuItemParser.h
+
+ Author: Stefan Hundhammer
+
+/-*/
+
+
+#include
+#include
+
+#define y2log_component "ui"
+#include
+
+#include "YCPMenuItemParser.h"
+#include "YCP_UI_Exception.h"
+#include "YUISymbols.h"
+
+#define VERBOSE_PARSER 0
+
+
+YItemCollection
+YCPMenuItemParser::parseMenuItemList( const YCPList & itemList )
+{
+ YItemCollection itemCollection;
+ itemCollection.reserve( itemList.size() );
+
+ try
+ {
+ for ( int i=0; i < itemList->size(); i++ )
+ {
+ YCPMenuItem * item = parseMenuItem( 0, // parent item
+ itemList->value(i) );
+ itemCollection.push_back( item );
+ }
+ }
+ catch ( YUIException & exception )
+ {
+ YItemIterator it = itemCollection.begin();
+
+ while ( it != itemCollection.end() )
+ {
+ // Delete all items created so far
+
+ YItem * item = *it;
+ ++it;
+ delete item;
+ }
+
+ throw;
+ }
+
+#if VERBOSE_PARSER
+ y2debug( "%d items", itemCollection.size() );
+#endif
+
+ return itemCollection;
+}
+
+
+
+YCPMenuItem *
+YCPMenuItemParser::parseMenuItem( YCPMenuItem * parent, const YCPValue & rawItem )
+{
+ YCPMenuItem * item = 0;
+
+#if VERBOSE_PARSER
+ y2debug( "Parsing: %s", rawItem->toString().c_str() );
+#endif
+
+ if ( rawItem->isTerm() &&
+ ( rawItem->asTerm()->name() == YUISymbol_item || // `item(...)
+ rawItem->asTerm()->name() == YUISymbol_menu ) ) // `menu(...)
+ {
+ item = parseMenuItem( parent, rawItem->asTerm() );
+ }
+ else // No term or neither `item(...) nor `menu(...)
+ {
+ YUI_THROW( YCPDialogSyntaxErrorException( "Expected `item(...)", rawItem ) );
+ }
+
+ return item;
+}
+
+
+YCPMenuItem *
+YCPMenuItemParser::parseMenuItem( YCPMenuItem * parent, const YCPTerm & itemTerm )
+{
+ YCPValue id = YCPNull();
+ YCPString iconName = YCPNull();
+ YCPString label = YCPNull();
+ YCPList subItemList = YCPNull();
+
+ const char * usage =
+ "Expected: `item(`id(`myID), `icon(\"MyIcon.png\"), \"MyItemText\", list subItemList )";
+
+#if VERBOSE_PARSER
+ y2debug( "Parsing: %s", itemTerm->toString().c_str() );
+#endif
+
+ for ( int i=0; i < itemTerm->size(); i++ )
+ {
+ YCPValue arg = itemTerm->value(i);
+
+#if VERBOSE_PARSER
+ y2debug( "Parsing term arg #%d: %s", i, arg->toString().c_str() );
+#endif
+
+ if ( arg->isTerm() ) // `id(), `icon()
+ {
+ YCPTerm term = arg->asTerm();
+
+ if ( term->size() != 1 ) // Both `id() and `icon() have 1 argument
+ YUI_THROW( YCPDialogSyntaxErrorException( usage, itemTerm ) );
+
+ if ( term->name() == YUISymbol_id // `id(...)
+ && id.isNull() ) // and don't have an ID yet
+ {
+ id = term->value(0);
+ }
+ else if ( term->name() == YUISymbol_icon // `icon(...)
+ && term->value(0)->isString() // with a string argument
+ && iconName.isNull() ) // and don't have an icon name yet
+ {
+ iconName = term->value(0)->asString();
+ }
+ else
+ {
+ YUI_THROW( YCPDialogSyntaxErrorException( usage, itemTerm ) );
+ }
+ }
+ else if ( arg->isString() // label (the user-visible text)
+ && label.isNull() ) // and don't have a label yet
+ {
+ label = arg->asString();
+ }
+ else if( arg->isList() // sub item list
+ && subItemList.isNull() ) // and don't have a sub item list yet
+ {
+ subItemList = arg->asList();
+ }
+ else
+ {
+ YUI_THROW( YCPDialogSyntaxErrorException( usage, itemTerm ) );
+ }
+ }
+
+ if ( label.isNull() ) // the label is required
+ YUI_THROW( YCPDialogSyntaxErrorException( usage, itemTerm ) );
+
+ if ( iconName.isNull() )
+ iconName = YCPString( "" );
+
+ if ( id.isNull() ) // no `id() ?
+ id = label; // use the label instead
+
+ YCPMenuItem * item = new YCPMenuItem( parent, label, id, iconName );
+ YUI_CHECK_NEW( item );
+
+ if ( ! subItemList.isNull() )
+ {
+ for ( int i=0; i < subItemList->size(); i++ )
+ {
+ parseMenuItem( item, subItemList->value(i) );
+ }
+ }
+
+ return item;
+}
Added: branches/tmp/sh/mod-ui/core/libyui/src/YCPMenuItemParser.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YCPMenuItemParser.h?rev=41353&view=auto
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YCPMenuItemParser.h (added)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YCPMenuItemParser.h Wed Oct 10 21:48:49 2007
@@ -0,0 +1,78 @@
+/*---------------------------------------------------------------------\
+| |
+| __ __ ____ _____ ____ |
+| \ \ / /_ _/ ___|_ _|___ \ |
+| \ V / _` \___ \ | | __) | |
+| | | (_| |___) || | / __/ |
+| |_|\__,_|____/ |_| |_____| |
+| |
+| core system |
+| (C) SuSE GmbH |
+\----------------------------------------------------------------------/
+
+ File: YCPMenuItemParser.h
+
+ Author: Stefan Hundhammer
+
+/-*/
+
+#ifndef YCPMenuItemParser_h
+#define YCPMenuItemParser_h
+
+#include
+#include "YCPMenuItem.h"
+
+
+/**
+ * Parser for menu item lists
+ **/
+class YCPMenuItemParser
+{
+public:
+
+ /**
+ * Parse a menu item list:
+ *
+ * [
+ * `item(`id( `myID1 ), "Label1" ),
+ * `item(`id( `myID2 ), `icon( "icon2.png"), "Label2", ),
+ * `menu(`id( `myID3 ), `icon( "icon3.png"), "Label3", [ subMenuList ] ),
+ * `item(`id( `myID3 ), `icon( "icon3.png"), "Label3", [ subMenuList ] ),
+ * ]
+ *
+ * Return a list of newly created YItem-derived objects.
+ *
+ * This function throws exceptions if there are syntax errors.
+ **/
+ static YItemCollection parseMenuItemList( const YCPList & ycpItemList );
+
+
+ /**
+ * Parse one item and create a YCPMenuItem from it.
+ *
+ * This function throws exceptions if there are syntax errors.
+ **/
+ static YCPMenuItem * parseMenuItem( YCPMenuItem * parent, const YCPValue & item );
+
+protected:
+
+ /**
+ * Parse an item term:
+ *
+ * `item(`id( `myID1 ), "Label1" )
+ * `item(`id( `myID2 ), `icon( "icon2.png"), "Label2", )
+ * `menu(`id( `myID3 ), `icon( "icon3.png"), "Label3", [ subMenuList ] )
+ * `item(`id( `myID3 ), `icon( "icon3.png"), "Label3", [ subMenuList ] )
+ *
+ * Everything but the label is optional. If no ID is specified, the label
+ * will be used as ID, which might not be very useful if labels are translated.
+ *
+ * This function throws exceptions if there are syntax errors.
+ **/
+ static YCPMenuItem * parseMenuItem( YCPMenuItem * parent, const YCPTerm & itemTerm );
+
+
+};
+
+
+#endif // YCPMenuItemParser_h
Added: branches/tmp/sh/mod-ui/core/libyui/src/YCPMenuItemWriter.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YCPMenuItemWriter.cc?rev=41353&view=auto
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YCPMenuItemWriter.cc (added)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YCPMenuItemWriter.cc Wed Oct 10 21:48:49 2007
@@ -0,0 +1,76 @@
+/*---------------------------------------------------------------------\
+| |
+| __ __ ____ _____ ____ |
+| \ \ / /_ _/ ___|_ _|___ \ |
+| \ V / _` \___ \ | | __) | |
+| | | (_| |___) || | / __/ |
+| |_|\__,_|____/ |_| |_____| |
+| |
+| core system |
+| (C) SuSE GmbH |
+\----------------------------------------------------------------------/
+
+ File: YCPMenuItemWriter.cc
+
+ Author: Stefan Hundhammer
+
+/-*/
+
+#include
+#include
+#include "YCPMenuItemWriter.h"
+#include "YUISymbols.h"
+
+
+YCPList
+YCPMenuItemWriter::itemList( YItemConstIterator begin, YItemConstIterator end )
+{
+ YCPList itemList;
+
+ for ( YItemConstIterator it = begin; it != end; ++it )
+ {
+ const YMenuItem * item = dynamic_cast (*it);
+
+ if ( item )
+ {
+ itemList->add( itemTerm( item ) );
+ }
+ }
+
+ return itemList;
+}
+
+
+YCPValue
+YCPMenuItemWriter::itemTerm( const YMenuItem * item )
+{
+ if ( ! item )
+ return YCPVoid();
+
+ YCPTerm itemTerm( YUISymbol_item ); // `item()
+
+ const YCPMenuItem * ycpItem = dynamic_cast (item);
+
+ if ( ycpItem && ycpItem->hasId() )
+ {
+ YCPTerm idTerm( YUISymbol_id ); // `id()
+ idTerm->add( ycpItem->id() );
+ itemTerm->add( idTerm );
+ }
+
+ if ( item->hasIconName() )
+ {
+ YCPTerm iconTerm( YUISymbol_icon ); // `icon()
+ iconTerm->add( YCPString( item->iconName() ) );
+ itemTerm->add( iconTerm );
+ }
+
+ itemTerm->add( YCPString( item->label() ) ); // label
+
+ if ( item->hasChildren() ) // subItemList
+ itemTerm->add( itemList( item->childrenBegin(), item->childrenEnd() ) );
+
+ return itemTerm;
+}
+
+
Added: branches/tmp/sh/mod-ui/core/libyui/src/YCPMenuItemWriter.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YCPMenuItemWriter.h?rev=41353&view=auto
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YCPMenuItemWriter.h (added)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YCPMenuItemWriter.h Wed Oct 10 21:48:49 2007
@@ -0,0 +1,60 @@
+/*---------------------------------------------------------------------\
+| |
+| __ __ ____ _____ ____ |
+| \ \ / /_ _/ ___|_ _|___ \ |
+| \ V / _` \___ \ | | __) | |
+| | | (_| |___) || | / __/ |
+| |_|\__,_|____/ |_| |_____| |
+| |
+| core system |
+| (C) SuSE GmbH |
+\----------------------------------------------------------------------/
+
+ File: YCPMenuItemWriter.h
+
+ Author: Stefan Hundhammer
+
+/-*/
+
+#ifndef YCPMenuItemWriter_h
+#define YCPMenuItemWriter_h
+
+#include
+#include
+#include
+
+#include "YCPMenuItem.h"
+
+
+/**
+ * Writer for menu item lists
+ **/
+class YCPMenuItemWriter
+{
+public:
+
+ /**
+ * Create a YCPList from a tree item collection:
+ *
+ * [
+ * `item(`id( `myID1 ), "Label1" ),
+ * `item(`id( `myID2 ), `icon( "icon2.png"), "Label2", ),
+ * `item(`id( `myID3 ), `icon( "icon3.png"), "Label3", [ subMenuList ] ),
+ * ]
+ **/
+ static YCPList itemList( YItemConstIterator begin, YItemConstIterator end );
+
+
+ /**
+ * Create a YCPTerm for one tree item:
+ *
+ * `item(`id( `myID1 ), "Label1" )
+ * `item(`id( `myID2 ), `icon( "icon2.png"), "Label2", )
+ * `item(`id( `myID3 ), `icon( "icon3.png"), "Label3", [ subMenuList ] )
+ **/
+ static YCPValue itemTerm( const YMenuItem * item );
+
+};
+
+
+#endif // YCPMenuItemWriter_h
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=41353&r1=41352&r2=41353&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YCPPropertyHandler.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YCPPropertyHandler.cc Wed Oct 10 21:48:49 2007
@@ -38,21 +38,24 @@
#include "YCPTreeItem.h"
#include "YCPItemParser.h"
#include "YCPItemWriter.h"
-#include "YCPTreeItemParser.h"
-#include "YCPTreeItemWriter.h"
+#include "YCPMenuItemParser.h"
+#include "YCPMenuItemWriter.h"
#include "YCPTableItemParser.h"
#include "YCPTableItemWriter.h"
+#include "YCPTreeItemParser.h"
+#include "YCPTreeItemWriter.h"
#include "YCPValueWidgetID.h"
#include "YCheckBox.h"
#include "YComboBox.h"
-#include "YMultiSelectionBox.h"
+#include "YMenuButton.h"
#include "YMultiProgressMeter.h"
+#include "YMultiSelectionBox.h"
#include "YRadioButton.h"
#include "YRadioButtonGroup.h"
#include "YSelectionBox.h"
-#include "YTree.h"
#include "YTable.h"
+#include "YTree.h"
#include "YUISymbols.h"
using std::list;
@@ -87,8 +90,10 @@
}
else if ( propertyName == YUIProperty_Items )
{
- // Make sure to try YTree and YTable before YSelectionWidget: both inherit YSelectionWidget!
+ // Make sure to try YMenuButton, YTable, YTree, before YSelectionWidget:
+ // they all inherit YSelectionWidget!
+ if ( trySetMenuButtonItems ( widget, val ) ) return true;
if ( trySetTreeItems ( widget, val ) ) return true;
if ( trySetTableItems ( widget, val ) ) return true;
if ( trySetSelectionWidgetItems ( widget, val ) ) return true;
@@ -171,10 +176,12 @@
}
else if ( propertyName == YUIProperty_Items )
{
- // Make sure to try YTree and YTable before YSelectionWidget: both inherit YSelectionWidget!
+ // Make sure to try YMenuButton, YTable, YTree, before YSelectionWidget:
+ // they all inherit YSelectionWidget!
- val = tryGetTreeItems ( widget ); if ( ! val.isNull() ) return val;
+ val = tryGetMenuButtonItems ( widget ); if ( ! val.isNull() ) return val;
val = tryGetTableItems ( widget ); if ( ! val.isNull() ) return val;
+ val = tryGetTreeItems ( widget ); if ( ! val.isNull() ) return val;
val = tryGetSelectionWidgetItems( widget ); if ( ! val.isNull() ) return val;
}
@@ -380,6 +387,27 @@
bool
+YCPPropertyHandler::trySetMenuButtonItems( YWidget * widget, const YCPValue & val )
+{
+ YMenuButton * menuButton = dynamic_cast (widget );
+
+ if ( ! menuButton )
+ return false;
+
+ if ( val->isList() )
+ {
+ menuButton->setItems( YCPMenuItemParser::parseMenuItemList( val->asList() ) );
+ return true;
+ }
+
+ YUI_THROW( YUIBadPropertyArgException( YProperty( YUIProperty_Items,
+ YOtherProperty ),
+ widget ) );
+ return false;
+}
+
+
+bool
YCPPropertyHandler::trySetTreeItems( YWidget * widget, const YCPValue & val )
{
YTree * tree = dynamic_cast (widget );
@@ -975,6 +1003,18 @@
YCPValue
+YCPPropertyHandler::tryGetMenuButtonItems( YWidget * widget )
+{
+ YMenuButton * menuButton = dynamic_cast (widget);
+
+ if ( ! menuButton )
+ return YCPNull();
+
+ return YCPMenuItemWriter::itemList( menuButton->itemsBegin(), menuButton->itemsEnd() );
+}
+
+
+YCPValue
YCPPropertyHandler::tryGetTableItems( YWidget * widget )
{
YTable * table = dynamic_cast (widget);
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=41353&r1=41352&r2=41353&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YCPPropertyHandler.h (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YCPPropertyHandler.h Wed Oct 10 21:48:49 2007
@@ -97,6 +97,7 @@
static bool trySetTreeValue ( YWidget * widget, const YCPValue & val );
static bool trySetTableValue ( YWidget * widget, const YCPValue & val );
static bool trySetComboBoxValue ( YWidget * widget, const YCPValue & val );
+ static bool trySetMenuButtonItems ( YWidget * widget, const YCPValue & val );
static bool trySetTreeItems ( YWidget * widget, const YCPValue & val );
static bool trySetTableItems ( YWidget * widget, const YCPValue & val );
static bool trySetTableCell ( YWidget * widget, const YCPTerm & propTerm, const YCPValue & val );
@@ -126,6 +127,7 @@
static YCPValue tryGetTableItem ( YWidget * widget, const YCPTerm & propertyTerm );
static YCPValue tryGetTableItems ( YWidget * widget );
static YCPValue tryGetTreeItems ( YWidget * widget );
+ static YCPValue tryGetMenuButtonItems ( YWidget * widget );
static YCPValue tryGetSelectionWidgetItems ( YWidget * widget );
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YEvent.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YEvent.cc?rev=41353&r1=41352&r2=41353&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YEvent.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YEvent.cc Wed Oct 10 21:48:49 2007
@@ -24,6 +24,7 @@
#include
#include
#include "YWidget.h"
+#include "YCPMenuItem.h"
#include "YEvent.h"
#include "YCPValueWidgetID.h"
@@ -297,7 +298,7 @@
YCPMap map = YEvent::ycpEvent();
// Add ID
- map->add( YCPString( "ID" ), _id );
+ map->add( YCPString( "ID" ), id() );
return map;
}
@@ -305,8 +306,21 @@
YCPValue YSimpleEvent::userInput()
{
- return _id;
+ return id();
}
+
+YCPValue YMenuEvent::id() const
+{
+ if ( _menuItem )
+ {
+ YCPMenuItem * ycpMenuItem = dynamic_cast (_menuItem);
+
+ if ( ycpMenuItem )
+ return ycpMenuItem->id();
+ }
+
+ return _id;
+}
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YEvent.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YEvent.h?rev=41353&r1=41352&r2=41353&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YEvent.h (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YEvent.h Wed Oct 10 21:48:49 2007
@@ -24,13 +24,15 @@
#include
#include
#include
+#include
using std::string;
class YWidget;
+class YMenuItem;
/**
- * @short Abstract base class for events to be returned upon UI::UserInput()
+ * Abstract base class for events to be returned upon UI::UserInput()
* and related.
**/
class YEvent
@@ -212,7 +214,7 @@
/**
- * @short abstract base class for events that just deal with an ID.
+ * Abstract base class for events that just deal with an ID.
**/
class YSimpleEvent: public YEvent
{
@@ -228,7 +230,7 @@
/**
* Returns the ID associated with this event.
**/
- YCPValue id() const { return _id; }
+ virtual YCPValue id() const { return _id; }
/**
* Constructs a YCP map to be returned upon UI::WaitForEvent().
@@ -253,15 +255,31 @@
/**
- * @short Event to be returned upon menu selection
+ * Event to be returned upon menu selection.
**/
class YMenuEvent: public YSimpleEvent
{
public:
- YMenuEvent( const YCPValue & id ) : YSimpleEvent( MenuEvent, id ) {}
- YMenuEvent( const char * id ) : YSimpleEvent( MenuEvent, id ) {}
- YMenuEvent( const string & id ) : YSimpleEvent( MenuEvent, id ) {}
+ YMenuEvent( YMenuItem * menuItem )
+ : YSimpleEvent( MenuEvent, YCPVoid() ),
+ _menuItem( menuItem )
+ {}
+
+ YMenuEvent( const YCPValue & id ) : YSimpleEvent( MenuEvent, id ), _menuItem(0) {}
+ YMenuEvent( const char * id ) : YSimpleEvent( MenuEvent, id ), _menuItem(0) {}
+ YMenuEvent( const string & id ) : YSimpleEvent( MenuEvent, id ), _menuItem(0) {}
+
+ /**
+ * Returns the ID associated with this event.
+ *
+ * Reimplemented from YSimpleEvent.
+ **/
+ virtual YCPValue id() const;
+
+protected:
+
+ YMenuItem * _menuItem;
};
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YMenuButton.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YMenuButton.cc?rev=41353&r1=41352&r2=41353&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YMenuButton.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YMenuButton.cc Wed Oct 10 21:48:49 2007
@@ -17,103 +17,45 @@
/-*/
-#include
-#include
#define y2log_component "ui"
#include
#include "YUISymbols.h"
#include "YMenuButton.h"
+#include "YMenuItem.h"
-YMenuButton::YMenuButton( const YWidgetOpt & opt, YCPString label )
- : YWidget( opt )
- , label( label )
- , next_index(0)
+struct YMenuButtonPrivate
{
- toplevel_menu = new YMenu( YCPString( "" ) );
-}
+ YMenuButtonPrivate()
+ {}
+
+ int dummy;
+};
-void YMenuButton::setLabel( const YCPString & label )
+YMenuButton::YMenuButton( YWidget * parent, const string & label )
+ : YSelectionWidget( parent, label,
+ false ) // enforceSingleSelection
+ , priv( new YMenuButtonPrivate() )
{
- this->label = label;
+ YUI_CHECK_NEW( priv );
}
-YCPString YMenuButton::getLabel()
+YMenuButton::~YMenuButton()
{
- return label;
+ // NOP
}
-YCPValue YMenuButton::changeWidget( const YCPSymbol & property, const YCPValue & newvalue )
+void YMenuButton::addItems( const YItemCollection & itemCollection )
{
- string s = property->symbol();
-
- /**
- * @property string Label the text on the MenuButton
- */
- if ( s == YUIProperty_Label )
- {
- if ( newvalue->isString() )
- {
- setLabel( newvalue->asString() );
- return YCPBoolean( true );
- }
- else
- {
- y2error( "MenuButton: Invalid parameter %s for Label property. Must be string",
- newvalue->toString().c_str() );
- return YCPBoolean( false );
- }
- }
- else return YWidget::changeWidget( property, newvalue );
-}
-
-
-
-YCPValue YMenuButton::queryWidget( const YCPSymbol & property )
-{
- string s = property->symbol();
- if ( s == YUIProperty_Label ) return getLabel();
- else return YWidget::queryWidget( property );
-}
-
-
-
-void
-YMenuButton::addMenuItem( const YCPString & item_label,
- const YCPValue & item_id,
- YMenu * parent_menu )
-{
- YMenuItem * item = new YMenuItem( item_label, parent_menu, next_index++, item_id );
-
- if ( ! parent_menu )
- {
- parent_menu = toplevel_menu;
- }
- parent_menu->addMenuItem( item );
-
- items.push_back( item );
-}
-
-
-YMenu *
-YMenuButton::addSubMenu( const YCPString & sub_menu_label,
- YMenu * parent_menu )
-{
- YMenu * menu = new YMenu( sub_menu_label, parent_menu );
-
- if ( ! parent_menu )
- {
- parent_menu = toplevel_menu;
- }
- parent_menu->addMenuItem( menu );
-
- return menu;
+ YSelectionWidget::addItems( itemCollection );
+ resolveShortcutConflicts();
+ rebuildMenuTree();
}
@@ -132,50 +74,56 @@
}
-YCPValue
-YMenuButton::indexToId( int index )
+const YPropertySet &
+YMenuButton::propertySet()
{
- if ( index >= 0 && ( unsigned ) index < items.size() )
- {
- YCPValue id = items[ index ]->getId();
- y2debug( "Selected menu item with ID '%s'", id->toString().c_str() );
+ static YPropertySet propSet;
- return id;
- }
- else
+ if ( propSet.isEmpty() )
{
- y2error( "No menu item with index %d", index );
- return YCPVoid();
+ /*
+ * @property string Label Label on the menu button
+ * @property itemList Items All menu items and submenus
+ * @property string IconPath Base path for icons (on menu items)
+ */
+ propSet.add( YProperty( YUIProperty_Label, YStringProperty ) );
+ propSet.add( YProperty( YUIProperty_Items, YOtherProperty ) );
+ propSet.add( YProperty( YUIProperty_IconPath, YStringProperty ) );
+ propSet.add( YWidget::propertySet() );
}
-}
-
-
-YMenuItem::YMenuItem( const YCPString & label,
- YMenu * parent_menu,
- int index,
- const YCPValue & id )
- : label( label )
- , id( id )
- , parent( parent_menu )
- , index( index )
-{
+ return propSet;
}
-YMenu::YMenu( const YCPString & label,
- YMenu * parent_menu,
- int index,
- const YCPValue & id )
- : YMenuItem( label, parent_menu, index, id )
+bool
+YMenuButton::setProperty( const string & propertyName, const YPropertyValue & val )
{
+ propertySet().check( propertyName, val.type() ); // throws exceptions if not found or type mismatch
+
+ if ( propertyName == YUIProperty_Label ) setLabel( val.stringVal() );
+ else if ( propertyName == YUIProperty_Items ) return false; // Needs special handling
+ else if ( propertyName == YUIProperty_IconPath ) setIconBasePath( val.stringVal() );
+ else
+ {
+ return YWidget::setProperty( propertyName, val );
+ }
+ return true; // success -- no special processing necessary
}
-void
-YMenu::addMenuItem( YMenuItem *item )
+YPropertyValue
+YMenuButton::getProperty( const string & propertyName )
{
- items.push_back( item );
+ propertySet().check( propertyName ); // throws exceptions if not found
+
+ if ( propertyName == YUIProperty_Label ) return YPropertyValue( label() );
+ else if ( propertyName == YUIProperty_Items ) return YPropertyValue( YOtherProperty );
+ else if ( propertyName == YUIProperty_IconPath ) return YPropertyValue( iconBasePath() );
+ else
+ {
+ return YWidget::getProperty( propertyName );
+ }
}
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YMenuButton.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YMenuButton.h?rev=41353&r1=41352&r2=41353&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YMenuButton.h (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YMenuButton.h Wed Oct 10 21:48:49 2007
@@ -19,223 +19,113 @@
#ifndef YMenuButton_h
#define YMenuButton_h
-#include "YWidget.h"
-#include
-#include
+#include "YSelectionWidget.h"
-class YMenu;
+class YMacroRecorder;
class YMenuItem;
+class YMenuButtonPrivate;
-typedef vector YMenuItemList;
-typedef vector::iterator YMenuItemListIterator;
-typedef vector::const_iterator YMenuItemListConstIterator;
-
-class YMenuButton : public YWidget
+/**
+ * MenuButton: Similar to PushButton, but with several actions: Upon clicking
+ * on a MenuButton (or activating it with the keyboard), a pop-up menu opens
+ * where the user can activate an action. Menu items in that pop-up menu can
+ * have submenus (that will pop up in separate pop-up menus).
+ *
+ * Internally, this widget is more similar to the Tree widget. The difference
+ * is that it does not keep a "selected" status, but triggers an action right
+ * away, just like a PushButton. Like PushButton, MenuButton sends an event
+ * right away when the user selects an item (clicks on a menu item or activates
+ * it with the keyboard). Items that have a submenu never send an event, they
+ * simply open their submenu when activated.
+ **/
+class YMenuButton : public YSelectionWidget
{
protected:
/**
- * Constructor
- * @param opt widget options
- * @param label the button label
+ * Constructor.
+ *
+ * 'label' is the user-visible text on the button (not above it like all
+ * other SelectionWidgets).
**/
- YMenuButton( const YWidgetOpt & opt, YCPString label );
+ YMenuButton( YWidget * parent, const string & label );
public:
/**
+ * Destructor.
+ **/
+ virtual ~YMenuButton();
+
+ /**
* Returns a descriptive name of this widget class for logging,
* debugging etc.
**/
virtual const char * widgetClass() const { return "YMenuButton"; }
/**
- * Implements the ui command changeWidget for the widget specific
- * properties.
- **/
- YCPValue changeWidget( const YCPSymbol & property, const YCPValue & newvalue );
-
- /**
- * Implements the ui command changeWidget for the widget specific
- * properties.
- **/
- YCPValue queryWidget( const YCPSymbol & property );
-
- /**
- * change the label of the push button. Overload this, but call
- * YMenuButton::setLabel at the end of your own function.
- **/
- virtual void setLabel( const YCPString & label );
-
- /**
- * Get the current label of the MenuButton entry. This method cannot be
- * overidden. The value of the label cannot be changed other than by
- * calling setLabel, i.e. not by the ui. Therefore setLabel stores the
- * current label in label.
- **/
- YCPString getLabel();
-
- /**
- * Get the MenuButton's toplevel menu.
- **/
- YMenu * getToplevelMenu() { return toplevel_menu; }
-
-
- /**
- * Add one menu item.
+ * Rebuild the displayed menu tree from the internally stored YMenuItems.
*
- * Pass 0 for 'parent_menu' to add this item to the MenuButton's toplevel
- * menu.
- **/
- void addMenuItem( const YCPString & item_label,
- const YCPValue & item_id,
- YMenu * parent_menu = 0 );
-
- /**
- * Add a submenu.
+ * The application should call this (once) after all items have been added
+ * with addItem(). YMenuButton::addItems() calls this automatically.
*
- * Pass 0 for 'parent_menu' to add this submenu to the MenuButton's toplevel
- * menu.
+ * Derived classes are required to implement this.
**/
- YMenu * addSubMenu( const YCPString & sub_menu_label,
- YMenu * parent_menu = 0 );
+ virtual void rebuildMenuTree() = 0;
/**
- * Retrieve the corresponding application ID to an internal menu item
- * index.
+ * Add multiple items. For some UIs, this can be more efficient than
+ * calling addItem() multiple times. This function also automatically calls
+ * resolveShortcutConflicts() and rebuildMenuTree() at the end.
+ *
+ * Derived classes can overwrite this function, but they should call this
+ * base class function at the end of the new implementation.
+ *
+ * Reimplemented from YSelectionWidget.
**/
- YCPValue indexToId( int index );
-
+ virtual void addItems( const YItemCollection & itemCollection );
/**
* Resolve keyboard shortcut conflicts: Change shortcuts of menu items if
* there are duplicates in the respective menu level.
*
- * This has to be called after all items are added, but before createMenu()
- * (see below).
+ * This has to be called after all items are added, but before rebuildMenuTree()
+ * (see above). YMenuButton::addItems() calls this automatically.
**/
void resolveShortcutConflicts();
/**
- * Actually create the menu hierarchy in the specific UI.
- * This is called when the complete menu hierarchy is known.
+ * Set a property.
+ * Reimplemented from YWidget.
+ *
+ * This function may throw YUIPropertyExceptions.
*
- * Overwrite this method.
+ * This function returns 'true' if the value was successfully set and
+ * 'false' if that value requires special handling (not in error cases:
+ * those are covered by exceptions).
**/
- virtual void createMenu() = 0;
+ virtual bool setProperty( const string & propertyName,
+ const YPropertyValue & val );
/**
- * Get the string of this widget that holds the keyboard shortcut.
- *
+ * Get a property.
* Reimplemented from YWidget.
+ *
+ * This method may throw YUIPropertyExceptions.
**/
- virtual string shortcutString() { return getLabel()->value(); }
+ virtual YPropertyValue getProperty( const string & propertyName );
/**
- * Set the string of this widget that holds the keyboard shortcut.
+ * Return this class's property set.
+ * This also initializes the property upon the first call.
*
* Reimplemented from YWidget.
**/
- virtual void setShortcutString( const string & str )
- { setLabel( YCPString( str ) ); }
-
-
-
-protected:
- /**
- * The button label
- **/
- YCPString label;
-
- /**
- * The next ( free ) item ID to use
- **/
- int next_index;
-
- /**
- * List of all items somewhere in the menu hierarchy.
- **/
- YMenuItemList items;
-
- /**
- * The top level menu
- **/
- YMenu * toplevel_menu;
-};
-
-
-/**
- * Helper class for menu items.
- *
- * This class provides the infrastructure for managing children
- * ( i.e. submenus ), yet it doesn't actually handle such children. Derived
- * classes may choose to do this.
- **/
-class YMenuItem
-{
-public:
-
- /**
- * Constructor.
- **/
- YMenuItem( const YCPString & label,
- YMenu * parent_menu = 0,
- int index = -1,
- const YCPValue & id = YCPVoid() );
-
- virtual ~YMenuItem() {}
-
-
- const YMenu * getParent() const { return parent; }
- const YCPValue & getId() const { return id; }
- int getIndex() const { return index; }
- const YCPString & getLabel() const { return label; }
- virtual bool hasChildren() const { return false; }
- YMenuItemList & itemList() { return items; }
- virtual bool isMenu() const { return false; }
-
- /**
- * Set this menu item's label. This will NOT have any immediate
- * visual effect with this base class method - it only stores the new label
- * for later retrieval. If a visual effect is desired, derived classes
- * should overwrite this method. Don't forget to call this base class
- * method in that case!
- **/
- virtual void setLabel( YCPString newLabel ) { label = newLabel; }
-
-
-protected:
-
- YCPString label;
- YCPValue id;
- YMenu * parent;
- int index;
- YMenuItemList items;
-};
-
-
-/**
- * Helper class for menus.
- *
- * Derived from @ref YMenuItem; this class can actually handle children.
- **/
-class YMenu: public YMenuItem
-{
-public:
-
- /**
- * Constructor
- **/
- YMenu( const YCPString & label,
- YMenu * parent_menu = 0,
- int index = -1,
- const YCPValue & id = YCPVoid() );
+ virtual const YPropertySet & propertySet();
- virtual ~YMenu() {}
+private:
- virtual bool hasChildren() const { return items.size() > 0; }
- void addMenuItem( YMenuItem *item );
- virtual bool isMenu() const { return true; }
+ ImplPtr<YMenuButtonPrivate> priv;
};
Added: branches/tmp/sh/mod-ui/core/libyui/src/YMenuItem.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YMenuItem.h?rev=41353&view=auto
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YMenuItem.h (added)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YMenuItem.h Wed Oct 10 21:48:49 2007
@@ -0,0 +1,88 @@
+/*---------------------------------------------------------------------\
+| |
+| __ __ ____ _____ ____ |
+| \ \ / /_ _/ ___|_ _|___ \ |
+| \ V / _` \___ \ | | __) | |
+| | | (_| |___) || | / __/ |
+| |_|\__,_|____/ |_| |_____| |
+| |
+| core system |
+| (C) SuSE GmbH |
+\----------------------------------------------------------------------/
+
+ File: YMenuItem.h
+
+ Author: Stefan Hundhammer
+
+/-*/
+
+#ifndef YMenuItem_h
+#define YMenuItem_h
+
+#include "YTreeItem.h"
+
+using std::string;
+using std::vector;
+
+
+/**
+ * Item class for menu items.
+ **/
+class YMenuItem: public YTreeItem
+{
+public:
+ /**
+ * Constructors for toplevel items.
+ **/
+ YMenuItem( const string & label )
+ : YTreeItem( label )
+ {}
+
+ YMenuItem( const string & label,
+ const string & iconName )
+ : YTreeItem( label, iconName )
+ {}
+
+ /**
+ * Constructors for items that have a parent item.
+ *
+ * They will automatically register this item with the parent item. The
+ * parent assumes ownership of this item and will delete it in its (the
+ * parent's) destructor.
+ **/
+ YMenuItem( YMenuItem * parent,
+ const string & label )
+ : YTreeItem( parent, label )
+ {}
+
+ YMenuItem( YMenuItem * parent,
+ const string & label,
+ const string & iconName )
+ : YTreeItem( parent, label, iconName )
+ {}
+
+ /**
+ * Destructor.
+ *
+ * This will delete all children.
+ **/
+ virtual ~YMenuItem() {}
+
+
+ /**
+ * Returns this item's parent item or 0 if it is a toplevel item.
+ **/
+ YMenuItem * parent() const
+ { return dynamic_cast ( YTreeItem::parent() ); }
+
+
+private:
+
+ // Disable unwanted base class methods
+
+ bool isOpen() const { return false; }
+ void setOpen( bool ) {}
+};
+
+
+#endif // YMenuItem_h
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YTree.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YTree.cc?rev=41353&r1=41352&r2=41353&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YTree.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YTree.cc Wed Oct 10 21:48:49 2007
@@ -55,7 +55,8 @@
}
-void YTree::addItems( const YItemCollection & itemCollection )
+void
+YTree::addItems( const YItemCollection & itemCollection )
{
YSelectionWidget::addItems( itemCollection );
rebuildTree();
@@ -75,7 +76,7 @@
* @property list<itemID> CurrentBranch List of IDs of current branch from root to current item
* @property itemList Items All items
* @property map<ItemID> OpenItems Map of IDs of all open items - can only be queried, not set
- * @property string Label caption above the tree
+ * @property string Label Caption above the tree
* @property string IconPath Base path for icons
*/
propSet.add( YProperty( YUIProperty_Value, YOtherProperty ) );
@@ -132,7 +133,8 @@
}
-void YTree::saveUserInput( YMacroRecorder *macroRecorder )
+void
+YTree::saveUserInput( YMacroRecorder *macroRecorder )
{
macroRecorder->recordWidgetProperty( this, YUIProperty_CurrentItem );
}
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YTreeItem.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YTreeItem.h?rev=41353&r1=41352&r2=41353&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YTreeItem.h (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YTreeItem.h Wed Oct 10 21:48:49 2007
@@ -37,11 +37,11 @@
* Constructors for toplevel items.
**/
YTreeItem( const string & label,
- bool isOpen );
+ bool isOpen = false );
YTreeItem( const string & label,
const string & iconName,
- bool isOpen );
+ bool isOpen = false );
/**
* Constructors for items that have a parent item.
@@ -52,12 +52,12 @@
**/
YTreeItem( YTreeItem * parent,
const string & label,
- bool isOpen );
+ bool isOpen = false );
YTreeItem( YTreeItem * parent,
const string & label,
const string & iconName,
- bool isOpen );
+ bool isOpen = false );
/**
* Destructor.
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YUI.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YUI.h?rev=41353&r1=41352&r2=41353&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YUI.h (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YUI.h Wed Oct 10 21:48:49 2007
@@ -453,7 +453,6 @@
// FIXME: Obsolete
public:
virtual YDialog *createDialog( YWidgetOpt & opt ) = 0;
- virtual YWidget *createMenuButton( YWidget *parent, YWidgetOpt & opt, const YCPString & label ) = 0;
// FIXME: Obsolete
// FIXME: Obsolete
// FIXME: Obsolete
Modified: branches/tmp/sh/mod-ui/qt/src/YQComboBox.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/qt/src/YQComboBox.cc?rev=41353&r1=41352&r2=41353&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/YQComboBox.cc (original)
+++ branches/tmp/sh/mod-ui/qt/src/YQComboBox.cc Wed Oct 10 21:48:49 2007
@@ -109,7 +109,7 @@
icon = QPixmap( iconName.c_str() );
if ( icon.isNull() )
- y2error( "Can't load icon %s", iconName.c_str() );
+ y2warning( "Can't load icon %s", iconName.c_str() );
}
if ( icon.isNull() )
Modified: branches/tmp/sh/mod-ui/qt/src/YQMenuButton.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/qt/src/YQMenuButton.cc?rev=41353&r1=41352&r2=41353&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/YQMenuButton.cc (original)
+++ branches/tmp/sh/mod-ui/qt/src/YQMenuButton.cc Wed Oct 10 21:48:49 2007
@@ -17,9 +17,9 @@
/-*/
-#include
#include
#include
+#include
#include
#include
#define y2log_component "qt-ui"
@@ -28,142 +28,227 @@
#include "utf8.h"
#include "YQUI.h"
#include "YQMenuButton.h"
-
-// Include low-level X headers AFTER Qt headers:
-// X.h pollutes the global namespace (!!!) with pretty useless #defines
-// like "Above", "Below" etc. that clash with some Qt headers.
+#include "YMenuItem.h"
#include "YEvent.h"
-YQMenuButton::YQMenuButton( QWidget * parent,
- const YWidgetOpt & opt,
- YCPString label )
- : QWidget( parent )
- , YMenuButton( opt, label )
- , _selected_item_index( -1 )
+
+YQMenuButton::YQMenuButton( YWidget * parent,
+ const string & label )
+ : QWidget( (QWidget *) parent->widgetRep() )
+ , YMenuButton( parent, label )
+ , _nextSerialNo( 0 )
+ , _selectedItem( 0 )
{
setWidgetRep( this );
- _qt_pushbutton = new QPushButton( fromUTF8( label->value() ), this );
- _qt_pushbutton->setMinimumSize( 2,2 );
- _qt_pushbutton->move( YQButtonBorder, YQButtonBorder );
- setMinimumSize( _qt_pushbutton->minimumSize()
+ _qt_button = new QPushButton( fromUTF8( label ), this );
+ // _qt_button->setMinimumSize( 2,2 );
+ _qt_button->move( YQButtonBorder, YQButtonBorder );
+ setMinimumSize( _qt_button->minimumSize()
+ 2 * QSize( YQButtonBorder, YQButtonBorder ) );
}
-void
-YQMenuButton::setEnabled( bool enabled )
+
+YQMenuButton::~YQMenuButton()
{
- _qt_pushbutton->setEnabled( enabled );
- YWidget::setEnabled( enabled );
+ // NOP
}
-int YQMenuButton::preferredWidth()
+void
+YQMenuButton::setLabel( const string & label )
{
- return 2*YQButtonBorder + _qt_pushbutton->sizeHint().width();
+ _qt_button->setText( fromUTF8( label ) );
+ YMenuButton::setLabel( label );
}
-int YQMenuButton::preferredHeight()
+void
+YQMenuButton::rebuildMenuTree()
{
- return 2*YQButtonBorder + _qt_pushbutton->sizeHint().height();
+ //
+ // Delete any previous menu
+ // (in case the menu items got replaced)
+ //
+
+ if ( _qt_button->popup() )
+ delete _qt_button->popup();
+
+ //
+ // Create toplevel menu
+ //
+
+ QPopupMenu * menu = new QPopupMenu( _qt_button );
+ YUI_CHECK_NEW( menu );
+ _qt_button->setPopup( menu );
+
+ connect( menu, SIGNAL( activated ( int ) ),
+ this, SLOT ( menuEntryActivated( int ) ) );
+
+ //
+ // Recursively add Qt menu items from the YMenuItems
+ //
+
+ _nextSerialNo = 0;
+ rebuildMenuTree( menu, itemsBegin(), itemsEnd() );
}
void
-YQMenuButton::setSize( int newWidth, int newHeight )
+YQMenuButton::rebuildMenuTree( QPopupMenu * parentMenu, YItemIterator begin, YItemIterator end )
{
- _qt_pushbutton->resize( newWidth - 2 * YQButtonBorder,
- newHeight - 2 * YQButtonBorder );
- resize( newWidth, newHeight );
+ for ( YItemIterator it = begin; it != end; ++it )
+ {
+ YMenuItem * item = dynamic_cast (*it);
+ YUI_CHECK_PTR( item );
+
+ QPixmap icon;
+
+ if ( item->hasIconName() )
+ {
+ string iconName = iconFullPath( item );
+ icon = QPixmap( iconName.c_str() );
+
+ if ( icon.isNull() )
+ y2warning( "Can't load icon %s", iconName.c_str() );
+ }
+
+ if ( item->hasChildren() )
+ {
+ QPopupMenu * subMenu = new QPopupMenu( parentMenu );
+ YUI_CHECK_NEW( subMenu );
+
+ if ( icon.isNull() )
+ parentMenu->insertItem( fromUTF8( item->label() ), subMenu );
+ else
+ parentMenu->insertItem( QIconSet( icon ), fromUTF8( item->label() ), subMenu );
+
+ connect( subMenu, SIGNAL( activated ( int ) ),
+ this, SLOT ( menuEntryActivated( int ) ) );
+
+ rebuildMenuTree( subMenu, item->childrenBegin(), item->childrenEnd() );
+ }
+ else // No children - leaf entry
+ {
+ item->setData( (void *) ++_nextSerialNo );
+
+ if ( icon.isNull() )
+ parentMenu->insertItem( fromUTF8( item->label() ), _nextSerialNo );
+ else
+ parentMenu->insertItem( QIconSet( icon ), fromUTF8( item->label() ), _nextSerialNo );
+ }
+ }
}
-void
-YQMenuButton::setLabel( const YCPString & label )
+YMenuItem *
+YQMenuButton::findMenuItem( int serialNo )
{
- _qt_pushbutton->setText( fromUTF8( label->value() ) );
+ return findMenuItem( serialNo, itemsBegin(), itemsEnd() );
}
-bool
-YQMenuButton::setKeyboardFocus()
+YMenuItem *
+YQMenuButton::findMenuItem( int serialNo, YItemConstIterator begin, YItemConstIterator end )
{
- _qt_pushbutton->setFocus();
+ for ( YItemConstIterator it = begin; it != end; ++it )
+ {
+ YMenuItem * item = dynamic_cast (*it);
- return true;
+ if ( item )
+ {
+ if ( item->data() == (void *) serialNo )
+ return item;
+
+ if ( item->hasChildren() )
+ {
+ YMenuItem * result = findMenuItem( serialNo, item->childrenBegin(), item->childrenEnd() );
+
+ if ( result )
+ return result;
+ }
+ }
+ }
+
+ return 0;
}
void
-YQMenuButton::menuEntryActivated( int menu_item_index )
+YQMenuButton::menuEntryActivated( int serialNo )
{
// y2debug( "Selected menu entry #%d", menu_item_index );
- _selected_item_index = menu_item_index;
-
- /*
- * Defer the real returnNow() until all popup related events have been
- * processed. This took me some hours to figure out; obviously exit_loop()
- * doesn't have any effect as long as there are still popups open. So be it
- * - use a zero timer to perform the real returnNow() later.
- */
-
- /*
- * the 100 delay is a ugly dirty workaround
- */
- QTimer::singleShot( 100, this, SLOT( returnNow() ) );
+ _selectedItem = findMenuItem( serialNo );
- // YQUI::ui()->wakeUpGuiThread();
- // YQUI::ui()->processEvents();
+ if ( _selectedItem )
+ {
+ /*
+ * Defer the real returnNow() until all popup related events have been
+ * processed. This took me some hours to figure out; obviously
+ * exit_loop() doesn't have any effect as long as there are still
+ * popups open. So be it - use a zero timer to perform the real
+ * returnNow() later.
+ */
+
+ /*
+ * the 100 delay is a ugly dirty workaround
+ */
+ QTimer::singleShot( 100, this, SLOT( returnNow() ) );
+ }
+ else
+ {
+ y2error( "No menu item with serial no. %d", serialNo );
+ }
}
void
YQMenuButton::returnNow()
{
- YQUI::ui()->sendEvent( new YMenuEvent( indexToId( _selected_item_index ) ) );
+ if ( _selectedItem )
+ {
+ YQUI::ui()->sendEvent( new YMenuEvent( _selectedItem ) );
+ _selectedItem = 0;
+ }
}
+
void
-YQMenuButton::createMenu()
+YQMenuButton::setEnabled( bool enabled )
{
- QPopupMenu * popup = new QPopupMenu( _qt_pushbutton );
- _qt_pushbutton->setPopup( popup );
- connect( popup, SIGNAL( activated(int) ),
- this, SLOT ( menuEntryActivated(int) ) );
+ _qt_button->setEnabled( enabled );
+ YWidget::setEnabled( enabled );
+}
- createMenu( getToplevelMenu(), popup );
+
+int YQMenuButton::preferredWidth()
+{
+ return 2*YQButtonBorder + _qt_button->sizeHint().width();
}
-void
-YQMenuButton::createMenu( YMenuItem * ymenu, QPopupMenu * qt_menu )
+int YQMenuButton::preferredHeight()
{
- YMenuItemListIterator it = ymenu->itemList().begin();
+ return 2*YQButtonBorder + _qt_button->sizeHint().height();
+}
- while ( it != ymenu->itemList().end() )
- {
- YMenuItem * item = *it;
- if ( item->isMenu() )
- {
- QPopupMenu * sub_menu = new QPopupMenu( qt_menu );
- // y2debug( "Inserting sub menu '%s'", item->getLabel()->value().c_str() );
- qt_menu->insertItem( fromUTF8( item->getLabel()->value() ), sub_menu );
- connect( sub_menu, SIGNAL( activated(int) ),
- this, SLOT ( menuEntryActivated(int) ) );
- createMenu( item, sub_menu );
+void
+YQMenuButton::setSize( int newWidth, int newHeight )
+{
+ _qt_button->resize( newWidth - 2 * YQButtonBorder,
+ newHeight - 2 * YQButtonBorder );
+ resize( newWidth, newHeight );
+}
- }
- else // simple menu item, no submenu
- {
- // y2debug( "Inserting menu item '%s'", item->getLabel()->value().c_str() );
- qt_menu->insertItem( fromUTF8( item->getLabel()->value() ), item->getIndex() );
- }
- ++it;
- }
+bool
+YQMenuButton::setKeyboardFocus()
+{
+ _qt_button->setFocus();
+
+ return true;
}
Modified: branches/tmp/sh/mod-ui/qt/src/YQMenuButton.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/qt/src/YQMenuButton.h?rev=41353&r1=41352&r2=41353&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/YQMenuButton.h (original)
+++ branches/tmp/sh/mod-ui/qt/src/YQMenuButton.h Wed Oct 10 21:48:49 2007
@@ -37,16 +37,34 @@
/**
* Constructor.
**/
- YQMenuButton( QWidget * parent,
- const YWidgetOpt & opt,
- YCPString label );
+ YQMenuButton( YWidget * parent,
+ const string & label );
/**
- * Inherited from YWidget: Sets the enabled state of the
- * widget. All new widgets are enabled per definition. Only
- * enabled widgets can take user input.
+ * Destructor.
**/
- void setEnabled( bool enabled );
+ virtual ~YQMenuButton();
+
+ /**
+ * Change the label on the button.
+ *
+ * Reimplemented from YMenuButton / YSelectionWidget.
+ **/
+ virtual void setLabel( const string & label );
+
+ /**
+ * Rebuild the displayed menu tree from the internally stored YMenuItems.
+ *
+ * Implemented from YMenuButton.
+ **/
+ virtual void rebuildMenuTree();
+
+ /**
+ * Set enabled / disabled state.
+ *
+ * Reimplemented from YWidget.
+ **/
+ virtual void setEnabled( bool enabled );
/**
* Preferred width of the widget.
@@ -68,35 +86,19 @@
* Reimplemented from YWidget.
**/
virtual void setSize( int newWidth, int newHeight );
-
- /**
- * Changes the label of the button
- **/
- void setLabel( const YCPString & label );
-
+
/**
* Accept the keyboard focus.
**/
virtual bool setKeyboardFocus();
- /**
- * Actually create the menu structure.
- *
- * Reimplemented - inherited from YMenuButton.
- **/
- virtual void createMenu();
-
- /**
- * Recursively create the menu structure.
- **/
- void createMenu( YMenuItem * ymenu, QPopupMenu * _qt_menu );
protected slots:
/**
* Triggered when any menu item is activated.
**/
- void menuEntryActivated( int menu_item_index );
+ void menuEntryActivated( int menuItemIndex );
/**
* Triggered via menuEntryActivated() by zero timer to get back in sync
@@ -107,8 +109,30 @@
protected:
- QPushButton * _qt_pushbutton;
- int _selected_item_index;
+ /**
+ * Recursively insert menu items into 'menu' from iterator 'begin' to iterator 'end'.
+ **/
+ void rebuildMenuTree( QPopupMenu * menu, YItemIterator begin, YItemIterator end );
+
+ /**
+ * Recursively find the first menu item with the specified serial no.
+ **/
+ YMenuItem * findMenuItem( int serialNo );
+
+ /**
+ * Recursively find the first menu item with the specified serial no
+ * from iterator 'begin' to iterator 'end'.
+ **/
+ YMenuItem * findMenuItem( int serialNo, YItemConstIterator begin, YItemConstIterator end );
+
+
+ //
+ // Data members
+ //
+
+ int _nextSerialNo;
+ YMenuItem * _selectedItem;
+ QPushButton * _qt_button;
};
#endif // YQMenuButton_h
Modified: branches/tmp/sh/mod-ui/qt/src/YQSelectionBox.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/qt/src/YQSelectionBox.cc?rev=41353&r1=41352&r2=41353&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/YQSelectionBox.cc (original)
+++ branches/tmp/sh/mod-ui/qt/src/YQSelectionBox.cc Wed Oct 10 21:48:49 2007
@@ -101,7 +101,7 @@
icon = QPixmap( iconName.c_str() );
if ( icon.isNull() )
- y2error( "Can't load icon %s", iconName.c_str() );
+ y2warning( "Can't load icon %s", iconName.c_str() );
}
if ( icon.isNull() )
Modified: branches/tmp/sh/mod-ui/qt/src/YQTable.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/qt/src/YQTable.cc?rev=41353&r1=41352&r2=41353&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/YQTable.cc (original)
+++ branches/tmp/sh/mod-ui/qt/src/YQTable.cc Wed Oct 10 21:48:49 2007
@@ -319,7 +319,7 @@
QPixmap icon = QPixmap( iconName.c_str() );
if ( icon.isNull() )
- y2error( "Can't load icon %s", iconName.c_str() );
+ y2warning( "Can't load icon %s", iconName.c_str() );
else
setPixmap( column, icon );
}
Modified: branches/tmp/sh/mod-ui/qt/src/YQTree.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/qt/src/YQTree.cc?rev=41353&r1=41352&r2=41353&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/YQTree.cc (original)
+++ branches/tmp/sh/mod-ui/qt/src/YQTree.cc Wed Oct 10 21:48:49 2007
@@ -299,7 +299,7 @@
QPixmap icon( iconName.c_str() );
if ( icon.isNull() )
- y2error( "Can't load icon %s", iconName.c_str() );
+ y2warning( "Can't load icon %s", iconName.c_str() );
else
setPixmap( 0, icon );
}
Modified: branches/tmp/sh/mod-ui/qt/src/YQUI.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/qt/src/YQUI.h?rev=41353&r1=41352&r2=41353&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/YQUI.h (original)
+++ branches/tmp/sh/mod-ui/qt/src/YQUI.h Wed Oct 10 21:48:49 2007
@@ -430,11 +430,6 @@
bool autoFonts() const { return _auto_fonts; }
- /*** Widget creation methods, all reimplemented from YUI ***/
-
- YWidget * createMenuButton ( YWidget * parent, YWidgetOpt & opt, const YCPString & label);
-
-
/*** Widget creation methods for optional widgets, all reimplemented from YUI ***/
bool hasBarGraph();
Modified: branches/tmp/sh/mod-ui/qt/src/YQUI_widgets.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/qt/src/YQUI_widgets.cc?rev=41353&r1=41352&r2=41353&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/YQUI_widgets.cc (original)
+++ branches/tmp/sh/mod-ui/qt/src/YQUI_widgets.cc Wed Oct 10 21:48:49 2007
@@ -22,22 +22,16 @@
#include "YQUI.h"
#include "YQBarGraph.h"
-#include "YQCheckBox.h"
#include "YQDate.h"
#include "YQDialog.h"
#include "YQDownloadProgress.h"
#include "YQDumbTab.h"
#include "YQIntField.h"
-#include "YQMenuButton.h"
#include "YQMultiProgressMeter.h"
#include "YQPackageSelectorPlugin.h"
#include "YQPartitionSplitter.h"
-#include "YQPatternSelector.h"
-#include "YQSimplePatchSelector.h"
#include "YQSlider.h"
-#include "YQTable.h"
#include "YQTime.h"
-#include "YQTree.h"
@@ -59,14 +53,6 @@
}
-YWidget * YQUI::createMenuButton ( YWidget * parent,
- YWidgetOpt & opt,
- const YCPString & label )
-{
- return new YQMenuButton( (QWidget *) ( parent->widgetRep() ), opt, label);
-}
-
-
//========= Optional widgets ========================================================
Modified: branches/tmp/sh/mod-ui/qt/src/YQWidgetFactory.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/qt/src/YQWidgetFactory.cc?rev=41353&r1=41352&r2=41353&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/YQWidgetFactory.cc (original)
+++ branches/tmp/sh/mod-ui/qt/src/YQWidgetFactory.cc Wed Oct 10 21:48:49 2007
@@ -232,7 +232,10 @@
YQMenuButton *
YQWidgetFactory::createMenuButton( YWidget * parent, const string & label )
{
- return 0; // FIXME: TO DO
+ YQMenuButton * menuButton = new YQMenuButton( parent, label );
+ YUI_CHECK_NEW( menuButton );
+
+ return menuButton;
}
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org