1 | // Copyright (C) 2020 The Qt Company Ltd. |
---|---|
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | #ifndef QGRAPHICSSVGITEM_H |
4 | #define QGRAPHICSSVGITEM_H |
5 | |
6 | #include <QtSvgWidgets/qtsvgwidgetsglobal.h> |
7 | |
8 | #if !defined(QT_NO_GRAPHICSVIEW) |
9 | |
10 | #include <QtWidgets/qgraphicsitem.h> |
11 | |
12 | QT_BEGIN_NAMESPACE |
13 | |
14 | |
15 | class QSvgRenderer; |
16 | class QGraphicsSvgItemPrivate; |
17 | |
18 | class Q_SVGWIDGETS_EXPORT QGraphicsSvgItem : public QGraphicsObject |
19 | { |
20 | Q_OBJECT |
21 | Q_INTERFACES(QGraphicsItem) |
22 | Q_PROPERTY(QString elementId READ elementId WRITE setElementId) |
23 | Q_PROPERTY(QSize maximumCacheSize READ maximumCacheSize WRITE setMaximumCacheSize) |
24 | |
25 | public: |
26 | QGraphicsSvgItem(QGraphicsItem *parentItem = nullptr); |
27 | QGraphicsSvgItem(const QString &fileName, QGraphicsItem *parentItem = nullptr); |
28 | |
29 | void setSharedRenderer(QSvgRenderer *renderer); |
30 | QSvgRenderer *renderer() const; |
31 | |
32 | void setElementId(const QString &id); |
33 | QString elementId() const; |
34 | |
35 | void setCachingEnabled(bool); |
36 | bool isCachingEnabled() const; |
37 | |
38 | void setMaximumCacheSize(const QSize &size); |
39 | QSize maximumCacheSize() const; |
40 | |
41 | QRectF boundingRect() const override; |
42 | |
43 | void paint(QPainter *painter, |
44 | const QStyleOptionGraphicsItem *option, |
45 | QWidget *widget = nullptr) override; |
46 | |
47 | enum { Type = 13 }; |
48 | int type() const override; |
49 | |
50 | private: |
51 | Q_DISABLE_COPY(QGraphicsSvgItem) |
52 | Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QGraphicsSvgItem) |
53 | |
54 | Q_PRIVATE_SLOT(d_func(), void _q_repaintItem()) |
55 | }; |
56 | |
57 | QT_END_NAMESPACE |
58 | |
59 | #endif // QT_NO_GRAPHICSVIEW |
60 | |
61 | #endif // QGRAPHICSSVGITEM_H |
62 |