YAPETUI::ListWidget< T > Class Template Reference

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

#include <listwidget.h>

List of all members.

Classes

class  ItemContains
 Used to search for item names. More...

Public Types


Public Member Functions

void deleteSelectedItem ()
virtual int focus () throw (UIException)
 Sets the focus to this widget.
std::list< T > & getList ()
const std::list< T > & getList () const
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 ()
 Sorts the list with the currently set sort order.
void setSortOrder (SortOrder so)
 Sorts the list.
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 (c_list_it &it) const
l_size_type validateIterator (list_it &it)
 Validates the given iterator against the list.

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 YAPETUI::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 82 of file listwidget.h.


Member Typedef Documentation

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

Definition at line 173 of file listwidget.h.

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

Definition at line 170 of file listwidget.h.

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

Definition at line 172 of file listwidget.h.


Member Enumeration Documentation

template<class T>
enum YAPETUI::ListWidget::SortOrder

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

Enumerator:
ASCENDING 
DESCENDING 

Definition at line 90 of file listwidget.h.


Constructor & Destructor Documentation

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

Definition at line 190 of file listwidget.h.

template<class T>
YAPETUI::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 508 of file listwidget.h.

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

Definition at line 529 of file listwidget.h.


Member Function Documentation

template<class T>
void YAPETUI::ListWidget< T >::clearWin (  )  throw (UIException) [inline, private]

Definition at line 264 of file listwidget.h.

Referenced by YAPETUI::ListWidget< YAPET::PartDec >::showListItems().

template<class T>
void YAPETUI::ListWidget< T >::createWindow ( int  sx,
int  sy,
int  w,
int  h 
) throw (UIException) [inline, private]

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

Definition at line 571 of file listwidget.h.

Referenced by MainWindow::deleteSelectedRecord().

template<class T>
virtual int YAPETUI::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 609 of file listwidget.h.

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

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

Definition at line 585 of file listwidget.h.

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

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

Definition at line 695 of file listwidget.h.

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

Definition at line 697 of file listwidget.h.

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

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

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

Returns:
SortOrder value.

Definition at line 714 of file listwidget.h.

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

template<class T>
void YAPETUI::ListWidget< T >::highlightItemIter ( list_it it  )  [inline, private]

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

Definition at line 191 of file listwidget.h.

template<class T>
int YAPETUI::ListWidget< T >::pagesize (  )  [inline, private]

template<class T>
void YAPETUI::ListWidget< T >::refresh (  )  throw (UIException) [inline]

template<class T>
void YAPETUI::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 561 of file listwidget.h.

Referenced by MainWindow::editSelectedRecord().

template<class T>
void YAPETUI::ListWidget< T >::resize ( int  sx,
int  sy,
int  w,
int  h 
) throw (UIException) [inline]

Definition at line 679 of file listwidget.h.

Referenced by MainWindow::resize().

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

Definition at line 391 of file listwidget.h.

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

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

Definition at line 451 of file listwidget.h.

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

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

Definition at line 441 of file listwidget.h.

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

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

Definition at line 422 of file listwidget.h.

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

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

Definition at line 408 of file listwidget.h.

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

template<class T>
void YAPETUI::ListWidget< T >::scrollUp (  )  [inline, private]

template<class T>
bool YAPETUI::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 777 of file listwidget.h.

Referenced by MainWindow::searchNext().

template<class T>
bool YAPETUI::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 756 of file listwidget.h.

Referenced by MainWindow::searchTerm().

template<class T>
int YAPETUI::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 255 of file listwidget.h.

Referenced by YAPETUI::ListWidget< YAPET::PartDec >::clearWin(), YAPETUI::ListWidget< YAPET::PartDec >::createWindow(), and YAPETUI::ListWidget< YAPET::PartDec >::focus().

template<class T>
void YAPETUI::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 544 of file listwidget.h.

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

template<class T>
void YAPETUI::ListWidget< T >::setSortOrder (  )  [inline]

template<class T>
void YAPETUI::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 724 of file listwidget.h.

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

template<class T>
void YAPETUI::ListWidget< T >::showListItems (  )  throw (UIException) [inline, private]

template<class T>
void YAPETUI::ListWidget< T >::showScrollIndicators (  )  throw (UIException) [inline, private]

template<class T>
void YAPETUI::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 329 of file listwidget.h.

Referenced by YAPETUI::ListWidget< YAPET::PartDec >::focus(), YAPETUI::ListWidget< YAPET::PartDec >::highlightItemIter(), YAPETUI::ListWidget< YAPET::PartDec >::refresh(), YAPETUI::ListWidget< YAPET::PartDec >::scrollDown(), YAPETUI::ListWidget< YAPET::PartDec >::scrollEnd(), YAPETUI::ListWidget< YAPET::PartDec >::scrollHome(), YAPETUI::ListWidget< YAPET::PartDec >::scrollPageDown(), YAPETUI::ListWidget< YAPET::PartDec >::scrollPageUp(), and YAPETUI::ListWidget< YAPET::PartDec >::scrollUp().

template<class T>
l_size_type YAPETUI::ListWidget< T >::size (  )  [inline]

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

Definition at line 218 of file listwidget.h.

template<class T>
l_size_type YAPETUI::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, a negative value otherwise if the iterator is not valid.

Definition at line 207 of file listwidget.h.

Referenced by YAPETUI::ListWidget< YAPET::PartDec >::highlightItemIter(), and YAPETUI::ListWidget< YAPET::PartDec >::searchNext().


Member Data Documentation

template<class T>
int YAPETUI::ListWidget< T >::cur_pos [private]

template<class T>
list_it YAPETUI::ListWidget< T >::cur_search_hit [private]

When the list is searched, this iterator points to the current hit of a search.

Definition at line 181 of file listwidget.h.

Referenced by YAPETUI::ListWidget< YAPET::PartDec >::searchNext(), and YAPETUI::ListWidget< YAPET::PartDec >::searchTerm().

template<class T>
bool YAPETUI::ListWidget< T >::hasfocus [private]

Indicates whether or not this widget has the focus. Determines how the border has to be drawn

Definition at line 135 of file listwidget.h.

Referenced by YAPETUI::ListWidget< YAPET::PartDec >::focus(), YAPETUI::ListWidget< YAPET::PartDec >::setBorder(), and YAPETUI::ListWidget< YAPET::PartDec >::showSelected().

template<class T>
int YAPETUI::ListWidget< T >::height [private]

template<class T>
std::list<T> YAPETUI::ListWidget< T >::itemlist [private]

template<class T>
std::string YAPETUI::ListWidget< T >::last_search_term [private]

Holds the last search term used.

Definition at line 188 of file listwidget.h.

Referenced by YAPETUI::ListWidget< YAPET::PartDec >::searchNext(), and YAPETUI::ListWidget< YAPET::PartDec >::searchTerm().

template<class T>
SortOrder YAPETUI::ListWidget< T >::sortorder [private]

template<class T>
int YAPETUI::ListWidget< T >::start_pos [private]

template<class T>
int YAPETUI::ListWidget< T >::width [private]

template<class T>
WINDOW* YAPETUI::ListWidget< T >::window [private]


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

Generated on Mon Apr 13 17:29:49 2009 for YAPET by  doxygen 1.5.8