Ammmaaziiing grace!!

Widget class is dead..

still in the repo for tooltip code

CCMAIL : aseigo@kde.org


svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=796973
This commit is contained in:
Alexis Ménard 2008-04-14 16:02:23 +00:00
parent fd37ae89b0
commit d5dd4e16ac
8 changed files with 21 additions and 92 deletions

View File

@ -59,7 +59,6 @@ set(plasma_LIB_SRCS
scripting/runnerscript.cpp
scripting/scriptengine.cpp
widgets/icon.cpp
widgets/widget.cpp
widgets/webcontent.cpp
)
@ -136,7 +135,6 @@ install(FILES
install(FILES
widgets/icon.h
widgets/webcontent.h
widgets/widget.h
DESTINATION ${INCLUDE_INSTALL_DIR}/plasma/widgets)
#For future

View File

@ -39,6 +39,7 @@
#include <QGraphicsSceneMouseEvent>
#include <QGraphicsLinearLayout>
#include <QDesktopWidget>
#include <QGraphicsView>
#include <QGraphicsProxyWidget>
#include <KIcon>
@ -68,23 +69,21 @@
#include "plasma/theme.h"
#include "plasma/view.h"
#include "plasma/widgets/widget.h"
//#define DYNAMIC_SHADOWS
namespace Plasma
{
class OverlayWidget : public Widget
class OverlayWidget : public QGraphicsWidget
{
public:
OverlayWidget(Widget *parent)
: Widget(parent, parent)
OverlayWidget(QGraphicsWidget *parent)
: QGraphicsWidget(parent)
{
resize(parent->size());
}
protected:
void paintWidget(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0)
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0)
{
Q_UNUSED(option)
Q_UNUSED(widget)
@ -92,7 +91,7 @@ protected:
painter->setRenderHint(QPainter::Antialiasing);
QColor wash = Plasma::Theme::self()->backgroundColor();
wash.setAlphaF(.6);
painter->fillPath(parent()->shape(), wash);
painter->fillPath(parentItem()->shape(), wash);
painter->restore();
}
};
@ -334,7 +333,7 @@ PackageStructure::Ptr Applet::Private::packageStructure(0);
Applet::Applet(QGraphicsItem *parent,
const QString& serviceID,
uint appletId)
: Widget(parent),
: QGraphicsWidget(parent),
d(new Private(KService::serviceByStorageId(serviceID), appletId))
{
// WARNING: do not access config() OR globalConfig() in this method!
@ -343,7 +342,7 @@ Applet::Applet(QGraphicsItem *parent,
}
Applet::Applet(QObject* parentObject, const QVariantList& args)
: Widget(0,parentObject),
: QGraphicsWidget(0),
d(new Private(KService::serviceByStorageId(args.count() > 0 ? args[0].toString() : QString()),
args.count() > 1 ? args[1].toInt() : 0))
{
@ -943,7 +942,7 @@ int Applet::type() const
QPainterPath Applet::shape() const
{
if (isContainment()) {
return Plasma::Widget::shape();
return QGraphicsWidget::shape();
}
return Plasma::roundedRectangle(boundingRect().adjusted(-2, -2, 2, 2), 10);
@ -1495,13 +1494,13 @@ QVariant Applet::itemChange(GraphicsItemChange change, const QVariant &value)
break;
};
return Widget::itemChange(change, value);
return QGraphicsWidget::itemChange(change, value);
}
void Applet::setGeometry(const QRectF& geometry)
{
QRectF beforeGeom = Widget::geometry();
Widget::setGeometry(geometry);
QRectF beforeGeom = QGraphicsWidget::geometry();
QGraphicsWidget::setGeometry(geometry);
if (geometry.size() != beforeGeom.size())
{
updateConstraints(Plasma::SizeConstraint);

View File

@ -24,6 +24,7 @@
#include <QtGui/QGraphicsItem>
#include <QtGui/QWidget>
#include <QtGui/QGraphicsWidget>
#include <KDE/KPluginInfo>
#include <KDE/KGenericFactory>
@ -31,9 +32,9 @@
#include <plasma/configxml.h>
#include <plasma/packagestructure.h>
#include <plasma/plasma.h>
#include <plasma/widgets/widget.h>
class KConfigDialog;
class QGraphicsView;
namespace Plasma
{
@ -58,10 +59,9 @@ class Package;
*
* See techbase.kde.org for tutorial on writing Applets using this class.
*/
class PLASMA_EXPORT Applet : public Widget
class PLASMA_EXPORT Applet : public QGraphicsWidget
{
Q_OBJECT
// Q_PROPERTY( QRectF maxSizeHint READ maxSizeHint )
Q_PROPERTY(bool hasConfigurationInterface READ hasConfigurationInterface WRITE setHasConfigurationInterface)
Q_PROPERTY(QString name READ name)
Q_PROPERTY(QString category READ category)
@ -69,7 +69,6 @@ class PLASMA_EXPORT Applet : public Widget
Q_PROPERTY(bool drawStandardBackground READ drawStandardBackground WRITE setDrawStandardBackground)
Q_PROPERTY(bool failedToLaunch READ failedToLaunch WRITE setFailedToLaunch)
Q_PROPERTY(bool needsConfiguring READ needsConfiguring WRITE setNeedsConfiguring)
Q_PROPERTY(QRectF boundingRect READ boundingRect)
Q_PROPERTY(QRectF geometry READ geometry WRITE setGeometry)
Q_PROPERTY(bool shouldConserveResources READ shouldConserveResources)
Q_PROPERTY(Qt::AspectRatioMode aspectRatioMode READ aspectRatioMode WRITE setAspectRatioMode)

View File

@ -651,14 +651,14 @@ void Containment::addApplet(Applet *applet, const QPointF &pos, bool delayInit)
applet->removeSceneEventFilter(currentContainment);
KConfigGroup oldConfig = applet->config();
currentContainment->d->applets.removeAll(applet);
addChild(applet);
applet->setParentItem(this);
// now move the old config to the new location
KConfigGroup c = config().group("Applets").group(QString::number(applet->id()));
oldConfig.reparent(&c);
applet->resetConfigurationObject();
} else {
addChild(applet);
applet->setParentItem(this);
}
d->applets << applet;

View File

@ -29,7 +29,7 @@
#include <KDebug>
#include "widgets/widget.h"
#include <plasma/applet.h>
namespace Plasma
{
@ -300,7 +300,7 @@ void PanelToolbox::toolMoved(QGraphicsItem *item)
{
//kDebug() << "geometry is now " << static_cast<Plasma::Widget*>(item)->geometry();
if (!showing() &&
QGraphicsItem::children().indexOf(static_cast<Plasma::Widget*>(item)) != -1) {
QGraphicsItem::children().indexOf(static_cast<Plasma::Applet*>(item)) != -1) {
item->hide();
}
}

View File

@ -30,8 +30,6 @@
#include <KDebug>
#include "widgets/widget.h"
namespace Plasma
{

View File

@ -86,11 +86,6 @@ Widget::Widget(QGraphicsItem *parent, QObject* parentObject)
{
setFlag(QGraphicsItem::ItemClipsToShape, true);
setFlag(QGraphicsItem::ItemClipsChildrenToShape, true);
Widget *w = dynamic_cast<Widget *>(parent);
if (w) {
w->addChild(this);
}
}
Widget::~Widget()
@ -103,49 +98,6 @@ Widget::~Widget()
delete d;
}
Widget *Widget::parent() const
{
return parent(this);
}
Widget *Widget::parent(const QGraphicsItem *item)
{
Q_ASSERT(item);
QGraphicsItem *parent = item->parentItem();
while (parent) {
Widget *parentWidget = dynamic_cast<Widget *>(parent);
if (parentWidget) {
return parentWidget;
}
parent = parent->parentItem();
}
return 0;
}
void Widget::addChild(Widget *w)
{
if (!w || QGraphicsItem::children().contains(w)) {
return;
}
w->setParentItem(this);
//kDebug() << "Added Child Widget" << (QObject*)w << "our geom is" << geometry();
QGraphicsLinearLayout * lay = dynamic_cast<QGraphicsLinearLayout *>(layout());
if (lay) {
lay->addItem(w);
}
updateGeometry();
//kDebug() << "after the item is added our geom is now" << geometry();
}
void Widget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
}
#ifdef TOOLTIPMANAGER
const ToolTipData* Widget::toolTip() const

View File

@ -77,23 +77,7 @@ public:
*/
virtual ~Widget();
/**
* @return this Plasma::Widget's parent, returns a null pointer if
* none exist.
*/
Q_INVOKABLE Widget *parent() const;
/**
* @return the Plasma::Widget parent for a given QGraphicsItem
*/
static Widget *parent(const QGraphicsItem *item);
/**
* Add another Plasma::Widget as a child of this one.
* @param widget the widget to reparent to this Plasma::Widget.
*/
Q_INVOKABLE void addChild(Widget *widget);
#ifdef TOOLTIPMANAGER
/**
* The Data from the tooltip
@ -124,8 +108,7 @@ protected:
virtual bool sceneEvent(QEvent *event);
#endif
private:
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
class Private;
Private *const d;
};