Home · All Classes · Main Classes · Deprecated
Public Member Functions | Static Public Member Functions | Protected Slots | Protected Member Functions | Protected Attributes

MWidgetView Class Reference

MWidgetView provides an abstract base class for MVC views. More...

Inherits QObject.

Inherited by MBasicSheetHeaderView, MBubbleItemView, MButtonView, MColorComboBoxView, MColorListView, MComboBoxView, MContainerView, MContentItemView, MExtendingBackgroundView, MExtensionAreaView, MGridItemView, MImageWidgetView, MLabelView, MListIndexView, MListItemView, MListView, MPannableWidgetView, MPositionIndicatorView, MSceneWindowView, MSeparatorView, MSliderView, MSpinnerView, MTextEditView, and MToolBarView.

List of all members.

Public Member Functions

virtual const char * styleType () const
 MWidgetView ()
 MWidgetView (MWidgetController *controller)
virtual ~MWidgetView ()
void show ()
void hide ()
void destroy ()
virtual void setActive (bool active)
void setModel (MWidgetModel *model)
virtual void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0)
virtual void setGeometry (const QRectF &rect)
virtual QPainterPath shape () const
virtual QRectF boundingRect () const
virtual void resizeEvent (QGraphicsSceneResizeEvent *event)
virtual void changeEvent (QEvent *event)
qreal effectiveOpacity () const
qreal opacity () const
qreal scale () const
void setOpacity (qreal opacity)
void setScale (qreal scale)
virtual QFont font () const

Static Public Member Functions

static const char * staticStyleType ()

Protected Slots

virtual void updateData (const QList< const char * > &modifications)
void updateMicroFocus ()

Protected Member Functions

virtual MWidgetStyleContainercreateStyleContainer () const
virtual QSizeF sizeHint (Qt::SizeHint which, const QSizeF &constraint=QSizeF()) const
virtual void mousePressEvent (QGraphicsSceneMouseEvent *event)
virtual void mouseReleaseEvent (QGraphicsSceneMouseEvent *event)
virtual void mouseMoveEvent (QGraphicsSceneMouseEvent *event)
virtual bool sceneEventFilter (QGraphicsItem *watched, QEvent *event)
void update (const QRectF &rect=QRectF())
void update (qreal x, qreal y, qreal width, qreal height)
void updateGeometry ()
QRectF geometry () const
QSizeF size () const
QPointF pos () const
QRectF rect () const
virtual QVariant inputMethodQuery (Qt::InputMethodQuery query) const
virtual void cancelEvent (MCancelEvent *event)
virtual void orientationChangeEvent (MOrientationChangeEvent *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)
QRect margins () const
int marginLeft () const
int marginTop () const
int marginRight () const
int marginBottom () const
QRect reactiveMargins () const
int reactiveMarginLeft () const
int reactiveMarginTop () const
int reactiveMarginRight () const
int reactiveMarginBottom () const
virtual void notifyItemChange (QGraphicsItem::GraphicsItemChange change, const QVariant &value)
virtual void drawBackground (QPainter *painter, const QStyleOptionGraphicsItem *option) const
virtual void drawContents (QPainter *painter, const QStyleOptionGraphicsItem *option) const
virtual void drawForeground (QPainter *painter, const QStyleOptionGraphicsItem *option) const
virtual void setupModel ()
virtual void applyStyle ()
MWidgetModelmodel ()
const MWidgetModelmodel () const
MWidgetStyleContainerstyle ()
const MWidgetStyleContainerstyle () const
 MWidgetView (MWidgetViewPrivate *dd)
 MWidgetView (MWidgetViewPrivate &dd, MWidgetController *controller)

Protected Attributes

MWidgetViewPrivate *const d_ptr

Detailed Description

MWidgetView provides an abstract base class for MVC views.

MWidgetView provides an abstract base class from which widgets using MVC pattern can inherit their views


Constructor & Destructor Documentation

MWidgetView::MWidgetView (  ) 

Constructor for the view.

MWidgetView::MWidgetView ( MWidgetController controller  ) 
MWidgetView::~MWidgetView (  )  [virtual]

Destructor for the view.

MWidgetView::MWidgetView ( MWidgetViewPrivate *  dd  )  [protected]
MWidgetView::MWidgetView ( MWidgetViewPrivate &  dd,
MWidgetController controller 
) [protected]

Member Function Documentation

void MWidgetView::applyStyle (  )  [protected, virtual]

