libyui-ncurses  2.57.2
NCTable.cc
1 /*
2  Copyright (C) 2000-2012 Novell, Inc
3  Copyright (C) 2020 SUSE LLC
4  This library is free software; you can redistribute it and/or modify
5  it under the terms of the GNU Lesser General Public License as
6  published by the Free Software Foundation; either version 2.1 of the
7  License, or (at your option) version 3.0 of the License. This library
8  is distributed in the hope that it will be useful, but WITHOUT ANY
9  WARRANTY; without even the implied warranty of MERCHANTABILITY or
10  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
11  License for more details. You should have received a copy of the GNU
12  Lesser General Public License along with this library; if not, write
13  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
14  Floor, Boston, MA 02110-1301 USA
15 */
16 
17 
18 /*-/
19 
20  File: NCTable.cc
21 
22  Authors: Michael Andres <ma@suse.de>
23  Stefan Hundhammer <shundhammer@suse.de>
24 
25 /-*/
26 
27 #define YUILogComponent "ncurses"
28 #include <yui/YUILog.h>
29 #include "NCTable.h"
30 #include "NCPopupMenu.h"
31 
32 #include <yui/YMenuButton.h>
33 #include <yui/YTypes.h>
34 
35 using std::string;
36 using std::vector;
37 using std::endl;
38 
39 
40 /*
41  * Some remarks about single/multi selection:
42  *
43  * A table in single selection mode has only one line/item selected which is
44  * equal to the current item (means the highlighted line). Querying CurrentItem
45  * in YCP looks for selectedItem()
46  * (see YCPPropertyHandler::tryGetSelectionWidgetValue).
47  *
48  * In multi selection mode there can be several items selected (here is means
49  * checked/marked with [x]) and the value is also got from selectedItem() when
50  * asking for `SelectedItems
51  * (see YCPPropertyHandler::tryGetSelectionWidgetValue).
52  *
53  * This means for multi selection mode: at the moment there isn't a possibility
54  * to get the CurrentItem. To get the current item (which line of the list is
55  * currently highlighted), a virtual function currentItem() like available for
56  * the MultiSelectionBox has to be provided to allow NCTable to specify the
57  * line number itself (getCurrentItem).
58  */
59 NCTable::NCTable( YWidget * parent,
60  YTableHeader * tableHeader,
61  bool multiSelection )
62  : YTable( parent, tableHeader, multiSelection )
63  , NCPadWidget( parent )
64  , _prefixCols( 0 )
65  , _nestedItems( false )
66  , _bigList( false )
67  , _multiSelect( multiSelection )
68  , _lastSortCol( 0 )
69  , _sortReverse( false )
70  , _sortStrategy( new NCTableSortDefault() )
71 {
72  // yuiDebug() << endl;
73 
74  InitPad();
75  rebuildHeaderLine();
76 }
77 
78 
79 NCTable::~NCTable()
80 {
81  if ( _sortStrategy )
82  delete _sortStrategy;
83 }
84 
85 
87 {
88  _prefixCols = 0;
89 
90  if ( _multiSelect )
91  ++_prefixCols;
92 
93  vector<NCstring> headers;
94  headers.resize( _prefixCols + columns() );
95 
96  for ( int i = 0; i < columns(); i++ )
97  {
98  int col = i + _prefixCols;
99 
100  if ( hasColumn( i ) )
101  {
102  NCstring hdr( alignmentStr( i ) );
103  hdr += header( i );
104  // yuiDebug() << "hdr[" << col << "]: \"" << hdr << "\"" << endl;
105  headers[ col ] = hdr;
106  }
107  }
108 
109  hasHeadline = myPad()->SetHeadline( headers );
110 }
111 
112 
114 {
115  switch ( alignment( col ) )
116  {
117  case YAlignUnchanged: return "L";
118  case YAlignBegin: return "L";
119  case YAlignCenter: return "C";
120  case YAlignEnd: return "R";
121 
122  // No 'default' branch: Let the compiler complain if there is an unhandled enum value.
123  }
124 
125  return "L";
126 }
127 
128 
129 void NCTable::setCell( int index, int col, const string & newtext )
130 {
131  NCTableLine * currentLine = myPad()->ModifyLine( index );
132 
133  if ( !currentLine )
134  {
135  yuiWarning() << "No such line: " << wpos( index, col ) << newtext << endl;
136  }
137  else
138  {
139  NCTableCol * currentCol = currentLine->GetCol( col );
140 
141  if ( !currentCol )
142  {
143  yuiWarning() << "No such col: " << wpos( index, col ) << newtext << endl;
144  }
145  else
146  {
147  // use NCtring to enforce recoding from UTF-8
148  currentCol->SetLabel( NCstring( newtext ) );
149  DrawPad();
150  }
151  }
152 }
153 
154 
155 void NCTable::cellChanged( const YTableCell * changedCell )
156 {
157  YUI_CHECK_PTR( changedCell );
158 
159  YTableItem * ytableItem = changedCell->parent();
160  YUI_CHECK_PTR( ytableItem );
161 
162  NCTableLine * tableLine = (NCTableLine *) ytableItem->data();
163  YUI_CHECK_PTR( tableLine );
164 
165  NCTableCol * tableCol = tableLine->GetCol( changedCell->column() );
166 
167  if ( tableCol )
168  {
169  tableCol->SetLabel( changedCell->label() );
170  DrawPad();
171  }
172  else
173  {
174  yuiError() << "No column #" << changedCell->column()
175  << " in item " << ytableItem
176  << endl;
177  }
178 }
179 
180 
181 void NCTable::setHeader( const vector<string> & headers )
182 {
183  YTableHeader * tableHeader = new YTableHeader();
184 
185  for ( unsigned i = 0; i < headers.size(); i++ )
186  {
187  tableHeader->addColumn( headers[ i ] );
188  }
189 
190  YTable::setTableHeader( tableHeader );
191  rebuildHeaderLine();
192 }
193 
194 
195 vector<string>
197 {
198  vector<string> headers;
199  headers.resize( columns() );
200 
201  for ( int col = 0; col < columns(); col++ )
202  {
203  headers[ col ] = header( col );
204  }
205 
206  return headers;
207 }
208 
209 
210 void NCTable::addItems( const YItemCollection & itemCollection )
211 {
212  myPad()->ClearTable();
213  YTable::addItems( itemCollection );
214 
215  if ( keepSorting() )
216  {
217  rebuildPadLines();
218  }
219  else
220  {
221  sortItems( _lastSortCol, _sortReverse );
222  // this includes rebuildPadLInes()
223  }
224 
225  if ( !_multiSelect )
226  selectCurrentItem();
227 
228  DrawPad();
229 }
230 
231 
232 void NCTable::addItem( YItem * yitem,
233  NCTableLine::STATE state )
234 {
235  if ( ! yitem->parent() ) // Only for toplevel items:
236  YTable::addItem( yitem ); // Notify the YTable base class
237 
238  addPadLine( 0, // parentLine
239  yitem,
240  false, // preventRedraw
241  state );
242 }
243 
244 
245 void NCTable::addItem( YItem * yitem,
246  bool preventRedraw,
247  NCTableLine::STATE state )
248 {
249  if ( ! yitem->parent() ) // Only for toplevel items:
250  YTable::addItem( yitem ); // Notify the YTable base class
251 
252  addPadLine( 0, // parentLine
253  yitem,
254  preventRedraw,
255  state );
256 }
257 
258 
259 void NCTable::addPadLine( NCTableLine * parentLine,
260  YItem * yitem,
261  bool preventRedraw,
262  NCTableLine::STATE state )
263 {
264  YTableItem *item = dynamic_cast<YTableItem *>( yitem );
265  YUI_CHECK_PTR( item );
266 
267  // Ideally, _nestedItems should be updated by iterating over ALL items
268  // before the first NCTableLine is created (i.e. before the first
269  // addPadLine() call) so they all get the proper prefix placeholder for
270  // reserving some screen space for the tree line graphics.
271  //
272  // This additional check is just a second line of defence.
273 
274  if ( parentLine || item->hasChildren() )
275  _nestedItems = true;
276 
277  vector<NCTableCol*> cells;
278 
279  if ( _multiSelect )
280  {
281  // Add a table tag to hold the "[ ]" / "[x]" marker.
282  cells.push_back( new NCTableTag( yitem, yitem->selected() ) );
283  }
284 
285  // Add all the cells
286  for ( YTableCellIterator it = item->cellsBegin(); it != item->cellsEnd(); ++it )
287  cells.push_back( new NCTableCol( NCstring(( *it )->label() ) ) );
288 
289  int index = myPad()->Lines();
290  item->setIndex( index );
291 
292  // yuiMilestone() << "Adding pad line for " << item << " index: " << item->index() << endl;
293 
294 
295  // Create the line itself
296  NCTableLine *line = new NCTableLine( parentLine,
297  item,
298  cells,
299  index,
300  _nestedItems,
301  state );
302  YUI_CHECK_NEW( line );
303  myPad()->Append( line );
304 
305  if ( item->selected() )
306  setCurrentItem( item->index() ) ;
307 
308  // Recurse over children (if there are any)
309 
310  for ( YItemIterator it = item->childrenBegin(); it != item->childrenEnd(); ++it )
311  {
312  addPadLine( line, *it, preventRedraw, state );
313  }
314 
315  if ( ! preventRedraw )
316  DrawPad();
317 }
318 
319 
321 {
322  myPad()->ClearTable();
323  _nestedItems = hasNestedItems( itemsBegin(), itemsEnd() );
324 
325  for ( YItemConstIterator it = itemsBegin(); it != itemsEnd(); ++it )
326  {
327  addPadLine( 0, // parentLine
328  *it,
329  true ); // preventRedraw
330  }
331 }
332 
333 
334 bool NCTable::hasNestedItems( const YItemCollection & itemCollection ) const
335 {
336  return hasNestedItems( itemCollection.begin(), itemCollection.end() );
337 }
338 
339 
340 bool NCTable::hasNestedItems( YItemConstIterator begin,
341  YItemConstIterator end ) const
342 {
343  for ( YItemConstIterator it = begin; it != end; ++it )
344  {
345  if ( (*it)->hasChildren() )
346  return true;
347  }
348 
349  return false;
350 }
351 
352 
354 {
355  myPad()->ClearTable();
356  YTable::deleteAllItems();
357  DrawPad();
358 
359  _nestedItems = false;
360  _lastSortCol = 0;
361  _sortReverse = false;
362 }
363 
364 
366 {
367  if ( myPad()->empty() )
368  return -1;
369 
370  // The intent of this condition is to return the original index, before
371  // sorting. But the condition was accidentally inverted in 2007 and now it
372  // always returns the index after sorting.
373  // Should we fix it? Depends on whether the current users rely on the
374  // current behavior.
375 
376  return keepSorting() ? getCurrentIndex() : myPad()->CurPos().L;
377 }
378 
379 
381 {
382  const NCTableLine * currentLine = myPad()->GetCurrentLine();
383 
384  if ( currentLine )
385  return currentLine->origItem();
386  else
387  return 0;
388 }
389 
390 
392 {
393  const NCTableLine * currentLine = myPad()->GetCurrentLine();
394 
395  return currentLine ? currentLine->index() : -1;
396 }
397 
398 
400 {
401  if ( myPad()->empty() )
402  myPad()->ScrlLine( 0 );
403 }
404 
405 
406 void NCTable::setCurrentItem( int index )
407 {
408  myPad()->ScrlLine( index );
409 }
410 
411 
412 void NCTable::selectItem( YItem *yitem, bool selected )
413 {
414  if ( ! yitem )
415  return;
416 
417  YTableItem *item = dynamic_cast<YTableItem *>( yitem );
418  YUI_CHECK_PTR( item );
419 
420  NCTableLine *line = (NCTableLine *) item->data();
421  YUI_CHECK_PTR( line );
422 
423  const NCTableLine *current_line = myPad()->GetLine( myPad()->CurPos().L );
424  YUI_CHECK_PTR( current_line );
425 
426  if ( !_multiSelect )
427  {
428  if ( !selected && ( line == current_line ) )
429  {
430  deselectAllItems();
431  }
432  else
433  {
434  // first highlight only, then select
435  setCurrentItem( line->index() );
436  YTable::selectItem( item, selected );
437  }
438  }
439  else // multiSelect
440  {
441  YTable::selectItem( item, selected );
442 
443  // yuiDebug() << item->label() << " is selected: " << std::boolalpha << selected << endl;
444 
445  // The NCTableTag holds the "[ ]" / "[x]" selection marker
446  NCTableTag * tagCell = line->tagCell();
447 
448  if ( tagCell )
449  tagCell->SetSelected( selected );
450  }
451 
452  DrawPad();
453 }
454 
455 
456 
457 /**
458  * Mark the currently highlighted table item as selected.
459  *
460  * Yes, it is really already highlighted, so no need to selectItem() and
461  * setCurrentItem() here again. (bsc#493884)
462  **/
464 {
465  const NCTableLine * currentLine = myPad()->GetCurrentLine();
466 
467  if ( currentLine )
468  YTable::selectItem( currentLine->origItem(), true );
469 }
470 
471 
473 {
474  if ( !_multiSelect )
475  {
476  setCurrentItem( -1 );
477  YTable::deselectAllItems();
478  }
479  else
480  {
481  YItemCollection itemCollection = YTable::selectedItems();
482  // This will return nested selected items as well
483 
484  for ( YItemConstIterator it = itemCollection.begin();
485  it != itemCollection.end();
486  ++it )
487  {
488  // Clear the item's internal selected status flag
489  // and update the "[x]" marker on the screen to "[ ]"
490  // in the corresponding NCTableTag
491 
492  selectItem( *it, false );
493  }
494  }
495 
496  DrawPad();
497 }
498 
499 
501 {
502  wsze sze = _bigList ? myPad()->tableSize() + 2 : wGetDefsze();
503  return sze.W;
504 }
505 
506 
508 {
509  wsze sze = _bigList ? myPad()->tableSize() + 2 : wGetDefsze();
510  return sze.H;
511 }
512 
513 
514 void NCTable::setSize( int newwidth, int newheight )
515 {
516  wRelocate( wpos( 0 ), wsze( newheight, newwidth ) );
517 }
518 
519 
520 void NCTable::setLabel( const string & nlabel )
521 {
522  // not implemented: YTable::setLabel( nlabel );
523  NCPadWidget::setLabel( NCstring( nlabel ) );
524 }
525 
526 
527 void NCTable::setEnabled( bool do_bv )
528 {
529  NCWidget::setEnabled( do_bv );
530  YTable::setEnabled( do_bv );
531 }
532 
533 
534 bool NCTable::setItemByKey( int key )
535 {
536  return myPad()->setItemByKey( key );
537 }
538 
539 
541 {
542  wsze psze( defPadSze() );
543  NCPad * npad = new NCTablePad( psze.H, psze.W, *this );
544  npad->bkgd( listStyle().item.plain );
545 
546  return npad;
547 }
548 
549 
550 /**
551  * NCurses widget keyboard handler.
552  *
553  * This is the starting point for handling key events. From here, key events
554  * are propagated to the pad and to the items.
555  **/
557 {
558  NCursesEvent ret = NCursesEvent::none;
559  bool sendEvent = false;
560  int currentIndex = getCurrentItem();
561 
562  // Call the pad's input handler via NCPadWidget::handleInput()
563  // which calls its pad class's input handler
564  // which may call the current item's input handler.
565  //
566  // Notice that most keys are handled on the level of the pad or the item,
567  // not here. See
568  //
569  // - NCTablePad::handleInput()
570  // - NCTablePadBase::handleInput()
571  // - NCTableLine::handleInput()
572 
573  bool handled = handleInput( key ); // NCTablePad::handleInput()
574 
575  switch ( key )
576  {
577  case CTRL( 'o' ): // Table sorting (Ordering)
578  if ( ! handled )
579  {
580  if ( ! keepSorting() )
581  {
582  interactiveSort();
583  return NCursesEvent::none;
584  }
585  }
586  break;
587 
588 
589  // Even if the event was already handled:
590  // Take care about sending UI events to the caller.
591 
592  case KEY_RETURN:
593 
594  sendEvent = true;
595 
596  if ( _multiSelect)
597  {
598  toggleCurrentItem();
599 
600  // Send ValueChanged on Return (like done for NCTree multiSelection)
601 
602  if ( notify() && sendEvent )
603  return NCursesEvent::ValueChanged;
604  }
605  // FALLTHRU
606 
607  case KEY_SPACE:
608 
609  if ( !_multiSelect )
610  {
611  if ( notify() && currentIndex != -1 )
612  return NCursesEvent::Activated;
613  }
614  break;
615  }
616 
617  if ( currentIndex != getCurrentItem() )
618  {
619  if ( notify() && immediateMode() )
620  ret = NCursesEvent::SelectionChanged;
621 
622  if ( !_multiSelect )
623  selectCurrentItem();
624  }
625 
626  return ret;
627 }
628 
629 
631 {
632  YTableItem * item = dynamic_cast<YTableItem *>( getCurrentItemPointer() );
633 
634  if ( item )
635  selectItem( item, !( item->selected() ) );
636 }
637 
638 
640 {
641  //
642  // Collect the non-empty column headers
643  //
644 
645  YItemCollection menuItems;
646  menuItems.reserve( columns() );
647 
648  for ( int col = 0; col < columns(); col++ )
649  {
650  string hdr = header( col );
651 
652  if ( ! hdr.empty() )
653  {
654  YMenuItem *item = new YMenuItem( header( col ) ) ;
655 
656  // need to set the index explicitly, YMenuItem inherits from YTreeItem
657  // and these don't have indexes set
658  item->setIndex( col );
659  menuItems.push_back( item );
660  }
661  }
662 
663  if ( ! menuItems.empty() )
664  {
665  //
666  // Post a popup with the column headers
667  //
668 
669  // Get the column; show the popup in the table's upper left corner
670  wpos pos( ScreenPos() + wpos( 2, 1 ) );
671 
672  NCPopupMenu *dialog = new NCPopupMenu( pos, menuItems.begin(), menuItems.end() );
673  int sortCol = dialog->post();
674 
675  // close the popup
676  YDialog::deleteTopmostDialog();
677 
678  if ( sortCol != -1 && hasColumn( sortCol ) )
679  {
680  //
681  // Do the sorting
682  //
683 
684  yuiDebug() << "Manually sorting by column #"
685  << sortCol << ": " << header( sortCol )
686  << endl;
687 
688  _sortReverse = sortCol == _lastSortCol ?
689  ! _sortReverse : false;
690 
691  sortItems( sortCol, _sortReverse );
692 
693  if ( !_multiSelect )
694  selectCurrentItem();
695 
696  DrawPad();
697  }
698  }
699 }
700 
701 
702 void NCTable::sortItems( int sortCol, bool reverse )
703 {
704  myPad()->ClearTable();
705 
706  // Sort the YItems.
707  //
708  // This may feel a little weird since those YItems are owned by the
709  // YSelectionWidget parent class. But we are only changing their sort
710  // order, not invalidating any item pointers; and the internal sort order
711  // is not anything that any calling application code may rely on.
712  //
713  // Since the NCTable now supports nested items, we can no longer simply
714  // sort the NCTableLines to keep this whole sorting localized: In the pad,
715  // they are just a flat list, and the hierarchy is not that easy to find
716  // out. But we need the hierarchy to sort each tree level separately in
717  // each branch.
718  //
719  // It is much simpler and less error-prone to just clear the pad (and thus
720  // get rid of any existing NCTableLines), sort the YItems and rebuild all
721  // the NCTableLines from the newly sorted YItems.
722 
723  _sortStrategy->setSortCol( sortCol );
724  _sortStrategy->setReverse( reverse );
725  _lastSortCol = sortCol;
726 
727  sortYItems( itemsBegin(), itemsEnd() );
728 
729  rebuildPadLines();
730 }
731 
732 
733 void NCTable::sortYItems( YItemIterator begin,
734  YItemIterator end )
735 {
736  // Sort the children first as long as the iterators are
737  // guaranteed to be valid
738 
739  for ( YItemIterator it = begin; it != end; ++it )
740  {
741  if ( (*it)->hasChildren() )
742  sortYItems( (*it)->childrenBegin(), (*it)->childrenEnd() );
743  }
744 
745  // Sort this level. This may make the iterators invalid.
746  _sortStrategy->sort( begin, end );
747 }
748 
749 
751 {
752  if ( _sortStrategy )
753  delete _sortStrategy;
754 
755  _sortStrategy = newStrategy;
756 }
757 
wsze
Screen dimension (screen size) in the order height, width: (H, W)
Definition: position.h:154
NCstring
A string with an optional hot key.
Definition: NCstring.h:36
NCTableCol
One cell in an NCTableLine with a label and a cell-specific style.
Definition: NCTableItem.h:422
NCTable::selectCurrentItem
void selectCurrentItem()
Select the current item (the item under the cursor).
Definition: NCTable.cc:463
NCTable::sortItems
void sortItems(int sortCol, bool reverse=false)
Sort the items by column no.
Definition: NCTable.cc:702
NCTable::setSortStrategy
void setSortStrategy(NCTableSortStrategyBase *newStrategy)
Set a sorting strategy.
Definition: NCTable.cc:750
NCWidget::setEnabled
virtual void setEnabled(bool do_bv)=0
Pure virtual to make sure every widget implements it.
Definition: NCWidget.cc:392
NCTable::CreatePad
virtual NCPad * CreatePad()
Create an empty pad and set its background.
Definition: NCTable.cc:540
NCTable::scrollToFirstItem
virtual void scrollToFirstItem()
Scroll to the first item.
Definition: NCTable.cc:399
NCTable::addPadLine
virtual void addPadLine(NCTableLine *parentLine, YItem *yitem, bool preventRedraw, NCTableLine::STATE state=NCTableLine::S_NORMAL)
Add a pad line (an NCTableLine) for 'yitem' and recurse into any of its children (and grandchildren e...
Definition: NCTable.cc:259
NCTable::addItems
virtual void addItems(const YItemCollection &itemCollection)
Add items.
Definition: NCTable.cc:210
NCTablePad
An NCPad for an NCTable.
Definition: NCTablePad.h:62
NCTable::getCurrentIndex
virtual int getCurrentIndex() const
Get the index of the current item (the item under the cursor) or -1 if there is none.
Definition: NCTable.cc:391
NCTable::getHeader
std::vector< std::string > getHeader() const
Get the table headers (the first line inside the table) as strings.
Definition: NCTable.cc:196
NCTableSortStrategyBase
Support classes for sorting by column in a table for use in an NCTablePad.
Definition: NCTableSort.h:36
NCTable::selectItem
virtual void selectItem(YItem *yitem, bool selected)
Select or deselect an item.
Definition: NCTable.cc:412
NCTable::preferredHeight
virtual int preferredHeight()
libyui geometry management: Return the preferred height for this widget.
Definition: NCTable.cc:507
NCTable::alignmentStr
NCstring alignmentStr(int col)
Return the NCurses alignment string for the alignment of the specified column: One of "L",...
Definition: NCTable.cc:113
NCTable::deleteAllItems
virtual void deleteAllItems()
Delete all items and clear the pad.
Definition: NCTable.cc:353
NCTable::getCurrentItemPointer
YItem * getCurrentItemPointer()
Return a pointer to the current item (the item under the cursor) or 0 if there is none,...
Definition: NCTable.cc:380
NCTable::setHeader
void setHeader(const std::vector< std::string > &head)
Set the table header (the first line inside the table) as strings.
Definition: NCTable.cc:181
NCTable::interactiveSort
void interactiveSort()
Interactive sorting by a user-selected column:
Definition: NCTable.cc:639
NCTable::getCurrentItem
virtual int getCurrentItem() const
Get the index of the current item (the item under the cursor) or -1 if there is none,...
Definition: NCTable.cc:365
NCTable::setSize
virtual void setSize(int newWidth, int newHeight)
libyui geometry management: Apply the width and height assigned from the parent layout widget.
Definition: NCTable.cc:514
NCPad
A virtual window with a real viewport (which is NCursesWindow) and a scrolling mechanism.
Definition: NCPad.h:113
NCTable::setEnabled
virtual void setEnabled(bool do_bv)
Enable or disable this widget.
Definition: NCTable.cc:527
NCTable::rebuildPadLines
void rebuildPadLines()
Build or rebuild the pad lines: Clear the pad, iterate over all YItems and add a corresponding NCTabl...
Definition: NCTable.cc:320
NCTable::toggleCurrentItem
void toggleCurrentItem()
Toggle the current item between selected and not selected.
Definition: NCTable.cc:630
NCTableSortDefault
Default sort strategy.
Definition: NCTableSort.h:73
wpos
Screen position pair in the order line, column: (L, C)
Definition: position.h:110
NCTable::rebuildHeaderLine
void rebuildHeaderLine()
Rebuild the table header line.
Definition: NCTable.cc:86
NCTableLine::origItem
YTableItem * origItem() const
Return the YItem this line corresponds to.
Definition: NCTableItem.h:127
NCursesWindow::bkgd
int bkgd(const chtype ch)
Set the background property and apply it to the window.
Definition: ncursesw.h:1445
NCTableLine::index
int index() const
Return the unique index by which this line can be identified.
Definition: NCTableItem.h:137
NCTable::setLabel
virtual void setLabel(const std::string &nlabel)
Set the label (the caption) above the table.
Definition: NCTable.cc:520
NCTableLine::GetCol
NCTableCol * GetCol(unsigned idx)
Return a non-const pointer for read/write operations to the column (the cell) with the specified inde...
Definition: NCTableItem.cc:293
NCTable::cellChanged
void cellChanged(const YTableCell *cell)
Notification that a cell has now changed content: Set that cell's content also in the corresponding t...
Definition: NCTable.cc:155
NCTableLine::tagCell
NCTableTag * tagCell() const
Return the tag cell or 0 if there is none.
Definition: NCTableItem.cc:574
NCTableLine
One line in a NCTable with multiple cells and an optional tree hierarchy.
Definition: NCTableItem.h:68
NCTable::setCurrentItem
virtual void setCurrentItem(int index)
Set the current item to the specified index.
Definition: NCTable.cc:406
NCTable::sortYItems
void sortYItems(YItemIterator begin, YItemIterator end)
Sort the YItems between 'begin' and 'end' using the current sort strategy.
Definition: NCTable.cc:733
NCTable::hasNestedItems
bool hasNestedItems(const YItemCollection &itemCollection) const
Return 'true' if any item in the item collection has any children, 'false' otherwise.
Definition: NCTable.cc:334
NCTable::setCell
void setCell(int index, int col, const std::string &newText)
Change the cell with item index 'index' and column no.
Definition: NCTable.cc:129
NCTable::addItem
virtual void addItem(YItem *yitem)
Add one item.
Definition: NCTable.h:77
NCursesEvent
Definition: NCurses.h:73
NCTable::setItemByKey
bool setItemByKey(int key)
Select an item by its hotkey.
Definition: NCTable.cc:534
NCPadWidget
Base class for widgets with scrollable contents.
Definition: NCPadWidget.h:40
NCTable::deselectAllItems
virtual void deselectAllItems()
Deselect all items.
Definition: NCTable.cc:472
NCTable::preferredWidth
virtual int preferredWidth()
libyui geometry management: Return the preferred width for this widget.
Definition: NCTable.cc:500
NCTableTag
A column (one cell) used as a selection marker: [ ]/[x] or ( )/(x).
Definition: NCTableItem.h:647
NCPopupMenu
Definition: NCPopupMenu.h:33
NCTable::wHandleInput
virtual NCursesEvent wHandleInput(wint_t key)
Keyboard input handler.
Definition: NCTable.cc:556