Changeset View
Changeset View
Standalone View
Standalone View
src/wrtembed/KReportDesigner.cpp
Show First 20 Lines • Show All 106 Lines • ▼ Show 20 Line(s) | 76 | public: | |||
---|---|---|---|---|---|
107 | QList<KReportDesignerItemBase*> copy_list; | 107 | QList<KReportDesignerItemBase*> copy_list; | ||
108 | QList<KReportDesignerItemBase*> cut_list; | 108 | QList<KReportDesignerItemBase*> cut_list; | ||
109 | }; | 109 | }; | ||
110 | 110 | | |||
111 | //! @internal | 111 | //! @internal | ||
112 | class Q_DECL_HIDDEN KReportDesigner::Private | 112 | class Q_DECL_HIDDEN KReportDesigner::Private | ||
113 | { | 113 | { | ||
114 | public: | 114 | public: | ||
115 | Private(){} | 115 | explicit Private(KReportDesigner *designer); | ||
116 | 116 | | |||
117 | ~Private() | 117 | ~Private() | ||
118 | { | 118 | { | ||
119 | delete dataSource; | 119 | delete dataSource; | ||
120 | } | 120 | } | ||
121 | 121 | | |||
122 | void init(const QDomElement *xml); | ||||
123 | | ||||
124 | #ifdef KREPORT_SCRIPTING | ||||
125 | void updateScripts(); | ||||
126 | #endif | ||||
127 | | ||||
128 | KReportDesigner * const q; | ||||
129 | | ||||
122 | QGridLayout *grid; | 130 | QGridLayout *grid; | ||
123 | KReportRuler *hruler; | 131 | KReportRuler *hruler; | ||
124 | KReportZoomHandler zoomHandler; | 132 | KReportZoomHandler zoomHandler; | ||
125 | QVBoxLayout *vboxlayout; | 133 | QVBoxLayout *vboxlayout; | ||
126 | KReportPropertiesButton *pageButton; | 134 | KReportPropertiesButton *pageButton; | ||
127 | 135 | | |||
128 | QGraphicsScene *activeScene = nullptr; | 136 | QGraphicsScene *activeScene = nullptr; | ||
129 | 137 | | |||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Line(s) | 173 | #endif | |||
183 | 191 | | |||
184 | QString originalInterpreter; //Value of the script interpreter at load time | 192 | QString originalInterpreter; //Value of the script interpreter at load time | ||
185 | QString originalScript; //Value of the script at load time | 193 | QString originalScript; //Value of the script at load time | ||
186 | 194 | | |||
187 | KReportDataSource *dataSource = nullptr; | 195 | KReportDataSource *dataSource = nullptr; | ||
188 | #ifdef KREPORT_SCRIPTING | 196 | #ifdef KREPORT_SCRIPTING | ||
189 | KReportScriptSource *scriptSource = nullptr; | 197 | KReportScriptSource *scriptSource = nullptr; | ||
190 | #endif | 198 | #endif | ||
199 | | ||||
200 | private: | ||||
201 | void loadXml(const QDomElement &data); | ||||
191 | }; | 202 | }; | ||
192 | 203 | | |||
193 | KReportDesigner::KReportDesigner(QWidget * parent) | 204 | KReportDesigner::Private::Private(KReportDesigner *designer) : q(designer) | ||
194 | : QWidget(parent), d(new Private()) | 205 | { | ||
206 | } | ||||
207 | | ||||
208 | // (must be init() instead of ctor because we are indirectly depending on initialized KReportDesigner::d here) | ||||
209 | void KReportDesigner::Private::init(const QDomElement *xml) | ||||
195 | { | 210 | { | ||
196 | KReportPluginManager::self(); // this loads icons early enough | 211 | KReportPluginManager::self(); // this loads icons early enough | ||
197 | 212 | | |||
198 | createProperties(); | 213 | q->createProperties(); | ||
199 | createActions(); | 214 | q->createActions(); | ||
200 | 215 | | |||
201 | d->grid = new QGridLayout(this); | 216 | grid = new QGridLayout(q); | ||
202 | d->grid->setSpacing(0); | 217 | grid->setSpacing(0); | ||
203 | d->grid->setMargin(0); | 218 | grid->setMargin(0); | ||
204 | d->grid->setColumnStretch(1, 1); | 219 | grid->setColumnStretch(1, 1); | ||
205 | d->grid->setRowStretch(1, 1); | 220 | grid->setRowStretch(1, 1); | ||
206 | d->grid->setSizeConstraint(QLayout::SetFixedSize); | 221 | grid->setSizeConstraint(QLayout::SetFixedSize); | ||
207 | 222 | | |||
208 | d->vboxlayout = new QVBoxLayout(); | 223 | vboxlayout = new QVBoxLayout(); | ||
209 | d->vboxlayout->setSpacing(0); | 224 | vboxlayout->setSpacing(0); | ||
210 | d->vboxlayout->setMargin(0); | 225 | vboxlayout->setMargin(0); | ||
211 | d->vboxlayout->setSizeConstraint(QLayout::SetFixedSize); | 226 | vboxlayout->setSizeConstraint(QLayout::SetFixedSize); | ||
212 | 227 | | |||
213 | //Create nice rulers | 228 | //Create nice rulers | ||
214 | d->hruler = new KReportRuler(this, Qt::Horizontal, d->zoomHandler); | 229 | hruler = new KReportRuler(nullptr, Qt::Horizontal, zoomHandler); | ||
215 | | ||||
216 | d->pageButton = new KReportPropertiesButton(this); | | |||
217 | 230 | | |||
218 | d->grid->addWidget(d->pageButton, 0, 0); | 231 | pageButton = new KReportPropertiesButton; | ||
219 | d->grid->addWidget(d->hruler, 0, 1); | | |||
220 | d->grid->addLayout(d->vboxlayout, 1, 0, 1, 2); | | |||
221 | 232 | | |||
222 | d->pageButton->setMaximumSize(QSize(19, 22)); | 233 | grid->addWidget(pageButton, 0, 0); | ||
223 | d->pageButton->setMinimumSize(QSize(19, 22)); | 234 | grid->addWidget(hruler, 0, 1); | ||
235 | grid->addLayout(vboxlayout, 1, 0, 1, 2); | ||||
224 | 236 | | |||
225 | d->detail = new KReportDesignerSectionDetail(this); | 237 | pageButton->setMaximumSize(QSize(19, 22)); | ||
226 | d->vboxlayout->insertWidget(0, d->detail); | 238 | pageButton->setMinimumSize(QSize(19, 22)); | ||
227 | 239 | | |||
228 | setLayout(d->grid); | 240 | if (!xml) { | ||
241 | detail = new KReportDesignerSectionDetail(q); | ||||
242 | vboxlayout->insertWidget(0, detail); | ||||
243 | } | ||||
229 | 244 | | |||
230 | connect(d->pageButton, SIGNAL(released()), this, SLOT(slotPageButton_Pressed())); | 245 | connect(pageButton, &KReportPropertiesButton::released, | ||
231 | emit pagePropertyChanged(d->set); | 246 | q, &KReportDesigner::slotPageButton_Pressed); | ||
247 | emit q->pagePropertyChanged(set); | ||||
232 | 248 | | |||
233 | connect(&d->set, SIGNAL(propertyChanged(KPropertySet&,KProperty&)), | 249 | connect(&set, &KPropertySet::propertyChanged, q, &KReportDesigner::slotPropertyChanged); | ||
234 | this, SLOT(slotPropertyChanged(KPropertySet&,KProperty&))); | | |||
235 | 250 | | |||
236 | changeSet(&d->set); | 251 | if (xml) { | ||
252 | loadXml(*xml); | ||||
237 | } | 253 | } | ||
238 | 254 | set.clearModifiedFlags(); | |||
239 | KReportDesigner::~KReportDesigner() | 255 | q->changeSet(&set); | ||
240 | { | | |||
241 | delete d; | | |||
242 | } | 256 | } | ||
243 | 257 | | |||
244 | KReportDesigner::KReportDesigner(QWidget *parent, const QDomElement &data) | 258 | void KReportDesigner::Private::loadXml(const QDomElement &data) | ||
245 | : KReportDesigner(parent) | | |||
246 | { | 259 | { | ||
247 | if (data.tagName() != QLatin1String("report:content")) { | 260 | if (data.tagName() != QLatin1String("report:content")) { | ||
248 | // arg we got an xml file but not one i know of | 261 | // arg we got an xml file but not one i know of | ||
249 | kreportWarning() << "root element was not <report:content>"; | 262 | kreportWarning() << "root element was not <report:content>"; | ||
250 | } | 263 | } | ||
251 | //kreportDebug() << data.text(); | 264 | //kreportDebug() << data.text(); | ||
252 | deleteDetail(); | | |||
253 | 265 | | |||
254 | QDomNodeList nlist = data.childNodes(); | 266 | QDomNodeList nlist = data.childNodes(); | ||
255 | QDomNode it; | 267 | QDomNode it; | ||
256 | 268 | | |||
257 | for (int i = 0; i < nlist.count(); ++i) { | 269 | for (int i = 0; i < nlist.count(); ++i) { | ||
258 | it = nlist.item(i); | 270 | it = nlist.item(i); | ||
259 | // at this level all the children we get should be Elements | 271 | // at this level all the children we get should be Elements | ||
260 | if (it.isElement()) { | 272 | if (it.isElement()) { | ||
261 | QString n = it.nodeName().toLower(); | 273 | QString n = it.nodeName().toLower(); | ||
262 | //kreportDebug() << n; | 274 | //kreportDebug() << n; | ||
263 | if (n == QLatin1String("report:title")) { | 275 | if (n == QLatin1String("report:title")) { | ||
264 | setReportTitle(it.firstChild().nodeValue()); | 276 | q->setReportTitle(it.firstChild().nodeValue()); | ||
265 | #ifdef KREPORT_SCRIPTING | 277 | #ifdef KREPORT_SCRIPTING | ||
266 | } else if (n == QLatin1String("report:script")) { | 278 | } else if (n == QLatin1String("report:script")) { | ||
267 | d->originalInterpreter = it.toElement().attribute(QLatin1String("report:script-interpreter"), QLatin1String("javascript")); | 279 | originalInterpreter = it.toElement().attribute(QLatin1String("report:script-interpreter"), QLatin1String("javascript")); | ||
268 | if (d->originalInterpreter.isEmpty()) { | 280 | if (originalInterpreter.isEmpty()) { | ||
269 | d->originalInterpreter = QLatin1String("javascript"); | 281 | originalInterpreter = QLatin1String("javascript"); | ||
270 | } | 282 | } | ||
271 | d->originalScript = it.firstChild().nodeValue(); | 283 | originalScript = it.firstChild().nodeValue(); | ||
272 | d->script->setValue(d->originalScript); | 284 | script->setValue(originalScript); | ||
273 | 285 | | |||
274 | if (d->originalInterpreter != QLatin1String("javascript") && d->originalInterpreter != QLatin1String("qtscript")) { | 286 | if (originalInterpreter != QLatin1String("javascript") && originalInterpreter != QLatin1String("qtscript")) { | ||
275 | QString msg = tr("This report contains scripts of type \"%1\". " | 287 | QString msg = tr("This report contains scripts of type \"%1\". " | ||
276 | "Only scripts written in JavaScript language are " | 288 | "Only scripts written in JavaScript language are " | ||
277 | "supported. To prevent losing the scripts, their type " | 289 | "supported. To prevent losing the scripts, their type " | ||
278 | "and content will not be changed unless you change these scripts." | 290 | "and content will not be changed unless you change these scripts." | ||
279 | ).arg(d->originalInterpreter); | 291 | ).arg(originalInterpreter); | ||
280 | QMessageBox::warning(this, tr("Unsupported Script Type"), msg); | 292 | QMessageBox::warning(q, tr("Unsupported Script Type"), msg); | ||
281 | } | 293 | } | ||
282 | #endif | 294 | #endif | ||
283 | } else if (n == QLatin1String("report:grid")) { | 295 | } else if (n == QLatin1String("report:grid")) { | ||
284 | d->showGrid->setValue(it.toElement().attribute(QLatin1String("report:grid-visible"), QString::number(1)).toInt() != 0); | 296 | showGrid->setValue(it.toElement().attribute(QLatin1String("report:grid-visible"), QString::number(1)).toInt() != 0); | ||
285 | d->gridSnap->setValue(it.toElement().attribute(QLatin1String("report:grid-snap"), QString::number(1)).toInt() != 0); | 297 | gridSnap->setValue(it.toElement().attribute(QLatin1String("report:grid-snap"), QString::number(1)).toInt() != 0); | ||
286 | d->gridDivisions->setValue(it.toElement().attribute(QLatin1String("report:grid-divisions"), QString::number(4)).toInt()); | 298 | gridDivisions->setValue(it.toElement().attribute(QLatin1String("report:grid-divisions"), QString::number(4)).toInt()); | ||
287 | d->unit->setValue(it.toElement().attribute(QLatin1String("report:page-unit"), QLatin1String("cm"))); | 299 | unit->setValue(it.toElement().attribute(QLatin1String("report:page-unit"), QLatin1String("cm"))); | ||
288 | } | 300 | } | ||
289 | 301 | | |||
290 | //! @todo Load page options | 302 | //! @todo Load page options | ||
291 | else if (n == QLatin1String("report:page-style")) { | 303 | else if (n == QLatin1String("report:page-style")) { | ||
292 | QString pagetype = it.firstChild().nodeValue(); | 304 | QString pagetype = it.firstChild().nodeValue(); | ||
293 | 305 | | |||
294 | if (pagetype == QLatin1String("predefined")) { | 306 | if (pagetype == QLatin1String("predefined")) { | ||
295 | d->pageSize->setValue(it.toElement().attribute(QLatin1String("report:page-size"), QLatin1String("A4"))); | 307 | pageSize->setValue(it.toElement().attribute(QLatin1String("report:page-size"), QLatin1String("A4"))); | ||
296 | } else if (pagetype == QLatin1String("custom")) { | 308 | } else if (pagetype == QLatin1String("custom")) { | ||
297 | d->pageSize->setValue(QLatin1String("Custom")); | 309 | pageSize->setValue(QLatin1String("Custom")); | ||
298 | d->customPageSize->setValue(QSizeF(KReportUnit::parseValue(it.toElement().attribute(QLatin1String("report:custom-page-width"), QLatin1String(""))), | 310 | customPageSize->setValue(QSizeF(KReportUnit::parseValue(it.toElement().attribute(QLatin1String("report:custom-page-width"), QLatin1String(""))), | ||
299 | KReportUnit::parseValue(it.toElement().attribute(QLatin1String("report:custom-page-height"), QLatin1String(""))))); | 311 | KReportUnit::parseValue(it.toElement().attribute(QLatin1String("report:custom-page-height"), QLatin1String(""))))); | ||
300 | } else if (pagetype == QLatin1String("label")) { | 312 | } else if (pagetype == QLatin1String("label")) { | ||
301 | //! @todo | 313 | //! @todo | ||
302 | } | 314 | } | ||
303 | 315 | | |||
304 | d->rightMargin->setValue(KReportUnit::parseValue(it.toElement().attribute(QLatin1String("fo:margin-right"), QLatin1String("1.0cm")))); | 316 | rightMargin->setValue(KReportUnit::parseValue(it.toElement().attribute(QLatin1String("fo:margin-right"), QLatin1String("1.0cm")))); | ||
305 | d->leftMargin->setValue(KReportUnit::parseValue(it.toElement().attribute(QLatin1String("fo:margin-left"), QLatin1String("1.0cm")))); | 317 | leftMargin->setValue(KReportUnit::parseValue(it.toElement().attribute(QLatin1String("fo:margin-left"), QLatin1String("1.0cm")))); | ||
306 | d->topMargin->setValue(KReportUnit::parseValue(it.toElement().attribute(QLatin1String("fo:margin-top"), QLatin1String("1.0cm")))); | 318 | topMargin->setValue(KReportUnit::parseValue(it.toElement().attribute(QLatin1String("fo:margin-top"), QLatin1String("1.0cm")))); | ||
307 | d->bottomMargin->setValue(KReportUnit::parseValue(it.toElement().attribute(QLatin1String("fo:margin-bottom"), QLatin1String("1.0cm")))); | 319 | bottomMargin->setValue(KReportUnit::parseValue(it.toElement().attribute(QLatin1String("fo:margin-bottom"), QLatin1String("1.0cm")))); | ||
308 | 320 | | |||
309 | d->orientation->setValue(it.toElement().attribute(QLatin1String("report:print-orientation"), QLatin1String("portrait"))); | 321 | orientation->setValue(it.toElement().attribute(QLatin1String("report:print-orientation"), QLatin1String("portrait"))); | ||
310 | 322 | | |||
311 | } else if (n == QLatin1String("report:body")) { | 323 | } else if (n == QLatin1String("report:body")) { | ||
312 | QDomNodeList sectionlist = it.childNodes(); | 324 | QDomNodeList sectionlist = it.childNodes(); | ||
313 | QDomNode sec; | 325 | QDomNode sec; | ||
314 | 326 | | |||
315 | for (int s = 0; s < sectionlist.count(); ++s) { | 327 | for (int s = 0; s < sectionlist.count(); ++s) { | ||
316 | sec = sectionlist.item(s); | 328 | sec = sectionlist.item(s); | ||
317 | if (sec.isElement()) { | 329 | if (sec.isElement()) { | ||
318 | QString sn = sec.nodeName().toLower(); | 330 | QString sn = sec.nodeName().toLower(); | ||
319 | //kreportDebug() << sn; | 331 | //kreportDebug() << sn; | ||
320 | if (sn == QLatin1String("report:section")) { | 332 | if (sn == QLatin1String("report:section")) { | ||
321 | QString sectiontype = sec.toElement().attribute(QLatin1String("report:section-type")); | 333 | QString sectiontype = sec.toElement().attribute(QLatin1String("report:section-type")); | ||
322 | if (section(KReportSectionData::sectionTypeFromString(sectiontype)) == nullptr) { | 334 | if (q->section(KReportSectionData::sectionTypeFromString(sectiontype)) == nullptr) { | ||
323 | insertSection(KReportSectionData::sectionTypeFromString(sectiontype)); | 335 | q->insertSection(KReportSectionData::sectionTypeFromString(sectiontype)); | ||
324 | section(KReportSectionData::sectionTypeFromString(sectiontype))->initFromXML(sec); | 336 | q->section(KReportSectionData::sectionTypeFromString(sectiontype))->initFromXML(sec); | ||
325 | } | 337 | } | ||
326 | } else if (sn == QLatin1String("report:detail")) { | 338 | } else if (sn == QLatin1String("report:detail")) { | ||
327 | KReportDesignerSectionDetail * rsd = new KReportDesignerSectionDetail(this); | 339 | KReportDesignerSectionDetail * rsd = new KReportDesignerSectionDetail(q); | ||
328 | rsd->initFromXML(&sec); | 340 | rsd->initFromXML(&sec); | ||
329 | setDetail(rsd); | 341 | q->setDetail(rsd); | ||
330 | } | 342 | } | ||
331 | } else { | 343 | } else { | ||
332 | kreportWarning() << "Encountered an unknown Element: " << n; | 344 | kreportWarning() << "Encountered an unknown Element: " << n; | ||
333 | } | 345 | } | ||
334 | } | 346 | } | ||
335 | } | 347 | } | ||
336 | } else { | 348 | } else { | ||
337 | kreportWarning() << "Encountered a child node of root that is not an Element"; | 349 | kreportWarning() << "Encountered a child node of root that is not an Element"; | ||
338 | } | 350 | } | ||
339 | } | 351 | } | ||
340 | this->slotPageButton_Pressed(); | 352 | updateScripts(); | ||
341 | emit reportDataChanged(); | 353 | emit q->reportDataChanged(); | ||
342 | slotPropertyChanged(d->set, *d->unit); // set unit for all items | 354 | q->slotPropertyChanged(set, *unit); // set unit for all items | ||
343 | setModified(false); | 355 | q->setModified(false); | ||
356 | } | ||||
357 | | ||||
358 | #ifdef KREPORT_SCRIPTING | ||||
359 | void KReportDesigner::Private::updateScripts() | ||||
360 | { | ||||
361 | if (scriptSource) { | ||||
362 | QStringList sl = scriptSource->scriptList(); | ||||
363 | sl.prepend(QString()); // prepend "none" | ||||
364 | script->setListData(sl, sl); | ||||
365 | } | ||||
366 | } | ||||
367 | #endif | ||||
368 | | ||||
369 | // ---- | ||||
370 | | ||||
371 | KReportDesigner::KReportDesigner(QWidget * parent) | ||||
372 | : QWidget(parent), d(new Private(this)) | ||||
373 | { | ||||
374 | d->init(nullptr); | ||||
375 | } | ||||
376 | | ||||
377 | KReportDesigner::KReportDesigner(QWidget *parent, const QDomElement &data) | ||||
378 | : QWidget(parent), d(new Private(this)) | ||||
379 | { | ||||
380 | d->init(&data); | ||||
381 | } | ||||
382 | | ||||
383 | KReportDesigner::~KReportDesigner() | ||||
384 | { | ||||
385 | delete d; | ||||
344 | } | 386 | } | ||
345 | 387 | | |||
346 | ///The saving code | 388 | ///The saving code | ||
347 | QDomElement KReportDesigner::document() const | 389 | QDomElement KReportDesigner::document() const | ||
348 | { | 390 | { | ||
349 | QDomDocument doc; | 391 | QDomDocument doc; | ||
350 | QString saveInterpreter; | 392 | QString saveInterpreter; | ||
351 | 393 | | |||
▲ Show 20 Lines • Show All 420 Lines • ▼ Show 20 Line(s) | 761 | { | |||
772 | d->set.addProperty(d->rightMargin); | 814 | d->set.addProperty(d->rightMargin); | ||
773 | d->set.addProperty(d->topMargin); | 815 | d->set.addProperty(d->topMargin); | ||
774 | d->set.addProperty(d->bottomMargin); | 816 | d->set.addProperty(d->bottomMargin); | ||
775 | 817 | | |||
776 | #ifdef KREPORT_SCRIPTING | 818 | #ifdef KREPORT_SCRIPTING | ||
777 | d->script = new KProperty("script", new KPropertyListData, QVariant(), tr("Object Script")); | 819 | d->script = new KProperty("script", new KPropertyListData, QVariant(), tr("Object Script")); | ||
778 | d->set.addProperty(d->script); | 820 | d->set.addProperty(d->script); | ||
779 | #endif | 821 | #endif | ||
780 | | ||||
781 | } | 822 | } | ||
782 | 823 | | |||
783 | /** | 824 | /** | ||
784 | @brief Handle property changes | 825 | @brief Handle property changes | ||
785 | */ | 826 | */ | ||
786 | void KReportDesigner::slotPropertyChanged(KPropertySet &s, KProperty &p) | 827 | void KReportDesigner::slotPropertyChanged(KPropertySet &s, KProperty &p) | ||
787 | { | 828 | { | ||
788 | setModified(true); | 829 | setModified(true); | ||
Show All 9 Lines | 832 | if (p.name() == "page-unit") { | |||
798 | d->set.property("margin-bottom").setOption("unit", newstr); | 839 | d->set.property("margin-bottom").setOption("unit", newstr); | ||
799 | d->set.property("custom-page-size").setOption("unit", newstr); | 840 | d->set.property("custom-page-size").setOption("unit", newstr); | ||
800 | } | 841 | } | ||
801 | } | 842 | } | ||
802 | 843 | | |||
803 | void KReportDesigner::slotPageButton_Pressed() | 844 | void KReportDesigner::slotPageButton_Pressed() | ||
804 | { | 845 | { | ||
805 | #ifdef KREPORT_SCRIPTING | 846 | #ifdef KREPORT_SCRIPTING | ||
806 | if (d->scriptSource) { | 847 | d->updateScripts(); | ||
807 | QStringList sl = d->scriptSource->scriptList(); | | |||
808 | sl.prepend(QString()); | | |||
809 | d->script->setListData(sl, sl); | | |||
810 | } | | |||
811 | changeSet(&d->set); | 848 | changeSet(&d->set); | ||
812 | #endif | 849 | #endif | ||
813 | } | 850 | } | ||
814 | 851 | | |||
815 | QSize KReportDesigner::sizeHint() const | 852 | QSize KReportDesigner::sizeHint() const | ||
816 | { | 853 | { | ||
817 | int w = 0; | 854 | int w = 0; | ||
818 | int h = 0; | 855 | int h = 0; | ||
▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Line(s) | 930 | if (!d->detail) { | |||
897 | if (d->pageHeaderEven) idx++; | 934 | if (d->pageHeaderEven) idx++; | ||
898 | if (d->pageHeaderLast) idx++; | 935 | if (d->pageHeaderLast) idx++; | ||
899 | if (d->pageHeaderAny) idx++; | 936 | if (d->pageHeaderAny) idx++; | ||
900 | if (d->reportHeader) idx++; | 937 | if (d->reportHeader) idx++; | ||
901 | d->detail = rsd; | 938 | d->detail = rsd; | ||
902 | d->vboxlayout->insertWidget(idx, d->detail); | 939 | d->vboxlayout->insertWidget(idx, d->detail); | ||
903 | } | 940 | } | ||
904 | } | 941 | } | ||
905 | void KReportDesigner::deleteDetail() | | |||
906 | { | | |||
907 | delete d->detail; | | |||
908 | d->detail = nullptr; | | |||
909 | } | | |||
910 | 942 | | |||
911 | KReportUnit KReportDesigner::pageUnit() const | 943 | KReportUnit KReportDesigner::pageUnit() const | ||
912 | { | 944 | { | ||
913 | const QString symbol = d->unit->value().toString(); | 945 | const QString symbol = d->unit->value().toString(); | ||
914 | KReportUnit unit(KReportUnit::symbolToType(symbol)); | 946 | KReportUnit unit(KReportUnit::symbolToType(symbol)); | ||
915 | return unit.isValid() ? unit : DEFAULT_UNIT; | 947 | return unit.isValid() ? unit : DEFAULT_UNIT; | ||
916 | } | 948 | } | ||
917 | 949 | | |||
▲ Show 20 Lines • Show All 98 Lines • ▼ Show 20 Line(s) | 1024 | if (d->sectionData.mouseAction == ReportWriterSectionData::MouseAction::Insert) { | |||
1016 | if (item) { | 1048 | if (item) { | ||
1017 | item->setVisible(true); | 1049 | item->setVisible(true); | ||
1018 | item->setSelected(true); | 1050 | item->setSelected(true); | ||
1019 | KReportItemBase* baseReportItem = dynamic_cast<KReportItemBase*>(item); | 1051 | KReportItemBase* baseReportItem = dynamic_cast<KReportItemBase*>(item); | ||
1020 | if (baseReportItem) { | 1052 | if (baseReportItem) { | ||
1021 | baseReportItem->setUnit(pageUnit()); | 1053 | baseReportItem->setUnit(pageUnit()); | ||
1022 | KPropertySet *set = baseReportItem->propertySet(); | 1054 | KPropertySet *set = baseReportItem->propertySet(); | ||
1023 | KReportDesigner::addMetaProperties(set, classString, iconName); | 1055 | KReportDesigner::addMetaProperties(set, classString, iconName); | ||
1056 | set->clearModifiedFlags(); | ||||
1024 | changeSet(set); | 1057 | changeSet(set); | ||
1025 | if (v && v->designer()) { | 1058 | if (v && v->designer()) { | ||
1026 | v->designer()->setModified(true); | 1059 | v->designer()->setModified(true); | ||
1027 | } | 1060 | } | ||
1028 | emit itemInserted(d->sectionData.itemToInsert); | 1061 | emit itemInserted(d->sectionData.itemToInsert); | ||
1029 | } | 1062 | } | ||
1030 | } | 1063 | } | ||
1031 | 1064 | | |||
▲ Show 20 Lines • Show All 141 Lines • ▼ Show 20 Line(s) | 1201 | foreach(KReportDesignerItemBase *item, d->sectionData.copy_list) { | |||
1173 | KReportItemBase *new_obj = dynamic_cast<KReportItemBase*>(ent); | 1206 | KReportItemBase *new_obj = dynamic_cast<KReportItemBase*>(ent); | ||
1174 | if (new_obj) { | 1207 | if (new_obj) { | ||
1175 | new_obj->setEntityName(suggestEntityName(type)); | 1208 | new_obj->setEntityName(suggestEntityName(type)); | ||
1176 | if (activeItem) { | 1209 | if (activeItem) { | ||
1177 | new_obj->setPosition(KReportItemBase::positionFromScene(QPointF(activeItem->x() + 10, activeItem->y() + 10))); | 1210 | new_obj->setPosition(KReportItemBase::positionFromScene(QPointF(activeItem->x() + 10, activeItem->y() + 10))); | ||
1178 | } else { | 1211 | } else { | ||
1179 | new_obj->setPosition(KReportItemBase::positionFromScene(QPointF(0, 0))); | 1212 | new_obj->setPosition(KReportItemBase::positionFromScene(QPointF(0, 0))); | ||
1180 | } | 1213 | } | ||
1214 | new_obj->propertySet()->clearModifiedFlags(); | ||||
1181 | changeSet(new_obj->propertySet()); | 1215 | changeSet(new_obj->propertySet()); | ||
1182 | } | 1216 | } | ||
1183 | QGraphicsItem *pasted_ent = dynamic_cast<QGraphicsItem*>(ent); | 1217 | QGraphicsItem *pasted_ent = dynamic_cast<QGraphicsItem*>(ent); | ||
1184 | if (pasted_ent) { | 1218 | if (pasted_ent) { | ||
1185 | pasted_ent->setSelected(true); | 1219 | pasted_ent->setSelected(true); | ||
1186 | canvas->addItem(pasted_ent); | 1220 | canvas->addItem(pasted_ent); | ||
1187 | pasted_ent->show(); | 1221 | pasted_ent->show(); | ||
1188 | d->sectionData.mouseAction = ReportWriterSectionData::MouseAction::Grab; | 1222 | d->sectionData.mouseAction = ReportWriterSectionData::MouseAction::Grab; | ||
▲ Show 20 Lines • Show All 365 Lines • Show Last 20 Lines |