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

MComboBox Class Reference

MComboBox implementation of a comboBox widget. More...

Inherits MWidgetController.

List of all members.

Public Slots

void clear ()
void setIconID (const QString &id)
void setIconVisible (bool)
void setTitle (const QString &title)
void setProgressIndicatorVisible (bool visible)
void showProgressIndicator ()
void hideProgressIndicator ()
void setCurrentIndex (int index)
void click ()
void dismiss ()

Signals

void clicked ()
void dismissed ()
void currentIndexChanged (int index)
void currentIndexChanged (const QString &text)
void activated (int index)
void activated (const QString &text)

Public Member Functions

 MComboBox (QGraphicsItem *parent=0)
virtual ~MComboBox ()
virtual void setItemModel (QAbstractItemModel *itemModel)
QAbstractItemModelitemModel () const
virtual void setSelectionModel (QItemSelectionModel *selectionModel)
QItemSelectionModelselectionModel () const
QString iconID () const
bool isIconVisible () const
QString title () const
bool isProgressIndicatorVisible () const
void addItem (const QString &text)
void addItem (const QString &iconID, const QString &text)
void addItems (const QStringList &texts)
int count () const
int currentIndex () const
QString currentText () const
QString itemText (int index) const
QString itemIconID (int index) const
void insertItem (int index, const QString &text)
void insertItem (int index, const QString &icon, const QString &text)
void insertItems (int index, const QStringList &list)
void removeItem (int index)
void setItemText (int index, const QString &text)
void setItemIconID (int index, const QString &iconID)

Properties

QString iconID
bool iconVisible
QString title
bool progressIndicatorVisible
QAbstractItemModel itemModel
QItemSelectionModel selectionModel
int currentIndex
QString currentText
int count

Detailed Description

MComboBox implementation of a comboBox widget.

Overview

The MComboBox widget is a combined button and popup list. It is very similar to QComboBox, but does not allow editing the text.

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

MComboBox uses the Qt's model/view framework for its popup list and to store its items. By default a QStandardItemModel stores the items and a MPopupList displays the popuplist. You can access the model by model(), but MComboBox also provides functions to set and get item data (e.g., setItemText() and itemText()). You can also set a new model.

A combobox can be populated using the insert functions, insertItem(), insertItems(), addItem() and addItems() for example. Items can be changed with setItemText(). An item can be removed with removeItem() and all items can be removed with clear(). The text of the current item is returned by currentText(), and the text of a numbered item is returned with itemText(). The current item can be set with setCurrentIndex(). The number of items in the combobox is returned by count();

For example, if you just want the user to pick from a list of strings:

        MComboBox *combobox = new MComboBox();
        combobox->setTitle("Select an item");
        combobox->setIconID("icon-l-gallery");

        QStringList stringList;
        stringList << "Item 1" << "Item 2";
        combobox->addItems(stringList);

Constructor & Destructor Documentation

MComboBox::MComboBox ( QGraphicsItem parent = 0  ) 

Constructs a combobox with the given parent.

MComboBox::~MComboBox (  )  [virtual]

Destroys the combobox.


Member Function Documentation

void MComboBox::activated ( int  index  )  [signal]

This signal is sent when the user chooses an item in the combobox.

The item's index is passed.

Note that this signal is sent even when the choice is not changed. If you need to know when the choice actually changes, use signal currentIndexChanged().

void MComboBox::activated ( const QString text  )  [signal]

This signal is sent when the user chooses an item in the combobox.

The item's text is passed.

Note that this signal is sent even when the choice is not changed. If you need to know when the choice actually changes, use signal currentIndexChanged().

void MComboBox::addItem ( const QString text  ) 

Adds an item to the combobox with the given text.

The item is appended to the list of existing items.

void MComboBox::addItem ( const QString iconID,
const QString text 
)

Adds an item to the combobox with the given iconID and text.

The item is appended to the list of existing items.

void MComboBox::addItems ( const QStringList texts  ) 

Adds each of the strings in the given texts to the combobox.

Each item is appended to the list of existing items in turn.

void MComboBox::clear (  )  [slot]

Clears the combobox, removing all items.

Note: If you have set an external model on the combobox this model will still be cleared when calling this function.

void MComboBox::click (  )  [slot]

Performs a click.

void MComboBox::clicked (  )  [signal]

This signal is emitted when comboBox is clicked.

int MComboBox::count (  )  const

the number of items in the combobox By default, for an empty combo box, this property has a value of 0.

int MComboBox::currentIndex (  )  const

the index of the current item in the combobox.

The current index can change when inserting or removing items.

