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

MWidget Class Reference

Inherits QGraphicsWidget.

Inherited by MWidgetController.

List of all members.

Public Types

enum  MouseEventCancelPolicy { MouseEventNoCancel, MouseEventCancelOnGestureStarted, MouseEventCancelOnGestureFinished }

Public Slots

virtual void clearActions ()

Signals

void displayEntered ()
void displayExited ()

Public Member Functions

 MWidget (QGraphicsItem *parent=0)
virtual ~MWidget ()
MSceneManagersceneManager () const
bool isOnDisplay () const
bool isSelected () const
QPointF paintOffset () const
void setPaintOffset (const QPointF &offset)
void grabGestureWithCancelPolicy (Qt::GestureType type, Qt::GestureFlags flags=Qt::GestureFlags(), MouseEventCancelPolicy cancelPolicy=MouseEventNoCancel)

Protected Member Functions

virtual void enterDisplayEvent ()
virtual void exitDisplayEvent ()
virtual void onDisplayChangeEvent (MOnDisplayChangeEvent *event)
virtual void cancelEvent (MCancelEvent *event)
virtual void orientationChangeEvent (MOrientationChangeEvent *event)
virtual void actionEvent (QActionEvent *)
virtual void contextMenuEvent (QGraphicsSceneContextMenuEvent *event)
virtual void retranslateUi ()
virtual void gestureEvent (QGestureEvent *event)
virtual void tapAndHoldGestureEvent (QGestureEvent *event, QTapAndHoldGesture *gesture)
virtual void panGestureEvent (QGestureEvent *event, QPanGesture *gesture)
virtual void pinchGestureEvent (QGestureEvent *event, QPinchGesture *gesture)
virtual void tapGestureEvent (QGestureEvent *event, QTapGesture *gesture)
virtual void swipeGestureEvent (QGestureEvent *event, QSwipeGesture *gesture)
 MWidget (MWidgetPrivate &dd, QGraphicsItem *parent)

Protected Attributes

MWidgetPrivate *const d_ptr

Properties

QSizePolicy sizePolicy
bool selected
bool onDisplay
QPointF paintOffset

Member Enumeration Documentation

This enum contains possible values of a mouse event cancel policy.

  • MouseEventNoCancel - the cancel event will not be sent if this widget receives a gesture.
  • MouseEventCancelOnGestureStarted - the cancel event will be sent when a gesture is being started and accepted by this widget.
  • MouseEventCancelOnGestureFinished - the cancel event will be sent when a gesture is being finished and was accepted by this widget.
See also:
grabGestureWithCancelPolicy.
Enumerator:
MouseEventNoCancel 
MouseEventCancelOnGestureStarted 
MouseEventCancelOnGestureFinished 

Constructor & Destructor Documentation

MWidget::MWidget ( QGraphicsItem parent = 0  ) 
MWidget::~MWidget (  )  [virtual]
MWidget::MWidget ( MWidgetPrivate &  dd,
QGraphicsItem parent 
) [protected]

Member Function Documentation

void MWidget::actionEvent ( QActionEvent  )  [protected, virtual]
void MWidget::cancelEvent ( MCancelEvent event  )  [protected, virtual]

This event handler is designed to allow widgets to cancel the effect of previously received event. One example of that behavior is a situation when the user starts to pan the view and the mousePress event that was sent when the user touched the screen needs to be cancelled.

Reimplemented in MWidgetController.

void MWidget::clearActions (  )  [virtual, slot]

Removes all the actions from the widget's action list. Note: actions are not deleted after removal from the list. To clear and delete the actions from the widget, following procedure is proposed: QList<QAction*> actions = widget->actions(); widget->clearActions(); qDeleteAll(actions);

void MWidget::contextMenuEvent ( QGraphicsSceneContextMenuEvent event  )  [protected, virtual]

This event handler can be reimplemented in a subclass to process context menu events. The event parameter contains details about the event to be handled.

