Home · All Classes · Main Classes · Deprecated
Public Slots | Signals | Public Member Functions

MPopupList Class Reference

MPopupList implements a popup list for the MeegoTouch Framework. More...

Inherits MDialog.

List of all members.

Public Slots

void click (const QModelIndex &index)
void setCurrentIndex (const QModelIndex &index)

Signals

void clicked (const QModelIndex &index)
void currentIndexChanged (const QModelIndex &index)
void scrollToIndex (const QModelIndex &index)

Public Member Functions

 MPopupList ()
virtual ~MPopupList ()
virtual void setItemModel (QAbstractItemModel *itemModel)
QAbstractItemModelitemModel () const
virtual void setSelectionModel (QItemSelectionModel *selectionModel)
QItemSelectionModelselectionModel () const
virtual void scrollTo (const QModelIndex &index)
QModelIndex currentIndex () const

Detailed Description

MPopupList implements a popup list for the MeegoTouch Framework.

MPopupList is providing limited number and predefined/system-defined set of values to the user, among which the user can choose one option, the selected option is displayed to the user. The alternatives in Popup list are mutually exclusive.

MPopupList derived from MDialog.

It makes heavy use of Qt's Interview Framework to move most code out of the view into in a model to be implemented by the user.

Use one of the various Qt convenience models if subclassing a model is not necessary.

Currently, we expect the model to have only one level of depth, e.g. a table or list and not a tree model. Qt's QComboBox can handle trees to by setting a root index but because writing tree models is more complex and showing a sublist is a rather rare use case, API is kept simple and expects simple models.

Usage guidelines

Example codes

If you just want the user to pick from a list of strings, use QStringListModel like:

          MPopupList *popuplist = new MPopupList();
          QStringListModel *model = new QStringListModel(this);
          QStringList stringList;
          stringList << "Item 1" << "Item 2";
          model->setStringList(stringList);
          popuplist->setItemModel(model);
          popuplist->appear();
See also:
MPopupListModel MPopupListStyle

Constructor & Destructor Documentation

MPopupList::MPopupList (  ) 

Constructs a new popuplist with no content.

MPopupList::~MPopupList (  )  [virtual]

Destroys the popuplist.


Member Function Documentation

void MPopupList::click ( const QModelIndex index  )  [slot]

Performs a click All the usual signals associated with a click are emitted as appropriate.

void MPopupList::clicked ( const QModelIndex index  )  [signal]

This signal is emitted when the item is clicked.

QModelIndex MPopupList::currentIndex (  )  const

Return the model index of the item that is currently being shown as the selected item.

Returns:
the current item model index or invalid QModelIndex
void MPopupList::currentIndexChanged ( const QModelIndex index  )  [signal]

This signal is emitted when the current selected item is changed.

QAbstractItemModel * MPopupList::itemModel (  )  const

Returns the model that this PopupList is presenting.

void MPopupList::scrollTo ( const QModelIndex index  )  [virtual]

Scrolls the view if necessary to ensure that the item at index is visible.

void MPopupList::scrollToIndex ( const QModelIndex index  )  [signal]

This signal is emitted when scrollTo(index) is called to tell the view to scroll to the given item index.

QItemSelectionModel * MPopupList::selectionModel (  )  const

Returns the current selection model.

See also:
setSelectionModel()
void MPopupList::setCurrentIndex ( const QModelIndex index  )  [slot]

Select the given item, deselecting all others.

This is equivalent to:

           selectionModel()->select(index, QItemSelectionModel::ClearAndSelect)

If index is not valid, the current selection is cleared

void MPopupList::setItemModel ( QAbstractItemModel itemModel  )  [virtual]

Sets the item model model as the new datasource for the PopupList.

If you do not want to write your own model, use QStringList model as a convenience adapter

MPopupList does not take ownership of the model. It is up the caller to ensure that it will be deleted. If the model is replaced, it is up to the caller to ensure the previous model is not leaked

  • model The model to use as a new datasource
void MPopupList::setSelectionModel ( QItemSelectionModel selectionModel  )  [virtual]

Sets the current selection model to the given selectionModel.

Note that, if you call setItemModel() after this function, the given selectionModel will be replaced by one created by the view.

Note:
It is up to the application to delete the old selection model if it is no longer needed; i.e., if it is not being used by other views. This will happen automatically when its parent object is deleted. However, if it does not have a parent, or if the parent is a long-lived object, it may be preferable to call its deleteLater() function to explicitly delete it.
See also:
selectionModel(), setItemModel(), clearSelection()

Copyright © 2010 Nokia Corporation
MeeGo Touch