• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

Plasma

  • Plasma
  • ExtenderItem
Public Slots | Signals | Public Member Functions | Protected Member Functions | Properties | List of all members
Plasma::ExtenderItem Class Reference

#include <extenderitem.h>

Inheritance diagram for Plasma::ExtenderItem:
Inheritance graph
[legend]

Public Slots

void destroy ()
 
void hideCloseButton ()
 
void returnToSource ()
 
void setCollapsed (bool collapsed)
 
void showCloseButton ()
 

Signals

void destroyed (Plasma::ExtenderItem *item)
 

Public Member Functions

 ExtenderItem (Extender *hostExtender, uint extenderItemId=0)
 
 ~ExtenderItem ()
 
QAction * action (const QString &name) const
 
void addAction (const QString &name, QAction *action)
 
uint autoExpireDelay () const
 
KConfigGroup config () const
 
Extender * extender () const
 
ExtenderGroup * group () const
 
QIcon icon () const
 
bool isCollapsed () const
 
bool isDetached () const
 
bool isGroup () const
 
bool isTransient () const
 
QString name () const
 
void setAutoExpireDelay (uint time)
 
void setExtender (Extender *extender, const QPointF &pos=QPointF(-1,-1))
 
void setGroup (ExtenderGroup *group)
 
void setGroup (ExtenderGroup *group, const QPointF &pos)
 
void setIcon (const QString &icon)
 
void setIcon (const QIcon &icon)
 
void setName (const QString &name)
 
void setTitle (const QString &title)
 
void setTransient (const bool transient)
 
void setWidget (QGraphicsItem *widget)
 
QString title () const
 
QGraphicsItem * widget () const
 

Protected Member Functions

void hoverLeaveEvent (QGraphicsSceneHoverEvent *event)
 
void hoverMoveEvent (QGraphicsSceneHoverEvent *event)
 
void mouseDoubleClickEvent (QGraphicsSceneMouseEvent *event)
 
void mouseMoveEvent (QGraphicsSceneMouseEvent *event)
 
void mousePressEvent (QGraphicsSceneMouseEvent *event)
 
void mouseReleaseEvent (QGraphicsSceneMouseEvent *event)
 
void moveEvent (QGraphicsSceneMoveEvent *event)
 
void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
 
void resizeEvent (QGraphicsSceneResizeEvent *event)
 
bool sceneEventFilter (QGraphicsItem *watched, QEvent *event)
 
QSizeF sizeHint (Qt::SizeHint which, const QSizeF &constraint) const
 

Properties

uint autoExpireDelay
 
bool collapsed
 
bool detached
 
Extender extender
 
QIcon icon
 
QString name
 
QString title
 
QGraphicsItem widget
 

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:

if (!extender()->hasItem("networkmonitoreth0")) {
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);
}

Note that we first check if the item already exists: ExtenderItems are persistent between sessions so we can't blindly add items since they might already exist.

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 80 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
hostExtenderThe extender the extender item belongs to.
extenderItemIdthe id of the extender item. Use the default 0 to assign a new, unique id to this extender item.

Definition at line 128 of file extenderitem.cpp.

Plasma::ExtenderItem::~ExtenderItem ( )

Definition at line 234 of file extenderitem.cpp.

Member Function Documentation

QAction * Plasma::ExtenderItem::action ( const QString &  name) const
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 554 of file extenderitem.cpp.

void Plasma::ExtenderItem::addAction ( const QString &  name,
QAction *  action 
)
Parameters
namethe name to store the action under in our collection.
actionthe action to add. Actions will be displayed as an icon in the drag handle.

Definition at line 540 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 240 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 579 of file extenderitem.cpp.

void Plasma::ExtenderItem::destroyed ( Plasma::ExtenderItem *  item)
signal

Emitted when the extender item is destroyed.

Since
4.4.1
Extender* Plasma::ExtenderItem::extender ( ) const
Returns
the extender this items belongs to.
ExtenderGroup * Plasma::ExtenderItem::group ( ) const
Returns
the group this item belongs to.
Since
4.3

Definition at line 483 of file extenderitem.cpp.

void Plasma::ExtenderItem::hideCloseButton ( )
slot

Hides the close button in this item's drag handle.

Definition at line 569 of file extenderitem.cpp.

void Plasma::ExtenderItem::hoverLeaveEvent ( QGraphicsSceneHoverEvent *  event)
protected

Definition at line 797 of file extenderitem.cpp.

void Plasma::ExtenderItem::hoverMoveEvent ( QGraphicsSceneHoverEvent *  event)
protected

Definition at line 793 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 493 of file extenderitem.cpp.

bool Plasma::ExtenderItem::isDetached ( ) const
Returns
whether or not this item is detached from its original source.

Definition at line 531 of file extenderitem.cpp.

bool Plasma::ExtenderItem::isGroup ( ) const
Returns
whether or not this is an ExtenderGroup.
Since
4.3

Definition at line 488 of file extenderitem.cpp.

