Home · All Classes · Grouped Classes · Annotated · Functions

QAbstractSoftKeyLabelHelper Class Reference

The QAbstractSoftKeyLabelHelper class provides an abstract base class for the softkey helpers, assisting in ensuring that the qsoftkey labels show the correct icons or words. More...

    #include <QAbstractSoftKeyLabelHelper>

Inherits QObject.

Inherited by QLineEditSoftKeyLabelHelper and QSoftKeyLabelHelper.

Public Functions

Public Slots

Protected Functions

Additional Inherited Members


Detailed Description

The QAbstractSoftKeyLabelHelper class provides an abstract base class for the softkey helpers, assisting in ensuring that the qsoftkey labels show the correct icons or words.

This class handles most of the interactions with the system, including notifications of changes to the widget being "helped".

QAbstractSoftkeyLabelHelper provides support for all other SoftKeyLabel helpers. It automatically registers itself and its widget or class with the ContextKeyManager, as well as ensuring that it is destroyed in a timely fashion.

It also connects several standard messages for use by its child classes, allowing these classes to simply set the correct buttons when the widget focuses in or out, or is asked to.

There are two different ways to create any member of the QSoftkeyHelper family, and two corresponding modes of use. QSoftkeyHelpers in general can be created on either a widget, taking a pointer to that widget, or on a class, taking a QString of the name of the class.

In either case, QAbstractSoftKeyLabelHelper ensures that the the helper automatically connects up typical messages, automatically registers with the server, and automatically destorys itself at an appropriate time. As a consequence, objects of this class can typically be instatiated on the heap and then forgotten about.

For example, to instantiate a MySoftkeyLabelHelper derived from QAbstractSoftKeyLabelHelper on a specific widget use:

    MyWidget* myWidget = new MyWidget();
    new MySoftkeyLabelHelper(myWidget);

To instantiate the same helper on all widgets of the MyWidget class use:

    new MySoftkeyLabelHelper("MyWidget");

Whenever any MyWidget gains focus, the sofkey helper is notified as appropriate.

Simple classes derived from QAbstractSoftKeyLabelHelper will typically need to implement only their constructor/destructor, focusIn() and updateAllLabels(), and will simply set appropriate keys according to the state of the widget being "helped". See QSoftKeyLabelHelper for an example of this sort of class used in Qtopia.

More complex classes may also need to implement focusOut(), enterEditFocus() and leaveEditFocus(), as well as currentWidgetChangeNotification(). For example QLineEditSoftKeyLabelHelper installs an event filter during enterEditocus() in order to react appropriately to QInputMethodEvents, and removes the event filter in leaveEditFocus(), and also clears its internal state when recieving currentWidgetChangeNotification(). For more information on this more complex example see QLineEditSoftKeyLabelHelper.


Member Function Documentation

QAbstractSoftKeyLabelHelper::QAbstractSoftKeyLabelHelper ( QWidget * widget )

Construct a QAbstractSoftKeyLabelHelper on widget and set up connections appropriately. Also connect the destroyed() signal of widget to the deleteLater() slot of this QAbstractSoftKeyLabelHelper, so that it is destroyed at the right time.

QAbstractSoftKeyLabelHelper::QAbstractSoftKeyLabelHelper ( const QString & className )

Construct a QAbstractSoftKeyLabelHelper on behalf of all classes implementing or derived from className.

QAbstractSoftKeyLabelHelper::~QAbstractSoftKeyLabelHelper ()   [virtual]

Destroy the QAbstractSoftKeyLabelHelper and clean up. Also deregister any widgets or classes with the server.

QString QAbstractSoftKeyLabelHelper::className () const   [virtual]

Returns the className that this helper is for, or an empty string if this helper is acting on behalf of a specific widget.

void QAbstractSoftKeyLabelHelper::clearLabel ( int key )   [protected]

Clear the label for . This is the same as setting the label to QSoftMenuBar::NoLabel Qt::Key_Select and Qt::Key_Back are the most common values for key. Qt::Key_Menu is used to change the third softkey, but this is uncommon in Qtopia, as this key is usually used for the soft menu and left unchanged.

See also setStandardLabel(), setLabelText(), and setLabelPixmap().

QWidget * QAbstractSoftKeyLabelHelper::currentWidget ()   [protected]

Returns the widget the helper is currently acting for. If the helper was instatiated on a widget, this will always be that widget. If the helper was instatiated on a class, this will be the widget implementing or derived from that class that most recently had focus.

Note: A non-zero value does not imply that that widget currently has focus.

See also setCurrentWidget().