Notification for derived classes. This method gets called when a new style is applied for this view. This happens e.g. when the object is constructed, when a new object name is given to the widget, or when the layout direction changes.

Reimplemented in MMessageBoxView, MSliderView, and MSpinnerView.

QRectF MWidgetView::boundingRect (  )  const [virtual]
void MWidgetView::cancelEvent ( MCancelEvent event  )  [protected, virtual]

This event handler is designed to allow widgets to cancel the previously received mousePress event. This situation occurs, 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 MSliderView.

void MWidgetView::changeEvent ( QEvent event  )  [virtual]
virtual MWidgetStyleContainer* MWidgetView::createStyleContainer (  )  const [inline, protected, virtual]
void MWidgetView::destroy (  ) 
void MWidgetView::drawBackground ( QPainter painter,
const QStyleOptionGraphicsItem option 
) const [protected, virtual]

Draws the background for this view.

void MWidgetView::drawContents ( QPainter painter,
const QStyleOptionGraphicsItem option 
) const [protected, virtual]

Draws the contents for this view.

Reimplemented in MSpinnerView.

void MWidgetView::drawForeground ( QPainter painter,
const QStyleOptionGraphicsItem option 
) const [protected, virtual]

Draws the foreground for this view.

qreal MWidgetView::effectiveOpacity (  )  const
QFont MWidgetView::font (  )  const [virtual]

return the used QFont.

QRectF MWidgetView::geometry (  )  const [protected]
void MWidgetView::hide (  ) 
QVariant MWidgetView::inputMethodQuery ( Qt::InputMethodQuery  query  )  const [protected, virtual]
int MWidgetView::marginBottom (  )  const [protected]

Returns bottom margin in pixels. This margin can be defined in css.

int MWidgetView::marginLeft (  )  const [protected]

Returns left margin in pixels. This margin can be defined in css.

int MWidgetView::marginRight (  )  const [protected]

Returns right margin in pixels. This margin can be defined in css.

QRect MWidgetView::margins (  )  const [protected]

Returns margins in pixels. These margins can be defined in css.

int MWidgetView::marginTop (  )  const [protected]

Returns top margin in pixels. This margin can be defined in css.

MWidgetModel * MWidgetView::model (  )  [protected]

Returns model of the widget. This method should be used only by the M_VIEW macro.

const MWidgetModel * MWidgetView::model (  )  const [protected]
void MWidgetView::mouseMoveEvent ( QGraphicsSceneMouseEvent event  )  [protected, virtual]

Reimplemented in MSliderView.

void MWidgetView::mousePressEvent ( QGraphicsSceneMouseEvent event  )  [protected, virtual]

Reimplemented in MBubbleItemView, MLabelView, and MSliderView.

void MWidgetView::mouseReleaseEvent ( QGraphicsSceneMouseEvent event  )  [protected, virtual]

Reimplemented in MBubbleItemView, MLabelView, and MSliderView.

void MWidgetView::notifyItemChange ( QGraphicsItem::GraphicsItemChange  change,
const QVariant value 
) [protected, virtual]

This is called from MWidgetController to notify that some part of the item's state has changed or will change. It is a read-only version of the QGraphicsWidget::itemChanged

The default implementation is to set the styleMode to "disabled" when an item becomes disabled, and to set the styleMode to "selected" when the item becomes selected. Reimplement this function to change this default behaviour or to react to other changes.

qreal MWidgetView::opacity (  )  const
void MWidgetView::orientationChangeEvent ( MOrientationChangeEvent event  )  [protected, virtual]

This event handler is designed to allow widgets to react to the orientation change.

void MWidgetView::paint ( QPainter painter,
const QStyleOptionGraphicsItem option,
QWidget widget = 0 
) [virtual]

Do not reimplement this method in derived classes.

See also:
{drawBackground,drawContents,drawForeground}
void MWidgetView::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 MSliderView.

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

QPointF MWidgetView::pos (  )  const [protected]
int MWidgetView::reactiveMarginBottom (  )  const [protected]

Returns bottom reactive margin in pixels. This margin can be defined in css.

int MWidgetView::reactiveMarginLeft (  )  const [protected]

Returns left reactive margin in pixels. This margin can be defined in css.

int MWidgetView::reactiveMarginRight (  )  const [protected]

Returns right reactive margin in pixels. This margin can be defined in css.

QRect MWidgetView::reactiveMargins (  )  const [protected]

Returns reactive margins in pixels. These margins can be defined in css.

