IMPROVEMENT: automatically repaint when the svg changes beneath it
svn path=/trunk/KDE/kdelibs/; revision=1167531
This commit is contained in:
parent
70fd5a6ae4
commit
cc942a894c
@ -27,27 +27,34 @@
|
|||||||
|
|
||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
|
|
||||||
class SvgWidgetPrivate
|
class SvgWidgetPrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SvgWidgetPrivate(Svg *s, const QString &element)
|
SvgWidgetPrivate(SvgWidget *widget, Svg *s, const QString &element)
|
||||||
: svg(s), elementID(element)
|
: q(widget), svg(s), elementID(element)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Svg *svg;
|
void svgChanged()
|
||||||
QString elementID;
|
{
|
||||||
|
q->update();
|
||||||
|
}
|
||||||
|
|
||||||
|
SvgWidget *q;
|
||||||
|
Svg *svg;
|
||||||
|
QString elementID;
|
||||||
};
|
};
|
||||||
|
|
||||||
SvgWidget::SvgWidget(QGraphicsItem *parent, Qt::WindowFlags wFlags)
|
SvgWidget::SvgWidget(QGraphicsItem *parent, Qt::WindowFlags wFlags)
|
||||||
: QGraphicsWidget(parent, wFlags),
|
: QGraphicsWidget(parent, wFlags),
|
||||||
d(new SvgWidgetPrivate(0, QString()))
|
d(new SvgWidgetPrivate(this, 0, QString()))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
SvgWidget::SvgWidget(Svg *svg, const QString &elementID, QGraphicsItem *parent, Qt::WindowFlags wFlags)
|
SvgWidget::SvgWidget(Svg *svg, const QString &elementID, QGraphicsItem *parent, Qt::WindowFlags wFlags)
|
||||||
: QGraphicsWidget(parent, wFlags),
|
: QGraphicsWidget(parent, wFlags),
|
||||||
d(new SvgWidgetPrivate(svg, elementID))
|
d(new SvgWidgetPrivate(this, svg, elementID))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +83,15 @@ void SvgWidget::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
|
|
||||||
void SvgWidget::setSvg(Svg *svg)
|
void SvgWidget::setSvg(Svg *svg)
|
||||||
{
|
{
|
||||||
|
if (d->svg) {
|
||||||
|
disconnect(d->svg);
|
||||||
|
}
|
||||||
|
|
||||||
d->svg = svg;
|
d->svg = svg;
|
||||||
|
|
||||||
|
if (svg) {
|
||||||
|
connect(svg, SIGNAL(repaintNeeded()), this, SLOT(svgChanged()));
|
||||||
|
}
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,6 +66,8 @@ class PLASMA_EXPORT SvgWidget : public QGraphicsWidget
|
|||||||
void mousePressEvent(QGraphicsSceneMouseEvent * event);
|
void mousePressEvent(QGraphicsSceneMouseEvent * event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Q_PRIVATE_SLOT(d, void svgChanged())
|
||||||
|
|
||||||
SvgWidgetPrivate * const d;
|
SvgWidgetPrivate * const d;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user