By default, for an empty combo box or a combo box in which no current item is set, this property has a value of -1.

void MComboBox::currentIndexChanged ( int  index  )  [signal]

This signal is emitted whenever the currentIndex in the combobox changes either through user interaction or programmatically.

void MComboBox::currentIndexChanged ( const QString text  )  [signal]

This is an overloaded member function, provided for convenience.

This signal is sent whenever the currentIndex in the combobox changes either through user interaction or programmatically. The item's text is passed.

QString MComboBox::currentText (  )  const

the text of the current item

By default, for an empty combo box or a combo box in which no current item is set, this property contains an empty string.

void MComboBox::dismiss (  )  [slot]

Dismisses popup list programatically.

void MComboBox::dismissed (  )  [signal]

This signal is emitted when popup list is dismissed.

void MComboBox::hideProgressIndicator (  )  [inline, slot]

hides progress indicator

QString MComboBox::iconID (  )  const

Returns the logical ID associated with this comboBox's icon.

void MComboBox::insertItem ( int  index,
const QString text 
)

Inserts the text into the combobox at the given index.

If the index is equal to or higher than the total number of items, the new item is appended to the list of existing items. If the index is zero or negative, the new item is prepended to the list of existing items.

See also:
insertItems()
void MComboBox::insertItem ( int  index,
const QString icon,
const QString text 
)

Inserts the icon, text into the combobox at the given index.

If the index is equal to or higher than the total number of items, the new item is appended to the list of existing items. If the index is zero or negative, the new item is prepended to the list of existing items.

See also:
insertItems()
void MComboBox::insertItems ( int  index,
const QStringList list 
)

Inserts the strings from the list into the combobox as separate items, starting at the index specified.

If the index is equal to or higher than the total number of items, the new items are appended to the list of existing items. If the index is zero or negative, the new items are prepended to the list of existing items.

See also:
insertItem()
bool MComboBox::isIconVisible (  )  const

Returns true if the icon of the comboBox is visible.

bool MComboBox::isProgressIndicatorVisible (  )  const

Returns true if progress indicator is visible.

QString MComboBox::itemIconID ( int  index  )  const

Returns the iconID for the given index in the combobox.

QAbstractItemModel* MComboBox::itemModel (  )  const

Returns the model that this comboBox is presenting.

QString MComboBox::itemText ( int  index  )  const

Returns the text for the given index in the combobox.

void MComboBox::removeItem ( int  index  ) 

Removes the item at the given index from the combobox.

This will update the current index if the index is removed.

QItemSelectionModel* MComboBox::selectionModel (  )  const

Returns the current selection model.

void MComboBox::setCurrentIndex ( int  index  )  [slot]

Set current index.

void MComboBox::setIconID ( const QString id  )  [slot]

Sets the logical ID associated with this comboBox's icon to id.

void MComboBox::setIconVisible ( bool  visible  )  [slot]

Set the visibility of the icon of the comboBox.

void MComboBox::setItemIconID ( int  index,
const QString iconID 
)

Sets the iconID for the item on the given index in the combobox.

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

Sets the item model itemModel as the new datasource for the comboBox.

itemModel must not be 0.

MComboBox 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.

  • itemModel The model to use as a new datasource
void MComboBox::setItemText ( int  index,
const QString text 
)

Sets the text for the item on the given index in the combobox.

void MComboBox::setProgressIndicatorVisible ( bool  visible  )  [slot]

shows progress indicator

void MComboBox::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.

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()
void MComboBox::setTitle ( const QString title  )  [slot]

Set comboBox title.

void MComboBox::showProgressIndicator (  )  [inline, slot]

shows progress indicator

QString MComboBox::title (  )  const

Returns the title of comboBox.


Property Documentation

MComboBox::count [read]

The number of items in the combobox.

By default, for an empty combo box, this property has the value of 0.

MComboBox::currentIndex [read, write]

The index of the current item in the combobox.

The current index can change when inserting or removing items.

By default, for an empty combo box or a combo box in which no current item is set, this property has the value of -1.

MComboBox::currentText [read]

The text of the current item.

By default, for an empty combo box or a combo box in which no current item is set, this property contains the empty string.

MComboBox::iconID [read, write]
MComboBox::iconVisible [read, write]
MComboBox::itemModel [read, write]

The QAbstractItemModel which is used by the MComboBox for the list of items.

MComboBox::progressIndicatorVisible [read, write]
MComboBox::selectionModel [read, write]

Keeps track of itemModel selected items.

MComboBox::title [read, write]

Copyright © 2010 Nokia Corporation
MeeGo Touch