int MWidgetView::reactiveMarginTop (  )  const [protected]

Returns top reactive margin in pixels. This margin can be defined in css.

QRectF MWidgetView::rect (  )  const [protected]
void MWidgetView::resizeEvent ( QGraphicsSceneResizeEvent event  )  [virtual]
qreal MWidgetView::scale (  )  const
bool MWidgetView::sceneEventFilter ( QGraphicsItem watched,
QEvent event 
) [protected, virtual]
void MWidgetView::setActive ( bool  active  )  [virtual]

Sets this widget view into active / inactive mode. Active mode of a widget view follows the active mode of the widget it is applied to. Derived classes can override this method to add custom behaviour when active mode is enabled or disabled.

See also:
MWidgetController::setActive() MWidgetController::isActive()
Parameters:
active Indicates whether active mode is set on or off.
void MWidgetView::setGeometry ( const QRectF rect  )  [virtual]
void MWidgetView::setModel ( MWidgetModel model  ) 

Sets a new model for this view. This method notifies derived classes by calling setupModel()

void MWidgetView::setOpacity ( qreal  opacity  ) 
void MWidgetView::setScale ( qreal  scale  ) 
void MWidgetView::setupModel (  )  [protected, virtual]

Notification for derived classes. This method gets called when a new model is applied for this view. This happens when MWidgetView::setModel() is called.

Reimplemented in MSliderView, and MSpinnerView.

QPainterPath MWidgetView::shape (  )  const [virtual]
void MWidgetView::show (  ) 
QSizeF MWidgetView::size (  )  const [protected]
QSizeF MWidgetView::sizeHint ( Qt::SizeHint  which,
const QSizeF constraint = QSizeF() 
) const [protected, virtual]

Default sizeHint implementation for a view.

To determine the size of a widget in a layout, the layout uses the widget's QGraphicsLayoutItem::preferredSize() and its QGraphicsLayoutItem::sizePolicy() functions. The preferred size of a MWidgetController is determined from:

  1. The constraint passed to the MWidgetController::sizeHint() function - usually due to the layout.
  2. Developer set hints (using QGraphicsLayoutItem::setPreferredSize(), etc).
  3. Style set size (e.g. from the CSS).
  4. View's sizeHint() function.
  5. MWidgetController::layout()->QGraphicsLayoutItem::sizeHint() function.

The sizes given from the first 3 steps are combined, in the order of preference as shown. If the height and/or width is not specified, then this function is called, with constraint set to the size determined so far. The result from the view is then combined with the constraint. Finally, if this size is still not valid, this is combined with QGraphicsWidget::sizeHint() which in turn uses the layouts sizeHint function.

The default implementation returns QSizeF(-1,-1) so that any layout attached to the controller is used instead.

If you reimplement this function and you use the constraint parameter to set the height of the widget depend on its width, you need to set controller's QGraphicsLayoutItem::sizePolicy() to have QSizePolicy::hasHeightForWidth().

Note: In order to create a widget that expands dynamically based on the contents inside the set layout, you should not reimplement this function, and should leave at least the height unspecified in the CSS. E.g. preferred-size: 200 -1;

See also:
Widget sizes
static const char* MWidgetView::staticStyleType (  )  [inline, static]
MWidgetStyleContainer & MWidgetView::style (  )  [protected]

Returns style of the widget. This method should be used only by the M_VIEW macro.

const MWidgetStyleContainer & MWidgetView::style (  )  const [protected]
virtual const char* MWidgetView::styleType (  )  const [inline, virtual]
void MWidgetView::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 MSliderView.

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

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

void MWidgetView::update ( qreal  x,
qreal  y,
qreal  width,
qreal  height 
) [protected]
void MWidgetView::update ( const QRectF rect = QRectF()  )  [protected]
void MWidgetView::updateData ( const QList< const char * > &  modifications  )  [protected, virtual, slot]

Notification of model modifications. This method gets called when some members of the model has been modified.

Reimplemented in MBubbleItemView, MContentItemView, MMessageBoxView, MSliderView, and MSpinnerView.

void MWidgetView::updateGeometry (  )  [protected]
void MWidgetView::updateMicroFocus (  )  [protected, slot]

Updates the widget's micro focus (i.e. notifies input context). Similar to QWidget::updateMicroFocus.


Member Data Documentation

MWidgetViewPrivate* const MWidgetView::d_ptr [protected]

Copyright © 2010 Nokia Corporation
MeeGo Touch