Home · All Classes · Main Classes · Deprecated |
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.
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.
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.
void MWidgetController::cancelEvent | ( | MCancelEvent * | event | ) | [protected, virtual] |
MWidgetController's implementation of cancelEvent() forwards the call to the view.
Reimplemented from MWidget.
QVariant MWidgetController::inputMethodQuery | ( | Qt::InputMethodQuery | query | ) | const [protected, virtual] |
MWidgetController's implementation of inputMethodQuery() forwards the call to the view.
bool MWidgetController::isActive | ( | ) | const |
Indicates whether this widget is an active state.
Reimplemented in MCompleter.
QVariant MWidgetController::itemChange | ( | GraphicsItemChange | change, | |
const QVariant & | value | |||
) | [protected, virtual] |
MWidgetController's implementation of itemChange() forwards the call to the view.
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.
const MWidgetModel * MWidgetController::model | ( | ) | const |
Returns a const pointer to the model of the widget.
This function will always return a valid model.
void MWidgetController::mouseMoveEvent | ( | QGraphicsSceneMouseEvent * | event | ) | [protected, virtual] |
MWidgetController's implementation of mouseMoveEvent() forwards the call to the view.
void MWidgetController::mousePressEvent | ( | QGraphicsSceneMouseEvent * | event | ) | [protected, virtual] |
MWidgetController's implementation of mousePressEvent() forwards the call to the view.
void MWidgetController::mouseReleaseEvent | ( | QGraphicsSceneMouseEvent * | event | ) | [protected, virtual] |
MWidgetController's implementation of mouseReleaseEvent() forwards the call to the view.
void MWidgetController::orientationChangeEvent | ( | MOrientationChangeEvent * | event | ) | [protected, virtual] |
MWidgetController's implementation of orientationChangeEvent() forwards the call to the view.
Reimplemented from MWidget.
void MWidgetController::panGestureEvent | ( | QGestureEvent * | event, | |
QPanGesture * | gesture | |||
) | [protected, virtual] |
MWidgetController's implementation of panGestureEvent() forwards the call to the view.
Reimplemented from MWidget.
void MWidgetController::pinchGestureEvent | ( | QGestureEvent * | event, | |
QPinchGesture * | gesture | |||
) | [protected, virtual] |
MWidgetController's implementation of pinchGestureEvent() forwards the call to the view.
Reimplemented from MWidget.
bool MWidgetController::sceneEventFilter | ( | QGraphicsItem * | watched, | |
QEvent * | event | |||
) | [protected, virtual] |
MWidgetController's implementation of sceneEventFilter() forwards the call to the view.
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.
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.
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.
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; }
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().
void MWidgetController::setView | ( | MWidgetView * | view | ) | [virtual] |
Sets the view of the widget.
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:
MButton button; button.setViewType(MButton::toggleType);
A button of the "toggle" type may for example look and behave like a checkbox or a slider, depending on the selected theme.
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.
Reimplemented from MWidget.
void MWidgetController::tapAndHoldGestureEvent | ( | QGestureEvent * | event, | |
QTapAndHoldGesture * | gesture | |||
) | [protected, virtual] |
MWidgetController's implementation of tapAndHoldGestureEvent() forwards the call to the view.
Reimplemented from MWidget.
void MWidgetController::tapGestureEvent | ( | QGestureEvent * | event, | |
QTapGesture * | gesture | |||
) | [protected, virtual] |
MWidgetController's implementation of tapGestureEvent() forwards the call to the view.
Reimplemented from MWidget.
void MWidgetController::updateData | ( | const QList< const char * > & | modifications | ) | [protected, virtual, slot] |
void MWidgetController::updateMicroFocus | ( | ) | [protected, slot] |
Updates the widget's micro focus.
const MWidgetView * MWidgetController::view | ( | ) | const [protected] |
Returns a constant pointer to the view of the widget.
MTheme::ViewType MWidgetController::viewType | ( | ) | const |
Returns the type of the widget's view.
const MTheme::ViewType MWidgetController::defaultType = "default" [static] |
Default widget view type.
bool MWidgetController::active [read, write] |
const QString & MWidgetController::styleName [read, write] |
MTheme::ViewType MWidgetController::viewType [read, write] |
Copyright © 2010 Nokia Corporation | MeeGo Touch |