Changeset View
Changeset View
Standalone View
Standalone View
src/items/image/KReportItemImage.cpp
Show All 31 Lines | |||||
32 | 32 | | |||
33 | KReportItemImage::KReportItemImage(const QDomNode & element) | 33 | KReportItemImage::KReportItemImage(const QDomNode & element) | ||
34 | { | 34 | { | ||
35 | createProperties(); | 35 | createProperties(); | ||
36 | QDomNodeList nl = element.childNodes(); | 36 | QDomNodeList nl = element.childNodes(); | ||
37 | QString n; | 37 | QString n; | ||
38 | QDomNode node; | 38 | QDomNode node; | ||
39 | 39 | | |||
40 | m_name->setValue(element.toElement().attribute(QLatin1String("report:name"))); | 40 | nameProperty()->setValue(element.toElement().attribute(QLatin1String("report:name"))); | ||
41 | m_controlSource->setValue(element.toElement().attribute(QLatin1String("report:item-data-source"))); | 41 | m_controlSource->setValue(element.toElement().attribute(QLatin1String("report:item-data-source"))); | ||
42 | m_resizeMode->setValue(element.toElement().attribute(QLatin1String("report:resize-mode"), QLatin1String("stretch"))); | 42 | m_resizeMode->setValue(element.toElement().attribute(QLatin1String("report:resize-mode"), QLatin1String("stretch"))); | ||
43 | Z = element.toElement().attribute(QLatin1String("report:z-index")).toDouble(); | 43 | setZ(element.toElement().attribute(QLatin1String("report:z-index")).toDouble()); | ||
44 | 44 | | |||
45 | parseReportRect(element.toElement(), &m_pos, &m_size); | 45 | parseReportRect(element.toElement()); | ||
46 | 46 | | |||
47 | for (int i = 0; i < nl.count(); i++) { | 47 | for (int i = 0; i < nl.count(); i++) { | ||
48 | node = nl.item(i); | 48 | node = nl.item(i); | ||
49 | n = node.nodeName(); | 49 | n = node.nodeName(); | ||
50 | 50 | | |||
51 | if (n == QLatin1String("report:inline-image-data")) { | 51 | if (n == QLatin1String("report:inline-image-data")) { | ||
52 | 52 | | |||
53 | setInlineImageData(node.firstChild().nodeValue().toLatin1()); | 53 | setInlineImageData(node.firstChild().nodeValue().toLatin1()); | ||
54 | } else { | 54 | } else { | ||
55 | kreportpluginWarning() << "while parsing image element encountered unknow element: " << n; | 55 | kreportpluginWarning() << "while parsing image element encountered unknow element: " << n; | ||
56 | } | 56 | } | ||
57 | } | 57 | } | ||
58 | 58 | | |||
59 | } | 59 | } | ||
60 | 60 | | |||
61 | KReportItemImage::~KReportItemImage() | 61 | KReportItemImage::~KReportItemImage() | ||
62 | { | 62 | { | ||
63 | delete m_set; | | |||
64 | } | 63 | } | ||
65 | 64 | | |||
66 | bool KReportItemImage::isInline() const | 65 | bool KReportItemImage::isInline() const | ||
67 | { | 66 | { | ||
68 | return !(inlineImageData().isEmpty()); | 67 | return !(inlineImageData().isEmpty()); | ||
69 | } | 68 | } | ||
70 | 69 | | |||
71 | QByteArray KReportItemImage::inlineImageData() const | 70 | QByteArray KReportItemImage::inlineImageData() const | ||
Show All 36 Lines | |||||
108 | { | 107 | { | ||
109 | if (mode() != m) { | 108 | if (mode() != m) { | ||
110 | m_resizeMode->setValue(m); | 109 | m_resizeMode->setValue(m); | ||
111 | } | 110 | } | ||
112 | } | 111 | } | ||
113 | 112 | | |||
114 | void KReportItemImage::createProperties() | 113 | void KReportItemImage::createProperties() | ||
115 | { | 114 | { | ||
116 | m_set = new KPropertySet; | | |||
117 | | ||||
118 | m_controlSource = new KProperty("item-data-source", QStringList(), QStringList(), QString(), tr("Data Source")); | 115 | m_controlSource = new KProperty("item-data-source", QStringList(), QStringList(), QString(), tr("Data Source")); | ||
119 | 116 | | |||
120 | QStringList keys, strings; | 117 | QStringList keys, strings; | ||
121 | keys << QLatin1String("clip") << QLatin1String("stretch"); | 118 | keys << QLatin1String("clip") << QLatin1String("stretch"); | ||
122 | strings << tr("Clip") << tr("Stretch"); | 119 | strings << tr("Clip") << tr("Stretch"); | ||
123 | m_resizeMode = new KProperty("resize-mode", keys, strings, QLatin1String("clip"), tr("Resize Mode")); | 120 | m_resizeMode = new KProperty("resize-mode", keys, strings, QLatin1String("clip"), tr("Resize Mode")); | ||
124 | 121 | | |||
125 | m_staticImage = new KProperty("static-image", QPixmap(), tr("Value"), tr("Value used if not bound to a field")); | 122 | m_staticImage = new KProperty("static-image", QPixmap(), tr("Value"), tr("Value used if not bound to a field")); | ||
126 | 123 | | |||
127 | addDefaultProperties(); | 124 | propertySet()->addProperty(m_controlSource); | ||
128 | m_set->addProperty(m_controlSource); | 125 | propertySet()->addProperty(m_resizeMode); | ||
129 | m_set->addProperty(m_resizeMode); | 126 | propertySet()->addProperty(m_staticImage); | ||
130 | m_set->addProperty(m_staticImage); | | |||
131 | } | 127 | } | ||
132 | 128 | | |||
133 | 129 | | |||
134 | void KReportItemImage::setColumn(const QString &c) | 130 | void KReportItemImage::setColumn(const QString &c) | ||
135 | { | 131 | { | ||
136 | m_controlSource->setValue(c); | 132 | m_controlSource->setValue(c); | ||
137 | } | 133 | } | ||
138 | 134 | | |||
Show All 26 Lines | 147 | { | |||
165 | OROImage * id = new OROImage(); | 161 | OROImage * id = new OROImage(); | ||
166 | id->setImage(img); | 162 | id->setImage(img); | ||
167 | if (mode().toLower() == QLatin1String("stretch")) { | 163 | if (mode().toLower() == QLatin1String("stretch")) { | ||
168 | id->setScaled(true); | 164 | id->setScaled(true); | ||
169 | id->setAspectRatioMode(Qt::KeepAspectRatio); | 165 | id->setAspectRatioMode(Qt::KeepAspectRatio); | ||
170 | id->setTransformationMode(Qt::SmoothTransformation); | 166 | id->setTransformationMode(Qt::SmoothTransformation); | ||
171 | } | 167 | } | ||
172 | 168 | | |||
173 | id->setPosition(m_pos.toScene() + offset); | 169 | id->setPosition(scenePosition(position()) + offset); | ||
174 | id->setSize(m_size.toScene()); | 170 | id->setSize(sceneSize(size())); | ||
175 | if (page) { | 171 | if (page) { | ||
176 | page->addPrimitive(id); | 172 | page->addPrimitive(id); | ||
177 | } | 173 | } | ||
178 | 174 | | |||
179 | if (section) { | 175 | if (section) { | ||
180 | OROImage *i2 = dynamic_cast<OROImage*>(id->clone()); | 176 | OROImage *i2 = dynamic_cast<OROImage*>(id->clone()); | ||
181 | i2->setPosition(m_pos.toPoint()); | 177 | i2->setPosition(scenePosition(position())); | ||
182 | section->addPrimitive(i2); | 178 | section->addPrimitive(i2); | ||
183 | } | 179 | } | ||
184 | 180 | | |||
185 | if (!page) { | 181 | if (!page) { | ||
186 | delete id; | 182 | delete id; | ||
187 | } | 183 | } | ||
188 | 184 | | |||
189 | return 0; //Item doesn't stretch the section height | 185 | return 0; //Item doesn't stretch the section height | ||
190 | } | 186 | } | ||
191 | 187 | | |||
192 | 188 | |