Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes

YAPET::UI::ListWidget< T > Class Template Reference

A widget showing a list of items for selecting one. More...

#include <listwidget.h>

Inheritance diagram for YAPET::UI::ListWidget< T >:
Inheritance graph
[legend]
Collaboration diagram for YAPET::UI::ListWidget< T >:
Collaboration graph
[legend]

List of all members.

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 ()
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 ListWidgetoperator= (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

Detailed Description

template<class T>
class YAPET::UI::ListWidget< T >

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.


Member Typedef Documentation

template<class T>
typedef std::list<T>::const_iterator YAPET::UI::ListWidget< T >::c_list_it [private]

Definition at line 209 of file listwidget.h.

template<class T>
typedef std::list<T>::size_type YAPET::UI::ListWidget< T >::l_size_type [private]

Definition at line 206 of file listwidget.h.

template<class T>
typedef std::list<T>::iterator YAPET::UI::ListWidget< T >::list_it [private]

Definition at line 208 of file listwidget.h.


Member Enumeration Documentation

template<class T>
enum YAPET::UI::ListWidget::SortOrder

The sort order that are available for sorting the list items.

Enumerator:
ASCENDING 
DESCENDING 

Definition at line 101 of file listwidget.h.


Constructor & Destructor Documentation

template<class T>
YAPET::UI::ListWidget< T >::ListWidget ( const ListWidget< T > &  lw  )  [inline, private]

Definition at line 226 of file listwidget.h.

template<class T>
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.

Parameters:
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.

template<class T>
virtual YAPET::UI::ListWidget< T >::~ListWidget (  )  [inline, virtual]

Definition at line 582 of file listwidget.h.


Member Function Documentation

template<class T>
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().

Here is the caller graph for this function:

template<class T>
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().

Here is the caller graph for this function:

template<class T>
void YAPET::UI::ListWidget< T >::deleteSelectedItem (  )  [inline]

Definition at line 625 of file listwidget.h.

Referenced by MainWindow::deleteSelectedRecord().

Here is the caller graph for this function:

template<class T>
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.

Returns:
the key stroke that made it loose the focus.

Definition at line 670 of file listwidget.h.

Referenced by MainWindow::run(), and FileOpen::run().

Here is the caller graph for this function:

template<class T>
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().

Here is the caller graph for this function:

template<class T>
std::list<T>& YAPET::UI::ListWidget< T >::getList (  )  [inline]

Definition at line 644 of file listwidget.h.

template<class T>
int YAPET::UI::ListWidget< T >::getListPos (  )  [inline]

Definition at line 765 of file listwidget.h.

template<class T>
T YAPET::UI::ListWidget< T >::getSelectedItem (  )  [inline]

Definition at line 769 of file listwidget.h.

Referenced by MainWindow::editSelectedRecord(), and FileOpen::run().

Here is the caller graph for this function:

template<class T>
SortOrder YAPET::UI::ListWidget< T >::getSortOrder (  )  const [inline]

Returns the current sort order that is applied to the list.

Returns:
SortOrder value.

Definition at line 790 of file listwidget.h.

Referenced by MainWindow::setSortOrder(), and YAPET::UI::ListWidget< YAPET::PartDec >::setSortOrder().

Here is the caller graph for this function:

template<class T>
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().

Here is the caller graph for this function:

template<class T>
const ListWidget& YAPET::UI::ListWidget< T >::operator= ( const ListWidget< T > &  lw  )  [inline, private]

Definition at line 227 of file listwidget.h.

template<class T>
int YAPET::UI::ListWidget< T >::pagesize (  )  [inline, private]
template<class T>
void YAPET::UI::ListWidget< T >::refresh (  )  throw (UIException) [inline]
template<class T>
void YAPET::UI::ListWidget< T >::replaceCurrentItem ( T &  item  )  [inline]

Replaces the item at the current position of the list selected by the user.

Parameters:
item the new item.

Definition at line 614 of file listwidget.h.

Referenced by MainWindow::editSelectedRecord().

Here is the caller graph for this function:

template<class T>
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().

Here is the caller graph for this function:

template<class T>
void YAPET::UI::ListWidget< T >::scrollDown (  )  [inline, private]

Definition at line 437 of file listwidget.h.

Referenced by YAPET::UI::ListWidget< YAPET::PartDec >::focus().

Here is the caller graph for this function:

template<class T>
void YAPET::UI::ListWidget< T >::scrollEnd (  )  [inline, private]

Definition at line 503 of file listwidget.h.

Referenced by YAPET::UI::ListWidget< YAPET::PartDec >::focus().

Here is the caller graph for this function:

template<class T>
void YAPET::UI::ListWidget< T >::scrollHome (  )  [inline, private]

Definition at line 494 of file listwidget.h.

Referenced by YAPET::UI::ListWidget< YAPET::PartDec >::focus().

Here is the caller graph for this function:

template<class T>
void YAPET::UI::ListWidget< T >::scrollPageDown (  )  [inline, private]

Definition at line 472 of file listwidget.h.

Referenced by YAPET::UI::ListWidget< YAPET::PartDec >::focus().

Here is the caller graph for this function:

template<class T>
void YAPET::UI::ListWidget< T >::scrollPageUp (  )  [inline, private]

Definition at line 454 of file listwidget.h.

Referenced by YAPET::UI::ListWidget< YAPET::PartDec >::focus().

Here is the caller graph for this function:

template<class T>
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().

Here is the caller graph for this function:

template<class T>
bool YAPET::UI::ListWidget< T >::searchNext (  )  [inline]

Performs a search again using the last search term again.

Return values:
\c true if the term was found again, else false

Definition at line 856 of file listwidget.h.

Referenced by MainWindow::searchNext().

Here is the caller graph for this function:

template<class T>
bool YAPET::UI::ListWidget< T >::searchTerm ( const char *  t  )  [inline]

Searches for a given term in the list items.

Parameters:
t the term to search for
Return values:
\c true if the term was found, else false.

Definition at line 835 of file listwidget.h.

Referenced by MainWindow::searchTerm().

Here is the caller graph for this function:

template<class T>
int YAPET::UI::ListWidget< T >::setBorder (  )  const [inline, private]

Sets the border depending on whether or not the list has the focus.

Return values:
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().

Here is the caller graph for this function:

template<class T>
void YAPET::UI::ListWidget< T >::setList ( typename std::list< T > &  l  )  [inline]

Sets a new list of items to display.

Parameters:
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().

Here is the caller graph for this function:

template<class T>
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.

Parameters:
so value of the type SortOrder

Definition at line 802 of file listwidget.h.

Referenced by MainWindow::addNewRecord(), MainWindow::editSelectedRecord(), and MainWindow::setSortOrder().

Here is the caller graph for this function:

template<class T>
void YAPET::UI::ListWidget< T >::setSortOrder (  )  [inline]
template<class T>
void YAPET::UI::ListWidget< T >::showListItems (  )  throw (UIException) [inline, private]
template<class T>
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().

Here is the caller graph for this function:

template<class T>
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.

Parameters:
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().

Here is the caller graph for this function:

template<class T>
l_size_type YAPET::UI::ListWidget< T >::size (  )  [inline]
template<class T>
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

Parameters:
it the iterator to be validated against itemlist.
Return values:
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().

Here is the caller graph for this function:

template<class T>
l_size_type YAPET::UI::ListWidget< T >::validateIterator ( c_list_it it  )  const [inline, private]

Definition at line 255 of file listwidget.h.


Member Data Documentation

template<class T>
int YAPET::UI::ListWidget< T >::cur_pos [private]
template<class T>
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().

template<class T>
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().

template<class T>
int YAPET::UI::ListWidget< T >::height [private]
template<class T>
std::list<T> YAPET::UI::ListWidget< T >::itemlist [private]
template<class T>
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().

template<class T>
SortOrder YAPET::UI::ListWidget< T >::sortorder [private]
template<class T>
int YAPET::UI::ListWidget< T >::start_pos [private]
template<class T>
int YAPET::UI::ListWidget< T >::width [private]
template<class T>
WINDOW* YAPET::UI::ListWidget< T >::window [private]

The documentation for this class was generated from the following file: