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

MWidgetController Class Reference

MWidgetController is the base class for a controller in the MVC widget model. More...

Inherits MWidget.

Inherited by MBasicSheetHeader, MBubbleItem, MButton, MColorList, MComboBox, MContainer, MContentItem, MExtensionArea, MGridItem, MImageWidget, MLabel, MList, MListIndex, MListItem, MPannableWidget, MPositionIndicator, MProgressIndicator, MSceneWindow, MSeparator, MSettingsLanguageWidget, MSlider, MStylableWidget, MTextEdit, and MToolBar.

List of all members.

Public Slots

void setViewType (const MTheme::ViewType &type)
virtual void setActive (bool active)
virtual void setObjectName (const QString &name)
void setStyleName (const QString &name)

Public Member Functions

 MWidgetController (QGraphicsItem *parent=0)
 MWidgetController (MWidgetModel *model, QGraphicsItem *parent=0)
virtual ~MWidgetController ()
void setModel (MWidgetModel *model)
MWidgetModelmodel ()
const MWidgetModelmodel () const
M::Position layoutPosition () const
void setLayoutPosition (M::Position layoutPosition)
MTheme::ViewType viewType () const
bool isActive () const
virtual void setView (MWidgetView *view)
const QStringstyleName () const

Static Public Attributes

static const MTheme::ViewType defaultType = "default"

Protected Slots

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

Protected Member Functions

virtual void mousePressEvent (QGraphicsSceneMouseEvent *event)
virtual void mouseReleaseEvent (QGraphicsSceneMouseEvent *event)
virtual void mouseMoveEvent (QGraphicsSceneMouseEvent *event)
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)
virtual bool sceneEventFilter (QGraphicsItem *watched, QEvent *event)
virtual QVariant itemChange (GraphicsItemChange change, const QVariant &value)
virtual QVariant inputMethodQuery (Qt::InputMethodQuery query) const
MWidgetStyleContainerstyle ()
const MWidgetStyleContainerstyle () const
const MWidgetViewview () const

Properties

MTheme::ViewType viewType
bool active
QString styleName

Detailed Description

MWidgetController is the base class for a controller in the MVC widget model.

MWidgetController is the base class of all components that implement the Model-View-Controller pattern for widgets. In a widget, the controller serves as the public interface to the application developer. The controller internally stores the widget's state in the model and delegates painting and event handling to the view.

Although the controller provides methods to set the view and model components, widgets derived from MWidgetController always provide an already initialised model while a view is constructed at the time it is needed unless otherwise explicitly set.


Constructor & Destructor Documentation

MWidgetController::MWidgetController ( QGraphicsItem parent = 0  )  [explicit]

Creates a new MWidgetController with the given parent.

MWidgetController::MWidgetController ( MWidgetModel model,
QGraphicsItem parent = 0 
) [explicit]

Creates a new MWidgetController with the given model and parent.

If model is 0, a MWidgetModel will be created.

MWidgetController::~MWidgetController (  )  [virtual]

Destroys the controller.


Member Function Documentation

void MWidgetController::cancelEvent ( MCancelEvent event  )  [protected, virtual]

MWidgetController's implementation of cancelEvent() forwards the call to the view.

See also:
MWidgetView::cancelEvent()

Reimplemented from MWidget.

QVariant MWidgetController::inputMethodQuery ( Qt::InputMethodQuery  query  )  const [protected, virtual]

MWidgetController's implementation of inputMethodQuery() forwards the call to the view.

See also:
MWidgetView::inputMethodQuery()
bool MWidgetController::isActive (  )  const

Indicates whether this widget is an active state.

See also:
setActive() MWidgetView::setActive()

Reimplemented in MCompleter.

QVariant MWidgetController::itemChange ( GraphicsItemChange  change,
const QVariant value 
) [protected, virtual]

MWidgetController's implementation of itemChange() forwards the call to the view.

See also:
MWidgetView::itemChange()

Reimplemented from QGraphicsWidget.

M::Position MWidgetController::layoutPosition (  )  const
MWidgetModel * MWidgetController::model (  ) 

Returns the model of the widget.

This function will always return a valid model. The model should not be directly manipulated in the application code, unless the application also explicitly creates the model. Instead, the widget should provide the necessary functions in the controller class.

See also:
setModel()
const MWidgetModel * MWidgetController::model (  )  const

Returns a const pointer to the model of the widget.

This function will always return a valid model.

See also:
setModel()
void MWidgetController::mouseMoveEvent ( QGraphicsSceneMouseEvent event  )  [protected, virtual]

MWidgetController's implementation of mouseMoveEvent() forwards the call to the view.

See also:
MWidgetView::mouseMoveEvent()
void MWidgetController::mousePressEvent ( QGraphicsSceneMouseEvent event  )  [protected, virtual]

MWidgetController's implementation of mousePressEvent() forwards the call to the view.

See also:
MWidgetView::mousePressEvent()
void MWidgetController::mouseReleaseEvent ( QGraphicsSceneMouseEvent event  )  [protected, virtual]

MWidgetController's implementation of mouseReleaseEvent() forwards the call to the view.

See also:
MWidgetView::mouseReleaseEvent()
void MWidgetController::orientationChangeEvent ( MOrientationChangeEvent event  )  [protected, virtual]

MWidgetController's implementation of orientationChangeEvent() forwards the call to the view.

