Author: sh-sh-sh
Date: Fri Mar 7 13:03:42 2008
New Revision: 45280
URL: http://svn.opensuse.org/viewcvs/yast?rev=45280&view=rev
Log:
Fixed bnc #357607: OpenItems property of Tree widget is broken
Modified:
trunk/ncurses/VERSION
trunk/ncurses/package/yast2-ncurses.changes
trunk/ncurses/src/NCTree.cc
trunk/ncurses/src/NCTree.h
Modified: trunk/ncurses/VERSION
URL: http://svn.opensuse.org/viewcvs/yast/trunk/ncurses/VERSION?rev=45280&r1=45279&r2=45280&view=diff
==============================================================================
--- trunk/ncurses/VERSION (original)
+++ trunk/ncurses/VERSION Fri Mar 7 13:03:42 2008
@@ -1 +1 @@
-2.16.18
+2.16.19
Modified: trunk/ncurses/package/yast2-ncurses.changes
URL: http://svn.opensuse.org/viewcvs/yast/trunk/ncurses/package/yast2-ncurses.changes?rev=45280&r1=45279&r2=45280&view=diff
==============================================================================
--- trunk/ncurses/package/yast2-ncurses.changes (original)
+++ trunk/ncurses/package/yast2-ncurses.changes Fri Mar 7 13:03:42 2008
@@ -1,4 +1,10 @@
-------------------------------------------------------------------
+Fri Mar 7 13:02:58 CET 2008 - sh@suse.de
+
+- Fixed bnc #357607: OpenItems property of Tree widget is broken
+- V 2.16.19
+
+-------------------------------------------------------------------
Fri Feb 29 15:21:14 CET 2008 - kmachalkova@suse.cz
- Workaround for missing arrow characters in xterm - use WACS_*ARROW
Modified: trunk/ncurses/src/NCTree.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/ncurses/src/NCTree.cc?rev=45280&r1=45279&r2=45280&view=diff
==============================================================================
--- trunk/ncurses/src/NCTree.cc (original)
+++ trunk/ncurses/src/NCTree.cc Fri Mar 7 13:03:42 2008
@@ -13,7 +13,6 @@
File: NCTree.cc
Author: Michael Andres
- Maintainer: Michael Andres
/-*/
@@ -25,18 +24,13 @@
#include "YSelectionWidget.h"
-///////////////////////////////////////////////////////////////////
-//
-// CLASS NAME : NCTableLine
-//
-// DESCRIPTION :
-//
-class NCTreeLine : public NCTableLine {
+class NCTreeLine : public NCTableLine
+{
- private:
+private:
- const YTreeItem & yitem;
- const unsigned level;
+ YTreeItem * yitem;
+ const unsigned level;
NCTreeLine * parent;
NCTreeLine * nsibling;
@@ -46,9 +40,9 @@
unsigned prefixLen() const { return level + 3; }
- public:
+public:
- NCTreeLine( NCTreeLine * p, const YTreeItem & item )
+ NCTreeLine( NCTreeLine * p, YTreeItem * item )
: NCTableLine( 0 )
, yitem( item )
, level ( p ? p->level + 1 : 0 )
@@ -57,137 +51,174 @@
, fchild ( 0 )
, prefix ( 0 )
{
- if ( parent ) {
- if ( parent->fchild ) {
- NCTreeLine * s = parent->fchild;
- for ( ; s->nsibling; s = s->nsibling )
- ;
- s->nsibling = this;
- } else {
- parent->fchild = this;
- }
- // FIXME ??? was yitem.isOpenByDefault()
- if ( !parent->yitem.isOpen() ) {
- SetState( S_HIDDEN );
+ if ( parent )
+ {
+ if ( parent->fchild )
+ {
+ NCTreeLine * s = parent->fchild;
+ for ( ; s->nsibling; s = s->nsibling )
+ ;
+ s->nsibling = this;
+ }
+ else
+ {
+ parent->fchild = this;
+ }
+ if ( !parent->yitem->isOpen() )
+ {
+ SetState( S_HIDDEN );
+ }
}
- }
- Append( new NCTableCol( NCstring( string( prefixLen(), ' ' )
- + yitem.label() ) ) );
+ Append( new NCTableCol( NCstring( string( prefixLen(), ' ' )
+ + yitem->label() ) ) );
}
virtual ~NCTreeLine() { delete [] prefix; }
public:
- const YTreeItem & Yitem() const { return yitem; }
- unsigned Level() const { return level; }
+ YTreeItem * YItem() const { return yitem; }
+ unsigned Level() const { return level; }
- virtual bool isVisible() const {
- return !parent || ( !isHidden() && parent->isVisible() );
+ virtual bool isVisible() const
+ {
+ return !parent || ( !isHidden() && parent->isVisible() );
}
- virtual int ChangeToVisible() {
- if ( isVisible() )
- return 0;
+
+ virtual int ChangeToVisible()
+ {
+ if ( isVisible() )
+ return 0;
- if ( parent ) {
- parent->ChangeToVisible();
- for ( NCTreeLine * c = parent->fchild; c; c = c->nsibling )
- c->ClearState( S_HIDDEN );
- } else {
- ClearState( S_HIDDEN );
- }
+ if ( parent )
+ {
+ parent->ChangeToVisible();
+
+ for ( NCTreeLine * c = parent->fchild; c; c = c->nsibling )
+ {
+ c->ClearState( S_HIDDEN );
+ c->YItem()->setOpen( true );
+ }
+ }
+ else
+ {
+ ClearState( S_HIDDEN );
+ yitem->setOpen( true );
+ }
- return 1;
+ return 1;
}
- virtual unsigned Hotspot( unsigned & at ) const {
- at = Level(); return 6;
+
+ virtual unsigned Hotspot( unsigned & at ) const
+ {
+ at = Level();
+ return 6;
}
- virtual int handleInput( wint_t key ) {
- if ( !fchild )
- return 0;
- switch ( key ) {
- case KEY_IC:
- if ( fchild->isVisible() )
- return 0;
- break;
- case KEY_DC:
- if ( !fchild->isVisible() )
- return 0;
- break;
- case KEY_SPACE:
+
+ virtual int handleInput( wint_t key )
+ {
+ if ( !fchild )
+ return 0;
+ switch ( key ) {
+ case KEY_IC:
+ if ( fchild->isVisible() )
+ return 0;
+ break;
+ case KEY_DC:
+ if ( !fchild->isVisible() )
+ return 0;
+ break;
+ case KEY_SPACE:
// case KEY_RETURN: - see bug 67350
- case '+':
- case '-':
- break;
- default:
- return 0;
- break;
- }
-
- if ( fchild->isVisible() ) {
- for ( NCTreeLine * c = fchild; c; c = c->nsibling )
- c->SetState( S_HIDDEN );
- } else {
- for ( NCTreeLine * c = fchild; c; c = c->nsibling )
- c->ClearState( S_HIDDEN );
- }
+ case '+':
+ case '-':
+ break;
+ default:
+ return 0;
+ break;
+ }
+
+ if ( fchild->isVisible() )
+ {
+ yitem->setOpen( false );
+ yuiMilestone() << "Closing item " << yitem->label() << endl;
+
+ for ( NCTreeLine * c = fchild; c; c = c->nsibling )
+ c->SetState( S_HIDDEN );
+ }
+ else
+ {
+ yitem->setOpen( true );
+ yuiMilestone() << "Opening item " << yitem->label() << endl;
+
+ for ( NCTreeLine * c = fchild; c; c = c->nsibling )
+ c->ClearState( S_HIDDEN );
+ }
- return 1;
+ return 1;
}
+
virtual void DrawAt( NCursesWindow & w, const wrect at,
NCTableStyle & tableStyle,
- bool active ) const {
+ bool active ) const
+ {
- NCTableLine::DrawAt( w, at, tableStyle, active );
+ NCTableLine::DrawAt( w, at, tableStyle, active );
- if ( !isSpecial() )
- w.bkgdset( tableStyle.getBG( vstate, NCTableCol::SEPARATOR ) );
+ if ( !isSpecial() )
+ w.bkgdset( tableStyle.getBG( vstate, NCTableCol::SEPARATOR ) );
+
+ if ( ! prefix )
+ {
+ prefix = new chtype[prefixLen()];
+ chtype * tagend = &prefix[prefixLen()-1];
+ *tagend-- = ACS_HLINE;
+ *tagend-- = fchild ? ACS_TTEE : ACS_HLINE;
+
+ if ( parent )
+ {
+ *tagend-- = nsibling ? ACS_LTEE : ACS_LLCORNER;
+
+ for ( NCTreeLine * p = parent; p; p = p->parent )
+ {
+ *tagend-- = p->nsibling ? ACS_VLINE : (' '&A_CHARTEXT);
+ }
+ }
+ else
+ {
+ *tagend-- = ACS_HLINE;
+ }
+ }
- if ( ! prefix ) {
- prefix = new chtype[prefixLen()];
- chtype * tagend = &prefix[prefixLen()-1];
- *tagend-- = ACS_HLINE;
- *tagend-- = fchild ? ACS_TTEE : ACS_HLINE;
- if ( parent ) {
- *tagend-- = nsibling ? ACS_LTEE : ACS_LLCORNER;
- for ( NCTreeLine * p = parent; p; p = p->parent ) {
- *tagend-- = p->nsibling ? ACS_VLINE : (' '&A_CHARTEXT);
- }
- } else
- *tagend-- = ACS_HLINE;
- }
-
- w.move( at.Pos.L, at.Pos.C );
- unsigned i = 0;
- for ( ; i < prefixLen(); ++i )
- w.addch( prefix[i] );
-
- w.move( at.Pos.L, at.Pos.C + prefixLen() - 2 );
- if ( fchild && !isSpecial() )
- w.bkgdset( tableStyle.highlightBG( vstate, NCTableCol::HINT,
- NCTableCol::SEPARATOR ) );
- if ( fchild && !fchild->isVisible() )
- w.addch( '+' );
- else
- w.addch( prefix[prefixLen() - 2] );
+ w.move( at.Pos.L, at.Pos.C );
+ unsigned i = 0;
+
+ for ( ; i < prefixLen(); ++i )
+ w.addch( prefix[i] );
+
+ w.move( at.Pos.L, at.Pos.C + prefixLen() - 2 );
+
+ if ( fchild && !isSpecial() )
+ w.bkgdset( tableStyle.highlightBG( vstate, NCTableCol::HINT,
+ NCTableCol::SEPARATOR ) );
+ if ( fchild && !fchild->isVisible() )
+ w.addch( '+' );
+ else
+ w.addch( prefix[prefixLen() - 2] );
}
};
-///////////////////////////////////////////////////////////////////
+
///////////////////////////////////////////////////////////////////
-//
-//
-// METHOD NAME : NCTree::NCTree
-// METHOD TYPE : Constructor
-//
-// DESCRIPTION :
-//
+
+
+
NCTree::NCTree( YWidget * parent, const string & nlabel )
: YTree( parent, nlabel )
, NCPadWidget( parent )
@@ -196,19 +227,14 @@
setLabel( nlabel );
}
-///////////////////////////////////////////////////////////////////
-//
-//
-// METHOD NAME : NCTree::~NCTree
-// METHOD TYPE : Destructor
-//
-// DESCRIPTION :
-//
+
+
NCTree::~NCTree()
{
yuiDebug() << endl;
}
+
///////////////////////////////////////////////////////////////////
//
//
@@ -219,12 +245,13 @@
//
inline const NCTreeLine * NCTree::getTreeLine( unsigned idx ) const
{
- if ( myPad() ) {
+ if ( myPad() )
return dynamic_cast(myPad()->GetLine( idx ));
- }
- return 0;
+ else
+ return 0;
}
+
///////////////////////////////////////////////////////////////////
//
//
@@ -241,6 +268,7 @@
return 0;
}
+
///////////////////////////////////////////////////////////////////
//
//
@@ -255,6 +283,7 @@
return sze.W;
}
+
///////////////////////////////////////////////////////////////////
//
//
@@ -269,6 +298,7 @@
return sze.H;
}
+
///////////////////////////////////////////////////////////////////
//
//
@@ -283,6 +313,7 @@
YWidget::setEnabled( do_bv );
}
+
///////////////////////////////////////////////////////////////////
//
//
@@ -296,6 +327,7 @@
wRelocate( wpos( 0 ), wsze( newheight, newwidth ) );
}
+
///////////////////////////////////////////////////////////////////
//
//
@@ -305,20 +337,23 @@
// DESCRIPTION : Return YTreeItem pointer for a current line
// (under the cursor)
//
-const YTreeItem * NCTree::getCurrentItem() const
+YTreeItem * NCTree::getCurrentItem() const
{
- const YTreeItem * yitem = 0;
+ YTreeItem * yitem = 0;
- if ( myPad() ) {
- const NCTreeLine * cline = dynamic_cast(myPad()->GetCurrentLine());
- if ( cline ) {
- yitem = &cline->Yitem();
+ if ( myPad() )
+ {
+ const NCTreeLine * cline = dynamic_cast(myPad()->GetCurrentLine());
+
+ if ( cline )
+ yitem = cline->YItem();
}
- }
- yuiDebug() << "-> " << (yitem?yitem->label().c_str():"noitem") << endl;
- return yitem;
+ yuiDebug() << "-> " << (yitem?yitem->label().c_str():"noitem") << endl;
+
+ return yitem;
}
+
///////////////////////////////////////////////////////////////////
//
//
@@ -335,7 +370,7 @@
YTreeItem * treeItem = dynamic_cast (item);
YUI_CHECK_PTR( treeItem );
- const YTreeItem *citem = getCurrentItem();
+ YTreeItem *citem = getCurrentItem();
if ( !selected && ( treeItem == citem ))
{
@@ -353,6 +388,7 @@
}
}
+
///////////////////////////////////////////////////////////////////
//
//
@@ -374,34 +410,23 @@
YUI_THROW( YUIException( "Can't find selected item" ) );
}
-///////////////////////////////////////////////////////////////////
-//
-//
-// METHOD NAME : NCTree::setLabel
-// METHOD TYPE : void
-//
-// DESCRIPTION :
-//
+
+
void NCTree::setLabel( const string & nlabel )
{
YTree::setLabel( nlabel );
NCPadWidget::setLabel( NCstring( nlabel ) );
}
-///////////////////////////////////////////////////////////////////
-//
-//
-// METHOD NAME : NCTree::rebuildTree
-// METHOD TYPE : void
-//
-// DESCRIPTION :
-//
+
+
void NCTree::rebuildTree()
{
DelPad();
Redraw();
}
+
///////////////////////////////////////////////////////////////////
//
//
@@ -418,16 +443,13 @@
return npad;
}
+
///////////////////////////////////////////////////////////////////
//
+// Creates tree lines and appends them to TreePad
+// (called recursively for each child of an item)
//
-// METHOD NAME : NCTree::Dit
-// METHOD TYPE : void
-//
-// DESCRIPTION : Creates tree lines and appends them to TreePad
-// (called recursively for each child of an item)
-//
-void NCTree::Dit( NCTreeLine * p, NCTreePad * pad, YTreeItem * item )
+void NCTree::CreateTreeLines( NCTreeLine * parentLine, NCTreePad * pad, YItem * item )
{
//static index counter
static int idx = 0;
@@ -435,23 +457,27 @@
//which makes selecting items painful
item->setIndex( idx++ );
- NCTreeLine * c = new NCTreeLine( p, *item );
+ YTreeItem * treeItem = dynamic_cast (item);
+ YUI_CHECK_PTR( treeItem );
- pad->Append( c );
+ NCTreeLine * line = new NCTreeLine( parentLine, treeItem );
+ pad->Append( line );
// iterate over children
for ( YItemIterator it = item->childrenBegin(); it < item->childrenEnd(); ++it )
{
- Dit( c, pad, (YTreeItem *)(*it) );
+ CreateTreeLines( line, pad, *it );
}
}
+
+
///////////////////////////////////////////////////////////////////
//
//
// METHOD NAME : NCTree::DrawPad
// METHOD TYPE : void
//
-// DESCRIPTION : Fills TreePad with lines (uses Dit to create them)
+// DESCRIPTION : Fills TreePad with lines (uses CreateTreeLines to create them)
//
void NCTree::DrawPad()
{
@@ -464,24 +490,18 @@
// YItemIterator iterates over the toplevel items
for ( YItemIterator it = itemsBegin(); it < itemsEnd(); ++it )
{
- Dit( 0, myPad(), (YTreeItem *)(*it) );
+ CreateTreeLines( 0, myPad(), *it );
}
NCPadWidget::DrawPad();
}
-///////////////////////////////////////////////////////////////////
-//
-//
-// METHOD NAME : NCTree::wHandleInput
-// METHOD TYPE : NCursesEvent
-//
-// DESCRIPTION :
-//
+
+
NCursesEvent NCTree::wHandleInput( wint_t key )
{
NCursesEvent ret = NCursesEvent::none;
- const YTreeItem * oldCurrentItem = getCurrentItem();
+ YTreeItem * oldCurrentItem = getCurrentItem();
if ( ! handleInput( key ) )
{
@@ -509,16 +529,19 @@
return ret;
}
+
+
///////////////////////////////////////////////////////////////////
//
//
// METHOD NAME : NCTree::deleteAllItems
// METHOD TYPE : void
//
-// DESCRIPTION : cleares the table and the lists holding
+// DESCRIPTION : clears the table and the lists holding
// the values
//
-void NCTree::deleteAllItems() {
+void NCTree::deleteAllItems()
+{
YTree::deleteAllItems();
myPad()->ClearTable();
}
Modified: trunk/ncurses/src/NCTree.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/ncurses/src/NCTree.h?rev=45280&r1=45279&r2=45280&view=diff
==============================================================================
--- trunk/ncurses/src/NCTree.h (original)
+++ trunk/ncurses/src/NCTree.h Fri Mar 7 13:03:42 2008
@@ -13,7 +13,6 @@
File: NCTree.h
Author: Michael Andres
- Maintainer: Michael Andres
/-*/
#ifndef NCTree_h
@@ -27,23 +26,19 @@
class NCTreeLine;
-///////////////////////////////////////////////////////////////////
-//
-// CLASS NAME : NCTree
-//
-// DESCRIPTION :
-//
-class NCTree : public YTree, public NCPadWidget {
- friend std::ostream & operator<<( std::ostream & STREAM, const NCTree & OBJ );
+class NCTree : public YTree, public NCPadWidget
+{
- NCTree & operator=( const NCTree & );
- NCTree ( const NCTree & );
+ friend std::ostream & operator<<( std::ostream & STREAM, const NCTree & OBJ );
- private:
- void Dit( NCTreeLine * p, NCTreePad * pad, YTreeItem * item );
+ NCTree & operator=( const NCTree & );
+ NCTree ( const NCTree & );
+
+private:
+ void CreateTreeLines( NCTreeLine * p, NCTreePad * pad, YItem * item );
- protected:
+protected:
virtual NCTreePad * myPad () const
{ return dynamic_cast ( NCPadWidget::myPad () ); }
@@ -51,19 +46,19 @@
const NCTreeLine * getTreeLine( unsigned idx ) const;
NCTreeLine * modifyTreeLine( unsigned idx );
- protected:
+protected:
virtual const char * location() const { return "NCTree"; }
virtual NCPad * CreatePad();
virtual void DrawPad();
- protected:
+protected:
virtual void startMultipleChanges() { startMultidraw(); }
virtual void doneMultipleChanges() { stopMultidraw(); }
- public:
+public:
NCTree( YWidget * parent, const string & label );
virtual ~NCTree();
@@ -81,7 +76,7 @@
virtual void setLabel( const string & nlabel );
virtual void rebuildTree();
- virtual const YTreeItem * getCurrentItem() const;
+ virtual YTreeItem * getCurrentItem() const;
virtual void selectItem( YItem *item, bool selected );
virtual void selectItem( int index );
@@ -90,15 +85,15 @@
virtual void setEnabled( bool do_bv );
- virtual bool setKeyboardFocus() {
- if ( !grabFocus() )
- return YWidget::setKeyboardFocus();
- return true;
+ virtual bool setKeyboardFocus()
+ {
+ if ( !grabFocus() )
+ return YWidget::setKeyboardFocus();
+ return true;
}
void deleteAllItems();
};
-///////////////////////////////////////////////////////////////////
#endif // NCTree_h
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org