bool Plasma::ExtenderItem::isTransient ( ) const
Returns
true if the ExtenderItem is transient.
Since
4.6

Definition at line 811 of file extenderitem.cpp.

void Plasma::ExtenderItem::mouseDoubleClickEvent ( QGraphicsSceneMouseEvent *  event)
protected

Definition at line 775 of file extenderitem.cpp.

void Plasma::ExtenderItem::mouseMoveEvent ( QGraphicsSceneMouseEvent *  event)
protected

Definition at line 677 of file extenderitem.cpp.

void Plasma::ExtenderItem::mousePressEvent ( QGraphicsSceneMouseEvent *  event)
protected

Definition at line 668 of file extenderitem.cpp.

void Plasma::ExtenderItem::mouseReleaseEvent ( QGraphicsSceneMouseEvent *  event)
protected

Definition at line 787 of file extenderitem.cpp.

void Plasma::ExtenderItem::moveEvent ( QGraphicsSceneMoveEvent *  event)
protected

Definition at line 654 of file extenderitem.cpp.

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 644 of file extenderitem.cpp.

void Plasma::ExtenderItem::resizeEvent ( QGraphicsSceneResizeEvent *  event)
protected

Definition at line 660 of file extenderitem.cpp.

void Plasma::ExtenderItem::returnToSource ( )
slot

Returns the extender item to its source applet.

Definition at line 633 of file extenderitem.cpp.

bool Plasma::ExtenderItem::sceneEventFilter ( QGraphicsItem *  watched,
QEvent *  event 
)
protected

Definition at line 782 of file extenderitem.cpp.

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 498 of file extenderitem.cpp.

void Plasma::ExtenderItem::setCollapsed ( bool  collapsed)
slot

Collapse or expand the extender item.

Defaults to false.

Definition at line 602 of file extenderitem.cpp.

void Plasma::ExtenderItem::setExtender ( Extender *  extender,
const QPointF &  pos = QPointF(-1, -1) 
)
Parameters
extenderthe extender this item belongs to.
posthe position in the extender this item should be added. Defaults to 'just append'.

Definition at line 348 of file extenderitem.cpp.

void Plasma::ExtenderItem::setGroup ( ExtenderGroup *  group)
Parameters
groupthe group you want this item to belong to. Note that you can't nest ExtenderGroups.
Since
4.3

Definition at line 442 of file extenderitem.cpp.

void Plasma::ExtenderItem::setGroup ( ExtenderGroup *  group,
const QPointF &  pos 
)
Parameters
groupthe group you want this item to belong to. Note that you can't nest ExtenderGroups.
groupthe new group
posposition inside the extender group
Since
4.5

Definition at line 447 of file extenderitem.cpp.

void Plasma::ExtenderItem::setIcon ( const QString &  icon)
Parameters
iconthe 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 334 of file extenderitem.cpp.

void Plasma::ExtenderItem::setIcon ( const QIcon &  icon)
Parameters
iconthe icon to display in the extender item's drag handle. Defaults to the source applet's icon.

Definition at line 325 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
namethe name of the item. Defaults to an empty string.

Definition at line 291 of file extenderitem.cpp.

void Plasma::ExtenderItem::setTitle ( const QString &  title)
Parameters
titlethe 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 277 of file extenderitem.cpp.

void Plasma::ExtenderItem::setTransient ( const bool  transient)

Set the ExtenderItem as transient: won't be saved in the Plasma config and won't be restored.

This is intended for items that have contents valid only for this session.

Parameters
transienttrue if the ExtenderItem will be transient
Since
4.6

Definition at line 806 of file extenderitem.cpp.

void Plasma::ExtenderItem::setWidget ( QGraphicsItem *  widget)
Parameters
widgetThe widget that should be wrapped into the extender item. It has to be a QGraphicsWidget.

Definition at line 302 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 559 of file extenderitem.cpp.

QSizeF Plasma::ExtenderItem::sizeHint ( Qt::SizeHint  which,
const QSizeF &  constraint 
) const
protected

Definition at line 801 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
readwrite

Definition at line 90 of file extenderitem.h.

bool Plasma::ExtenderItem::collapsed
readwrite

Definition at line 88 of file extenderitem.h.

bool Plasma::ExtenderItem::detached
read

Definition at line 89 of file extenderitem.h.

Extender * Plasma::ExtenderItem::extender
readwrite

Definition at line 87 of file extenderitem.h.

QIcon Plasma::ExtenderItem::icon
readwrite

Definition at line 86 of file extenderitem.h.

QString Plasma::ExtenderItem::name
readwrite

Definition at line 85 of file extenderitem.h.

QString Plasma::ExtenderItem::title
readwrite

Definition at line 84 of file extenderitem.h.

QGraphicsItem * Plasma::ExtenderItem::widget
readwrite

Definition at line 83 of file extenderitem.h.


The documentation for this class was generated from the following files:
  • extenderitem.h
  • extenderitem.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:48:35 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Plasma

Skip menu "Plasma"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal