A widget showing a list of items for selecting one. More...
#include <listwidget.h>


Classes | |
| class | ItemContains |
| Used to search for item names. More... | |
Public Types | |
| enum | SortOrder { ASCENDING, DESCENDING } |
The sort order available. More... | |
Public Member Functions | |
| void | deleteSelectedItem () |
| virtual int | focus () throw (UIException) |
| Sets the focus to this widget. | |
| const std::list< T > & | getList () const |
| std::list< T > & | getList () |
| int | getListPos () |
| T | getSelectedItem () |
| SortOrder | getSortOrder () const |
| Returns the sort order applied to the list. | |
| ListWidget (std::list< T > l, int sx, int sy, int w, int h) throw (UIException) | |
| Constructor. | |
| void | refresh () throw (UIException) |
| void | replaceCurrentItem (T &item) |
| Replace the item at the current position selected. | |
| void | resize (int sx, int sy, int w, int h) throw (UIException) |
| bool | searchNext () |
| Searches again using the last search term used. | |
| bool | searchTerm (const char *t) |
| Searches for a term in the list items. | |
| void | setList (typename std::list< T > &l) |
| Sets a new list of items to display. | |
| void | setSortOrder (SortOrder so) |
| Sorts the list. | |
| void | setSortOrder () |
| Sorts the list with the currently set sort order. | |
| l_size_type | size () |
| virtual | ~ListWidget () |
Private Types | |
| typedef std::list< T > ::const_iterator | c_list_it |
| typedef std::list< T >::size_type | l_size_type |
| typedef std::list< T >::iterator | list_it |
Private Member Functions | |
| void | clearWin () throw (UIException) |
| void | createWindow (int sx, int sy, int w, int h) throw (UIException) |
| void | highlightItemIter (list_it &it) |
| ListWidget (const ListWidget &lw) | |
| const ListWidget & | operator= (const ListWidget &lw) |
| int | pagesize () |
| void | scrollDown () |
| void | scrollEnd () |
| void | scrollHome () |
| void | scrollPageDown () |
| void | scrollPageUp () |
| void | scrollUp () |
| int | setBorder () const |
| Sets the border depending on the focus. | |
| void | showListItems () throw (UIException) |
| void | showScrollIndicators () throw (UIException) |
| void | showSelected (int old_pos) throw (UIException) |
| Highlights the selected item. | |
| l_size_type | validateIterator (list_it &it) |
| Validates the given iterator against the list. | |
| l_size_type | validateIterator (c_list_it &it) const |
Private Attributes | |
| int | cur_pos |
| The position within the visible items. | |
| list_it | cur_search_hit |
| Points the current hit of a search. | |
| bool | hasfocus |
| Indicates whether or not the widget has the focus. | |
| int | height |
| std::list< T > | itemlist |
| Items displayed. | |
| std::string | last_search_term |
| Holds the last search term. | |
| SortOrder | sortorder |
| Holds the sort order currently applied. | |
| int | start_pos |
| Holds the starting position within the list. | |
| int | width |
| WINDOW * | window |
This template shows a list of items on the screen and allows the user to select one of it. If the list is larger than the available screen height, it allows to scroll.
The objects stored in the std::list are expected to have a method c_str() which should return the name or whatever of the item. This string is displayed on the screen. Further, the object need to provide a less-than operator for sorting purpose.
Definition at line 93 of file listwidget.h.
typedef std::list<T>::const_iterator YAPET::UI::ListWidget< T >::c_list_it [private] |
Definition at line 209 of file listwidget.h.
typedef std::list<T>::size_type YAPET::UI::ListWidget< T >::l_size_type [private] |
Definition at line 206 of file listwidget.h.
typedef std::list<T>::iterator YAPET::UI::ListWidget< T >::list_it [private] |
Definition at line 208 of file listwidget.h.
| enum YAPET::UI::ListWidget::SortOrder |
The sort order that are available for sorting the list items.
Definition at line 101 of file listwidget.h.
| YAPET::UI::ListWidget< T >::ListWidget | ( | const ListWidget< T > & | lw | ) | [inline, private] |
Definition at line 226 of file listwidget.h.
| YAPET::UI::ListWidget< T >::ListWidget | ( | std::list< T > | l, | |
| int | sx, | |||
| int | sy, | |||
| int | w, | |||
| int | h | |||
| ) | throw (UIException) [inline] |
Initializes the widget, but does not show it.
| l | the list holding the items to be displayed. The items of the list are expected to have a method called c_str() for getting their names. Empty lists are allowed. | |
| sx | the horizontal start position of the widget on the screen. | |
| sy | the vertical start position of the widget on the screen. | |
| w | the width of the widget. | |
| h | the height of the widget. |
Definition at line 562 of file listwidget.h.
| virtual YAPET::UI::ListWidget< T >::~ListWidget | ( | ) | [inline, virtual] |
Definition at line 582 of file listwidget.h.
| void YAPET::UI::ListWidget< T >::clearWin | ( | ) | throw (UIException) [inline, private] |
Definition at line 303 of file listwidget.h.
Referenced by YAPET::UI::ListWidget< YAPET::PartDec >::showListItems().

