die, setSize, die, and all the problems you represent. silly duplicated, not-like-qwidget API anyways. ;)

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=773505
This commit is contained in:
Aaron J. Seigo 2008-02-11 08:24:09 +00:00
parent e83f329de0
commit a438b53373
5 changed files with 7 additions and 53 deletions

View File

@ -1352,52 +1352,28 @@ QVariant Applet::itemChange(GraphicsItemChange change, const QVariant &value)
return Widget::itemChange(change, value);
}
void Applet::setSize(int width, int height)
{
setSize(QSizeF(width, height));
}
void Applet::setSize(const QSizeF &size)
{
setGeometry(QRectF(pos(), size));
}
void Applet::setGeometry(const QRectF& geometry)
{
Plasma::Constraints updatedConstraints(0);
QSizeF s = size();
QPointF p = pos();
if (geometry.size().width() > 0 && geometry.size().height() > 0 && size() != geometry.size()) {
prepareGeometryChange();
qreal width = qBound(minimumSize().width(), geometry.size().width(), maximumSize().width());
qreal height = qBound(minimumSize().height(), geometry.size().height(), maximumSize().height());
// it is important we call Widget::setSize(QSizeF) here to avoid recursing back to this
// method, creating an infinite loop
Widget::setSize(QSizeF(width, height));
if (layout()) {
layout()->setGeometry(QRectF(QPoint(0, 0), contentSize()));
}
if (managingLayout()) {
managingLayout()->invalidate();
}
Widget::setGeometry(geometry);
if (s != size()) {
if (d->background) {
d->background->resize(size());
}
updatedConstraints |= Plasma::SizeConstraint;
}
if (geometry.topLeft() != pos()) {
setPos(geometry.topLeft());
if (p != pos()) {
updatedConstraints |= Plasma::LocationConstraint;
}
if (updatedConstraints) {
updateConstraints(updatedConstraints);
emit geometryChanged();
update();
}
}

View File

@ -729,16 +729,6 @@ class PLASMA_EXPORT Applet : public Widget
*/
QVariant itemChange(GraphicsItemChange change, const QVariant &value);
/**
* Reimplemented from QGraphicsItem
*/
void setSize(int width, int height);
/**
* Reimplemented from QGraphicsItem
*/
void setSize(const QSizeF& size);
protected Q_SLOTS:
/**
* @internal used to show the configuration of an applet on first show

View File

@ -70,7 +70,7 @@ Flash::Flash(QGraphicsItem *parent)
d->color = Qt::black;
d->animId = 0;
d->state = Private::Invisible;
setSize(QSizeF(40, 100));
resize(QSizeF(40, 100));
setCachePaintMode( NoCacheMode );
}

View File

@ -273,16 +273,6 @@ void Widget::setGeometry(const QRectF& geometry)
update();
}
void Widget::setSize(qreal width, qreal height)
{
setSize(QSizeF(width, height));
}
void Widget::setSize(const QSizeF& size)
{
d->size = size;
}
void Widget::updateGeometry()
{
if (managingLayout()) {

View File

@ -307,8 +307,6 @@ protected:
virtual void paintWidget(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
QVariant itemChange(GraphicsItemChange change, const QVariant &value);
void setSize(qreal width, qreal height);
virtual void setSize(const QSizeF& size);
void managingLayoutChanged();
virtual bool sceneEvent(QEvent *event);