Home · All Namespaces · All Classes · Main Classes
Public Member Functions | Protected Slots | Protected Member Functions | Properties | Friends

McpContentWidget Class Reference

An activatable entry in the control panel. More...

#include <mcpcontentwidget.h>

Inheritance diagram for McpContentWidget:
Inheritance graph
[legend]
Collaboration diagram for McpContentWidget:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 McpContentWidget (McpAppletObject *applet=0, QGraphicsItem *parent=0)
 Constructor.
 ~McpContentWidget ()
void setApplet (McpAppletObject *applet)
 Sets the applet the McpContentWidget should handle.
McpAppletObjectapplet () 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

Detailed Description

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.


Constructor & Destructor Documentation

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.

                                :
    MListItem (parent),
    d_ptr (new McpContentWidgetPrivate)
{
    setApplet (applet);
}

Here is the call graph for this function:

McpContentWidget::~McpContentWidget (  ) 

Definition at line 53 of file mcpcontentwidget.cpp.

{
    delete d_ptr;
}


Member Function Documentation

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]

Definition at line 69 of file mcpcontentwidget.cpp.

{
    return applet() && !applet()->text2().isEmpty();
}

Here is the call graph for this function:

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);
}

Here is the call graph for this function:

QString McpContentWidget::imageID (  )  const [protected]
bool McpContentWidget::isChecked (  )  const [protected]

Definition at line 75 of file mcpcontentwidget.cpp.

{
    return applet() && applet()->toggle();
}

Here is the call graph for this function:

void McpContentWidget::retranslateUi (  )  [protected, virtual]

Definition at line 294 of file mcpcontentwidget.cpp.

{
    if (d_ptr->m_Applet) {
        updateText ();
    }
}

Here is the call graph for this function:

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()));
    }
}

Here is the call graph for this function:

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);
}

Here is the call graph for this function:

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();
}

Here is the call graph for this function:

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;
    }
}

Here is the call graph for this function:

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]

Friends And Related Function Documentation

friend class Ut_McpContentWidget [friend]

Definition at line 133 of file mcpcontentwidget.h.


Property Documentation

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.


The documentation for this class was generated from the following files:

Copyright © 2009 Nokia Corporation Generated on Thu Nov 4 2010 18:21:33
Doxygen 1.7.1
DirectUI