Reimplemented in MList.

void MWidget::displayEntered (  )  [signal]

A signal that is emitted when:

  • the widget has entered the visible area of the display
  • the page containing the widget is not obscured anymore by another window / page
  • the widget is explicitly shown with show() or setVisible(true) and is on the display area.

Note!: the stacking order of widgets is not taken into account

Changing opacity from 0 to greater value doesn't cause this signal to be emitted. If widget has opacity 0 it will not emit this signal when entering display.

See also:
enterDisplayEvent
void MWidget::displayExited (  )  [signal]

A signal that is emitted when:

  • the widget has left the visible area of the display
  • the page containing the widget has become obscured by another window / page
  • the widget is explicitly hidden with hide() or setVisible(false).

Note!: the stacking order of widgets is not taken into account

Changing opacity to from a value > 0 to 0 doesn't cause this signal to be emitted. If widget has opacity 0 it will not emit this signal when exiting display.

See also:
exitDisplayEvent
void MWidget::enterDisplayEvent (  )  [protected, virtual]

A handler that is called just before displayEntered() is emitted.

Due to undocumented QT behaviour QTBUG-18267, widgets with opacity 0 are treated as if isVisible == false, so they don't receive any events. To work around this, set opacity to 0.001 instead of 0.

void MWidget::exitDisplayEvent (  )  [protected, virtual]

A handler that is called just before displayExited() is emitted.

Due to undocumented QT behaviour QTBUG-18267, widgets with opacity 0 are treated as if isVisible == false, so they don't receive any events. To work around this, set opacity to 0.001 instead of 0.

void MWidget::gestureEvent ( QGestureEvent event  )  [protected, virtual]

This event handler is designed to allow widgets to react to the gesture events. Reimplement it to make your widget sensitive to custom made gestures.

Default implementation handles gestures used by M library. Please remember to call MWidget::gestureEvent() if this method is overriden.

void MWidget::grabGestureWithCancelPolicy ( Qt::GestureType  type,
Qt::GestureFlags  flags = Qt::GestureFlags(),
MouseEventCancelPolicy  cancelPolicy = MouseEventNoCancel 
)

Subscribes the widget to gestures events of a specific type. Allows definition of cancel event handling policy for that gesture.

The meegotouch library can send cancel event to the current mouse grabber and stop processing mouse events. This allows the UI to react to situation when the user starts a gesture on top of interactive elements like buttons. In a typical example, the user starts panning gesture over a button, which will initially reach the pressed state. Then the user moves his finger and the button will then be moved back to un-pressed state, without triggering actions connected to it. Internally, the button will receive a cancel event and it will not receive the release event.

This method is an overloaded version of grabGesture defined in QGraphicsWidget which introduces cancelPolicy argument. It can be used to define the reaction to started or finished gesture when it reaches the object of the MWidget.

See also:
MouseEventCancelPolicy
bool MWidget::isOnDisplay (  )  const

Checks whether the widget might be seen on the display.

Returning true means that:

  • Widget himself is not hidden (isVisible() property is true).
  • Widget lies within sight of some QGraphicsView that is currently being displayed.

Note that it does not guarantee, however, that the widget actually is being shown on the display. There could be, for instance, some opaque QGraphicsItem on top of it (along the z axis) blocking it from getting rendered on the viewport.

Returning false means that currently this widget cannot be seen on the display in any way. E.g.: If the widget happens to be out of sight of all the QGraphicsViews that are rendering his scene.

Its computational cost is significantly higher than that of a simple attribute getter such as isVisible().

bool MWidget::isSelected (  )  const

Returns true if widget is selected otherwise false.

See also:
setSelected(bool)
void MWidget::onDisplayChangeEvent ( MOnDisplayChangeEvent event  )  [protected, virtual]

