[yast-commit] r55342 - in /trunk/ncurses/src: NCFileSelection.cc NCFileSelection.h
Author: gs Date: Mon Feb 9 13:08:54 2009 New Revision: 55342 URL: http://svn.opensuse.org/viewcvs/yast?rev=55342&view=rev Log: correct references to YTableItem (addLine()/ getTag()), NCFileSelectionTag derived from YTableCell Modified: trunk/ncurses/src/NCFileSelection.cc trunk/ncurses/src/NCFileSelection.h Modified: trunk/ncurses/src/NCFileSelection.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/ncurses/src/NCFileSelection.cc?rev=55342&r1=55341&r2=55342&view=diff ============================================================================== --- trunk/ncurses/src/NCFileSelection.cc (original) +++ trunk/ncurses/src/NCFileSelection.cc Mon Feb 9 13:08:54 2009 @@ -140,26 +140,21 @@ } -NCFileSelectionTag::NCFileSelectionTag( const NCFileInfo & info ) - : NCTableCol( NCstring( " " ), SEPARATOR ) +NCFileSelectionTag::NCFileSelectionTag( NCFileInfo * info ) + : YTableCell( " " ) , fileInfo( info ) { - + setLabel( fileInfo->_tag ); } - -void NCFileSelectionTag::DrawAt( NCursesWindow & w, const wrect at, - NCTableStyle & tableStyle, - NCTableLine::STATE linestate, - unsigned colidx ) const +NCFileSelectionTag::~NCFileSelectionTag() { - NCTableCol::DrawAt( w, at, tableStyle, linestate, colidx ); - - w.addch( at.Pos.L, at.Pos.C, fileInfo._tag.c_str()[0] ); - w.addch( at.Pos.L, at.Pos.C + 1, fileInfo._tag.c_str()[1] ); + if ( fileInfo ) + { + delete fileInfo; + } } - NCFileSelection::NCFileSelection( YWidget * parent, YTableHeader * tableHeader, NCFileSelectionType type, @@ -214,8 +209,8 @@ if ( index != -1 ) { - NCFileInfo info = getFileInfo( index ); - return info._name; + NCFileInfo * info = getFileInfo( index ); + return info->_name; } else { @@ -227,7 +222,7 @@ void NCFileSelection::setCurrentDir() { string selected = getCurrentLine(); - yuiMilestone() << "Current line: " << selected << endl; + yuiMilestone() << "Current directory: " << selected << endl; if ( selected != ".." ) { @@ -257,20 +252,18 @@ void NCFileSelection::addLine( const vector<string> & elements, - const NCFileInfo & info ) + NCFileInfo * info ) { - vector<NCTableCol*> Items( elements.size() + 1, 0 ); + YTableItem *tabItem = new YTableItem(); - // fill first column (containing the file information) - Items[0] = new NCFileSelectionTag( info ); + tabItem->addCell( new NCFileSelectionTag( info ) ); - for ( unsigned i = 1; i < elements.size() + 1; ++i ) - { - // use NCstring to enforce recoding from 'utf8' - Items[i] = new NCTableCol( NCstring( elements[i-1] ), NCTableCol::PLAIN ); + for ( unsigned i = 1; i < elements.size()+1; ++i ) { + tabItem->addCell( elements[i-1] ); } - myPad()->Append( Items ); + // use all-at-once insertion mode - DrawPad() is called only after the loop + addItem(tabItem, true); } @@ -280,7 +273,7 @@ } -bool NCFileTable::createListEntry( const NCFileInfo & fileInfo ) +bool NCFileTable::createListEntry( NCFileInfo * fileInfo ) { vector<string> data; @@ -289,23 +282,21 @@ case T_Overview: { data.reserve( 2 ); - data.push_back( fileInfo._name ); + data.push_back( fileInfo->_name ); break; } - case T_Detailed: { data.reserve( 6 ); - data.push_back( fileInfo._name ); + data.push_back( fileInfo->_name ); char size_buf[50]; - sprintf( size_buf, "%lld", fileInfo._size ); + sprintf( size_buf, "%lld", fileInfo->_size ); data.push_back( size_buf ); - data.push_back( fileInfo._perm ); - data.push_back( fileInfo._user ); - data.push_back( fileInfo._group ); + data.push_back( fileInfo->_perm ); + data.push_back( fileInfo->_user ); + data.push_back( fileInfo->_group ); break; } - default: { data.reserve( 2 ); @@ -321,7 +312,7 @@ } -bool NCDirectoryTable::createListEntry( const NCFileInfo & fileInfo ) +bool NCDirectoryTable::createListEntry( NCFileInfo * fileInfo ) { vector<string> data; @@ -330,20 +321,18 @@ case T_Overview: { data.reserve( 2 ); - data.push_back( fileInfo._name ); + data.push_back( fileInfo->_name ); break; } - case T_Detailed: { data.reserve( 4 ); - data.push_back( fileInfo._name ); - data.push_back( fileInfo._perm ); - data.push_back( fileInfo._user ); - data.push_back( fileInfo._group ); + data.push_back( fileInfo->_name ); + data.push_back( fileInfo->_perm ); + data.push_back( fileInfo->_user ); + data.push_back( fileInfo->_group ); break; } - default: { data.reserve( 2 ); @@ -359,13 +348,13 @@ } -NCFileInfo NCFileSelection::getFileInfo( int index ) +NCFileInfo * NCFileSelection::getFileInfo( int index ) { // get the tag NCFileSelectionTag *cc = getTag( index ); if ( !cc ) - return NCFileInfo( ); + return 0; return cc->getFileInfo(); } @@ -380,8 +369,10 @@ return 0; // get first column (the column containing the status info) - NCFileSelectionTag * cc = static_cast<NCFileSelectionTag *>( cl->GetCol( 0 ) ); - + YTableItem *it = dynamic_cast<YTableItem*> (cl->origItem() ); + YTableCell *tcell = it->cell(0); + NCFileSelectionTag * cc = static_cast<NCFileSelectionTag *>( tcell ); + return cc; } @@ -593,7 +584,7 @@ if ((( *it ) == ".." && currentDir != "/" ) || ( *it ) != ".." ) { - createListEntry( NCFileInfo(( *it ), &statInfo ) ); + createListEntry( new NCFileInfo(( *it ), &statInfo ) ); } } else if ( S_ISLNK( statInfo.st_mode ) ) @@ -602,7 +593,7 @@ { if ( S_ISREG( linkInfo.st_mode ) ) { - createListEntry( NCFileInfo(( *it ), &linkInfo, true ) ); + createListEntry( new NCFileInfo(( *it ), &linkInfo, true ) ); } } } @@ -731,7 +722,7 @@ if ((( *it ) == ".." && currentDir != "/" ) || ( *it ) != ".." ) { - createListEntry( NCFileInfo(( *it ), &statInfo ) ); + createListEntry( new NCFileInfo(( *it ), &statInfo ) ); } } else if ( S_ISLNK( statInfo.st_mode ) ) @@ -740,7 +731,7 @@ { if ( S_ISDIR( linkInfo.st_mode ) ) { - createListEntry( NCFileInfo(( *it ), &linkInfo, true ) ); + createListEntry( new NCFileInfo(( *it ), &linkInfo, true ) ); } } } Modified: trunk/ncurses/src/NCFileSelection.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/ncurses/src/NCFileSelection.h?rev=55342&r1=55341&r2=55342&view=diff ============================================================================== --- trunk/ncurses/src/NCFileSelection.h (original) +++ trunk/ncurses/src/NCFileSelection.h Mon Feb 9 13:08:54 2009 @@ -74,25 +74,20 @@ * This class is used for the first column of the file table. * Contains the file data. **/ -class NCFileSelectionTag : public NCTableCol +class NCFileSelectionTag : public YTableCell { private: - NCFileInfo fileInfo; + NCFileInfo * fileInfo; public: - NCFileSelectionTag( const NCFileInfo & info ); + NCFileSelectionTag( NCFileInfo * info ); - virtual ~NCFileSelectionTag() {} + ~NCFileSelectionTag(); - virtual void DrawAt( NCursesWindow & w, const wrect at, - NCTableStyle & tableStyle, - NCTableLine::STATE linestate, - unsigned colidx ) const; - - NCFileInfo getFileInfo() const { return fileInfo; } + NCFileInfo * getFileInfo() const { return fileInfo; } }; @@ -146,7 +141,7 @@ * index: The list index * return: fileInfo Information about the file (directory) */ - NCFileInfo getFileInfo( int index ); + NCFileInfo * getFileInfo( int index ); /** * Set the type of the table widget @@ -155,7 +150,7 @@ void setTableType( NCFileSelectionType type ) { tableType = type; }; virtual void addLine( const vector<string> & elements, - const NCFileInfo & fileInfo ); + NCFileInfo * fileInfo ); /** * Get number of lines ( list entries ) @@ -181,7 +176,7 @@ /** * Creates a line in the package table. */ - virtual bool createListEntry( const NCFileInfo & fileInfo ) = 0; + virtual bool createListEntry( NCFileInfo * fileInfo ) = 0; /** * Get the current directory @@ -238,7 +233,7 @@ virtual void fillHeader(); - virtual bool createListEntry( const NCFileInfo & fileInfo ); + virtual bool createListEntry( NCFileInfo * fileInfo ); /** * Fill the list of files @@ -262,7 +257,7 @@ virtual void fillHeader(); - virtual bool createListEntry( const NCFileInfo & fileInfo ); + virtual bool createListEntry( NCFileInfo * fileInfo ); /** * Fill the list of directories. -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
gs@svn.opensuse.org