put naturalSize property back in: turns out was necessary to make things clean

svn path=/trunk/KDE/kdebase/runtime/; revision=1204364
This commit is contained in:
Marco Martin 2010-12-06 21:54:58 +00:00
parent 8a92c6b5f3
commit 4ff23c21ea
2 changed files with 22 additions and 1 deletions

View File

@ -31,7 +31,6 @@ SvgItem::SvgItem(QDeclarativeItem *parent)
: QDeclarativeItem(parent)
{
setFlag(QGraphicsItem::ItemHasNoContents, false);
}
@ -42,6 +41,7 @@ SvgItem::~SvgItem()
void SvgItem::setElementId(const QString &elementID)
{
m_elementID = elementID;
emit naturalSizeChanged();
update();
}
@ -50,6 +50,18 @@ QString SvgItem::elementId() const
return m_elementID;
}
QSizeF SvgItem::naturalSize() const
{
if (!m_svg) {
return QSizeF();
} else if (!m_elementID.isEmpty()) {
return m_svg.data()->elementSize(m_elementID);
}
return m_svg.data()->size();
}
void SvgItem::setSvg(Plasma::Svg *svg)
{
if (m_svg) {
@ -57,6 +69,9 @@ void SvgItem::setSvg(Plasma::Svg *svg)
}
m_svg = svg;
connect(svg, SIGNAL(repaintNeeded()), this, SLOT(update()));
connect(svg, SIGNAL(repaintNeeded()), this, SIGNAL(naturalSizeChanged()));
connect(svg, SIGNAL(sizeChanged()), this, SIGNAL(naturalSizeChanged()));
emit naturalSizeChanged();
}
Plasma::Svg *SvgItem::svg() const

View File

@ -31,6 +31,7 @@ class SvgItem : public QDeclarativeItem
Q_PROPERTY(QString elementId READ elementId WRITE setElementId)
Q_PROPERTY(Plasma::Svg * svg READ svg WRITE setSvg)
Q_PROPERTY(QSizeF naturalSize READ naturalSize NOTIFY naturalSizeChanged)
public:
SvgItem(QDeclarativeItem *parent=0);
@ -42,8 +43,13 @@ public:
void setSvg(Plasma::Svg *svg);
Plasma::Svg *svg() const;
QSizeF naturalSize() const;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
Q_SIGNALS:
void naturalSizeChanged();
private:
QWeakPointer<Plasma::Svg> m_svg;
QString m_elementID;