This event handler allows a widget to notify subscribers (and its children) about changes in its presence on the display. enterDisplayEvent() and exitDisplayEvent() convenience handlers are called by the default implementation. MOnDisplayChangeEvent may be sent e.g. if the widget gets panned out of display, the widget is explicitly hidden/shown or the window gets obscured by another window.

void MWidget::orientationChangeEvent ( MOrientationChangeEvent event  )  [protected, virtual]

This event handler is designed to allow widgets to react to the orientation change. Reimplement it to make your widget sensitive to orientation changes. Default implementation does nothing.

Reimplemented in MWidgetController.

QPointF MWidget::paintOffset (  )  const

Returns the offset by which the widget will be transformed when painted.

This convenience function is equivalent to querying the horizontal and vertical translation factors of the widgets's transform().

See also:
setPaintOffset()
void MWidget::panGestureEvent ( QGestureEvent event,
QPanGesture gesture 
) [protected, virtual]

This event handler is designed to allow widgets to react to the pan gesture event. Default implementation does nothing.

Gesture events are ignored by default. If you want to specifically accept a gesture state, you need to call QGestureEvent::accept(QGesture*) or similar.

Reimplemented in MWidgetController.

void MWidget::pinchGestureEvent ( QGestureEvent event,
QPinchGesture gesture 
) [protected, virtual]

This event handler is designed to allow widgets to react to the pinch gesture event. Default implementation does nothing.

Gesture events are ignored by default. If you want to specifically accept a gesture state, you need to call QGestureEvent::accept(QGesture*) or similar.

Reimplemented in MWidgetController.

void MWidget::retranslateUi (  )  [protected, virtual]

This virtual function is called when this widget received a QEvent::LanguageChange event.

Reimplement this function in your own widgets to retranslate user-visible strings.

MSceneManager * MWidget::sceneManager (  )  const

Returns a pointer to the scene manager that manages the widget. If the widget's scene doesn't have a scene manager, returns a null pointer.

void MWidget::setPaintOffset ( const QPointF offset  ) 

Sets the offset by which the widget will be transformed when painted.

This convenience function is equivalent to calling setTransform on the widget, supplying a QTransform that shifts the widget by offset.

The paint offset allows for a widget to appear as if in a position different than that of the widget's pos() property. This allows for example to animate the widget's apparent location using a QPropertyAnimation without affecting layouting or the layout affecting the animation.

See also:
paintOffset()
void MWidget::swipeGestureEvent ( QGestureEvent event,
QSwipeGesture gesture 
) [protected, virtual]

This event handler is designed to allow widgets to react to the swipe gesture event. Default implementation does nothing.

Gesture events are ignored by default. If you want to specifically accept a gesture state, you need to call QGestureEvent::accept(QGesture*) or similar.

Reimplemented in MWidgetController.

void MWidget::tapAndHoldGestureEvent ( QGestureEvent event,
QTapAndHoldGesture gesture 
) [protected, virtual]

This event handler is designed to allow widgets to react to the tap&hold gesture event. Default implementation does nothing.

Gesture events are ignored by default. If you want to specifically accept a gesture state, you need to call QGestureEvent::accept(QGesture*) or similar.

Reimplemented in MWidgetController.

void MWidget::tapGestureEvent ( QGestureEvent event,
QTapGesture gesture 
) [protected, virtual]

This event handler is designed to allow widgets to react to the tap gesture event. Default implementation does nothing.

Gesture events are ignored by default. If you want to specifically accept a gesture state, you need to call QGestureEvent::accept(QGesture*) or similar.

Reimplemented in MWidgetController.


Member Data Documentation

MWidgetPrivate* const MWidget::d_ptr [protected]

Reimplemented in MExtensionArea.


Property Documentation

bool MWidget::onDisplay [read]
QPointF MWidget::paintOffset [read, write]
bool MWidget::selected [read, write]
QSizePolicy MWidget::sizePolicy [read, write]

Copyright © 2010 Nokia Corporation
MeeGo Touch