Author: sh-sh-sh
Date: Thu Jun 28 14:41:25 2007
New Revision: 39083
URL: http://svn.opensuse.org/viewcvs/yast?rev=39083&view=rev
Log:
new class for selection widgets
Added:
branches/tmp/sh/mod-ui/core/libyui/src/YCPItem.h
Modified:
branches/tmp/sh/mod-ui/core/libyui/src/Makefile.am
branches/tmp/sh/mod-ui/core/libyui/src/YItem.h
branches/tmp/sh/mod-ui/core/libyui/src/YSelectionBox.h
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=39083&r1=39082&r2=39083&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/Makefile.am (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/Makefile.am Thu Jun 28 14:41:25 2007
@@ -81,7 +81,12 @@
ImplPtr.h \
UI.h \
YApplication.h \
+ YBothDim.h \
+ YCPDialogParser.h \
+ YCPValueWidgetID.h \
YChildrenManager.h \
+ YItem.h \
+ YCPItem.h \
YOptionalWidgetFactory.h \
YPackageSelectorPlugin.h \
YProperty.h \
@@ -94,10 +99,7 @@
YUI_util.h \
YWidgetFactory.h \
YWidgetID.h \
- YCPValueWidgetID.h \
- YCPDialogParser.h \
YWidgetOpt.h \
- YBothDim.h \
\
YAlignment.h \
YBarGraph.h \
Added: branches/tmp/sh/mod-ui/core/libyui/src/YCPItem.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YCPItem.h?rev=39083&view=auto
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YCPItem.h (added)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YCPItem.h Thu Jun 28 14:41:25 2007
@@ -0,0 +1,101 @@
+/*---------------------------------------------------------------------\
+| |
+| __ __ ____ _____ ____ |
+| \ \ / /_ _/ ___|_ _|___ \ |
+| \ V / _` \___ \ | | __) | |
+| | | (_| |___) || | / __/ |
+| |_|\__,_|____/ |_| |_____| |
+| |
+| core system |
+| (C) SuSE GmbH |
+\----------------------------------------------------------------------/
+
+ File: YCPItem.h
+
+ Author: Stefan Hundhammer
+
+/-*/
+
+#ifndef YCPItem_h
+#define YCPItem_h
+
+#include
+#include
+#include "YItem.h"
+
+
+/**
+ * Item class with YCPValue IDs
+ **/
+class YCPItem: public YItem
+{
+public:
+
+ /**
+ * Constructors
+ **/
+ YCPItem( const YCPString & label,
+ const YCPValue & id,
+ bool sel = false )
+ : YItem( label->value(), sel )
+ , _id( id )
+ {}
+
+ YCPItem( const YCPString & label,
+ const YCPValue & id,
+ const YCPString & iconName,
+ bool sel = false )
+ : YItem( label->value(), iconName->value(), sel )
+ , _id( id )
+ {}
+
+ /**
+ * Destructor.
+ **/
+ virtual ~YCPItem()
+ {}
+
+ /**
+ * 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( YItem::label() ); }
+
+ /**
+ * Set this item's label with a YCPString.
+ **/
+ void setLabel( const YCPString & newLabel )
+ { YItem::setLabel( newLabel->value() ); }
+
+ /**
+ * Return this icon's icon name as a YCPString.
+ **/
+ YCPString iconName() const { return YCPString( YItem::iconName() ); }
+
+ /**
+ * Set this icon's icon name with a YCPString.
+ **/
+ void setIconName( const YCPString & newIconName )
+ { YItem::setIconName( newIconName->value() ); }
+
+
+private:
+ YCPValue _id;
+};
+
+
+#endif // YCPItem_h
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YItem.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YItem.h?rev=39083&r1=39082&r2=39083&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YItem.h (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YItem.h Thu Jun 28 14:41:25 2007
@@ -23,26 +23,81 @@
#include <list>
-struct YItem
+/**
+ * Simple item class for SelectionBox, ComboBox, MultiSelectionBox etc. items.
+ **/
+class YItem
{
- string label;
- string id;
- bool isSelected;
-
- YItem( string labelText )
- : label( labelText )
- , id( labelText )
- , isSelected( false )
+public:
+
+ /**
+ * Constructor with just the label and optionally the selected state.
+ **/
+ YItem( const string & label, bool sel = false )
+ : _label( label )
+ , _selected( sel )
+ {}
+
+ /**
+ * Constructor with label and icon name and optionally the selected state.
+ **/
+ YItem( const string & label, const string & iconName, bool sel = false )
+ : _label( label )
+ , _iconName( iconName )
+ , _selected( sel )
{}
- YItem( string labelText, string idText, bool sel = false )
- : label( labelText )
- , id( idText )
- , isSelected( sel )
+ /**
+ * Virtual Destructor. Only needed to enforce this class getting a VTable
+ * so RTTI and dynymic_cast will work.
+ **/
+ virtual ~YItem()
{}
-}; // struct YItem
-typedef list<YItem> YItemList;
+ /**
+ * Return this item's label. This is what the user sees in a dialog, so
+ * this will usually be a translated text.
+ **/
+ string label() const { return _label; }
+
+ /**
+ * Set this item's label.
+ **/
+ void setLabel( const string & newLabel ) { _label = newLabel; }
+
+ /**
+ * Return this icon's icon name.
+ **/
+ string iconName() const { return _iconName; }
+
+ /**
+ * Set this icon's icon name.
+ **/
+ void setIconName( const string & newIconName ) { _iconName = newIconName; }
+
+ /**
+ * Return 'true' if this item is currently selected.
+ **/
+ bool selected() const { return _selected; }
+
+ /**
+ * Select or unselect this item. This does not have any effect on any other
+ * item; if it is desired that only one item is selected at any time, the
+ * caller has to take care of that.
+ **/
+ void setSelected( bool sel = true ) { _selected = sel; }
+
+
+private:
+ string _label;
+ string _iconName;
+ bool _selected;
+};
+
+
+typedef list YItemList;
+typedef YItemList::iterator YItemListIterator;
+typedef YItemList::const_iterator YItemListConstIterator;
#endif // YItem_h
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YSelectionBox.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YSelectionBox.h?rev=39083&r1=39082&r2=39083&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YSelectionBox.h (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YSelectionBox.h Thu Jun 28 14:41:25 2007
@@ -20,6 +20,7 @@
#define YSelectionBox_h
#include "YSelectionWidget.h"
+#include "YCPItem.h"
#include
#include
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org