|
libyui-ncurses
2.57.2
|
A table with rows and columns. More...
#include <NCTable.h>


Public Member Functions | |
| NCTable (YWidget *parent, YTableHeader *tableHeader, bool multiSelection=false) | |
| void | setHeader (const std::vector< std::string > &head) |
| Set the table header (the first line inside the table) as strings. | |
| std::vector< std::string > | getHeader () const |
| Get the table headers (the first line inside the table) as strings. More... | |
| virtual void | addItems (const YItemCollection &itemCollection) |
| Add items. More... | |
| virtual void | addItem (YItem *yitem) |
| Add one item. More... | |
| virtual void | addItem (YItem *yitem, NCTableLine::STATE state) |
| Add one item with the specified state and redraw the table. More... | |
| virtual void | deleteAllItems () |
| Delete all items and clear the pad. More... | |
| virtual int | getCurrentIndex () const |
| Get the index of the current item (the item under the cursor) or -1 if there is none. | |
| virtual int | getCurrentItem () const |
| Get the index of the current item (the item under the cursor) or -1 if there is none, i.e. More... | |
| YItem * | getCurrentItemPointer () |
| Return a pointer to the current item (the item under the cursor) or 0 if there is none, i.e. More... | |
| virtual void | setCurrentItem (int index) |
| Set the current item to the specified index. | |
| virtual void | scrollToFirstItem () |
| Scroll to the first item. | |
| virtual void | selectItem (YItem *yitem, bool selected) |
| Select or deselect an item. More... | |
| void | selectCurrentItem () |
| Select the current item (the item under the cursor). More... | |
| virtual void | deselectAllItems () |
| Deselect all items. More... | |
| virtual NCursesEvent | wHandleInput (wint_t key) |
| Keyboard input handler. More... | |
| virtual int | preferredWidth () |
| libyui geometry management: Return the preferred width for this widget. More... | |
| virtual int | preferredHeight () |
| libyui geometry management: Return the preferred height for this widget. More... | |
| virtual void | setSize (int newWidth, int newHeight) |
| libyui geometry management: Apply the width and height assigned from the parent layout widget. More... | |
| virtual void | setLabel (const std::string &nlabel) |
| Set the label (the caption) above the table. More... | |
| virtual void | setEnabled (bool do_bv) |
| Enable or disable this widget. More... | |
| virtual bool | setKeyboardFocus () |
| Set the keyboard focus to this widget. More... | |
| bool | setItemByKey (int key) |
| Select an item by its hotkey. More... | |
| void | SetSepChar (const chtype colSepchar) |
| Set the column separator character. More... | |
| void | SetSepWidth (const unsigned sepwidth) |
| Set the separator width. More... | |
| void | SetHotCol (int hcol) |
| Set the hotkey column (?). More... | |
| bool | bigList () const |
| Flag: Is this a big list? | |
| void | setBigList (bool big) |
| Set the "big list" flag. | |
| void | stripHotkeys () |
| Remove all hotkeys from the pad. | |
| void | setSortStrategy (NCTableSortStrategyBase *newStrategy) |
| Set a sorting strategy. More... | |
| NCTableSortStrategyBase * | sortStrategy () const |
| Return the current sorting strategy. | |
Public Member Functions inherited from NCPadWidget | |
| NCPadWidget (NCWidget *myparent=0) | |
| NCPadWidget (YWidget *parent) | |
| size_t | Columns () |
| void | setLabel (const NClabel &nlabel) |
Public Member Functions inherited from NCWidget | |
| void | grabSet (NCWidget *ngrab) |
| void | grabRelease (NCWidget *ograb) |
| NCWidget (NCWidget *myparent) | |
| NCWidget (YWidget *parent=0) | |
| bool | isValid () const |
| bool | winExist () const |
| virtual const NCstyle::Style & | wStyle () const |
| const NCstyle::StWidget & | widgetStyle (bool nonactive=false) const |
| const NCstyle::StWidget & | frameStyle () const |
| const NCstyle::StList & | listStyle () const |
| wsze | wGetDefsze () const |
| wrect | wGetSize () const |
| void | Update () |
| void | Redraw (bool sub=false) |
| void | Recoded () |
| NC::WState | GetState () const |
| void | SetState (const NC::WState newstate, bool force=false) |
| virtual bool | HasHotkey (int key) |
| virtual bool | HasFunctionHotkey (int key) const |
| virtual NCursesEvent | wHandleHotkey (wint_t key) |
| void | DumpOn (std::ostream &str, std::string prfx) const |
Public Member Functions inherited from tnode< NCWidget * > | |
| tnode (NCWidget * v, self *p=0, bool behind=true) | |
| New node, added as the last child by default (which is natural). More... | |
| tnode (NCWidget * v, self &p, bool behind=true) | |
| New node, added as the last child by default (which is natural). More... | |
| tnode (NCWidget * v, self &p, self &s, bool behind=true) | |
| New node under p, just after s (or before s if behind==false) More... | |
| void | Disconnect () |
| Disconnect from the parent and siblings, but keep children. | |
| bool | ReparentTo (self &p, bool behind=true) |
| Disconnect from old parent, connect to new parent p. More... | |
| bool | ReparentTo (self &p, self &s, bool behind=true) |
| Disconnect from old parent, connect to new parent p and sibling s. More... | |
| NCWidget * & | Value () const |
| NCWidget * & | operator() () const |
| Alias for Value. | |
| self * | Parent () |
| const self * | Parent () const |
| self * | Psibling () |
| Previous sibling. | |
| const self * | Psibling () const |
| Previous sibling. | |
| self * | Nsibling () |
| Next sibling. | |
| const self * | Nsibling () const |
| Next sibling. | |
| self * | Fchild () |
| First child. | |
| const self * | Fchild () const |
| First child. | |
| self * | Lchild () |
| Last child. | |
| const self * | Lchild () const |
| Last child. | |
| bool | HasParent () const |
| bool | HasSiblings () const |
| bool | HasChildren () const |
| bool | IsParentOf (const self &c) const |
| bool | IsSiblingOf (const self &s) const |
| bool | IsChildOf (const self &p) const |
| unsigned | Depth () const |
| Depth: zero if no parent, otherwise 1 + parent's depth. | |
| bool | IsDescendantOf (const self &n) const |
| bool | IsDescendantOf (const self *n) const |
| self & | Top () |
| Root of the tree. | |
| const self & | Top () const |
| self * | Next (bool restart=false) |
| Next node: depth first, pre-order. More... | |
| self * | Next (self *&c, bool restart=false) |
| Return Next and assign it to c. | |
| const self * | Next (bool restart=false) const |
| const self * | Next (const self *&c, bool restart=false) const |
| self * | Prev (bool restart=false) |
| self * | Prev (self *&c, bool restart=false) |
| Return Prev and assign it to c. | |
| const self * | Prev (bool restart=false) const |
| const self * | Prev (const self *&c, bool restart=false) const |
Protected Member Functions | |
| virtual const char * | location () const |
| Code location for logging. More... | |
| virtual NCPad * | CreatePad () |
| Create an empty pad and set its background. | |
| virtual NCTablePad * | myPad () const |
| Return the TreePad that belongs to this widget. More... | |
| virtual void | addItem (YItem *yitem, bool preventRedraw, NCTableLine::STATE state=NCTableLine::S_NORMAL) |
| Internal overloaded version of addItem(). More... | |
| 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 etc.). More... | |
| void | rebuildPadLines () |
| Build or rebuild the pad lines: Clear the pad, iterate over all YItems and add a corresponding NCTableLine to the pad. More... | |
| void | rebuildHeaderLine () |
| Rebuild the table header line. | |
| NCstring | alignmentStr (int col) |
| Return the NCurses alignment string for the alignment of the specified column: One of "L", "C", "R" (Left, Center, Right). | |
| bool | hasNestedItems (const YItemCollection &itemCollection) const |
| Return 'true' if any item in the item collection has any children, 'false' otherwise. | |
| bool | hasNestedItems (YItemConstIterator begin, YItemConstIterator end) const |
| virtual void | startMultipleChanges () |
| Optimization for NCurses from libyui: Notification that multiple changes are about to come. More... | |
| virtual void | doneMultipleChanges () |
| Optimization for NCurses from libyui: Notification that multiple changes are now finished. More... | |
| void | toggleCurrentItem () |
| Toggle the current item between selected and not selected. | |
| void | cellChanged (const YTableCell *cell) |
| Notification that a cell has now changed content: Set that cell's content also in the corresponding table line. | |
| void | setCell (int index, int col, const std::string &newText) |
| Change the cell with item index 'index' and column no. More... | |
| void | assignIndex (YItemConstIterator begin, YItemConstIterator end) |
| Recursively iterate over items and assign each one a unique item index. More... | |
| void | assignIndex (YItem *item) |
| Assign an item a unique index. | |
| void | interactiveSort () |
| Interactive sorting by a user-selected column: More... | |
| void | sortItems (int sortCol, bool reverse=false) |
| Sort the items by column no. More... | |
| void | sortYItems (YItemIterator begin, YItemIterator end) |
| Sort the YItems between 'begin' and 'end' using the current sort strategy. | |
Protected Member Functions inherited from NCPadWidget | |
| void | startMultidraw () |
| void | stopMultidraw () |
| bool | inMultidraw () const |
| unsigned | labelWidth () const |
| virtual void | wCreate (const wrect &newrect) |
| virtual void | wDelete () |
| virtual void | wRedraw () |
| virtual void | wRecoded () |
| wsze | defPadSze () const |
| virtual void | DrawPad () |
| void | InitPad () |
| void | AdjustPad (wsze nsze) |
| void | DelPad () |
| virtual void | HScroll (unsigned total, unsigned visible, unsigned start) |
| virtual void | VScroll (unsigned total, unsigned visible, unsigned start) |
| virtual void | ScrollHead (NCursesWindow &w, unsigned ccol) |
| virtual void | AdjustPadSize (wsze &minsze) |
| virtual bool | handleInput (wint_t key) |
Protected Member Functions inherited from NCWidget | |
| virtual void | PreDisconnect () |
| virtual void | PostDisconnect () |
| virtual void | PreReparent () |
| virtual void | PostReparent () |
| NCursesWindow * | ParentWin () |
| bool | grabFocus () |
| virtual void | grabNotify (NCWidget *) |
| virtual bool | wantFocus (NCWidget &ngrab) |
| void | wMoveChildTo (NCWidget &child, const wpos &newpos) |
| void | wRelocate (const wrect &newrect) |
| void | wRelocate (const wpos &newpos, const wsze &newsze) |
| virtual void | wMoveTo (const wpos &newpos) |
| virtual void | wUpdate (bool forced_br=false) |
| wpos | ScreenPos () const |
Protected Member Functions inherited from NCursesError | |
| NCursesError (const char *msg="unknown error",...) | |
| NCursesError (int val, const char *msg="unknown error",...) | |
| NCursesError & | NCError (const char *msg="unknown error",...) |
| NCursesError & | NCError (int val, const char *msg="unknown error",...) |
Friends | |
| std::ostream & | operator<< (std::ostream &str, const NCTable &obj) |
Additional Inherited Members | |
Protected Types inherited from tnode< NCWidget * > | |
| typedef tnode< NCWidget * > | self |
Protected Attributes inherited from NCPadWidget | |
| bool | hasHeadline |
| bool | activeLabelOnly |
Protected Attributes inherited from NCWidget | |
| NCWidget *const | grabedBy |
| NCursesWindow * | win |
| (owned) | |
| wsze | defsze |
| wrect | framedim |
| wrect | inparent |
| bool | noUpdates |
| bool | skipNoDimWin |
| NC::WState | wstate |
| NClabel * | hotlabel |
Protected Attributes inherited from tnode< NCWidget * > | |
| NCWidget * | val |
Protected Attributes inherited from NCursesError | |
| int | errval_i |
| std::string | errmsg_t |
A table with rows and columns.
Items may be nested.
See also https://github.com/libyui/libyui-ncurses/blob/master/doc/nctable-and-nctree.md
|
inlinevirtual |
|
protectedvirtual |
Internal overloaded version of addItem().
This creates a visual representation of the new table line consisting of individual cells. If 'preventRedraw' is 'false', the table is redrawn; otherwise, it is up to the caller to redraw the table.
This is used in addItem( yitem ) and addItems( itemCollection ) in this class, but also in the derived NCFileSelection and NCPkgTable classes.
Definition at line 245 of file NCTable.cc.
|
virtual |
Add one item with the specified state and redraw the table.
This overloaded version is first defined here and also used in NCPopupTable. Notice that this does not have a default value for the 'state' parameter to avoid clashing with the addItem( YItem * ) version inherited from YSelectionWidget which might be used from C++ applications using libyui.
Definition at line 232 of file NCTable.cc.
|
virtual |
Add items.
Reimplemented from YSelectionWidget to optimize sorting.
Definition at line 210 of file NCTable.cc.
|
protectedvirtual |
Add a pad line (an NCTableLine) for 'yitem' and recurse into any of its children (and grandchildren etc.).
Make sure to update _nestedItems (by iterating over all the YItems) before the first one is added so they will reserve some screen space for the tree hierarchy line graphics (using the prefix placeholder).
This can realistically only be done when bulk-adding all YItems at once. If they are added one by one, the first few may not have any children, so their corresponding pad lines will not reserve screen space for the prefix, leading to ugly results.
If there is no item nesting at all, this does not matter, of course.
Definition at line 259 of file NCTable.cc.
|
protected |
Recursively iterate over items and assign each one a unique item index.
As long as the items don't have any child items, each one simply gets its initial position in the item collection. When there are children, however, there will be gaps between the index of one toplevel item and the next.
It is generally unsafe to make assumptions about the indices except that they are unique within one table, and an item will keep its initial index, no matter how the table is sorted.
The indices restart from 0 after the table has been cleared, i.e. after deleteAllItems() or at the start of setItems().
|
virtual |
Delete all items and clear the pad.
Implemented from YSelectionWidget.
Reimplemented in NCFileSelection.
Definition at line 353 of file NCTable.cc.
|
virtual |
|
inlineprotectedvirtual |
|
virtual |
Get the index of the current item (the item under the cursor) or -1 if there is none, i.e.
the table is empty.
FIXME: This is a misnomer of epic proportions. This should be named getCurrentIndex(). A method called getCurrentItem() should return the item (i.e. a pointer or a reference), not an index! But since this is all over the place in derived classes and in libyui-ncurses-pkg as well, this is not a trivial thing to fix.
Definition at line 365 of file NCTable.cc.
| YItem * NCTable::getCurrentItemPointer | ( | ) |
Return a pointer to the current item (the item under the cursor) or 0 if there is none, i.e.
the table is empty.
FIXME: This is what getCurrentItem() should really be.
Definition at line 380 of file NCTable.cc.