| void YAPET::UI::ListWidget< T >::createWindow | ( | int | sx, | |
| int | sy, | |||
| int | w, | |||
| int | h | |||
| ) | throw (UIException) [inline, private] |
Definition at line 519 of file listwidget.h.
Referenced by YAPET::UI::ListWidget< YAPET::PartDec >::ListWidget(), and YAPET::UI::ListWidget< YAPET::PartDec >::resize().

| void YAPET::UI::ListWidget< T >::deleteSelectedItem | ( | ) | [inline] |
Definition at line 625 of file listwidget.h.
Referenced by MainWindow::deleteSelectedRecord().

| virtual int YAPET::UI::ListWidget< T >::focus | ( | ) | throw (UIException) [inline, virtual] |
Focus the widget and shows it on the screen. The widget handles the following key strokes:
KEY_UP KEY_DOWN KEY_HOME KEY_A1 KEY_END KEY_C1 KEY_NPAGE KEY_C3 KEY_PPAGE KEY_A3 KEY_REFRESH Every other key stroke make it loosing the focus.
Definition at line 670 of file listwidget.h.
Referenced by MainWindow::run(), and FileOpen::run().

| const std::list<T>& YAPET::UI::ListWidget< T >::getList | ( | ) | const [inline] |
Definition at line 641 of file listwidget.h.
Referenced by MainWindow::addNewRecord(), MainWindow::closeFile(), and MainWindow::saveFile().

| std::list<T>& YAPET::UI::ListWidget< T >::getList | ( | ) | [inline] |
Definition at line 644 of file listwidget.h.
| int YAPET::UI::ListWidget< T >::getListPos | ( | ) | [inline] |
Definition at line 765 of file listwidget.h.
| T YAPET::UI::ListWidget< T >::getSelectedItem | ( | ) | [inline] |
Definition at line 769 of file listwidget.h.
Referenced by MainWindow::editSelectedRecord(), and FileOpen::run().

| SortOrder YAPET::UI::ListWidget< T >::getSortOrder | ( | ) | const [inline] |
Returns the current sort order that is applied to the list.
SortOrder value. Definition at line 790 of file listwidget.h.
Referenced by MainWindow::setSortOrder(), and YAPET::UI::ListWidget< YAPET::PartDec >::setSortOrder().

| void YAPET::UI::ListWidget< T >::highlightItemIter | ( | list_it & | it | ) | [inline, private] |
Definition at line 267 of file listwidget.h.
Referenced by YAPET::UI::ListWidget< YAPET::PartDec >::searchNext(), and YAPET::UI::ListWidget< YAPET::PartDec >::searchTerm().

