Changeset View
Changeset View
Standalone View
Standalone View
src/wrtembed/KReportDesignerSection.cpp
Show First 20 Lines • Show All 171 Lines • ▼ Show 20 Line(s) | 171 | if (changeSet) { | |||
---|---|---|---|---|---|
172 | slotSceneClicked(); // switches property set to this section | 172 | slotSceneClicked(); // switches property set to this section | ||
173 | } | 173 | } | ||
174 | 174 | | |||
175 | qreal h = d->scene->height() + delta; | 175 | qreal h = d->scene->height() + delta; | ||
176 | 176 | | |||
177 | if (h < 1) h = 1; | 177 | if (h < 1) h = 1; | ||
178 | 178 | | |||
179 | h = d->scene->gridPoint(QPointF(0, h)).y(); | 179 | h = d->scene->gridPoint(QPointF(0, h)).y(); | ||
180 | d->sectionData->m_height->setValue(INCH_TO_POINT(h/d->dpiY)); | 180 | d->sectionData->m_height->setValue(INCH_TO_POINT(h / d->dpiY), | ||
181 | delta == 0 ? KProperty::ValueOption::IgnoreOld | ||||
182 | : KProperty::ValueOption::None); | ||||
181 | d->sectionRuler->setRulerLength(h); | 183 | d->sectionRuler->setRulerLength(h); | ||
182 | 184 | | |||
183 | d->scene->setSceneRect(0, 0, d->scene->width(), h); | 185 | d->scene->setSceneRect(0, 0, d->scene->width(), h); | ||
184 | d->sceneView->resizeContents(QSize(d->scene->width(), h)); | 186 | d->sceneView->resizeContents(QSize(d->scene->width(), h)); | ||
185 | 187 | | |||
188 | if (delta != 0) { | ||||
186 | d->reportDesigner->setModified(true); | 189 | d->reportDesigner->setModified(true); | ||
187 | } | 190 | } | ||
191 | } | ||||
188 | 192 | | |||
189 | void KReportDesignerSection::buildXML(QDomDocument *doc, QDomElement *section) | 193 | void KReportDesignerSection::buildXML(QDomDocument *doc, QDomElement *section) | ||
190 | { | 194 | { | ||
191 | KReportUtils::setAttribute(section, QLatin1String("svg:height"), d->sectionData->m_height->value().toDouble()); | 195 | KReportUtils::setAttribute(section, QLatin1String("svg:height"), d->sectionData->m_height->value().toDouble()); | ||
192 | section->setAttribute(QLatin1String("fo:background-color"), d->sectionData->backgroundColor().name()); | 196 | section->setAttribute(QLatin1String("fo:background-color"), d->sectionData->backgroundColor().name()); | ||
193 | 197 | | |||
194 | // now get a list of all the QGraphicsItems on this scene and output them. | 198 | // now get a list of all the QGraphicsItems on this scene and output them. | ||
195 | QGraphicsItemList list = d->scene->items(); | 199 | QGraphicsItemList list = d->scene->items(); | ||
Show All 13 Lines | 207 | { | |||
209 | d->sectionData->m_height->setValue(h); | 213 | d->sectionData->m_height->setValue(h); | ||
210 | 214 | | |||
211 | h = POINT_TO_INCH(h) * d->dpiY; | 215 | h = POINT_TO_INCH(h) * d->dpiY; | ||
212 | //kreportDebug() << "Section Height: " << h; | 216 | //kreportDebug() << "Section Height: " << h; | ||
213 | d->scene->setSceneRect(0, 0, d->scene->width(), h); | 217 | d->scene->setSceneRect(0, 0, d->scene->width(), h); | ||
214 | slotResizeBarDragged(0); | 218 | slotResizeBarDragged(0); | ||
215 | 219 | | |||
216 | d->sectionData->m_backgroundColor->setValue(QColor(section.toElement().attribute(QLatin1String("fo:background-color"), QLatin1String("#ffffff")))); | 220 | d->sectionData->m_backgroundColor->setValue(QColor(section.toElement().attribute(QLatin1String("fo:background-color"), QLatin1String("#ffffff")))); | ||
221 | d->sectionData->propertySet()->clearModifiedFlags(); | ||||
217 | 222 | | |||
223 | KReportPluginManager* manager = KReportPluginManager::self(); | ||||
218 | for (int i = 0; i < nl.count(); ++i) { | 224 | for (int i = 0; i < nl.count(); ++i) { | ||
219 | node = nl.item(i); | 225 | node = nl.item(i); | ||
220 | n = node.nodeName(); | 226 | n = node.nodeName(); | ||
221 | if (n.startsWith(QLatin1String("report:"))) { | 227 | if (n.startsWith(QLatin1String("report:"))) { | ||
222 | //Load objects | 228 | //Load objects | ||
223 | //report:line is a special case as it is not a plugin | 229 | //report:line is a special case as it is not a plugin | ||
230 | QObject *obj = nullptr; | ||||
231 | KReportPluginInterface *plugin = nullptr; | ||||
224 | QString reportItemName = n.mid(qstrlen("report:")); | 232 | QString reportItemName = n.mid(qstrlen("report:")); | ||
225 | if (reportItemName == QLatin1String("line")) { | 233 | if (reportItemName == QLatin1String("line")) { | ||
226 | (new KReportDesignerItemLine(node, d->sceneView->designer(), d->scene))->setVisible(true); | 234 | obj = new KReportDesignerItemLine(node, d->sceneView->designer(), d->scene); | ||
227 | continue; | 235 | } else { | ||
228 | } | 236 | plugin = manager->plugin(reportItemName); | ||
229 | KReportPluginManager* manager = KReportPluginManager::self(); | | |||
230 | KReportPluginInterface *plugin = manager->plugin(reportItemName); | | |||
231 | if (plugin) { | 237 | if (plugin) { | ||
232 | QObject *obj = plugin->createDesignerInstance(node, d->reportDesigner, d->scene); | 238 | obj = plugin->createDesignerInstance(node, d->reportDesigner, d->scene); | ||
239 | } | ||||
240 | } | ||||
233 | if (obj) { | 241 | if (obj) { | ||
234 | KReportDesignerItemRectBase *entity = dynamic_cast<KReportDesignerItemRectBase*>(obj); | 242 | KReportDesignerItemRectBase *entity = dynamic_cast<KReportDesignerItemRectBase*>(obj); | ||
235 | if (entity) { | 243 | if (entity) { | ||
236 | entity->setVisible(true); | 244 | entity->setVisible(true); | ||
237 | } | 245 | } | ||
238 | KReportItemBase *item = dynamic_cast<KReportItemBase*>(obj); | 246 | KReportItemBase *item = dynamic_cast<KReportItemBase*>(obj); | ||
239 | if (item) { | 247 | if (item) { | ||
240 | item->setUnit(d->reportDesigner->pageUnit()); | 248 | item->setUnit(d->reportDesigner->pageUnit()); | ||
249 | if (plugin) { | ||||
241 | KReportDesigner::addMetaProperties(item->propertySet(), | 250 | KReportDesigner::addMetaProperties(item->propertySet(), | ||
242 | plugin->metaData()->name(), | 251 | plugin->metaData()->name(), | ||
243 | plugin->metaData()->iconName()); | 252 | plugin->metaData()->iconName()); | ||
244 | } | 253 | } | ||
245 | continue; | 254 | item->propertySet()->clearModifiedFlags(); | ||
246 | } | 255 | } | ||
247 | } | 256 | } | ||
248 | } | 257 | } | ||
249 | kreportWarning() << "Encountered unknown node while parsing section: " << n; | 258 | kreportWarning() << "Encountered unknown node while parsing section: " << n; | ||
250 | } | 259 | } | ||
251 | } | 260 | } | ||
252 | 261 | | |||
253 | QSize KReportDesignerSection::sizeHint() const | 262 | QSize KReportDesignerSection::sizeHint() const | ||
▲ Show 20 Lines • Show All 179 Lines • Show Last 20 Lines |