| vector< string > NCTable::getHeader | ( | ) | const |
Get the table headers (the first line inside the table) as strings.
Alignment flags are removed.
Definition at line 196 of file NCTable.cc.
|
protected |
Interactive sorting by a user-selected column:
Open a popup with the (non-empty) column headers and let the user choose one for sorting.
Definition at line 639 of file NCTable.cc.
|
inlineprotectedvirtual |
|
inlineprotectedvirtual |
Return the TreePad that belongs to this widget.
Overloaded from NCPadWidget to narrow the type to the actual one used in this widget.
Reimplemented from NCPadWidget.
Definition at line 289 of file NCTable.h.

|
virtual |
libyui geometry management: Return the preferred height for this widget.
Implemented from YWidget.
Definition at line 507 of file NCTable.cc.
|
virtual |
libyui geometry management: Return the preferred width for this widget.
Implemented from YWidget.
Definition at line 500 of file NCTable.cc.
|
protected |
Build or rebuild the pad lines: Clear the pad, iterate over all YItems and add a corresponding NCTableLine to the pad.
This recurses into any child YItems.
This does not redraw the pad. Do that from the outside.
Definition at line 320 of file NCTable.cc.
| void NCTable::selectCurrentItem | ( | ) |
Select the current item (the item under the cursor).
Mark the currently highlighted table item as selected.
Yes, it is really already highlighted, so no need to selectItem() and setCurrentItem() here again. (bsc#493884)
Definition at line 463 of file NCTable.cc.

|
virtual |
Select or deselect an item.
Implemented from YSelectionWidget.
Definition at line 412 of file NCTable.cc.

|
protected |
Change the cell with item index 'index' and column no.
'col' to 'newText'.
Definition at line 129 of file NCTable.cc.

|
virtual |
Enable or disable this widget.
Implemented from YWidget.
Reimplemented from NCPadWidget.
Definition at line 527 of file NCTable.cc.

|
inline |
Set the hotkey column (?).
Used only in NCPopupTable.
Definition at line 240 of file NCTable.h.

| bool NCTable::setItemByKey | ( | int | key | ) |
Select an item by its hotkey.
Used only in NCPopupTable::wHandleHotkey().
Definition at line 534 of file NCTable.cc.
|
inlinevirtual |
|
virtual |
Set the label (the caption) above the table.
YTable does not specify a label because a table has a whole row of headers.
Definition at line 520 of file NCTable.cc.
|
inline |
Set the column separator character.
Used only in NCPopupTable and in NCFileSelection.
Definition at line 226 of file NCTable.h.

|
inline |
Set the separator width.
Used only in NCPopupTable.
Definition at line 233 of file NCTable.h.

|
virtual |
libyui geometry management: Apply the width and height assigned from the parent layout widget.
Implemented from YWidget.
Definition at line 514 of file NCTable.cc.
| void NCTable::setSortStrategy | ( | NCTableSortStrategyBase * | newStrategy | ) |
|
protected |
Sort the items by column no.
'sortCol' with the current sort strategy.
This sorts the YItems and recreates all NCTableLines. All YItem pointers remain valid, but the NCTableLines do not.
Definition at line 702 of file NCTable.cc.
|
inlineprotectedvirtual |
|
virtual |
Keyboard input handler.
NCurses widget keyboard handler.
This is the starting point for handling key events. From here, key events are propagated to the pad and to the items.
Implemented from NCWidget.
This is the starting point for handling key events. From here, key events are propagated to the pad and to the items.
Reimplemented from NCWidget.
Reimplemented in NCDirectoryTable, and NCFileTable.
Definition at line 556 of file NCTable.cc.