| const ListWidget& YAPET::UI::ListWidget< T >::operator= | ( | const ListWidget< T > & | lw | ) | [inline, private] |
Definition at line 227 of file listwidget.h.
| int YAPET::UI::ListWidget< T >::pagesize | ( | ) | [inline, private] |
Definition at line 299 of file listwidget.h.
Referenced by YAPET::UI::ListWidget< YAPET::PartDec >::highlightItemIter(), YAPET::UI::ListWidget< YAPET::PartDec >::scrollDown(), YAPET::UI::ListWidget< YAPET::PartDec >::scrollEnd(), YAPET::UI::ListWidget< YAPET::PartDec >::scrollPageDown(), YAPET::UI::ListWidget< YAPET::PartDec >::scrollPageUp(), YAPET::UI::ListWidget< YAPET::PartDec >::showListItems(), and YAPET::UI::ListWidget< YAPET::PartDec >::showScrollIndicators().

| void YAPET::UI::ListWidget< T >::refresh | ( | ) | throw (UIException) [inline] |
Definition at line 737 of file listwidget.h.
Referenced by MainWindow::deleteSelectedRecord(), MainWindow::refresh(), FileOpen::refresh(), YAPET::UI::ListWidget< YAPET::PartDec >::setList(), and MainWindow::setSortOrder().

| void YAPET::UI::ListWidget< T >::replaceCurrentItem | ( | T & | item | ) | [inline] |
Replaces the item at the current position of the list selected by the user.
| item | the new item. |
Definition at line 614 of file listwidget.h.
Referenced by MainWindow::editSelectedRecord().

| void YAPET::UI::ListWidget< T >::resize | ( | int | sx, | |
| int | sy, | |||
| int | w, | |||
| int | h | |||
| ) | throw (UIException) [inline] |
Definition at line 746 of file listwidget.h.
Referenced by MainWindow::resize().

| void YAPET::UI::ListWidget< T >::scrollDown | ( | ) | [inline, private] |
Definition at line 437 of file listwidget.h.
Referenced by YAPET::UI::ListWidget< YAPET::PartDec >::focus().

| void YAPET::UI::ListWidget< T >::scrollEnd | ( | ) | [inline, private] |
Definition at line 503 of file listwidget.h.
Referenced by YAPET::UI::ListWidget< YAPET::PartDec >::focus().

| void YAPET::UI::ListWidget< T >::scrollHome | ( | ) | [inline, private] |
Definition at line 494 of file listwidget.h.
Referenced by YAPET::UI::ListWidget< YAPET::PartDec >::focus().

| void YAPET::UI::ListWidget< T >::scrollPageDown | ( | ) | [inline, private] |
Definition at line 472 of file listwidget.h.
Referenced by YAPET::UI::ListWidget< YAPET::PartDec >::focus().

| void YAPET::UI::ListWidget< T >::scrollPageUp | ( | ) | [inline, private] |
Definition at line 454 of file listwidget.h.
Referenced by YAPET::UI::ListWidget< YAPET::PartDec >::focus().

| void YAPET::UI::ListWidget< T >::scrollUp | ( | ) | [inline, private] |
Definition at line 422 of file listwidget.h.
Referenced by YAPET::UI::ListWidget< YAPET::PartDec >::deleteSelectedItem(), and YAPET::UI::ListWidget< YAPET::PartDec >::focus().

| bool YAPET::UI::ListWidget< T >::searchNext | ( | ) | [inline] |
Performs a search again using the last search term again.
| \c | true if the term was found again, else false |
Definition at line 856 of file listwidget.h.
Referenced by MainWindow::searchNext().

| bool YAPET::UI::ListWidget< T >::searchTerm | ( | const char * | t | ) | [inline] |
Searches for a given term in the list items.
| t | the term to search for |
| \c | true if the term was found, else false. |
Definition at line 835 of file listwidget.h.
Referenced by MainWindow::searchTerm().

| int YAPET::UI::ListWidget< T >::setBorder | ( | ) | const [inline, private] |
Sets the border depending on whether or not the list has the focus.
| the | return value of the call to wborder(). |
Definition at line 292 of file listwidget.h.
Referenced by YAPET::UI::ListWidget< YAPET::PartDec >::clearWin(), YAPET::UI::ListWidget< YAPET::PartDec >::createWindow(), and YAPET::UI::ListWidget< YAPET::PartDec >::focus().

