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
This commit is contained in:
Aaron J. Seigo 2007-06-21 18:07:39 +00:00
parent c37fabf01c
commit 5f8c6be988
4 changed files with 21 additions and 1 deletions

View File

@ -30,6 +30,7 @@
#include "corona.h" #include "corona.h"
#include "dataenginemanager.h" #include "dataenginemanager.h"
#include "plasma.h"
namespace Plasma namespace Plasma
{ {

View File

@ -181,6 +181,12 @@ class PLASMA_EXPORT Applet : public QObject, public QGraphicsItem
**/ **/
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
/**
* Reimplented from QGraphicsItem
**/
enum { Type = Plasma::AppletType };
int type() const { return Type; }
Q_SIGNALS: Q_SIGNALS:
/** /**
* Emit this signal when your applet needs to take (or lose) keyboard * Emit this signal when your applet needs to take (or lose) keyboard

View File

@ -19,6 +19,8 @@
#ifndef PLASMA_DEFS_H #ifndef PLASMA_DEFS_H
#define PLASMA_DEFS_H #define PLASMA_DEFS_H
#include <QGraphicsItem>
#include <plasma/plasma_export.h> #include <plasma/plasma_export.h>
/** /**
@ -75,6 +77,10 @@ enum Location { Floating = 0 /**< Free floating. Neither geometry or z-ordering
RightEdge /**< Along the right side of the screen */ 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 void setMinId(int minId);
PLASMA_EXPORT int uniqueId(); PLASMA_EXPORT int uniqueId();
PLASMA_EXPORT Direction locationToDirection(Location location); PLASMA_EXPORT Direction locationToDirection(Location location);

View File

@ -25,6 +25,7 @@
#include <plasma/plasma_export.h> #include <plasma/plasma_export.h>
#include <plasma/dataengine.h> #include <plasma/dataengine.h>
#include <plasma/plasma.h>
#include <plasma/widgets/layoutitem.h> #include <plasma/widgets/layoutitem.h>
namespace Plasma namespace Plasma
@ -62,6 +63,12 @@ class PLASMA_EXPORT LineEdit : public QGraphicsTextItem, public LayoutItem
const QString toHtml(); const QString toHtml();
const QString toPlainText(); const QString toPlainText();
/**
* Reimplented from QGraphicsItem
**/
enum { Type = Plasma::LineEditType };
int type() const { return Type; }
Q_SIGNALS: Q_SIGNALS:
void editingFinished(); void editingFinished();
void textChanged(const QString &text); void textChanged(const QString &text);