KMyMoneySelector Class Reference

#include <kmymoneyselector.h>

Inheritance diagram for KMyMoneySelector:

QWidget kMyMoneyAccountSelector
Collaboration diagram for KMyMoneySelector:

Collaboration graph
[legend]

List of all members.

Public Slots

void slotSelectAllItems (void)
void slotDeselectAllItems (void)
int slotMakeCompletion (const QRegExp &exp)
int slotMakeCompletion (const QString &txt)

Signals

void stateChanged (void)
void itemSelected (const QString &id)

Public Member Functions

 KMyMoneySelector (QWidget *parent=0, const char *name=0, QWidget::WFlags flags=0)
virtual ~KMyMoneySelector ()
void setSelectionMode (const QListView::SelectionMode mode)
QListView::SelectionMode selectionMode (void) const
void selectedItems (QStringList &list) const
QStringList selectedItems (void) const
void itemList (QStringList &list) const
QStringList itemList (void) const
bool allItemsSelected (void) const
void setSelected (const QString &id, const bool state=false)
KListViewlistView (void) const
void selectAllItems (const bool state)
void selectItems (const QStringList &itemList, const bool state)
void protectItem (const QString &itemId, const bool protect=true)
void setOptimizedWidth (void)
void removeItem (const QString &id)
QListViewItemnewItem (const QString &name, const QString &key=QString(), const QString &id=QString(), QCheckListItem::Type type=QCheckListItem::RadioButtonController)
QListViewItemnewItem (const QString &name, QListViewItem *after, const QString &key=QString(), const QString &id=QString(), QCheckListItem::Type type=QCheckListItem::RadioButtonController)
QListViewItemnewItem (QListViewItem *parent, const QString &name, const QString &key, const QString &id)
QListViewItemnewTopItem (const QString &name, const QString &key, const QString &id)
virtual bool match (const QRegExp &exp, QListViewItem *item) const
void ensureItemVisible (const QListViewItem *item)
QListViewItemitem (const QString &id) const
virtual bool contains (const QString &txt) const
virtual void clear (void)
int optimizedWidth (void) const

Protected Slots

void slotShowSelected (void)
void slotItemSelected (QListViewItem *it_v)
void slotListRightMouse (QListViewItem *it_v, const QPoint &p, int)

Protected Member Functions

void selectedItems (QStringList &list, QListViewItem *item) const
bool allItemsSelected (const QListViewItem *item) const
void selectAllSubItems (QListViewItem *item, const bool state)
void selectSubItems (QListViewItem *item, const QStringList &itemList, const bool state)

Protected Attributes

KListViewm_listView
QStringList m_itemList
QString m_baseName
QListView::SelectionMode m_selMode
QHBoxLayout * m_layout

Private Attributes

const QListViewItemm_visibleItem


Detailed Description

This class implements a general selector for id based objects. It is based on a tree view. Using this widget, one can select one or multiple items depending on the mode of operation and the set of items selected to be displayed. (see setSelectionMode() ).


Constructor & Destructor Documentation

KMyMoneySelector::KMyMoneySelector ( QWidget parent = 0,
const char *  name = 0,
QWidget::WFlags  flags = 0 
)

virtual KMyMoneySelector::~KMyMoneySelector (  )  [virtual]


Member Function Documentation

void KMyMoneySelector::setSelectionMode ( const QListView::SelectionMode  mode  ) 

This method sets the mode of operation of this widget. Supported values are QListView::Single and QListView::Multi.

Parameters:
mode QListView::Single selects single selection mode and QListView::Multi selects multi selection mode
Note:
When the widget is created, it defaults to QListView::Single. Any items loaded into the widget will be cleared if the mode changes. Changing the selection mode also changes the type of the items created through newItem(). You should therefor set the selection mode before you create items.

Reimplemented in kMyMoneyAccountSelector.

QListView::SelectionMode KMyMoneySelector::selectionMode ( void   )  const [inline]

returns the selection mode of the widget.

See also:
setSelectionMode()

void KMyMoneySelector::selectedItems ( QStringList &  list  )  const

This method returns the list of selected item ids. If no item is selected, the list is empty. The list is cleared when the method is called.

