Plasma
Plasma::ExtenderItem Class Reference
Provides detachable items for an Extender. More...
#include <Plasma/ExtenderItem>

Detailed Description
Provides detachable items for an Extender.This class wraps around a QGraphicsWidget and provides drag&drop handling, a draghandle, title and ability to display qactions as a row of icon, ability to expand, collapse, return to source and tracks configuration associated with this item for you.
Typical usage of ExtenderItems in your applet could look like this:
ExtenderItem *item = new ExtenderItem(extender()); //name can be used to later access this item through extender()->item(name): item->setName("networkmonitoreth0"); item->config().writeEntry("device", "eth0"); initExtenderItem(item);
You'll then need to implement the initExtenderItem function. Having this function in your applet makes sure that detached extender items get restored after plasma is restarted, just like applets are. That is also the reason that we write an entry in item->config(). In this function you should instantiate a QGraphicsWidget or QGraphicsItem and call the setWidget function on the ExtenderItem. This is the only correct way of adding actual content to a extenderItem. An example:
void MyApplet::initExtenderItem(Plasma::ExtenderItem *item) { QGraphicsWidget *myNetworkMonitorWidget = new NetworkMonitorWidget(item); dataEngine("networktraffic")->connectSource(item->config().readEntry("device", ""), myNetworkMonitorWidget); item->setWidget(myNetworkMonitorWidget); }
Definition at line 74 of file extenderitem.h.
Constructor & Destructor Documentation
Plasma::ExtenderItem::ExtenderItem | ( | Extender * | hostExtender, | |
uint | extenderItemId = 0 | |||
) | [explicit] |
The constructor takes care of adding this item to an extender.
- Parameters:
-
hostExtender The extender the extender item belongs to. extenderItemId the id of the extender item. Use the default 0 to assign a new, unique id to this extender item.
Definition at line 83 of file extenderitem.cpp.
Plasma::ExtenderItem::~ExtenderItem | ( | ) |
Definition at line 160 of file extenderitem.cpp.
Member Function Documentation
- Returns:
- the QAction with the given name from our collection. By default the action collection contains a "movebacktosource" action which will be only shown when the item is detached.
Definition at line 343 of file extenderitem.cpp.
- Parameters:
-
name the name to store the action under in our collection. action the action to add. Actions will be displayed as an icon in the drag handle.
Definition at line 329 of file extenderitem.cpp.
uint Plasma::ExtenderItem::autoExpireDelay | ( | ) | const |
- Returns:
- whether or not this extender item has an auto expire delay.
KConfigGroup Plasma::ExtenderItem::config | ( | ) | const |
fetch the configuration of this widget.
- Returns:
- the configuration of this widget.
Definition at line 169 of file extenderitem.cpp.
void Plasma::ExtenderItem::destroy | ( | ) | [slot] |
Destroys the extender item.
As opposed to calling delete on this class, destroy also removes the config group associated with this item.
Definition at line 368 of file extenderitem.cpp.
Extender* Plasma::ExtenderItem::extender | ( | ) | const |
- Returns:
- the extender this items belongs to.
void Plasma::ExtenderItem::hideCloseButton | ( | ) | [slot] |
void Plasma::ExtenderItem::hoverLeaveEvent | ( | QGraphicsSceneHoverEvent * | event | ) | [protected] |
Definition at line 706 of file extenderitem.cpp.
void Plasma::ExtenderItem::hoverMoveEvent | ( | QGraphicsSceneHoverEvent * | event | ) | [protected] |
Definition at line 690 of file extenderitem.cpp.
QIcon Plasma::ExtenderItem::icon | ( | ) | const |
- Returns:
- the icon being displayed in the extender item's drag handle.
bool Plasma::ExtenderItem::isCollapsed | ( | ) | const |
- Returns:
- whether or not the extender item is collapsed.
Definition at line 282 of file extenderitem.cpp.
bool Plasma::ExtenderItem::isDetached | ( | ) | const |
- Returns:
- whether or not this item is detached from it's original source.
Definition at line 320 of file extenderitem.cpp.
void Plasma::ExtenderItem::mouseDoubleClickEvent | ( | QGraphicsSceneMouseEvent * | event | ) | [protected] |
Definition at line 683 of file extenderitem.cpp.
void Plasma::ExtenderItem::mouseMoveEvent | ( | QGraphicsSceneMouseEvent * | event | ) | [protected] |
Definition at line 549 of file extenderitem.cpp.
void Plasma::ExtenderItem::mousePressEvent | ( | QGraphicsSceneMouseEvent * | event | ) | [protected] |
Definition at line 534 of file extenderitem.cpp.
void Plasma::ExtenderItem::mouseReleaseEvent | ( | QGraphicsSceneMouseEvent * | event | ) | [protected] |
Definition at line 716 of file extenderitem.cpp.
void Plasma::ExtenderItem::moveEvent | ( | QGraphicsSceneMoveEvent * | event | ) | [protected] |
QString Plasma::ExtenderItem::name | ( | ) | const |
- Returns:
- the name of the item.
void Plasma::ExtenderItem::paint | ( | QPainter * | painter, | |
const QStyleOptionGraphicsItem * | option, | |||
QWidget * | widget | |||
) | [protected] |
Definition at line 458 of file extenderitem.cpp.
void Plasma::ExtenderItem::resizeEvent | ( | QGraphicsSceneResizeEvent * | event | ) | [protected] |
void Plasma::ExtenderItem::returnToSource | ( | ) | [slot] |
void Plasma::ExtenderItem::setAutoExpireDelay | ( | uint | time | ) |
- Parameters:
-
time (in ms) before this extender item destroys itself unless it is detached, in which case this extender stays around. 0 means forever and is the default.
Definition at line 287 of file extenderitem.cpp.
void Plasma::ExtenderItem::setCollapsed | ( | bool | collapsed | ) | [slot] |
Collapse or expand the extender item.
Defaults to false.
Definition at line 380 of file extenderitem.cpp.
void Plasma::ExtenderItem::setExtender | ( | Extender * | extender, | |
const QPointF & | pos = QPointF(-1, -1) | |||
) |
- Parameters:
-
extender the extender this item belongs to. pos the position in the extender this item should be added. Defaults to 'just append'.
Definition at line 235 of file extenderitem.cpp.
void Plasma::ExtenderItem::setIcon | ( | const QIcon & | icon | ) |
- Parameters:
-
icon the icon to display in the extender item's drag handle. Defaults to the source applet's icon.
Definition at line 215 of file extenderitem.cpp.
void Plasma::ExtenderItem::setIcon | ( | const QString & | icon | ) |
- Parameters:
-
icon the icon name to display in the extender item's drag handle. Defaults to the source applet's icon. This icon name will also be stored in the item's configuration, so you don't have to manually store/restore this information.
Definition at line 221 of file extenderitem.cpp.
void Plasma::ExtenderItem::setName | ( | const QString & | name | ) |
You can assign names to extender items to look them up through the item() function.
Make sure you only use unique names. This name will be stored in the item's configuration.
- Parameters:
-
name the name of the item. Defaults to an empty string.
Definition at line 187 of file extenderitem.cpp.
void Plasma::ExtenderItem::setTitle | ( | const QString & | title | ) |
- Parameters:
-
title the title that will be shown in the extender item's dragger. Default is no title. This title will also be stored in the item's configuration, so you don't have to manually store/restore this information for your extender items.
Definition at line 175 of file extenderitem.cpp.
void Plasma::ExtenderItem::setWidget | ( | QGraphicsItem * | widget | ) |
- Parameters:
-
widget The widget that should be wrapped into the extender item.
Definition at line 198 of file extenderitem.cpp.
void Plasma::ExtenderItem::showCloseButton | ( | ) | [slot] |
Shows a close button in this item's drag handle.
By default a close button will not be shown.
Definition at line 348 of file extenderitem.cpp.
QString Plasma::ExtenderItem::title | ( | ) | const |
- Returns:
- the title shown in the extender item's dragger.
QGraphicsItem* Plasma::ExtenderItem::widget | ( | ) | const |
- Returns:
- The widget that is wrapped into the extender item.
Property Documentation
uint Plasma::ExtenderItem::autoExpireDelay [write] |
Definition at line 84 of file extenderitem.h.
bool Plasma::ExtenderItem::collapsed [read, write] |
Definition at line 82 of file extenderitem.h.
bool Plasma::ExtenderItem::detached [read] |
Definition at line 83 of file extenderitem.h.
Extender * Plasma::ExtenderItem::extender [read, write] |
Definition at line 81 of file extenderitem.h.
QIcon Plasma::ExtenderItem::icon [read, write] |
Definition at line 80 of file extenderitem.h.
QString Plasma::ExtenderItem::name [read, write] |
Definition at line 79 of file extenderitem.h.
QString Plasma::ExtenderItem::title [read, write] |
Definition at line 78 of file extenderitem.h.
QGraphicsItem * Plasma::ExtenderItem::widget [read, write] |
Definition at line 77 of file extenderitem.h.
The documentation for this class was generated from the following files: