Author: kmachalkova
Date: Tue Jan 6 11:09:35 2009
New Revision: 54389
URL: http://svn.opensuse.org/viewcvs/yast?rev=54389&view=rev
Log:
Fixed crash after pressing some keys handled by
parent class - PkgTable items did not contain
correct references to YTableItems (I wonder how
it might have worked so far :)) (#462961)
Modified:
trunk/ncurses-pkg/src/NCPkgTable.cc
trunk/ncurses-pkg/src/NCPkgTable.h
Modified: trunk/ncurses-pkg/src/NCPkgTable.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/ncurses-pkg/src/NCPkgTable.cc?rev=54389&r1=54388&r2=54389&view=diff
==============================================================================
--- trunk/ncurses-pkg/src/NCPkgTable.cc (original)
+++ trunk/ncurses-pkg/src/NCPkgTable.cc Tue Jan 6 11:09:35 2009
@@ -43,38 +43,15 @@
//
NCPkgTableTag::NCPkgTableTag( ZyppObj objPtr, ZyppSel selPtr,
ZyppStatus stat )
- : NCTableCol( NCstring( " " ), SEPARATOR )
+ : YTableCell( " " )
, status ( stat )
, dataPointer( objPtr )
, selPointer( selPtr )
{
-
-}
-
-///////////////////////////////////////////////////////////////////
-//
-//
-// METHOD NAME : NCPkgTableTag::DrawAt
-// METHOD TYPE : virtual DrawAt
-//
-// DESCRIPTION :
-//
-void NCPkgTableTag::DrawAt( NCursesWindow & w, const wrect at,
- NCTableStyle & tableStyle,
- NCTableLine::STATE linestate,
- unsigned colidx ) const
-{
- NCTableCol::DrawAt( w, at, tableStyle, linestate, colidx );
-
- string statusStr = statusToStr( status );
- w.addch( at.Pos.L, at.Pos.C, statusStr.c_str()[0] );
- w.addch( at.Pos.L, at.Pos.C +1, statusStr.c_str()[1] );
- w.addch( at.Pos.L, at.Pos.C +2, statusStr.c_str()[2] );
- w.addch( at.Pos.L, at.Pos.C +3, statusStr.c_str()[3] );
+ setLabel( statusToString(stat) );
}
-
-string NCPkgTableTag::statusToStr( ZyppStatus stat ) const
+string NCPkgTableTag::statusToString( ZyppStatus stat ) const
{
// convert ZyppStatus to string
switch ( stat )
@@ -156,16 +133,18 @@
ZyppObj objPtr,
ZyppSel slbPtr )
{
- vector Items( elements.size()+1, 0 );
+ YTableItem *tabItem = new YTableItem();
// fill first column (containing the status information and the package pointers)
- Items[0] = new NCPkgTableTag( objPtr, slbPtr, stat );
+ tabItem->addCell( new NCPkgTableTag( objPtr, slbPtr, stat ));
+
for ( unsigned i = 1; i < elements.size()+1; ++i ) {
- // NCTableCol has NCstring argument to enforce 'utf8' encoding
- Items[i] = new NCTableCol( elements[i-1] );
+ tabItem->addCell( elements[i-1] );
}
- myPad()->Append( Items );
+
+ addItem(tabItem);
+ yuiMilestone() << "adding line" << endl;
// don't call DrawPad(); for every line - is called once after the loop
@@ -392,7 +371,9 @@
}
// get first column (the column containing the status info)
- NCPkgTableTag * cc = static_cast( cl->GetCol( 0 ) );
+ YTableItem *it = dynamic_cast (cl->origItem() );
+ YTableCell *tcell = it->cell(0);
+ NCPkgTableTag * cc = static_cast( tcell );
// get the object pointer
ZyppSel slbPtr = getSelPointer( index );
ZyppObj objPtr = getDataPointer( index );
@@ -422,7 +403,9 @@
// set new status (if status has changed)
if ( getStatus(index) != newstatus )
{
+ int index = getCurrentItem();
cc->setStatus( newstatus );
+ cellChanged( index, 0, cc->statusToString (newstatus) );
}
}
}
@@ -875,7 +858,9 @@
return 0;
// get first column (the column containing the status info)
- NCPkgTableTag * cc = static_cast( cl->GetCol( 0 ) );
+ YTableItem *it = dynamic_cast (cl->origItem() );
+ YTableCell *tcell = it->cell(0);
+ NCPkgTableTag * cc = static_cast( tcell );
return cc;
}
Modified: trunk/ncurses-pkg/src/NCPkgTable.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/ncurses-pkg/src/NCPkgTable.h?rev=54389&r1=54388&r2=54389&view=diff
==============================================================================
--- trunk/ncurses-pkg/src/NCPkgTable.h (original)
+++ trunk/ncurses-pkg/src/NCPkgTable.h Tue Jan 6 11:09:35 2009
@@ -41,7 +41,7 @@
* not installed, to be deleted and so on).
*
**/
-class NCPkgTableTag : public NCTableCol {
+class NCPkgTableTag : public YTableCell {
private:
@@ -49,9 +49,6 @@
ZyppObj dataPointer;
// cannot get at it from dataPointer
ZyppSel selPointer;
-
- // returns the corresponding string value to given package status
- string statusToStr( ZyppStatus stat ) const;
public:
@@ -59,15 +56,13 @@
ZyppSel selPtr,
ZyppStatus stat = S_NoInst );
- virtual ~NCPkgTableTag() {}
-
- virtual void DrawAt( NCursesWindow & w, const wrect at,
- NCTableStyle & tableStyle,
- NCTableLine::STATE linestate,
- unsigned colidx ) const;
+ ~NCPkgTableTag() {}
- void setStatus( ZyppStatus stat ) { status = stat; }
+ void setStatus( ZyppStatus stat ) { status = stat; }
ZyppStatus getStatus() const { return status; }
+ // returns the corresponding string value to given package status
+ string statusToString( ZyppStatus stat ) const;
+
ZyppObj getDataPointer() const { return dataPointer; }
ZyppSel getSelPointer() const { return selPointer; }
};
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org