Parameters:
list reference to id list

QStringList KMyMoneySelector::selectedItems ( void   )  const

Convenience method for above method. Requires more resources. Provided only for backward compatibility.

Todo:
Deprecated after 1.0

void KMyMoneySelector::itemList ( QStringList &  list  )  const

This method returns the list of all item ids. The list is cleared when the method is called.

Parameters:
list reference to id list

QStringList KMyMoneySelector::itemList ( void   )  const

Convenience method for above method. Requires more resources. Provided only for backward compatibility.

Todo:
Deprecated after 1.0

bool KMyMoneySelector::allItemsSelected ( void   )  const

This method returns an information if all items currently shown are selected or not.

Return values:
true All items shown are selected
false Not all items are selected
Note:
If the selection mode is set to Single, this method always returns false.

void KMyMoneySelector::setSelected ( const QString &  id,
const bool  state = false 
)

This method sets the current selected item and marks the checkbox according to state in multi-selection-mode.

Parameters:
id id of account
state state of checkbox in multi-selection-mode true checked false not checked (default)

KListView* KMyMoneySelector::listView ( void   )  const [inline]

Return a pointer to the KListView object

void KMyMoneySelector::selectAllItems ( const bool  state  ) 

This method selects/deselects all items that are currently in the item list according to the parameter state.

Parameters:
state select items if true, deselect otherwise

void KMyMoneySelector::selectItems ( const QStringList &  itemList,
const bool  state 
)

This method selects/deselects all items that are currently in this object's item list AND are present in the supplied itemList of items to select, according to the state.

Parameters:
itemList of item ids to apply state to
state select items if true, deselect otherwise

void KMyMoneySelector::protectItem ( const QString &  itemId,
const bool  protect = true 
)

Protect an entry from selection. Protection is controlled by the parameter protect.

Parameters:
itemId id of item for which to modify the protection
protect if true, the entry specified by accId cannot be selected. If false, it can be selected. Defaults to true.

void KMyMoneySelector::setOptimizedWidth ( void   ) 

This method modifies the width of the widget to match its optimal size so that all entries fit completely.

void KMyMoneySelector::removeItem ( const QString &  id  ) 

This method removes an item with a given id from the list.

Parameters:
id QString containing id of item to be removed

QListViewItem* KMyMoneySelector::newItem ( const QString &  name,
const QString &  key = QString(),
const QString &  id = QString(),
QCheckListItem::Type  type = QCheckListItem::RadioButtonController 
)

This method creates a new top level KMyMoneyCheckListItem object in the list view. The type can be influenced with the type argument. It defaults to QCheckListItem::RadioButtonController. If id is empty, the item is not selectable. It will be shown 'opened' (see QListViewItem::setOpen())

Returns:
pointer to newly created object

QListViewItem* KMyMoneySelector::newItem ( const QString &  name,
QListViewItem after,
const QString &  key = QString(),
const QString &  id = QString(),
QCheckListItem::Type  type = QCheckListItem::RadioButtonController 
)

Same as above, but create the item following the item pointed to by after. If after is 0, then behave as previous method

QListViewItem* KMyMoneySelector::newItem ( QListViewItem parent,
const QString &  name,
const QString &  key,
const QString &  id 
)

This method creates a new selectable object depending on the selection mode. This is either a KListViewItem for single selection mode or a KMyMoneyCheckListItem for multi selection mode

Note:
The new item will be the first one in the selection
Parameters:
parent pointer to parent item
name the displayed name
key String to be used for completion. If empty defaults to name
id the id used to identify the objects
Returns:
pointer to newly created object

QListViewItem* KMyMoneySelector::newTopItem ( const QString &  name,
const QString &  key,
const QString &  id 
)

This method creates a new selectable object depending on the selection mode. This is either a KListViewItem for single selection mode or a KMyMoneyCheckListItem for multi selection mode. In contrast to the above method, the parent is always the view.

Note:
The new item will be the first one in the selection
Parameters:
name the displayed name
key String to be used for completion. If empty defaults to name
id the id used to identify the objects
Returns:
pointer to newly created object

virtual bool KMyMoneySelector::match ( const QRegExp &  exp,
QListViewItem item 
) const [virtual]

