Author: sh-sh-sh Date: Mon Sep 24 18:11:01 2007 New Revision: 41059 URL: http://svn.opensuse.org/viewcvs/yast?rev=41059&view=rev Log: moved YTreeItem out Added: branches/tmp/sh/mod-ui/core/libyui/src/YTreeItem.cc branches/tmp/sh/mod-ui/core/libyui/src/YTreeItem.h Modified: branches/tmp/sh/mod-ui/core/libyui/src/Makefile.am branches/tmp/sh/mod-ui/core/libyui/src/YCPTreeItem.h branches/tmp/sh/mod-ui/core/libyui/src/YItem.cc branches/tmp/sh/mod-ui/core/libyui/src/YItem.h branches/tmp/sh/mod-ui/core/libyui/src/YTree.cc branches/tmp/sh/mod-ui/ncurses/src/NCTree.cc branches/tmp/sh/mod-ui/ncurses/src/pkg/NCPkgPopupTree.cc branches/tmp/sh/mod-ui/qt/src/YQTree.cc 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=41059&r1=41058&r2=41059&view=diff ============================================================================== --- branches/tmp/sh/mod-ui/core/libyui/src/Makefile.am (original) +++ branches/tmp/sh/mod-ui/core/libyui/src/Makefile.am Mon Sep 24 18:11:01 2007 @@ -19,6 +19,7 @@ YCPPropertyHandler.cc \ YCPValueWidgetID.cc \ YItem.cc \ + YTreeItem.cc \ YProperty.cc \ YUIComponent.cc \ YUIException.cc \ @@ -98,6 +99,7 @@ YCP_UI_Exception.h \ YChildrenManager.h \ YItem.h \ + YTreeItem.h \ YOptionalWidgetFactory.h \ YPackageSelectorPlugin.h \ YProperty.h \ Modified: branches/tmp/sh/mod-ui/core/libyui/src/YCPTreeItem.h URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YCPTreeItem.h?rev=41059&r1=41058&r2=41059&view=diff ============================================================================== --- branches/tmp/sh/mod-ui/core/libyui/src/YCPTreeItem.h (original) +++ branches/tmp/sh/mod-ui/core/libyui/src/YCPTreeItem.h Mon Sep 24 18:11:01 2007 @@ -21,7 +21,7 @@ #include <ycp/YCPValue.h> #include <ycp/YCPString.h> -#include "YItem.h" +#include "YTreeItem.h" /** Modified: branches/tmp/sh/mod-ui/core/libyui/src/YItem.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YItem.cc?rev=41059&r1=41058&r2=41059&view=diff ============================================================================== --- branches/tmp/sh/mod-ui/core/libyui/src/YItem.cc (original) +++ branches/tmp/sh/mod-ui/core/libyui/src/YItem.cc Mon Sep 24 18:11:01 2007 @@ -26,79 +26,3 @@ **/ YItemCollection YItem::_noChildren; - - - -YTreeItem::YTreeItem( const string & label, - bool isOpen ) - : YItem( label ) - , _parent( 0 ) - , _isOpen( isOpen ) - , _data( 0 ) -{ -} - - -YTreeItem::YTreeItem( const string & label, - const string & iconName, - bool isOpen ) - : YItem( label, iconName ) - , _parent( 0 ) - , _isOpen( isOpen ) - , _data( 0 ) -{ -} - - -YTreeItem::YTreeItem( YTreeItem * parent, - const string & label, - bool isOpen ) - : YItem( label ) - , _parent( parent ) - , _isOpen( isOpen ) - , _data( 0 ) -{ - if ( parent ) - parent->addChild( this ); -} - - -YTreeItem::YTreeItem( YTreeItem * parent, - const string & label, - const string & iconName, - bool isOpen ) - : YItem( label, iconName ) - , _parent( parent ) - , _isOpen( isOpen ) - , _data( 0 ) -{ - if ( parent ) - parent->addChild( this ); -} - - -YTreeItem::~YTreeItem() -{ - deleteChildren(); -} - - -void YTreeItem::addChild( YItem * child ) -{ - _children.push_back( child ); -} - - -void YTreeItem::deleteChildren() -{ - YItemIterator it = childrenBegin(); - - while ( it != childrenEnd() ) - { - YItem * child = *it; - ++it; - delete child; - } - - _children.clear(); -} 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=41059&r1=41058&r2=41059&view=diff ============================================================================== --- branches/tmp/sh/mod-ui/core/libyui/src/YItem.h (original) +++ branches/tmp/sh/mod-ui/core/libyui/src/YItem.h Mon Sep 24 18:11:01 2007 @@ -174,131 +174,5 @@ }; -/** - * Item class for tree items. - * - * This class implements children management. - **/ -class YTreeItem: public YItem -{ -public: - /** - * Constructors for toplevel items. - **/ - YTreeItem( const string & label, - bool isOpen ); - - YTreeItem( const string & label, - const string & iconName, - bool isOpen ); - - /** - * 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. - **/ - YTreeItem( YTreeItem * parent, - const string & label, - bool isOpen ); - - YTreeItem( YTreeItem * parent, - const string & label, - const string & iconName, - bool isOpen ); - - /** - * Destructor. - * - * This will delete all children. - **/ - virtual ~YTreeItem(); - - /** - * Return 'true' if this item has any child items. - * - * Reimplemented from YItem. - **/ - virtual bool hasChildren() const { return ! _children.empty(); } - - /** - * Return an iterator that points to the first child item of this item. - * - * Reimplemented from YItem. - **/ - virtual YItemIterator childrenBegin() { return _children.begin(); } - virtual YItemConstIterator childrenBegin() const { return _children.begin(); } - - /** - * Return an iterator that points after the last child item of this item. - * - * Reimplemented from YItem. - **/ - virtual YItemIterator childrenEnd() { return _children.end(); } - virtual YItemConstIterator childrenEnd() const { return _children.end(); } - - /** - * Add a child item to this item. - * - * Note that the constructors that accept a parent pointer will - * automatically add themselves to their parent, so applications will - * normally not have to call this function. - **/ - virtual void addChild( YItem * child ); - - /** - * Delete all child items. - **/ - virtual void deleteChildren(); - - /** - * Return 'true' if this tree item should be displayed open (with its - * children visible) by default. - **/ - bool isOpen() const { return _isOpen; } - - /** - * Change the 'isOpen' flag. - **/ - void setOpen( bool open ) { _isOpen = open; } - - /** - * Returns this item's parent item or 0 if it is a toplevel item. - **/ - YTreeItem * parent() const { return _parent; } - - /** - * Set the opaque data pointer for application use. - * - * Applications can use this to store the pointer to a counterpart of this - * tree item. It is the application's responsibility to watch for dangling - * pointers and possibliy deleting the data. All this class ever does with - * this pointer is to store it. - **/ - void setData( void * newData ) { _data = newData; } - - /** - * Return the opaque data pointer. - **/ - void * data() const { return _data; } - -private: - - YTreeItem * _parent; - YItemCollection _children; - bool _isOpen; - void * _data; -}; - - -typedef vector<YTreeItem *> YTreeItemCollection; -typedef YTreeItemCollection::iterator YTreeItemIterator; -typedef YTreeItemCollection::const_iterator YTreeItemConstIterator; - -typedef vector<const YTreeItem *> YConstTreeItemCollection; -typedef YConstTreeItemCollection::iterator YConstTreeItemIterator; -typedef YConstTreeItemCollection::const_iterator YConstTreeItemConstIterator; - #endif // YItem_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=41059&r1=41058&r2=41059&view=diff ============================================================================== --- branches/tmp/sh/mod-ui/core/libyui/src/YTree.cc (original) +++ branches/tmp/sh/mod-ui/core/libyui/src/YTree.cc Mon Sep 24 18:11:01 2007 @@ -24,7 +24,7 @@ #include "YSelectionWidget.h" #include "YMacroRecorder.h" #include "YTree.h" -#include "YItem.h" +#include "YTreeItem.h" struct YTreePrivate { Added: branches/tmp/sh/mod-ui/core/libyui/src/YTreeItem.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YTreeItem.cc?rev=41059&view=auto ============================================================================== --- branches/tmp/sh/mod-ui/core/libyui/src/YTreeItem.cc (added) +++ branches/tmp/sh/mod-ui/core/libyui/src/YTreeItem.cc Mon Sep 24 18:11:01 2007 @@ -0,0 +1,94 @@ +/*---------------------------------------------------------------------\ +| | +| __ __ ____ _____ ____ | +| \ \ / /_ _/ ___|_ _|___ \ | +| \ V / _` \___ \ | | __) | | +| | | (_| |___) || | / __/ | +| |_|\__,_|____/ |_| |_____| | +| | +| core system | +| (C) SuSE GmbH | +\----------------------------------------------------------------------/ + + File: YTreeItem.cc + + Author: Stefan Hundhammer <sh@suse.de> + +/-*/ + +#include "YTreeItem.h" + + +YTreeItem::YTreeItem( const string & label, + bool isOpen ) + : YItem( label ) + , _parent( 0 ) + , _isOpen( isOpen ) + , _data( 0 ) +{ +} + + +YTreeItem::YTreeItem( const string & label, + const string & iconName, + bool isOpen ) + : YItem( label, iconName ) + , _parent( 0 ) + , _isOpen( isOpen ) + , _data( 0 ) +{ +} + + +YTreeItem::YTreeItem( YTreeItem * parent, + const string & label, + bool isOpen ) + : YItem( label ) + , _parent( parent ) + , _isOpen( isOpen ) + , _data( 0 ) +{ + if ( parent ) + parent->addChild( this ); +} + + +YTreeItem::YTreeItem( YTreeItem * parent, + const string & label, + const string & iconName, + bool isOpen ) + : YItem( label, iconName ) + , _parent( parent ) + , _isOpen( isOpen ) + , _data( 0 ) +{ + if ( parent ) + parent->addChild( this ); +} + + +YTreeItem::~YTreeItem() +{ + deleteChildren(); +} + + +void YTreeItem::addChild( YItem * child ) +{ + _children.push_back( child ); +} + + +void YTreeItem::deleteChildren() +{ + YItemIterator it = childrenBegin(); + + while ( it != childrenEnd() ) + { + YItem * child = *it; + ++it; + delete child; + } + + _children.clear(); +} Added: 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=41059&view=auto ============================================================================== --- branches/tmp/sh/mod-ui/core/libyui/src/YTreeItem.h (added) +++ branches/tmp/sh/mod-ui/core/libyui/src/YTreeItem.h Mon Sep 24 18:11:01 2007 @@ -0,0 +1,152 @@ +/*---------------------------------------------------------------------\ +| | +| __ __ ____ _____ ____ | +| \ \ / /_ _/ ___|_ _|___ \ | +| \ V / _` \___ \ | | __) | | +| | | (_| |___) || | / __/ | +| |_|\__,_|____/ |_| |_____| | +| | +| core system | +| (C) SuSE GmbH | +\----------------------------------------------------------------------/ + + File: YTreeItem.h + + Author: Stefan Hundhammer <sh@suse.de> + +/-*/ + +#ifndef YTreeItem_h +#define YTreeItem_h + +#include "YItem.h" + + +/** + * Item class for tree items. + * + * This class implements children management. + **/ +class YTreeItem: public YItem +{ +public: + /** + * Constructors for toplevel items. + **/ + YTreeItem( const string & label, + bool isOpen ); + + YTreeItem( const string & label, + const string & iconName, + bool isOpen ); + + /** + * 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. + **/ + YTreeItem( YTreeItem * parent, + const string & label, + bool isOpen ); + + YTreeItem( YTreeItem * parent, + const string & label, + const string & iconName, + bool isOpen ); + + /** + * Destructor. + * + * This will delete all children. + **/ + virtual ~YTreeItem(); + + /** + * Return 'true' if this item has any child items. + * + * Reimplemented from YItem. + **/ + virtual bool hasChildren() const { return ! _children.empty(); } + + /** + * Return an iterator that points to the first child item of this item. + * + * Reimplemented from YItem. + **/ + virtual YItemIterator childrenBegin() { return _children.begin(); } + virtual YItemConstIterator childrenBegin() const { return _children.begin(); } + + /** + * Return an iterator that points after the last child item of this item. + * + * Reimplemented from YItem. + **/ + virtual YItemIterator childrenEnd() { return _children.end(); } + virtual YItemConstIterator childrenEnd() const { return _children.end(); } + + /** + * Add a child item to this item. + * + * Note that the constructors that accept a parent pointer will + * automatically add themselves to their parent, so applications will + * normally not have to call this function. + **/ + virtual void addChild( YItem * child ); + + /** + * Delete all child items. + **/ + virtual void deleteChildren(); + + /** + * Return 'true' if this tree item should be displayed open (with its + * children visible) by default. + **/ + bool isOpen() const { return _isOpen; } + + /** + * Change the 'isOpen' flag. + **/ + void setOpen( bool open ) { _isOpen = open; } + + /** + * Returns this item's parent item or 0 if it is a toplevel item. + **/ + YTreeItem * parent() const { return _parent; } + + /** + * Set the opaque data pointer for application use. + * + * Applications can use this to store the pointer to a counterpart of this + * tree item. It is the application's responsibility to watch for dangling + * pointers and possibliy deleting the data. All this class ever does with + * this pointer is to store it. + **/ + void setData( void * newData ) { _data = newData; } + + /** + * Return the opaque data pointer. + **/ + void * data() const { return _data; } + +private: + + YTreeItem * _parent; + YItemCollection _children; + bool _isOpen; + void * _data; +}; + + +typedef vector<YTreeItem *> YTreeItemCollection; +typedef YTreeItemCollection::iterator YTreeItemIterator; +typedef YTreeItemCollection::const_iterator YTreeItemConstIterator; + +typedef vector<const YTreeItem *> YConstTreeItemCollection; +typedef YConstTreeItemCollection::iterator YConstTreeItemIterator; +typedef YConstTreeItemCollection::const_iterator YConstTreeItemConstIterator; + + +#endif // YTreeItem_h Modified: branches/tmp/sh/mod-ui/ncurses/src/NCTree.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/ncurses/src/NCTree.cc?rev=41059&r1=41058&r2=41059&view=diff ============================================================================== --- branches/tmp/sh/mod-ui/ncurses/src/NCTree.cc (original) +++ branches/tmp/sh/mod-ui/ncurses/src/NCTree.cc Mon Sep 24 18:11:01 2007 @@ -19,7 +19,7 @@ #include "Y2Log.h" #include "NCTree.h" -#include "YItem.h" +#include "YTreeItem.h" #include "YSelectionWidget.h" Modified: branches/tmp/sh/mod-ui/ncurses/src/pkg/NCPkgPopupTree.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/ncurses/src/pkg/NCPkgPopupTree.cc?rev=41059&r1=41058&r2=41059&view=diff ============================================================================== --- branches/tmp/sh/mod-ui/ncurses/src/pkg/NCPkgPopupTree.cc (original) +++ branches/tmp/sh/mod-ui/ncurses/src/pkg/NCPkgPopupTree.cc Mon Sep 24 18:11:01 2007 @@ -22,6 +22,7 @@ #include "NCTree.h" #include "YMenuButton.h" #include "YDialog.h" +#include "YTreeItem.h" #include "NCLayoutBox.h" #include "NCPkgNames.h" #include "NCPackageSelector.h" 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=41059&r1=41058&r2=41059&view=diff ============================================================================== --- branches/tmp/sh/mod-ui/qt/src/YQTree.cc (original) +++ branches/tmp/sh/mod-ui/qt/src/YQTree.cc Mon Sep 24 18:11:01 2007 @@ -32,7 +32,7 @@ #include "YEvent.h" #include "utf8.h" #include "YQTree.h" -#include "YItem.h" +#include "YTreeItem.h" #include "YQSignalBlocker.h" #include "YQWidgetCaption.h" -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org