#include <kmymoneyselector.h>
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) |
KListView * | listView (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) |
QListViewItem * | newItem (const QString &name, const QString &key=QString(), const QString &id=QString(), QCheckListItem::Type type=QCheckListItem::RadioButtonController) |
QListViewItem * | newItem (const QString &name, QListViewItem *after, const QString &key=QString(), const QString &id=QString(), QCheckListItem::Type type=QCheckListItem::RadioButtonController) |
QListViewItem * | newItem (QListViewItem *parent, const QString &name, const QString &key, const QString &id) |
QListViewItem * | newTopItem (const QString &name, const QString &key, const QString &id) |
virtual bool | match (const QRegExp &exp, QListViewItem *item) const |
void | ensureItemVisible (const QListViewItem *item) |
QListViewItem * | item (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 | |
KListView * | m_listView |
QStringList | m_itemList |
QString | m_baseName |
QListView::SelectionMode | m_selMode |
QHBoxLayout * | m_layout |
Private Attributes | |
const QListViewItem * | m_visibleItem |
KMyMoneySelector::KMyMoneySelector | ( | QWidget * | parent = 0 , |
|
const char * | name = 0 , |
|||
QWidget::WFlags | flags = 0 | |||
) |
virtual KMyMoneySelector::~KMyMoneySelector | ( | ) | [virtual] |
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
.
mode | QListView::Single selects single selection mode and QListView::Multi selects multi selection mode |
Reimplemented in kMyMoneyAccountSelector.
QListView::SelectionMode KMyMoneySelector::selectionMode | ( | void | ) | const [inline] |
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.
list | reference to id list |
QStringList KMyMoneySelector::selectedItems | ( | void | ) | const |
Convenience method for above method. Requires more resources. Provided only for backward compatibility.
void KMyMoneySelector::itemList | ( | QStringList & | list | ) | const |
This method returns the list of all item ids. The list is cleared when the method is called.
list | reference to id list |
QStringList KMyMoneySelector::itemList | ( | void | ) | const |
Convenience method for above method. Requires more resources. Provided only for backward compatibility.
bool KMyMoneySelector::allItemsSelected | ( | void | ) | const |
This method returns an information if all items currently shown are selected or not.
true | All items shown are selected | |
false | Not all items are selected |
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.
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
.
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
.
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
.
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.
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())
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
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 |
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.
name | the displayed name | |
key | String to be used for completion. If empty defaults to name | |
id | the id used to identify the objects |
virtual bool KMyMoneySelector::match | ( | const QRegExp & | exp, | |
QListViewItem * | item | |||
) | const [virtual] |
This method checks if a given item matches the given regular expression exp.
exp | const reference to a regular expression object | |
item | pointer to QListViewItem |
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.
item | pointer to QListViewItem that should be made visible |
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.
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.
txt | const reference to string to be looked for |
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.
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.
item | pointer to item to start with |
void KMyMoneySelector::selectAllSubItems | ( | QListViewItem * | item, | |
const bool | state | |||
) | [protected] |
This is a helper method for selectAllItems().
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().
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
exp | const reference to QRegExp that an item must match to stay visible |
int KMyMoneySelector::slotMakeCompletion | ( | const QString & | txt | ) | [slot] |
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
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.
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.
it_v | pointer to list view item that was pressed | |
p | the position where the mouse was pressed |
KListView* KMyMoneySelector::m_listView [protected] |
QStringList KMyMoneySelector::m_itemList [protected] |
QString KMyMoneySelector::m_baseName [protected] |
QListView::SelectionMode KMyMoneySelector::m_selMode [protected] |
QHBoxLayout* KMyMoneySelector::m_layout [protected] |
const QListViewItem* KMyMoneySelector::m_visibleItem [private] |