| void YAPET::UI::ListWidget< T >::setList | ( | typename std::list< T > & | l | ) | [inline] |
Sets a new list of items to display.
| l | the list holding the items to be displayed. The items of the list are expected to have a method called c_str() for getting their names. Empty lists are allowed. |
Definition at line 597 of file listwidget.h.
Referenced by MainWindow::changePassword(), and FileOpen::run().

| void YAPET::UI::ListWidget< T >::setSortOrder | ( | SortOrder | so | ) | [inline] |
Sorts the list using the given order. It expects that T has defined the less than operator.
| so | value of the type SortOrder |
Definition at line 802 of file listwidget.h.
Referenced by MainWindow::addNewRecord(), MainWindow::editSelectedRecord(), and MainWindow::setSortOrder().

| void YAPET::UI::ListWidget< T >::setSortOrder | ( | ) | [inline] |
Sorts the list using the currently set sort order.
Definition at line 822 of file listwidget.h.
Referenced by YAPET::UI::ListWidget< YAPET::PartDec >::ListWidget(), YAPET::UI::ListWidget< YAPET::PartDec >::replaceCurrentItem(), YAPET::UI::ListWidget< YAPET::PartDec >::setList(), and YAPET::UI::ListWidget< YAPET::PartDec >::setSortOrder().

| void YAPET::UI::ListWidget< T >::showListItems | ( | ) | throw (UIException) [inline, private] |
Definition at line 339 of file listwidget.h.
Referenced by YAPET::UI::ListWidget< YAPET::PartDec >::highlightItemIter(), YAPET::UI::ListWidget< YAPET::PartDec >::refresh(), YAPET::UI::ListWidget< YAPET::PartDec >::scrollDown(), YAPET::UI::ListWidget< YAPET::PartDec >::scrollEnd(), YAPET::UI::ListWidget< YAPET::PartDec >::scrollHome(), YAPET::UI::ListWidget< YAPET::PartDec >::scrollPageDown(), YAPET::UI::ListWidget< YAPET::PartDec >::scrollPageUp(), and YAPET::UI::ListWidget< YAPET::PartDec >::scrollUp().

| void YAPET::UI::ListWidget< T >::showScrollIndicators | ( | ) | throw (UIException) [inline, private] |
Definition at line 316 of file listwidget.h.
Referenced by YAPET::UI::ListWidget< YAPET::PartDec >::focus(), and YAPET::UI::ListWidget< YAPET::PartDec >::showListItems().

| void YAPET::UI::ListWidget< T >::showSelected | ( | int | old_pos | ) | throw (UIException) [inline, private] |
Highlights the selected item in the list. However, this is depending of the global member hasfocus. If hasfocus is false, the highlight is removed.
| old_pos | tells the method the position of the old highlight, so it can be removed. If the value is less than 0, it does not try to clear the old highlight. |
Definition at line 372 of file listwidget.h.
Referenced by YAPET::UI::ListWidget< YAPET::PartDec >::focus(), YAPET::UI::ListWidget< YAPET::PartDec >::highlightItemIter(), YAPET::UI::ListWidget< YAPET::PartDec >::refresh(), YAPET::UI::ListWidget< YAPET::PartDec >::scrollDown(), YAPET::UI::ListWidget< YAPET::PartDec >::scrollEnd(), YAPET::UI::ListWidget< YAPET::PartDec >::scrollHome(), YAPET::UI::ListWidget< YAPET::PartDec >::scrollPageDown(), YAPET::UI::ListWidget< YAPET::PartDec >::scrollPageUp(), and YAPET::UI::ListWidget< YAPET::PartDec >::scrollUp().

| l_size_type YAPET::UI::ListWidget< T >::size | ( | ) | [inline] |
Definition at line 779 of file listwidget.h.
Referenced by MainWindow::bottomRightWinContent(), MainWindow::deleteSelectedRecord(), MainWindow::editSelectedRecord(), MainWindow::searchNext(), and MainWindow::searchTerm().

