| Home · All Namespaces · All Classes · Main Classes |
An activatable entry in the control panel. More...
#include <mcpcontentwidget.h>


Public Member Functions | |
| McpContentWidget (McpAppletObject *applet=0, QGraphicsItem *parent=0) | |
| Constructor. | |
| ~McpContentWidget () | |
| void | setApplet (McpAppletObject *applet) |
| Sets the applet the McpContentWidget should handle. | |
| McpAppletObject * | applet () const |
| Returns the applet the McpContentWidget visualizes. | |
Protected Slots | |
| void | updateContents () |
| Make the object update according to the values the applet returns. | |
Protected Member Functions | |
| virtual void | retranslateUi () |
| virtual void | showEvent (QShowEvent *event) |
| virtual void | hideEvent (QHideEvent *event) |
| virtual void | constructRealWidget () |
| void | updateText () |
| Updates all texts according to the values the applet returns. | |
| void | updateImage () |
| Updates the picture according to what the applet returns. | |
| void | setImageFromFile (const QString &fileName) |
| void | setImageName (const QString &name) |
| int | widgetType () const |
| bool | hasTwoTextLines () const |
| bool | isChecked () const |
| QString | title () const |
| QString | subtitle () const |
| QString | imageID () const |
Properties | |
| QString | title |
| QString | subtitle |
| QString | checked |
| QString | widgetType |
| QString | imageID |
Friends | |
| class | Ut_McpContentWidget |
An activatable entry in the control panel.
This class implements the brief view of an applet shown on the screen in applet lists.
It has a McpAppletObject associated with it, so when the user clicks on the widget the applet variant is activated. The widget connects its clicked() signal to the activate() signal of the McpAppletObject object, so the applet variant will be started when the widget is clicked.
The widget updates its contents automatically if the applet notifies it about the changes, see McpBrief::valuesChanged().
Definition at line 47 of file mcpcontentwidget.h.
| McpContentWidget::McpContentWidget | ( | McpAppletObject * | applet = 0, |
|
| QGraphicsItem * | parent = 0 | |||
| ) |
Constructor.
If you do not set an applet here, be sure to do that before the widget gets shown on the screen. See setApplet().
Definition at line 43 of file mcpcontentwidget.cpp.

| McpContentWidget::~McpContentWidget | ( | ) |
Definition at line 53 of file mcpcontentwidget.cpp.
{
delete d_ptr;
}
| McpAppletObject * McpContentWidget::applet | ( | ) | const |
Returns the applet the McpContentWidget visualizes.
Definition at line 257 of file mcpcontentwidget.cpp.
{
return d_ptr->m_Applet;
}
| void McpContentWidget::constructRealWidget | ( | ) | [protected, virtual] |
Sets up the contentitem according to the values the applet provides: widgettype, texts, icons etc.
Definition at line 225 of file mcpcontentwidget.cpp.
{
// this markes that readding the items to the layout is not yet
// necessery. The ensure functions changes it to true if they detected the
// need for it
d_ptr->m_LayoutIsToBeChanged = false;
// we create the widgets (if not created yet)
// and update their contents if necessery
ensureImageIsCreated();
ensureToggleIsCreated();
ensureTextsAreCreated();
// we set them in the layout correctly
ensureWidgetsAreLayouted();
}
| bool McpContentWidget::hasTwoTextLines | ( | ) | const [protected] |
| void McpContentWidget::hideEvent | ( | QHideEvent * | event | ) | [protected, virtual] |
Definition at line 402 of file mcpcontentwidget.cpp.
{
if (!d_ptr->m_Hidden) {// prevents multiple hideEvents coming
d_ptr->m_Hidden = true;
if (d_ptr->m_Applet)
disconnect (d_ptr->m_Applet, SIGNAL (briefChanged()),
this, SLOT (updateContents()));
}
MListItem::hideEvent(event);
}

| QString McpContentWidget::imageID | ( | ) | const [protected] |
| bool McpContentWidget::isChecked | ( | ) | const [protected] |
| void McpContentWidget::retranslateUi | ( | ) | [protected, virtual] |
Definition at line 294 of file mcpcontentwidget.cpp.
{
if (d_ptr->m_Applet) {
updateText ();
}
}