void QAbstractSoftKeyLabelHelper::currentWidgetChangeNotification ( QWidget * newWidget, QWidget * oldWidget )   [virtual protected]

This function is called when focus changes to a widget under this QAbstractSoftKeyLabelHelpers juristiction. newWidget is the widget gaining focus, and oldWidget is the widget that just lost focus.

Implement this function to perform any initialisation/state reset necessary when changing widgets. Connections and event filters should be removed on focus-out, so this will generally only be necessary if the helper keeps state for some reason.

This function is called after the QAbstractSoftKeyLabelHelper registers various notifications, but before the the helper recieves any pending focusIn() or enterEditFocus() notifications.

See also focusIn() and enterEditFocus().

bool QAbstractSoftKeyLabelHelper::enterEditFocus ( QWidget * widget )   [virtual]

Implement this function in a derived class to respond to gaining edit focus on the current widget widget. The Default implementation returns false.

See also focusIn(), focusOut(), and leaveEditFocus().

bool QAbstractSoftKeyLabelHelper::focusIn ( QWidget * widget )   [pure virtual]

Implement this function in a derived class to respond to gaining focus on the current widget widget. This is typically where any necessary connections should be made or eventFilters installed

The return value is not used by the system, and derived functions are free to utilise it as convenient.

See also QObject::connect(), QObject::installEventFilter(), focusOut(), enterEditFocus(), and leaveEditFocus().

bool QAbstractSoftKeyLabelHelper::focusOut ( QWidget * widget )   [virtual]

Implement this function in a derived class to respond to losing focus on the current widget widget. The Default implementation returns false.

See also focusIn(), enterEditFocus(), and leaveEditFocus().

bool QAbstractSoftKeyLabelHelper::leaveEditFocus ( QWidget * widget )   [virtual]

Implement this function in a derived class to respond to losing edit focus on the current widget widget. The Default implementation returns false.

See also focusIn(), focusOut(), and enterEditFocus().

void QAbstractSoftKeyLabelHelper::setClass ( const QString & className )   [virtual protected]

Set the class for a softkey helper to className.

This is intended as a once-off function used once after creating a Softkey Helper.

Changing classes and reusing helpers should work in theory, but it is recommended that a new one is instantiated for each class and old ones are destroyed when no longer needed.

void QAbstractSoftKeyLabelHelper::setCurrentWidget ( QWidget * newWidget )

This function is called by the server when focus moves to a widget that implements this helpers className (or inherits from that class). QAbstractSoftKeyLabelHelper sets up appropriate notifications for newWidget.

See also currentWidget().

void QAbstractSoftKeyLabelHelper::setLabelPixmap ( int key, const QString & pm )   [protected]

Set the label for to the pixmap named by pm.

Qt::Key_Select and Qt::Key_Back are the most common values for key. Qt::Key_Menu is used to change the third softkey, but this is uncommon in Qtopia, as this key is usually used for the soft menu and left unchanged.

See also setStandardLabel(), setLabelText(), and clearLabel().

void QAbstractSoftKeyLabelHelper::setLabelText ( int key, const QString & text )   [protected]

Set the label for to string text.

Qt::Key_Select and Qt::Key_Back are the most common values for key. Qt::Key_Menu is used to change the third softkey, but this is uncommon in Qtopia, as this key is usually used for the soft menu and left unchanged.

See also setStandardLabel(), setLabelPixmap(), and clearLabel().

void QAbstractSoftKeyLabelHelper::setStandardLabel ( int key, QSoftMenuBar::StandardLabel label )   [protected]

Set the label for to the standard Qtopia label label.

Qt::Key_Select and Qt::Key_Back are the most common values for key. Qt::Key_Menu is used to change the third softkey, but this is uncommon in Qtopia, as this key is usually used for the soft menu and left unchanged.

See also setLabelText(), setLabelPixmap(), and clearLabel().

void QAbstractSoftKeyLabelHelper::updateAllLabels ( QWidget * widget = 0 )   [pure virtual slot]

Implement this function to update all SoftKey labels for widget.

Use setStandardLabel() to set the labels themselves.

See QSoftKeyLabelHelper for a simple example, and QLineEditSoftKeyHelper::updateAllLabels() for a more complex example.

See also setStandardLabel(), setStandardLabel(), setLabelText(), setLabelPixmap(), clearLabel(), QSoftKeyLabelHelper::updateAllLabels(), and QLineEditSoftKeyLabelHelper::updateAllLabels().


Copyright © 2007 Trolltech Trademarks
Qtopia 4.3.0