See also:
MWidgetView::orientationChangeEvent()

Reimplemented from MWidget.

void MWidgetController::panGestureEvent ( QGestureEvent event,
QPanGesture gesture 
) [protected, virtual]

MWidgetController's implementation of panGestureEvent() forwards the call to the view.

See also:
MWidgetView::panGestureEvent()

Reimplemented from MWidget.

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

MWidgetController's implementation of pinchGestureEvent() forwards the call to the view.

See also:
MWidgetView::pinchGestureEvent()

Reimplemented from MWidget.

bool MWidgetController::sceneEventFilter ( QGraphicsItem watched,
QEvent event 
) [protected, virtual]

MWidgetController's implementation of sceneEventFilter() forwards the call to the view.

See also:
MWidgetView::sceneEventFilter()
void MWidgetController::setActive ( bool  active  )  [virtual, slot]

Set the active state of the widget

Active state is communicated to the widget view and can affect how the widget is presented. By default widgets are inactive. What active state semantically means is up the individual widget.

See also:
isActive() MWidgetView::setActive()
void MWidgetController::setLayoutPosition ( M::Position  layoutPosition  ) 
void MWidgetController::setModel ( MWidgetModel model  ) 

Sets the model of the widget.

This function will increase the reference count on the given model. If a model was already set prior to calling this function, that model's reference count will be decreased and the model destroyed if it reaches 0.

See also:
model()
void MWidgetController::setObjectName ( const QString name  )  [virtual, slot]

Set the objectName to name

This function sets the QObject::objectName property of the widget and reloads the style of the widget view. The object name is used by the theme system to select a style with a matching ID.

Warning: Since QObject::setObjectName() is non-virtual, code like:

       MLabel *label = new MLabel("Hello");
       label->setObjectName("hello");

Would correctly restyle the label. But:

       QGraphicsWidget *label = new MLabel("Hello");
       label->setObjectName("hello");

Would not update the CSS style correctly.

Note that multiple objects can have the same name, and consequently the same style.

Deprecated:
Use setStyleName() to set the style name of the widget.
void MWidgetController::setStyleName ( const QString name  )  [slot]

Set the style name to name.

This function sets the style name property of the widget to name and reloads the style of the widget view. The style name is used to select a style with a matching name from the theme.

An example of setting the object name:

        mywidget->setStyleName("warning");

In a CSS file you can then specify a style for this particular widget:

        #warning { background-color: #FF0000; }
See also:
styleName()
void MWidgetController::setupModel (  )  [protected, virtual, slot]

Notification of model having changed.

This function is called when the model of the widget is initially set or when later replaced. You can reimplement this method to synchronize your widget's internal state with that of the new model.

An example would be an widget that creates a child label widget; on setupModel() it should synchronize the label text with the model data. Subsequent updates to the model data and the resulting changes to the label are delivered through updateData().

Note:
The widget uses the base implementation of this function to set up notification of changes in the model. Because of this, it is very important that subclasses call the base implementation.
See also:
setModel()
updateData()
void MWidgetController::setView ( MWidgetView view  )  [virtual]

Sets the view of the widget.

See also:
view()
void MWidgetController::setViewType ( const MTheme::ViewType type  )  [slot]

Set the view type of the widget.

The type determines which MWidgetView the theme system will select at runtime.

Example:

A button of the "toggle" type may for example look and behave like a checkbox or a slider, depending on the selected theme.

See also:
viewType()
const MWidgetStyleContainer & MWidgetController::style (  )  const [protected]

Returns a constant reference to the style of the widget.

MWidgetStyleContainer & MWidgetController::style (  )  [protected]

Returns the style of the widget.

Reimplemented from QGraphicsWidget.

const QString& MWidgetController::styleName (  )  const

Returns the style name of the widget.

void MWidgetController::swipeGestureEvent ( QGestureEvent event,
QSwipeGesture gesture 
) [protected, virtual]

MWidgetController's implementation of swipeGestureEvent() forwards the call to the view.

See also:
MWidgetView::swipeGestureEvent()

Reimplemented from MWidget.

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

MWidgetController's implementation of tapAndHoldGestureEvent() forwards the call to the view.

See also:
MWidgetView::tapAndHoldGestureEvent()

Reimplemented from MWidget.

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

MWidgetController's implementation of tapGestureEvent() forwards the call to the view.

See also:
MWidgetView::tapGestureEvent()

Reimplemented from MWidget.

void MWidgetController::updateData ( const QList< const char * > &  modifications  )  [protected, virtual, slot]

Notification of model data modifications.

This function is called when some members of the widget model have been modified.

Reimplemented in MList, and MSlider.

void MWidgetController::updateMicroFocus (  )  [protected, slot]

Updates the widget's micro focus.

See also:
QWidget::updateMicroFocus.
const MWidgetView * MWidgetController::view (  )  const [protected]

Returns a constant pointer to the view of the widget.

See also:
setView()
MTheme::ViewType MWidgetController::viewType (  )  const

Returns the type of the widget's view.

See also:
setViewType()

Member Data Documentation

Default widget view type.

See also:
viewType(), setViewType()

Property Documentation

bool MWidgetController::active [read, write]
const QString & MWidgetController::styleName [read, write]
MTheme::ViewType MWidgetController::viewType [read, write]

Copyright © 2010 Nokia Corporation
MeeGo Touch