Plasma
extenderitem.h
Go to the documentation of this file.
00001 /* 00002 * Copyright 2008, 2009 by Rob Scheepmaker <r.scheepmaker@student.utwente.nl> 00003 * 00004 * This library is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU Lesser General Public 00006 * License as published by the Free Software Foundation; either 00007 * version 2.1 of the License, or (at your option) any later version. 00008 * 00009 * This library is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Lesser General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Lesser General Public 00015 * License along with this library; if not, write to the Free Software 00016 * Foundation, Inc., 51 Franklin St, Fifth Floor, 00017 * Boston, MA 02110-1301 USA 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 ExtenderGroup; 00036 class ExtenderItemPrivate; 00037 00080 class PLASMA_EXPORT ExtenderItem : public QGraphicsWidget 00081 { 00082 Q_OBJECT 00083 Q_PROPERTY(QGraphicsItem * widget READ widget WRITE setWidget) 00084 Q_PROPERTY(QString title READ title WRITE setTitle) 00085 Q_PROPERTY(QString name READ name WRITE setName) 00086 Q_PROPERTY(QIcon icon READ icon WRITE setIcon) 00087 Q_PROPERTY(Extender * extender READ extender WRITE setExtender) 00088 Q_PROPERTY(bool collapsed READ isCollapsed WRITE setCollapsed) 00089 Q_PROPERTY(bool detached READ isDetached) 00090 Q_PROPERTY(uint autoExpireDelay READ autoExpireDelay WRITE setAutoExpireDelay) 00091 00092 public: 00099 explicit ExtenderItem(Extender *hostExtender, uint extenderItemId = 0); 00100 00101 ~ExtenderItem(); 00102 00107 KConfigGroup config() const; 00108 00113 void setWidget(QGraphicsItem *widget); 00114 00118 QGraphicsItem *widget() const; 00119 00125 void setTitle(const QString &title); 00126 00130 QString title() const; 00131 00138 void setName(const QString &name); 00139 00143 QString name() const; 00144 00151 void setIcon(const QString &icon); 00152 00157 void setIcon(const QIcon &icon); 00158 00162 QIcon icon() const; 00163 00169 void setExtender(Extender *extender, const QPointF &pos = QPointF(-1, -1)); 00170 00174 Extender *extender() const; 00175 00181 void setGroup(ExtenderGroup *group); 00182 00191 void setGroup(ExtenderGroup *group, const QPointF &pos); 00192 00197 ExtenderGroup *group() const; 00198 00203 bool isGroup() const; 00204 00209 void setAutoExpireDelay(uint time); 00210 00214 uint autoExpireDelay() const; 00215 00219 bool isDetached() const; 00220 00224 bool isCollapsed() const; 00225 00231 void addAction(const QString &name, QAction *action); 00232 00238 QAction *action(const QString &name) const; 00239 00249 void setTransient(const bool transient); 00250 00255 bool isTransient() const; 00256 00257 public Q_SLOTS: 00262 void destroy(); 00263 00267 void setCollapsed(bool collapsed); 00268 00272 void returnToSource(); 00273 00278 void showCloseButton(); 00279 00283 void hideCloseButton(); 00284 00285 Q_SIGNALS: 00290 void destroyed(Plasma::ExtenderItem *item); 00291 00292 protected: 00293 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); 00294 00295 void moveEvent(QGraphicsSceneMoveEvent *event); 00296 void resizeEvent(QGraphicsSceneResizeEvent *event); 00297 00298 void mousePressEvent(QGraphicsSceneMouseEvent *event); 00299 void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event); 00300 void mouseMoveEvent(QGraphicsSceneMouseEvent *event); 00301 void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); 00302 00303 void hoverMoveEvent(QGraphicsSceneHoverEvent *event); 00304 void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); 00305 00306 bool sceneEventFilter(QGraphicsItem *watched, QEvent *event); 00307 00308 QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint) const; 00309 00310 private: 00311 Q_PRIVATE_SLOT(d, void toggleCollapse()) 00312 Q_PRIVATE_SLOT(d, void updateToolBox()) 00313 Q_PRIVATE_SLOT(d, void themeChanged()) 00314 Q_PRIVATE_SLOT(d, void sourceAppletRemoved()) 00315 Q_PRIVATE_SLOT(d, void actionDestroyed(QObject*)) 00316 00317 ExtenderItemPrivate * const d; 00318 00319 friend class Applet; 00320 friend class Extender; 00321 friend class ExtenderPrivate; 00322 friend class ExtenderItemPrivate; 00323 }; 00324 } // namespace Plasma 00325 #endif // PLASMA_EXTENDERITEM_H
KDE 4.6 API Reference