Plasma
extenderitem.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef PLASMA_EXTENDERITEM_H
00021 #define PLASMA_EXTENDERITEM_H
00022
00023 #include <QtGui/QGraphicsWidget>
00024
00025 #include <kconfiggroup.h>
00026 #include <kicon.h>
00027
00028 #include "plasma/plasma_export.h"
00029
00030 namespace Plasma
00031 {
00032
00033 class Applet;
00034 class Extender;
00035 class ExtenderItemPrivate;
00036
00074 class PLASMA_EXPORT ExtenderItem : public QGraphicsWidget
00075 {
00076 Q_OBJECT
00077 Q_PROPERTY(QGraphicsItem * widget READ widget WRITE setWidget)
00078 Q_PROPERTY(QString title READ title WRITE setTitle)
00079 Q_PROPERTY(QString name READ name WRITE setName)
00080 Q_PROPERTY(QIcon icon READ icon WRITE setIcon)
00081 Q_PROPERTY(Extender * extender READ extender WRITE setExtender)
00082 Q_PROPERTY(bool collapsed READ isCollapsed WRITE setCollapsed)
00083 Q_PROPERTY(bool detached READ isDetached)
00084 Q_PROPERTY(uint autoExpireDelay WRITE setAutoExpireDelay)
00085
00086 public:
00093 explicit ExtenderItem(Extender *hostExtender, uint extenderItemId = 0);
00094
00095 ~ExtenderItem();
00096
00101 KConfigGroup config() const;
00102
00106 void setWidget(QGraphicsItem *widget);
00107
00111 QGraphicsItem *widget() const;
00112
00118 void setTitle(const QString &title);
00119
00123 QString title() const;
00124
00131 void setName(const QString &name);
00132
00136 QString name() const;
00137
00144 void setIcon(const QString &icon);
00145
00150 void setIcon(const QIcon &icon);
00151
00155 QIcon icon() const;
00156
00162 void setExtender(Extender *extender, const QPointF &pos = QPointF(-1, -1));
00163
00167 Extender *extender() const;
00168
00173 void setAutoExpireDelay(uint time);
00174
00178 uint autoExpireDelay() const;
00179
00183 bool isDetached() const;
00184
00188 bool isCollapsed() const;
00189
00195 void addAction(const QString &name, QAction *action);
00196
00202 QAction *action(const QString &name) const;
00203
00204 public Q_SLOTS:
00209 void destroy();
00210
00214 void setCollapsed(bool collapsed);
00215
00219 void returnToSource();
00220
00225 void showCloseButton();
00226
00230 void hideCloseButton();
00231
00232 protected:
00233 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
00234
00235 void moveEvent(QGraphicsSceneMoveEvent *event);
00236 void resizeEvent(QGraphicsSceneResizeEvent *event);
00237
00238 void mousePressEvent(QGraphicsSceneMouseEvent *event);
00239 void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
00240 void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
00241 void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
00242
00243 void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
00244 void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
00245
00246 private:
00247 Q_PRIVATE_SLOT(d, void toggleCollapse())
00248 Q_PRIVATE_SLOT(d, void updateToolBox())
00249 Q_PRIVATE_SLOT(d, void themeChanged())
00250 Q_PRIVATE_SLOT(d, void sourceAppletRemoved())
00251 Q_PRIVATE_SLOT(d, void previousTargetExtenderDestroyed(QObject*))
00252 Q_PRIVATE_SLOT(d, void actionDestroyed(QObject*))
00253
00254 ExtenderItemPrivate * const d;
00255
00256 friend class Extender;
00257 friend class ExtenderPrivate;
00258 };
00259 }
00260 #endif // PLASMA_EXTENDERITEM_H