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

McpAppletObject Class Reference

This class represents all informations about the applet. More...

#include <mcpappletobject.h>

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

List of all members.

Public Slots

void slotClicked ()
void setToggle (bool checked)
bool activatePluginByName (const QString &name) const
 A slot for the inter plugin activation.
void activateSlot (int widgetId=-1)

Signals

void briefChanged ()
void activate (int pageId)

Public Member Functions

 McpAppletObject (McpAppletMetadata *metadata)
virtual ~McpAppletObject ()
int widgetTypeID () const
 Returns what type of brief widget shall an applet variant use.
bool toggle () const
QString text1 () const
QString text2 () const
QString iconName () const
int getMainWidgetId () const
 Calls the applet and returns the partid set for this desktop file.

Protected Member Functions

McpBriefbrief () const

Detailed Description

This class represents all informations about the applet.

It both gives access to the binary libs of the applet, and its desktop file.

Definition at line 42 of file mcpappletobject.h.


Constructor & Destructor Documentation

McpAppletObject::McpAppletObject ( McpAppletMetadata metadata  ) 

Definition at line 50 of file mcpappletobject.cpp.

                                                           :
      McpAppletPlugin(metadata),
      d_ptr (new McpAppletObjectPrivate)
{
}

McpAppletObject::~McpAppletObject (  )  [virtual]

Definition at line 56 of file mcpappletobject.cpp.

{
    MCP_DEBUG ("Destroying %p", this);
    delete d_ptr;
}


Member Function Documentation

void McpAppletObject::activate ( int  pageId  )  [signal]
bool McpAppletObject::activatePluginByName ( const QString &  appletName  )  const [slot]

A slot for the inter plugin activation.

Parameters:
appletName The name of the applet to activate.

This slot will activate an other applet. First the function will find the applet using the applet database then it will emit a signal for it, so it is going to be started.

FIXME: to be moved to McpAppletDb ?

Definition at line 182 of file mcpappletobject.cpp.

{
    Q_UNUSED(appletName);
    McpAppletObject  *otherApplet;

    MCP_WARNING ("Want to start '%s'", MCP_STR (appletName));

    otherApplet = McpAppletDb::instance()->applet (appletName);
    if (otherApplet) {
        otherApplet->activateSlot ();
        return true;
    }

    MCP_WARNING ("Applet with name '%s' not found.", MCP_STR (appletName));
    return false;
}

Here is the call graph for this function:

void McpAppletObject::activateSlot ( int  widgetId = -1  )  [slot]

Definition at line 268 of file mcpappletobject.cpp.

{
    MCP_DEBUG ("Emitting activate(%d)", pageId);
    emit activate(pageId);
}

Here is the call graph for this function:

McpBrief * McpAppletObject::brief (  )  const [protected]

Definition at line 230 of file mcpappletobject.cpp.

{
    if (d_ptr->m_Brief == 0 && applet() != 0) {
        d_ptr->m_Brief = applet()->constructBrief (getMainWidgetId());

        if (d_ptr->m_Brief != 0) {
            connect (d_ptr->m_Brief, SIGNAL (valuesChanged ()), 
                    this, SIGNAL (briefChanged ()));
            connect (d_ptr->m_Brief, SIGNAL (activateSignal ()), 
                    this, SLOT (activateSlot ()));
        }
    }

    return d_ptr->m_Brief;
}

Here is the call graph for this function:

void McpAppletObject::briefChanged (  )  [signal]
int McpAppletObject::getMainWidgetId (  )  const

Calls the applet and returns the partid set for this desktop file.

This function will take the "MCP/Part" key and call the "int partID(const QString& partStr)" function of the plugin to get the widgetId for the first/main widget. If the applet is not available the function will return -1, that is an invalid widgetId.

Definition at line 221 of file mcpappletobject.cpp.

{
    if (!isAppletLoaded())
        return -1;

    return applet()->partID(metadata()->part());
}

Here is the call graph for this function:

QString McpAppletObject::iconName (  )  const

Returns the icon name for the applet by calling the McpBrief::icon() virtual method. If the applet returns the empty string (default implementation) the method will return the icon name provided in the desktop file.

Definition at line 156 of file mcpappletobject.cpp.

{
    QString retval;

    if (brief())
        retval = brief()->icon();

    if (retval.isEmpty())
        retval = metadata()->imageName();

    MCP_DEBUG ("Returning %s", MCP_STR(retval));
    return retval;
}

Here is the call graph for this function:

void McpAppletObject::setToggle ( bool  checked  )  [slot]

Definition at line 201 of file mcpappletobject.cpp.

{
    if (brief()) {
        brief()->setToggle(checked);
    } else {
        qWarning("Can not set toggle state for the applet %s",
                 qPrintable(metadata()->fileName()));
    }
}

Here is the call graph for this function:

void McpAppletObject::slotClicked (  )  [slot]

This slot will 1) count the activations for the 'most used' category 2) re-enable if the applet is disabled and 3) send the activate() signal so thath the applet will be loaded and shown.

Definition at line 255 of file mcpappletobject.cpp.

{
    metadata()->incrementUsage();

    if (metadata()->isDisabled()) {
        MCP_DEBUG ("Enabling debug.");
        metadata()->setDisabled (false);
    }

    activateSlot();
}

Here is the call graph for this function:

QString McpAppletObject::text1 (  )  const

Definition at line 112 of file mcpappletobject.cpp.

{
    McpAppletIf* applet = this->applet();
    if (applet) {
        // use McpBrief::titleText() if specified:
        QString text1;

        McpBrief* brief = this->brief();
        if (brief) {
            text1 = brief->titleText();
            if (!text1.isEmpty()) return text1;
        }

        // use McpAppletIf::title() by default:
        // FIXME: deprecated to avoid confusion
        text1 = applet->title();
        if (!text1.isEmpty()) return text1;
    }

    /* in case the applet does not specify a title, use the one from the
     * desktop file:
     */
    return metadata()->text1();
}

Here is the call graph for this function:

QString McpAppletObject::text2 (  )  const

Definition at line 138 of file mcpappletobject.cpp.

{
    /*
     * FIXME: This feature is not in the UI spec, we have no localization for
     * the string.
     */
    if (metadata()->isDisabled())
        return QString ("Disabled");

    return (brief() ? brief()->valueText() : QString());
}

Here is the call graph for this function:

bool McpAppletObject::toggle (  )  const

Definition at line 101 of file mcpappletobject.cpp.

{
    if (brief()) {
        return brief()->toggle ();
    }

    qWarning() << Q_FUNC_INFO << "no brief"; 
    return false;
}

Here is the call graph for this function:

int McpAppletObject::widgetTypeID (  )  const

Returns what type of brief widget shall an applet variant use.

Gets the required brief widget type code of the applet variant.

Definition at line 68 of file mcpappletobject.cpp.

{
    int         retval;

    /*
     * If we have a brief and it provides us a widget type id that is valid, we
     * can use that.
     */
    if (brief()) {
        retval = brief()->widgetTypeID ();
        if (McpWidgetType::isIdValid(retval)) {
            MCP_DEBUG ("brief->widgetTypeID () provides a widget type.");
            return retval;

            // invalid marks for us that the type is specified in the .desktop
            // instead
        }
    }

    // return the value from the desktop file:
    retval = metadata()->widgetTypeID ();
    if (McpWidgetType::isIdValid(retval)) {
        return retval;
    }

    /*
     * Otherwise we return the default value, simple plugins can rely on this.
     */
    MCP_DEBUG ("Using default widget type.");
    return McpWidgetType::Label;
}

Here is the call graph for this function:


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