| l_size_type YAPET::UI::ListWidget< T >::validateIterator | ( | list_it & | it | ) | [inline, private] |
Indicates whether or not the given iterator is still valid for the list
| it | the iterator to be validated against itemlist. |
| a | positive value (including zero) to indicate the position of the iterator, ((l_size_type)-1) to indicate an error. |
Definition at line 244 of file listwidget.h.
Referenced by YAPET::UI::ListWidget< YAPET::PartDec >::highlightItemIter(), and YAPET::UI::ListWidget< YAPET::PartDec >::searchNext().

| l_size_type YAPET::UI::ListWidget< T >::validateIterator | ( | c_list_it & | it | ) | const [inline, private] |
Definition at line 255 of file listwidget.h.
int YAPET::UI::ListWidget< T >::cur_pos [private] |
Holds the position within the visible items. By adding cur_pos + start_pos the item actually selected by the user as offset from the beginning of the list is yielded.
Definition at line 189 of file listwidget.h.
Referenced by YAPET::UI::ListWidget< YAPET::PartDec >::deleteSelectedItem(), YAPET::UI::ListWidget< YAPET::PartDec >::getListPos(), YAPET::UI::ListWidget< YAPET::PartDec >::getSelectedItem(), YAPET::UI::ListWidget< YAPET::PartDec >::highlightItemIter(), YAPET::UI::ListWidget< YAPET::PartDec >::replaceCurrentItem(), YAPET::UI::ListWidget< YAPET::PartDec >::scrollDown(), YAPET::UI::ListWidget< YAPET::PartDec >::scrollEnd(), YAPET::UI::ListWidget< YAPET::PartDec >::scrollHome(), YAPET::UI::ListWidget< YAPET::PartDec >::scrollPageDown(), YAPET::UI::ListWidget< YAPET::PartDec >::scrollPageUp(), YAPET::UI::ListWidget< YAPET::PartDec >::scrollUp(), YAPET::UI::ListWidget< YAPET::PartDec >::setList(), YAPET::UI::ListWidget< YAPET::PartDec >::showScrollIndicators(), and YAPET::UI::ListWidget< YAPET::PartDec >::showSelected().
list_it YAPET::UI::ListWidget< T >::cur_search_hit [private] |
When the list is searched, this iterator points to the current hit of a search.
Definition at line 217 of file listwidget.h.
Referenced by YAPET::UI::ListWidget< YAPET::PartDec >::searchNext(), and YAPET::UI::ListWidget< YAPET::PartDec >::searchTerm().
bool YAPET::UI::ListWidget< T >::hasfocus [private] |
Indicates whether or not this widget has the focus. Determines how the border has to be drawn
Definition at line 171 of file listwidget.h.
Referenced by YAPET::UI::ListWidget< YAPET::PartDec >::focus(), YAPET::UI::ListWidget< YAPET::PartDec >::setBorder(), and YAPET::UI::ListWidget< YAPET::PartDec >::showSelected().
int YAPET::UI::ListWidget< T >::height [private] |
std::list<T> YAPET::UI::ListWidget< T >::itemlist [private] |
The actual list holding the items displayed by the widget.
Definition at line 205 of file listwidget.h.
Referenced by YAPET::UI::ListWidget< YAPET::PartDec >::deleteSelectedItem(), YAPET::UI::ListWidget< YAPET::PartDec >::getList(), YAPET::UI::ListWidget< YAPET::PartDec >::getSelectedItem(), YAPET::UI::ListWidget< YAPET::PartDec >::replaceCurrentItem(), YAPET::UI::ListWidget< YAPET::PartDec >::scrollDown(), YAPET::UI::ListWidget< YAPET::PartDec >::scrollEnd(), YAPET::UI::ListWidget< YAPET::PartDec >::scrollHome(), YAPET::UI::ListWidget< YAPET::PartDec >::scrollPageDown(), YAPET::UI::ListWidget< YAPET::PartDec >::scrollPageUp(), YAPET::UI::ListWidget< YAPET::PartDec >::scrollUp(), YAPET::UI::ListWidget< YAPET::PartDec >::searchNext(), YAPET::UI::ListWidget< YAPET::PartDec >::searchTerm(), YAPET::UI::ListWidget< YAPET::PartDec >::setList(), YAPET::UI::ListWidget< YAPET::PartDec >::setSortOrder(), YAPET::UI::ListWidget< YAPET::PartDec >::showListItems(), YAPET::UI::ListWidget< YAPET::PartDec >::showScrollIndicators(), YAPET::UI::ListWidget< YAPET::PartDec >::showSelected(), YAPET::UI::ListWidget< YAPET::PartDec >::size(), and YAPET::UI::ListWidget< YAPET::PartDec >::validateIterator().
std::string YAPET::UI::ListWidget< T >::last_search_term [private] |
Holds the last search term used.
Definition at line 224 of file listwidget.h.
Referenced by YAPET::UI::ListWidget< YAPET::PartDec >::searchNext(), and YAPET::UI::ListWidget< YAPET::PartDec >::searchTerm().
SortOrder YAPET::UI::ListWidget< T >::sortorder [private] |
Holds the sort order that is currently applied to the list.
Definition at line 197 of file listwidget.h.
Referenced by YAPET::UI::ListWidget< YAPET::PartDec >::getSortOrder(), YAPET::UI::ListWidget< YAPET::PartDec >::replaceCurrentItem(), YAPET::UI::ListWidget< YAPET::PartDec >::setList(), and YAPET::UI::ListWidget< YAPET::PartDec >::setSortOrder().
int YAPET::UI::ListWidget< T >::start_pos [private] |
This holds the position from where we start showing items on the screen.
Definition at line 179 of file listwidget.h.
Referenced by YAPET::UI::ListWidget< YAPET::PartDec >::deleteSelectedItem(), YAPET::UI::ListWidget< YAPET::PartDec >::getListPos(), YAPET::UI::ListWidget< YAPET::PartDec >::getSelectedItem(), YAPET::UI::ListWidget< YAPET::PartDec >::highlightItemIter(), YAPET::UI::ListWidget< YAPET::PartDec >::replaceCurrentItem(), YAPET::UI::ListWidget< YAPET::PartDec >::scrollDown(), YAPET::UI::ListWidget< YAPET::PartDec >::scrollEnd(), YAPET::UI::ListWidget< YAPET::PartDec >::scrollHome(), YAPET::UI::ListWidget< YAPET::PartDec >::scrollPageDown(), YAPET::UI::ListWidget< YAPET::PartDec >::scrollPageUp(), YAPET::UI::ListWidget< YAPET::PartDec >::scrollUp(), YAPET::UI::ListWidget< YAPET::PartDec >::setList(), YAPET::UI::ListWidget< YAPET::PartDec >::showListItems(), and YAPET::UI::ListWidget< YAPET::PartDec >::showScrollIndicators().
int YAPET::UI::ListWidget< T >::width [private] |
Definition at line 162 of file listwidget.h.
Referenced by YAPET::UI::ListWidget< YAPET::PartDec >::createWindow(), YAPET::UI::ListWidget< YAPET::PartDec >::ListWidget(), YAPET::UI::ListWidget< YAPET::PartDec >::showListItems(), YAPET::UI::ListWidget< YAPET::PartDec >::showScrollIndicators(), and YAPET::UI::ListWidget< YAPET::PartDec >::showSelected().
WINDOW* YAPET::UI::ListWidget< T >::window [private] |
Definition at line 160 of file listwidget.h.
Referenced by YAPET::UI::ListWidget< YAPET::PartDec >::clearWin(), YAPET::UI::ListWidget< YAPET::PartDec >::createWindow(), YAPET::UI::ListWidget< YAPET::PartDec >::focus(), YAPET::UI::ListWidget< YAPET::PartDec >::refresh(), YAPET::UI::ListWidget< YAPET::PartDec >::resize(), YAPET::UI::ListWidget< YAPET::PartDec >::setBorder(), YAPET::UI::ListWidget< YAPET::PartDec >::showListItems(), YAPET::UI::ListWidget< YAPET::PartDec >::showScrollIndicators(), YAPET::UI::ListWidget< YAPET::PartDec >::showSelected(), and YAPET::UI::ListWidget< YAPET::PartDec >::~ListWidget().
1.7.1