From 5f8c6be98841cda70c8e3bcae8db35403d2a843d Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Thu, 21 Jun 2007 18:07:39 +0000 Subject: [PATCH] make Applet (and lineedit) usable with qgraphics_item cast. we probably want to do this with all of our QGI subclasses. i introduced a new enum in the Plasma namespace, ItemType, so we can keep track of these id's centrally. however, the right click mechanism is rather broken in its implementation; we need a way to offer a centralized menu on appets no metter where they are clicked. svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=678562 --- applet.cpp | 1 + applet.h | 6 ++++++ plasma.h | 6 ++++++ widgets/lineedit.h | 9 ++++++++- 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/applet.cpp b/applet.cpp index b0fc5ff55..dffbfb1f2 100644 --- a/applet.cpp +++ b/applet.cpp @@ -30,6 +30,7 @@ #include "corona.h" #include "dataenginemanager.h" +#include "plasma.h" namespace Plasma { diff --git a/applet.h b/applet.h index 8d186e0a8..bd5bd0eee 100644 --- a/applet.h +++ b/applet.h @@ -181,6 +181,12 @@ class PLASMA_EXPORT Applet : public QObject, public QGraphicsItem **/ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); + /** + * Reimplented from QGraphicsItem + **/ + enum { Type = Plasma::AppletType }; + int type() const { return Type; } + Q_SIGNALS: /** * Emit this signal when your applet needs to take (or lose) keyboard diff --git a/plasma.h b/plasma.h index 1d9e9eeae..00d0d7326 100644 --- a/plasma.h +++ b/plasma.h @@ -19,6 +19,8 @@ #ifndef PLASMA_DEFS_H #define PLASMA_DEFS_H +#include + #include /** @@ -75,6 +77,10 @@ enum Location { Floating = 0 /**< Free floating. Neither geometry or z-ordering RightEdge /**< Along the right side of the screen */ }; +enum ItemTypes { AppletType = QGraphicsItem::UserType + 1, + LineEditType = QGraphicsItem::UserType + 2 + }; + PLASMA_EXPORT void setMinId(int minId); PLASMA_EXPORT int uniqueId(); PLASMA_EXPORT Direction locationToDirection(Location location); diff --git a/widgets/lineedit.h b/widgets/lineedit.h index 425a23f09..f39905a42 100644 --- a/widgets/lineedit.h +++ b/widgets/lineedit.h @@ -25,6 +25,7 @@ #include #include +#include #include namespace Plasma @@ -57,11 +58,17 @@ class PLASMA_EXPORT LineEdit : public QGraphicsTextItem, public LayoutItem QRectF geometry() const; void setGeometry(const QRectF& geometry); QSizeF sizeHint() const; - + void setDefaultText(QString text); const QString toHtml(); const QString toPlainText(); + /** + * Reimplented from QGraphicsItem + **/ + enum { Type = Plasma::LineEditType }; + int type() const { return Type; } + Q_SIGNALS: void editingFinished(); void textChanged(const QString &text);