This method checks if a given item matches the given regular expression exp.

Parameters:
exp const reference to a regular expression object
item pointer to QListViewItem
Return values:
true item matches
false item does not match

Reimplemented in kMyMoneyAccountSelector.

void KMyMoneySelector::ensureItemVisible ( const QListViewItem item  ) 

This method delays the call for m_listView->ensureItemVisible(item) for about 10ms. This seems to be necessary when the widget is not (yet) visible on the screen after creation.

Parameters:
item pointer to QListViewItem that should be made visible
See also:
slotShowSelected()

QListViewItem* KMyMoneySelector::item ( const QString &  id  )  const

This method returns a pointer to the QListViewItem with the id id. If such an item is not contained in the list, 0 will be returned.

Parameters:
id id to be used to find a QListViewItem pointer for

virtual bool KMyMoneySelector::contains ( const QString &  txt  )  const [virtual]

This method returns, if any of the items in the selector contains the text txt.

Parameters:
txt const reference to string to be looked for
Return values:
true exact match found
false no match found

Reimplemented in kMyMoneyAccountSelector.

virtual void KMyMoneySelector::clear ( void   )  [virtual]

Clears all items of the selector and the associated listview.

int KMyMoneySelector::optimizedWidth ( void   )  const

This method returns the optimal width for the widget

void KMyMoneySelector::slotSelectAllItems ( void   )  [inline, slot]

This slot selects all items that are currently in the item list of the widget.

void KMyMoneySelector::slotDeselectAllItems ( void   )  [inline, slot]

This slot deselects all items that are currently in the item list of the widget.

void KMyMoneySelector::stateChanged ( void   )  [signal]

void KMyMoneySelector::itemSelected ( const QString &  id  )  [signal]

void KMyMoneySelector::selectedItems ( QStringList &  list,
QListViewItem item 
) const [protected]

Helper method for selectedItems() to traverse the tree.

Parameters:
list list of selected ids
item pointer to item to start with

bool KMyMoneySelector::allItemsSelected ( const QListViewItem item  )  const [protected]

Helper method for allItemsSelected() to traverse the tree.

Parameters:
item pointer to item to start with

void KMyMoneySelector::selectAllSubItems ( QListViewItem item,
const bool  state 
) [protected]

This is a helper method for selectAllItems().

Parameters:
item pointer to item to start with
state selection state (true = selected, false = not selected)

void KMyMoneySelector::selectSubItems ( QListViewItem item,
const QStringList &  itemList,
const bool  state 
) [protected]

This is a helper method for selectItems().

Parameters:
item pointer to item to start with
itemList list of ids to be selected
state selection state (true = selected, false = not selected)

int KMyMoneySelector::slotMakeCompletion ( const QRegExp &  exp  )  [slot]

Hide all listview items that do not match the regular expression exp. This method returns the number of visible items

Parameters:
exp const reference to QRegExp that an item must match to stay visible
Returns:
number of visible items

int KMyMoneySelector::slotMakeCompletion ( const QString &  txt  )  [slot]

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Parameters:
txt contains the pattern for a QRegExp

void KMyMoneySelector::slotShowSelected ( void   )  [protected, slot]

This slot is usually connected to a timer signal and simply calls m_listView->ensureItemVisible() for the last selected item in this widget.

See also:
ensureItemVisible(), setSelected(const QString&)

void KMyMoneySelector::slotItemSelected ( QListViewItem it_v  )  [protected, slot]

This slot is connected to the KListView executed signal

void KMyMoneySelector::slotListRightMouse ( QListViewItem it_v,
const QPoint &  p,
int   
) [protected, slot]

This slot processes the right mouse button press on a list view item.

Parameters:
it_v pointer to list view item that was pressed
p the position where the mouse was pressed


Member Data Documentation

QStringList KMyMoneySelector::m_itemList [protected]

QString KMyMoneySelector::m_baseName [protected]

QListView::SelectionMode KMyMoneySelector::m_selMode [protected]

QHBoxLayout* KMyMoneySelector::m_layout [protected]


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

Generated on Wed Jan 26 13:08:08 2011 for KMyMoney by  doxygen 1.5.6