Changeset View
Changeset View
Standalone View
Standalone View
lib/documentview/svgviewadapter.cpp
Show First 20 Lines • Show All 41 Lines • ▼ Show 20 Line(s) | |||||
42 | { | 42 | { | ||
43 | 43 | | |||
44 | /// SvgImageView //// | 44 | /// SvgImageView //// | ||
45 | SvgImageView::SvgImageView(QGraphicsItem* parent) | 45 | SvgImageView::SvgImageView(QGraphicsItem* parent) | ||
46 | : AbstractImageView(parent) | 46 | : AbstractImageView(parent) | ||
47 | , mSvgItem(new QGraphicsSvgItem(this)) | 47 | , mSvgItem(new QGraphicsSvgItem(this)) | ||
48 | , mAlphaBackgroundMode(AbstractImageView::AlphaBackgroundCheckBoard) | 48 | , mAlphaBackgroundMode(AbstractImageView::AlphaBackgroundCheckBoard) | ||
49 | , mAlphaBackgroundColor(Qt::black) | 49 | , mAlphaBackgroundColor(Qt::black) | ||
50 | , mDocumentFullyLoaded(false) | ||||
50 | { | 51 | { | ||
51 | // So we aren't unnecessarily drawing the background for every paint() | 52 | // So we aren't unnecessarily drawing the background for every paint() | ||
52 | setCacheMode(QGraphicsItem::DeviceCoordinateCache); | 53 | setCacheMode(QGraphicsItem::DeviceCoordinateCache); | ||
53 | } | 54 | } | ||
54 | 55 | | |||
55 | void SvgImageView::loadFromDocument() | 56 | void SvgImageView::loadFromDocument() | ||
56 | { | 57 | { | ||
57 | Document::Ptr doc = document(); | 58 | Document::Ptr doc = document(); | ||
Show All 16 Lines | 74 | if (zoomToFit()) { | |||
74 | setZoom(computeZoomToFit(), QPointF(-1, -1), ForceUpdate); | 75 | setZoom(computeZoomToFit(), QPointF(-1, -1), ForceUpdate); | ||
75 | } else if (zoomToFill()) { | 76 | } else if (zoomToFill()) { | ||
76 | setZoom(computeZoomToFill(), QPointF(-1, -1), ForceUpdate); | 77 | setZoom(computeZoomToFill(), QPointF(-1, -1), ForceUpdate); | ||
77 | } else { | 78 | } else { | ||
78 | mSvgItem->setScale(zoom()); | 79 | mSvgItem->setScale(zoom()); | ||
79 | } | 80 | } | ||
80 | applyPendingScrollPos(); | 81 | applyPendingScrollPos(); | ||
81 | completed(); | 82 | completed(); | ||
83 | mDocumentFullyLoaded = true; | ||||
82 | } | 84 | } | ||
83 | 85 | | |||
84 | void SvgImageView::onZoomChanged() | 86 | void SvgImageView::onZoomChanged() | ||
85 | { | 87 | { | ||
86 | mSvgItem->setScale(zoom()); | 88 | mSvgItem->setScale(zoom()); | ||
87 | adjustItemPos(); | 89 | adjustItemPos(); | ||
88 | update(); | 90 | update(); | ||
89 | } | 91 | } | ||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Line(s) | 133 | case AbstractImageView::AlphaBackgroundSolid: | |||
133 | break; | 135 | break; | ||
134 | default: | 136 | default: | ||
135 | Q_ASSERT(0); | 137 | Q_ASSERT(0); | ||
136 | } | 138 | } | ||
137 | } | 139 | } | ||
138 | 140 | | |||
139 | void SvgImageView::paint(QPainter* painter, const QStyleOptionGraphicsItem* /*option*/, QWidget* /*widget*/) | 141 | void SvgImageView::paint(QPainter* painter, const QStyleOptionGraphicsItem* /*option*/, QWidget* /*widget*/) | ||
140 | { | 142 | { | ||
143 | if (mDocumentFullyLoaded) { | ||||
141 | drawAlphaBackground(painter); | 144 | drawAlphaBackground(painter); | ||
142 | } | 145 | } | ||
146 | } | ||||
143 | 147 | | |||
144 | //// SvgViewAdapter //// | 148 | //// SvgViewAdapter //// | ||
145 | struct SvgViewAdapterPrivate | 149 | struct SvgViewAdapterPrivate | ||
146 | { | 150 | { | ||
147 | SvgImageView* mView; | 151 | SvgImageView* mView; | ||
148 | }; | 152 | }; | ||
149 | 153 | | |||
150 | SvgViewAdapter::SvgViewAdapter() | 154 | SvgViewAdapter::SvgViewAdapter() | ||
▲ Show 20 Lines • Show All 104 Lines • Show Last 20 Lines |