| void McpContentWidget::setApplet | ( | McpAppletObject * | applet | ) |
Sets the applet the McpContentWidget should handle.
Currently you can only call it before the ContentItem is popped up, due to limitations of MContentItem.
Definition at line 263 of file mcpcontentwidget.cpp.
{
/*
* If we had an old applet object.
*/
if (d_ptr->m_Applet) {
/*
* Metadata is owned by the appletdb, so not removed, only disconnected
* both ways, but only the signals between the two participants.
*/
disconnect (d_ptr->m_Applet, 0, this, 0);
disconnect (this, 0, d_ptr->m_Applet, 0);
}
d_ptr->m_Applet = applet;
/*
* If we have a applet object we can construct a widget for that and then
* we can connect some signals.
*/
if (d_ptr->m_Applet) {
constructRealWidget ();
/*
* This will count the activations and activate the applet.
*/
connect (this, SIGNAL (clicked()),
d_ptr->m_Applet, SLOT (slotClicked()));
}
}

| void McpContentWidget::setImageFromFile | ( | const QString & | fileName | ) | [protected] |
sets the image based on its filepath
Definition at line 370 of file mcpcontentwidget.cpp.
{
bool success;
QImage image;
Q_ASSERT (d_ptr->m_ImageW);
success = image.load (fileName);
if (!success) {
MCP_WARNING ("The image was not loaded from %s", MCP_STR(fileName));
return;
}
d_ptr->m_ImageW->setImage (image);
}
| void McpContentWidget::setImageName | ( | const QString & | name | ) | [protected] |
sets the image with the given name (id)
Definition at line 360 of file mcpcontentwidget.cpp.
{
Q_ASSERT (d_ptr->m_ImageW);
d_ptr->m_ImageW->setImage (name); // FIXME XXX why is it not working???
}
| void McpContentWidget::showEvent | ( | QShowEvent * | event | ) | [protected, virtual] |
Definition at line 386 of file mcpcontentwidget.cpp.
{
if (d_ptr->m_Hidden) {
// prevents multiple showEvents coming
d_ptr->m_Hidden = false;
if (d_ptr->m_Applet)
connect (d_ptr->m_Applet, SIGNAL (briefChanged ()),
this, SLOT (updateContents()));
updateContents();
}
MListItem::showEvent(event);
}

| QString McpContentWidget::subtitle | ( | ) | const [protected] |
| QString McpContentWidget::title | ( | ) | const [protected] |
| void McpContentWidget::updateContents | ( | ) | [protected, slot] |
Make the object update according to the values the applet returns.
It is connected on the McpBrief::valuesChanged() signal if any.
Definition at line 348 of file mcpcontentwidget.cpp.
{
if (!d_ptr->m_Applet)
return;
constructRealWidget();
}

| void McpContentWidget::updateImage | ( | ) | [protected] |
Updates the picture according to what the applet returns.
Definition at line 315 of file mcpcontentwidget.cpp.
{
// ----------- image specific: -------------
if (widgetType() == McpWidgetType::Image) {
QString source = d_ptr->m_Applet->iconName();
/*
* The image file might be big, so we need a little speed up here, otherwise
* the paging effect is blocked when we go back to the main page.
*/
if (source == d_ptr->m_ImageName)
return;
// no picture :(
if (source.isEmpty()) return;
// if it is a filepath, it has to be absolute, otherwise we have an id
// which we request from the theme
if (!source.contains('/')) {
setImageName (source);
} else {
setImageFromFile (source);
}
d_ptr->m_ImageName = source;
}
}

| void McpContentWidget::updateText | ( | ) | [protected] |
Updates all texts according to the values the applet returns.
Definition at line 303 of file mcpcontentwidget.cpp.
{
ensureTextsAreCreated();
ensureWidgetsAreLayouted();
}
| int McpContentWidget::widgetType | ( | ) | const [protected] |
friend class Ut_McpContentWidget [friend] |
Definition at line 133 of file mcpcontentwidget.h.
QString McpContentWidget::checked [read] |
Definition at line 54 of file mcpcontentwidget.h.
QString McpContentWidget::imageID [read] |
Definition at line 56 of file mcpcontentwidget.h.
QString McpContentWidget::subtitle [read] |
Definition at line 53 of file mcpcontentwidget.h.
QString McpContentWidget::title [read] |
Definition at line 52 of file mcpcontentwidget.h.
int McpContentWidget::widgetType [read] |
Definition at line 55 of file mcpcontentwidget.h.
| Copyright © 2009 Nokia Corporation | Generated on Thu Nov 4 2010 18:21:33 Doxygen 1.7.1 |
DirectUI |