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


Public Member Functions | |
| McpContentItem (McpAppletObject *applet=0, QGraphicsItem *parent=0) | |
| Constructor. | |
| ~McpContentItem () | |
| void | setApplet (McpAppletObject *applet) |
| Sets the applet the McpContentItem should handle. | |
| McpAppletObject * | applet () const |
| Returns the applet the McpContentItem 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) |
| void | releaseImage () |
Friends | |
| class | Ut_McpContentItem |
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(). This class was DEPRECATED because MContentItem does not support the necessery functionality for us (see NB#178164). It will be removed in near future.
Please use McpContentWidget instead.
Definition at line 56 of file mcpcontentitem.h.
| McpContentItem::McpContentItem | ( | 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 37 of file mcpcontentitem.cpp.
:
MContentItem (MContentItem::IconAndTwoTextLabels, parent),
d_ptr (new McpContentItemPrivate)
{
setApplet (applet);
}

| McpContentItem::~McpContentItem | ( | ) |
Definition at line 47 of file mcpcontentitem.cpp.
{
releaseImage();
delete d_ptr;
}

| McpAppletObject * McpContentItem::applet | ( | ) | const |
Returns the applet the McpContentItem visualizes.
Definition at line 118 of file mcpcontentitem.cpp.
{
return d_ptr->m_Applet;
}
| void McpContentItem::constructRealWidget | ( | ) | [protected, virtual] |
Sets up the contentitem according to the values the applet provides: widgettype, texts, icons etc.
Definition at line 91 of file mcpcontentitem.cpp.
{
d_ptr->m_WidgetTypeId = d_ptr->m_Applet->widgetTypeID();
MContentItem::ContentItemStyle styl;
switch (d_ptr->m_WidgetTypeId) {
case McpWidgetType::Image:
MCP_DEBUG ("### McpWidgetType::Image ###");
styl = IconAndSingleTextLabel;
break;
case McpWidgetType::Toggle:
qWarning("Support for toggle type as briefwidget was removed from "
"controlpanel according to the latest specifications (%s)",
qPrintable(applet()->metadata()->name()));
default:
MCP_DEBUG ("### McpWidgetType::Label ###");
styl = SingleTextLabel;
break;
}
if (!d_ptr->m_Applet->text2().isEmpty()) {
styl = ::invertTwoLineMode (styl);
}
model()->setItemStyle(styl);
}

| void McpContentItem::hideEvent | ( | QHideEvent * | event | ) | [protected, virtual] |
Definition at line 294 of file mcpcontentitem.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()));
}
MContentItem::hideEvent(event);
}

| void McpContentItem::releaseImage | ( | ) | [protected] |
| void McpContentItem::retranslateUi | ( | ) | [protected, virtual] |
Definition at line 155 of file mcpcontentitem.cpp.
{
if (d_ptr->m_Applet) {
updateText ();
}
}

| void McpContentItem::setApplet | ( | McpAppletObject * | applet | ) |
Sets the applet the McpContentItem should handle.
Currently you can only call it before the ContentItem is popped up, due to limitations of MContentItem.
Definition at line 124 of file mcpcontentitem.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 McpContentItem::setImageFromFile | ( | const QString & | fileName | ) | [protected] |
sets the image based on its filepath
Definition at line 263 of file mcpcontentitem.cpp.
{
bool success;
QImage image;
success = image.load (fileName);
if (!success) {
MCP_WARNING ("The image was not loaded from %s", MCP_STR(fileName));
return;
}
setImage (image);
}
| void McpContentItem::setImageName | ( | const QString & | name | ) | [protected] |
sets the image with the given name (id)
Definition at line 254 of file mcpcontentitem.cpp.
{
setImageID (name);
}
| void McpContentItem::showEvent | ( | QShowEvent * | event | ) | [protected, virtual] |
Definition at line 278 of file mcpcontentitem.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();
}
MContentItem::showEvent(event);
}

| void McpContentItem::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 232 of file mcpcontentitem.cpp.
{
if (!d_ptr->m_Applet)
return;
updateText();
updateImage();
}

| void McpContentItem::updateImage | ( | ) | [protected] |
Updates the picture according to what the applet returns.
Definition at line 196 of file mcpcontentitem.cpp.
{
// ----------- image specific: -------------
if (d_ptr->m_WidgetTypeId == 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;
/* we release the original pixmap, if any */
releaseImage();
// 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 McpContentItem::updateText | ( | ) | [protected] |
Updates all texts according to the values the applet returns.
Definition at line 175 of file mcpcontentitem.cpp.
{
// --------- label specific ------------
QString text2 = applet()->text2();
/*
* if emptyness of text2 changes, we will have to switch from twolinemode,
* so that the labels remains centered
*
* FIXME: this is not working, the first time determines which mode the
* item will be in, because the widget sizes are set up at setupModel time
* only, so currently MContentItem only supports changing the value at
* construction time (bug/feature request to libm if it is important)
if (text2.isEmpty() != subtitle().isEmpty()) {
invertTwoLineMode();
}
*/
setTitle (applet()->text1());
setSubtitle (text2);
}

friend class Ut_McpContentItem [friend] |
Definition at line 125 of file mcpcontentitem.h.
| Copyright © 2009 Nokia Corporation | Generated on Thu Nov 4 2010 18:21:33 Doxygen 1.7.1 |
DirectUI |