Plasma
extender.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_EXTENDER_H 00021 #define PLASMA_EXTENDER_H 00022 00023 #include <QtGui/QGraphicsWidget> 00024 00025 #include "plasma/framesvg.h" 00026 #include "plasma/plasma_export.h" 00027 00028 namespace Plasma 00029 { 00030 00031 class ExtenderGroup; 00032 class ExtenderPrivate; 00033 class ExtenderItem; 00034 class Applet; 00035 00065 class PLASMA_EXPORT Extender : public QGraphicsWidget 00066 { 00067 Q_OBJECT 00068 Q_PROPERTY(QString emptyExtenderMessage READ emptyExtenderMessage WRITE setEmptyExtenderMessage) 00069 Q_PROPERTY(QList<ExtenderItem*> items READ items()) 00070 Q_PROPERTY(QList<ExtenderItem*> attachedItems READ attachedItems()) 00071 Q_PROPERTY(QList<ExtenderItem*> detachedItems READ detachedItems()) 00072 Q_PROPERTY(QList<ExtenderGroup*> groups READ groups()) 00073 Q_PROPERTY(bool empty READ isEmpty()) 00074 00075 public: 00079 enum Appearance { 00080 NoBorders = 0, 00083 BottomUpStacked = 1, 00089 TopDownStacked = 2 00095 }; 00096 00107 explicit Extender(Applet *applet); 00108 00109 ~Extender(); 00110 00114 void setEmptyExtenderMessage(const QString &message); 00115 00119 QString emptyExtenderMessage() const; 00120 00125 QList<ExtenderItem*> items() const; 00126 00130 QList<ExtenderItem*> attachedItems() const; 00131 00135 QList<ExtenderItem*> detachedItems() const; 00136 00144 Q_INVOKABLE ExtenderItem *item(const QString &name) const; 00145 00152 Q_INVOKABLE ExtenderGroup *group(const QString &name) const; 00153 00162 Q_INVOKABLE bool hasItem(const QString &name) const; 00163 00168 bool isEmpty() const; 00169 00176 void setAppearance(Appearance appearance); 00177 00181 Appearance appearance() const; 00182 00187 QList<ExtenderGroup*> groups() const; 00188 00193 Applet *applet() const; 00194 00195 protected: 00204 virtual void itemAddedEvent(ExtenderItem *item, const QPointF &pos = QPointF(-1, -1)); 00205 00211 virtual void itemRemovedEvent(ExtenderItem *item); 00212 00217 virtual void itemHoverEnterEvent(ExtenderItem *item); 00218 00228 virtual void itemHoverMoveEvent(ExtenderItem *item, const QPointF &pos); 00229 00234 virtual void itemHoverLeaveEvent(ExtenderItem *item); 00235 00242 virtual void saveState(); 00243 00250 virtual FrameSvg::EnabledBorders enabledBordersForItem(ExtenderItem *item) const; 00251 00255 QVariant itemChange(GraphicsItemChange change, const QVariant &value); 00256 00260 void resizeEvent(QGraphicsSceneResizeEvent *event); 00261 00265 void mousePressEvent(QGraphicsSceneMouseEvent *event); 00266 00270 void dragEnterEvent(QGraphicsSceneDragDropEvent *event); 00271 00275 void dragMoveEvent(QGraphicsSceneDragDropEvent *event); 00276 00280 void dragLeaveEvent(QGraphicsSceneDragDropEvent *event); 00281 00285 void dropEvent(QGraphicsSceneDragDropEvent *event); 00286 00287 Q_SIGNALS: 00291 void itemAttached(Plasma::ExtenderItem *); 00292 00296 void itemDetached(Plasma::ExtenderItem *); 00297 00301 void geometryChanged(); 00302 00303 private: 00304 ExtenderPrivate *const d; 00305 00306 Q_PRIVATE_SLOT(d, void delayItemAddedEvent()) 00307 Q_PRIVATE_SLOT(d, void extenderItemDestroyed(Plasma::ExtenderItem *item)) 00308 Q_PRIVATE_SLOT(d, void viewportGeometryChanged(const QRectF &)) 00309 00310 friend class ExtenderPrivate; 00311 friend class ExtenderGroup; 00312 friend class ExtenderGroupPrivate; 00313 friend class ExtenderItem; 00314 friend class ExtenderItemPrivate; 00315 //dialog needs access to the extender's applet location. 00316 friend class DialogPrivate; 00317 //applet should be able to call saveState(); 00318 friend class Applet; 00319 00320 }; 00321 } // Plasma namespace 00322 00323 #endif //PLASMA_EXTENDER_H 00324
KDE 4.6 API Reference