Plasma
#include <extender.h>
Public Types | |
enum | Appearance { NoBorders = 0, BottomUpStacked = 1, TopDownStacked = 2 } |
Signals | |
void | geometryChanged () |
void | itemAttached (Plasma::ExtenderItem *) |
void | itemDetached (Plasma::ExtenderItem *) |
Public Member Functions | |
Extender (Applet *applet) | |
~Extender () | |
Appearance | appearance () const |
Applet * | applet () const |
QList< ExtenderItem * > | attachedItems () const |
QList< ExtenderItem * > | detachedItems () const |
QString | emptyExtenderMessage () const |
Q_INVOKABLE ExtenderGroup * | group (const QString &name) const |
QList< ExtenderGroup * > | groups () const |
Q_INVOKABLE bool | hasItem (const QString &name) const |
bool | isEmpty () const |
Q_INVOKABLE ExtenderItem * | item (const QString &name) const |
QList< ExtenderItem * > | items () const |
void | setAppearance (Appearance appearance) |
void | setEmptyExtenderMessage (const QString &message) |
Protected Member Functions | |
void | dragEnterEvent (QGraphicsSceneDragDropEvent *event) |
void | dragLeaveEvent (QGraphicsSceneDragDropEvent *event) |
void | dragMoveEvent (QGraphicsSceneDragDropEvent *event) |
void | dropEvent (QGraphicsSceneDragDropEvent *event) |
virtual FrameSvg::EnabledBorders | enabledBordersForItem (ExtenderItem *item) const |
virtual void | itemAddedEvent (ExtenderItem *item, const QPointF &pos=QPointF(-1,-1)) |
QVariant | itemChange (GraphicsItemChange change, const QVariant &value) |
virtual void | itemHoverEnterEvent (ExtenderItem *item) |
virtual void | itemHoverLeaveEvent (ExtenderItem *item) |
virtual void | itemHoverMoveEvent (ExtenderItem *item, const QPointF &pos) |
virtual void | itemRemovedEvent (ExtenderItem *item) |
void | mousePressEvent (QGraphicsSceneMouseEvent *event) |
void | resizeEvent (QGraphicsSceneResizeEvent *event) |
virtual void | saveState () |
Properties | |
QList< ExtenderItem * > | attachedItems |
QList< ExtenderItem * > | detachedItems |
bool | empty |
QString | emptyExtenderMessage |
QList< ExtenderGroup * > | groups |
QList< ExtenderItem * > | items |
Detailed Description
Extends applets to allow detachable parts.
An Extender is a widget that visually extends the normal contents of an applet with additional dynamic widgets called ExtenderItems. These ExtenderItems can be detached by the user and dropped either on another Extender or on the canvas directly.
This widget allows using ExtenderItems in your applet. Extender takes care of the presentation of a collection of ExtenderItems and keeps track of ExtenderItems that originate in it.
The default Extender implementation displays extender items in a vertical layout with spacers that appear when dropping an ExtenderItem over it.
If you wish to have a different presentation of extender items, you can choose to subclass Extender and reimplement the extenderItem* events and, optionally, the saveState function.
To use an Extender in you applet, you'll have to instantiate one. A call to extender() in your applet will create an extender on your applet if you haven't got one already. Every applet can contain only one extender. Think of it as a decorator that adds some functionality to applets that require it. Never instantiate an Extender before init() in your applet. This won't work correctly since a scene is required when an Extender is instantiated.
As soon as an Extender is instantiated, ExtenderItems contained previously in this Extender are restored using the initExtenderItem function from the applet the items originally came from. For more information on how this works and how to use ExtenderItems in general, see the ExtenderItem API documentation.
Definition at line 65 of file extender.h.
Member Enumeration Documentation
Description on how to render the extender's items.
Definition at line 79 of file extender.h.
Constructor & Destructor Documentation
|
explicit |
Creates an extender.
Note that extender expects applet to have a config(), and needs a scene because of that. So you should only instantiate an extender in init() or later, not in an applet's constructor. The constructor also takes care of restoring ExtenderItems that were contained in this extender before, so ExtenderItems are persistent between sessions. Note that a call to extender() in an applet will instantiate an Extender for you if one isn't already associated with your applet.
- Parameters
-
applet The applet this extender is part of. Null is not allowed here.
Definition at line 88 of file extender.cpp.
Plasma::Extender::~Extender | ( | ) |
Definition at line 133 of file extender.cpp.
Member Function Documentation
Extender::Appearance Plasma::Extender::appearance | ( | ) | const |
- Returns
- the current way of rendering extender items that is used.
Definition at line 339 of file extender.cpp.
Applet * Plasma::Extender::applet | ( | ) | const |
- Since
- 4.4
Definition at line 358 of file extender.cpp.
QList<ExtenderItem*> Plasma::Extender::attachedItems | ( | ) | const |
- Returns
- a list of all attached extender items.
QList<ExtenderItem*> Plasma::Extender::detachedItems | ( | ) | const |
- Returns
- a list of all detached extender items.
|
protected |
Reimplemented from QGraphicsWidget.
Definition at line 399 of file extender.cpp.
|
protected |
Reimplemented from QGraphicsWidget.
Definition at line 432 of file extender.cpp.
|
protected |
Reimplemented from QGraphicsWidget.
Definition at line 418 of file extender.cpp.
|
protected |
Reimplemented from QGraphicsWidget.
Definition at line 476 of file extender.cpp.
QString Plasma::Extender::emptyExtenderMessage | ( | ) | const |
- Returns
- The text to be shown whenever the applet's layout is empty.
|
protectedvirtual |
This function get's called on every item to determine which background border's to render.
- Parameters
-
item the item for which its position or extender has changed.
- Returns
- the borders that have to be enabled on its background.
Definition at line 605 of file extender.cpp.
|
signal |
Fires when an extender's preferred size changes.
ExtenderGroup * Plasma::Extender::group | ( | const QString & | name | ) | const |
Extra convenience function for obtaining groups specified by name.
This will avoid needed to call item and casting to ExtenderGroup, which is otherwise quite common.
- Returns
- the requested group
- Since
- 4.3
Definition at line 293 of file extender.cpp.
QList<ExtenderGroup*> Plasma::Extender::groups | ( | ) | const |
- Returns
- a list of groups that are contained in this extender.
- Since
- 4.3
bool Plasma::Extender::hasItem | ( | const QString & | name | ) | const |
This function can be used for easily determining if a certain item is already displayed in an extender item somewhere, so your applet doesn't duplicate this item.
This is needed because ExtenderItems are persistent, so you can't blindly add new extender items in all cases.
- Returns
- whether or not this item already exists.
- Since
- 4.3
Definition at line 298 of file extender.cpp.
bool Plasma::Extender::isEmpty | ( | ) | const |
- Returns
- true if the Extender is visually empty (though it may have items such as empty groups or detached items associatd with it)
Definition at line 927 of file extender.cpp.
ExtenderItem * Plasma::Extender::item | ( | const QString & | name | ) | const |
This function can be used for obtaining the extender item specified by name.
For checking whether or not an item already exists, you should use hasItem instead: while plasma is starting up, not all detached items might have been instantiated yet. hasItem returns true even if the requested item isn't instantiated yet.
- Returns
- the requested item
Definition at line 241 of file extender.cpp.
|
protectedvirtual |
Get's called after an item has been added to this extender.
The bookkeeping has already been done when this function get's called. The only thing left to do is put it somewhere appropriate. The default implementation adds the extenderItem to the appropriate place in a QGraphicsLinearLayout.
- Parameters
-
item The item that has just been added. pos The location the item has been dropped in local coordinates.
Definition at line 490 of file extender.cpp.
|
signal |
Fires when an extender item is added to this extender.
|
protected |
Reimplemented from QGraphicsWidget.
Definition at line 370 of file extender.cpp.
|
signal |
Fires when an extender item is removed from this extender.
|
protectedvirtual |
Get's called when an ExtenderItem that get's dragged enters this extender.
Default implementation does nothing.
Definition at line 552 of file extender.cpp.
|
protectedvirtual |
Get's called when an ExtenderItem that was previously hovering over this extender moves away from this extender.
The default implementation removes any spacer from the layout.
Definition at line 589 of file extender.cpp.
|
protectedvirtual |
Gets called when an ExtenderItem is hovering over this extender.
Implement this function to give some visual feedback about what will happen when the mouse button is released at that position. The default implementation shows a spacer at the appropriate location in the layout.
- Parameters
-
item The item that's hovering over this extender. Most useful for obtaining the size of the spacer. pos The location the item is hovering.
Definition at line 557 of file extender.cpp.
|
protectedvirtual |
Get's called after an item has been removed from this extender.
All bookkeeping has already been done when this function get's called.
- Parameters
-
item The item that has just been removed.
Definition at line 525 of file extender.cpp.
QList<ExtenderItem*> Plasma::Extender::items | ( | ) | const |
- Returns
- a list of all extender items (attached AND detached) where the source applet is this applet.
|
protected |
Reimplemented from QGraphicsWidget.
Definition at line 385 of file extender.cpp.
|
protected |
Reimplemented from QGraphicsWidget.
Definition at line 379 of file extender.cpp.
|
protectedvirtual |
This function get's called for every extender when plasma exits.
Implement this function to store the current state of this extender (position in a layout for example), so this can be restored when applet starts again. The default implementation stores the y coordinate of every extender item in the config field extenderItemPos.
Definition at line 363 of file extender.cpp.
void Plasma::Extender::setAppearance | ( | Appearance | appearance | ) |
Use this function to instruct the extender on how to render its items.
Usually you will want to call this function in your applet's constraintsEvent, allthough this is already done for you when using PopupApplet as base class for your applet. Defaults to NoBorders.
- Parameters
-
appearance the way this extender should look.
Definition at line 329 of file extender.cpp.
void Plasma::Extender::setEmptyExtenderMessage | ( | const QString & | message | ) |
- Parameters
-
message The text to be shown whenever the applet's extender is empty.
Definition at line 163 of file extender.cpp.
Property Documentation
|
read |
Definition at line 70 of file extender.h.
|
read |
Definition at line 71 of file extender.h.
|
read |
Definition at line 73 of file extender.h.
|
readwrite |
Definition at line 68 of file extender.h.
|
read |
Definition at line 72 of file extender.h.
|
read |
Definition at line 69 of file extender.h.
The documentation for this class was generated from the following files:
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.