Changeset View
Changeset View
Standalone View
Standalone View
src/wrtembed/KReportDesigner.cpp
1 | /* This file is part of the KDE project | 1 | /* This file is part of the KDE project | ||
---|---|---|---|---|---|
2 | * Copyright (C) 2001-2007 by OpenMFG, LLC <info@openmfg.com> | 2 | * Copyright (C) 2001-2007 by OpenMFG, LLC <info@openmfg.com> | ||
3 | * Copyright (C) 2007-2010 by Adam Pigg <adam@piggz.co.uk> | 3 | * Copyright (C) 2007-2010 by Adam Pigg <adam@piggz.co.uk> | ||
4 | * Copyright (C) 2011 Jarosław Staniek <staniek@kde.org> | 4 | * Copyright (C) 2011-2017 Jarosław Staniek <staniek@kde.org> | ||
5 | * | 5 | * | ||
6 | * This library is free software; you can redistribute it and/or | 6 | * This library is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU Lesser General Public | 7 | * modify it under the terms of the GNU Lesser General Public | ||
8 | * License as published by the Free Software Foundation; either | 8 | * License as published by the Free Software Foundation; either | ||
9 | * version 2.1 of the License, or (at your option) any later version. | 9 | * version 2.1 of the License, or (at your option) any later version. | ||
10 | * | 10 | * | ||
11 | * This library is distributed in the hope that it will be useful, | 11 | * This library is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
Show All 9 Lines | |||||
22 | #include "KReportDesignerSectionScene.h" | 22 | #include "KReportDesignerSectionScene.h" | ||
23 | #include "KReportDesignerSectionView.h" | 23 | #include "KReportDesignerSectionView.h" | ||
24 | #include "KReportDesignerSectionDetailGroup.h" | 24 | #include "KReportDesignerSectionDetailGroup.h" | ||
25 | #include "KReportPropertiesButton.h" | 25 | #include "KReportPropertiesButton.h" | ||
26 | #include "KReportSectionEditor.h" | 26 | #include "KReportSectionEditor.h" | ||
27 | #include "KReportDesignerSectionDetail.h" | 27 | #include "KReportDesignerSectionDetail.h" | ||
28 | #include "KReportDesignerItemLine.h" | 28 | #include "KReportDesignerItemLine.h" | ||
29 | #include "KReportRuler_p.h" | 29 | #include "KReportRuler_p.h" | ||
30 | #include "KReportZoomHandler.h" | 30 | #include "KReportZoomHandler_p.h" | ||
31 | #include "KReportPageSize.h" | 31 | #include "KReportPageSize.h" | ||
32 | #include "KReportUtils_p.h" | 32 | #include "KReportUtils_p.h" | ||
33 | #include "KReportUtils.h" | 33 | #include "KReportUtils.h" | ||
34 | #include "KReportPluginInterface.h" | 34 | #include "KReportPluginInterface.h" | ||
35 | #include "KReportPluginManager.h" | 35 | #include "KReportPluginManager.h" | ||
36 | #include "KReportSection.h" | 36 | #include "KReportSection.h" | ||
37 | #include "KReportPluginMetaData.h" | 37 | #include "KReportPluginMetaData.h" | ||
38 | #include "kreport_debug.h" | 38 | #include "kreport_debug.h" | ||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Line(s) | 79 | enum MouseAction { | |||
91 | MA_ResizeSW, | 91 | MA_ResizeSW, | ||
92 | MA_ResizeW | 92 | MA_ResizeW | ||
93 | }; | 93 | }; | ||
94 | 94 | | |||
95 | int selected_x_offset; | 95 | int selected_x_offset; | ||
96 | int selected_y_offset; | 96 | int selected_y_offset; | ||
97 | 97 | | |||
98 | MouseAction mouseAction; | 98 | MouseAction mouseAction; | ||
99 | QString insertItem; | 99 | QString itemToInsert; | ||
100 | 100 | | |||
101 | QList<KReportDesignerItemBase*> copy_list; | 101 | QList<KReportDesignerItemBase*> copy_list; | ||
102 | QList<KReportDesignerItemBase*> cut_list; | 102 | QList<KReportDesignerItemBase*> cut_list; | ||
103 | }; | 103 | }; | ||
104 | 104 | | |||
105 | //! @internal | 105 | //! @internal | ||
106 | class Q_DECL_HIDDEN KReportDesigner::Private | 106 | class Q_DECL_HIDDEN KReportDesigner::Private | ||
107 | { | 107 | { | ||
108 | public: | 108 | public: | ||
109 | Private(){} | 109 | Private(){} | ||
110 | 110 | | |||
111 | ~Private() | 111 | ~Private() | ||
112 | { | 112 | { | ||
113 | delete zoom; | | |||
114 | delete sectionData; | | |||
115 | delete set; | | |||
116 | delete dataSource; | 113 | delete dataSource; | ||
117 | } | 114 | } | ||
118 | 115 | | |||
119 | QGridLayout *grid; | 116 | QGridLayout *grid; | ||
120 | KReportRuler *hruler; | 117 | KReportRuler *hruler; | ||
121 | KReportZoomHandler *zoom; | 118 | KReportZoomHandler zoomHandler; | ||
122 | QVBoxLayout *vboxlayout; | 119 | QVBoxLayout *vboxlayout; | ||
123 | KReportPropertiesButton *pageButton; | 120 | KReportPropertiesButton *pageButton; | ||
124 | 121 | | |||
125 | QGraphicsScene *activeScene = nullptr; | 122 | QGraphicsScene *activeScene = nullptr; | ||
126 | 123 | | |||
127 | ReportWriterSectionData *sectionData; | 124 | ReportWriterSectionData sectionData; | ||
128 | 125 | | |||
129 | KReportDesignerSection *reportHeader = nullptr; | 126 | KReportDesignerSection *reportHeader = nullptr; | ||
130 | KReportDesignerSection *pageHeaderFirst = nullptr; | 127 | KReportDesignerSection *pageHeaderFirst = nullptr; | ||
131 | KReportDesignerSection *pageHeaderOdd = nullptr; | 128 | KReportDesignerSection *pageHeaderOdd = nullptr; | ||
132 | KReportDesignerSection *pageHeaderEven = nullptr; | 129 | KReportDesignerSection *pageHeaderEven = nullptr; | ||
133 | KReportDesignerSection *pageHeaderLast = nullptr; | 130 | KReportDesignerSection *pageHeaderLast = nullptr; | ||
134 | KReportDesignerSection *pageHeaderAny = nullptr; | 131 | KReportDesignerSection *pageHeaderAny = nullptr; | ||
135 | 132 | | |||
136 | KReportDesignerSection *pageFooterFirst = nullptr; | 133 | KReportDesignerSection *pageFooterFirst = nullptr; | ||
137 | KReportDesignerSection *pageFooterOdd = nullptr; | 134 | KReportDesignerSection *pageFooterOdd = nullptr; | ||
138 | KReportDesignerSection *pageFooterEven = nullptr; | 135 | KReportDesignerSection *pageFooterEven = nullptr; | ||
139 | KReportDesignerSection *pageFooterLast = nullptr; | 136 | KReportDesignerSection *pageFooterLast = nullptr; | ||
140 | KReportDesignerSection *pageFooterAny = nullptr; | 137 | KReportDesignerSection *pageFooterAny = nullptr; | ||
141 | KReportDesignerSection *reportFooter = nullptr; | 138 | KReportDesignerSection *reportFooter = nullptr; | ||
142 | KReportDesignerSectionDetail *detail = nullptr; | 139 | KReportDesignerSectionDetail *detail = nullptr; | ||
143 | 140 | | |||
144 | //Properties | 141 | //Properties | ||
145 | KPropertySet *set; | 142 | KPropertySet set; | ||
146 | KPropertySet *itmset; | 143 | KPropertySet *itemSet; | ||
147 | KProperty *title; | 144 | KProperty *title; | ||
148 | KProperty *pageSize; | 145 | KProperty *pageSize; | ||
149 | KProperty *orientation; | 146 | KProperty *orientation; | ||
150 | KProperty *unit; | 147 | KProperty *unit; | ||
151 | KProperty *customHeight; | 148 | KProperty *customHeight; | ||
152 | KProperty *customWidth; | 149 | KProperty *customWidth; | ||
153 | KProperty *leftMargin; | 150 | KProperty *leftMargin; | ||
154 | KProperty *rightMargin; | 151 | KProperty *rightMargin; | ||
Show All 35 Lines | |||||
190 | { | 187 | { | ||
191 | init(); | 188 | init(); | ||
192 | } | 189 | } | ||
193 | 190 | | |||
194 | void KReportDesigner::init() | 191 | void KReportDesigner::init() | ||
195 | { | 192 | { | ||
196 | KReportPluginManager::self(); // this loads icons early enough | 193 | KReportPluginManager::self(); // this loads icons early enough | ||
197 | 194 | | |||
198 | d->sectionData = new ReportWriterSectionData(); | | |||
199 | createProperties(); | 195 | createProperties(); | ||
200 | createActions(); | 196 | createActions(); | ||
201 | 197 | | |||
202 | d->grid = new QGridLayout(this); | 198 | d->grid = new QGridLayout(this); | ||
203 | d->grid->setSpacing(0); | 199 | d->grid->setSpacing(0); | ||
204 | d->grid->setMargin(0); | 200 | d->grid->setMargin(0); | ||
205 | d->grid->setColumnStretch(1, 1); | 201 | d->grid->setColumnStretch(1, 1); | ||
206 | d->grid->setRowStretch(1, 1); | 202 | d->grid->setRowStretch(1, 1); | ||
207 | d->grid->setSizeConstraint(QLayout::SetFixedSize); | 203 | d->grid->setSizeConstraint(QLayout::SetFixedSize); | ||
208 | 204 | | |||
209 | d->vboxlayout = new QVBoxLayout(); | 205 | d->vboxlayout = new QVBoxLayout(); | ||
210 | d->vboxlayout->setSpacing(0); | 206 | d->vboxlayout->setSpacing(0); | ||
211 | d->vboxlayout->setMargin(0); | 207 | d->vboxlayout->setMargin(0); | ||
212 | d->vboxlayout->setSizeConstraint(QLayout::SetFixedSize); | 208 | d->vboxlayout->setSizeConstraint(QLayout::SetFixedSize); | ||
213 | 209 | | |||
214 | //Create nice rulers | 210 | //Create nice rulers | ||
215 | d->zoom = new KReportZoomHandler(); | 211 | d->hruler = new KReportRuler(this, Qt::Horizontal, d->zoomHandler); | ||
216 | d->hruler = new KReportRuler(this, Qt::Horizontal, d->zoom); | | |||
217 | 212 | | |||
218 | d->pageButton = new KReportPropertiesButton(this); | 213 | d->pageButton = new KReportPropertiesButton(this); | ||
219 | 214 | | |||
220 | d->hruler->setUnit(KReportUnit(KReportUnit::Centimeter)); | 215 | d->hruler->setUnit(KReportUnit(KReportUnit::Centimeter)); | ||
221 | 216 | | |||
222 | d->grid->addWidget(d->pageButton, 0, 0); | 217 | d->grid->addWidget(d->pageButton, 0, 0); | ||
223 | d->grid->addWidget(d->hruler, 0, 1); | 218 | d->grid->addWidget(d->hruler, 0, 1); | ||
224 | d->grid->addLayout(d->vboxlayout, 1, 0, 1, 2); | 219 | d->grid->addLayout(d->vboxlayout, 1, 0, 1, 2); | ||
225 | 220 | | |||
226 | d->pageButton->setMaximumSize(QSize(19, 22)); | 221 | d->pageButton->setMaximumSize(QSize(19, 22)); | ||
227 | d->pageButton->setMinimumSize(QSize(19, 22)); | 222 | d->pageButton->setMinimumSize(QSize(19, 22)); | ||
228 | 223 | | |||
229 | d->detail = new KReportDesignerSectionDetail(this); | 224 | d->detail = new KReportDesignerSectionDetail(this); | ||
230 | d->vboxlayout->insertWidget(0, d->detail); | 225 | d->vboxlayout->insertWidget(0, d->detail); | ||
231 | 226 | | |||
232 | setLayout(d->grid); | 227 | setLayout(d->grid); | ||
233 | 228 | | |||
234 | connect(d->pageButton, SIGNAL(released()), this, SLOT(slotPageButton_Pressed())); | 229 | connect(d->pageButton, SIGNAL(released()), this, SLOT(slotPageButton_Pressed())); | ||
235 | emit pagePropertyChanged(*d->set); | 230 | emit pagePropertyChanged(d->set); | ||
236 | 231 | | |||
237 | connect(d->set, SIGNAL(propertyChanged(KPropertySet&,KProperty&)), | 232 | connect(&d->set, SIGNAL(propertyChanged(KPropertySet&,KProperty&)), | ||
238 | this, SLOT(slotPropertyChanged(KPropertySet&,KProperty&))); | 233 | this, SLOT(slotPropertyChanged(KPropertySet&,KProperty&))); | ||
239 | 234 | | |||
240 | changeSet(d->set); | 235 | changeSet(&d->set); | ||
241 | } | 236 | } | ||
242 | 237 | | |||
243 | KReportDesigner::~KReportDesigner() | 238 | KReportDesigner::~KReportDesigner() | ||
244 | { | 239 | { | ||
245 | delete d; | 240 | delete d; | ||
246 | } | 241 | } | ||
247 | 242 | | |||
248 | ///The loading Code | 243 | ///The loading Code | ||
▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Line(s) | 310 | } else if (n == QLatin1String("report:body")) { | |||
338 | } | 333 | } | ||
339 | } | 334 | } | ||
340 | } else { | 335 | } else { | ||
341 | kreportWarning() << "Encountered a child node of root that is not an Element"; | 336 | kreportWarning() << "Encountered a child node of root that is not an Element"; | ||
342 | } | 337 | } | ||
343 | } | 338 | } | ||
344 | this->slotPageButton_Pressed(); | 339 | this->slotPageButton_Pressed(); | ||
345 | emit reportDataChanged(); | 340 | emit reportDataChanged(); | ||
346 | slotPropertyChanged(*d->set, *d->unit); // set unit for all items | 341 | slotPropertyChanged(d->set, *d->unit); // set unit for all items | ||
347 | setModified(false); | 342 | setModified(false); | ||
348 | } | 343 | } | ||
349 | 344 | | |||
350 | ///The saving code | 345 | ///The saving code | ||
351 | QDomElement KReportDesigner::document() const | 346 | QDomElement KReportDesigner::document() const | ||
352 | { | 347 | { | ||
353 | QDomDocument doc; | 348 | QDomDocument doc; | ||
354 | QString saveInterpreter; | 349 | QString saveInterpreter; | ||
▲ Show 20 Lines • Show All 139 Lines • ▼ Show 20 Line(s) | 453 | { | |||
494 | case KReportSectionData::ReportFooter: | 489 | case KReportSectionData::ReportFooter: | ||
495 | sec = d->reportFooter; | 490 | sec = d->reportFooter; | ||
496 | break; | 491 | break; | ||
497 | default: | 492 | default: | ||
498 | sec = 0; | 493 | sec = 0; | ||
499 | } | 494 | } | ||
500 | return sec; | 495 | return sec; | ||
501 | } | 496 | } | ||
497 | | ||||
498 | KReportDesignerSection* KReportDesigner::createSection() | ||||
499 | { | ||||
500 | return new KReportDesignerSection(this, d->zoomHandler); | ||||
501 | } | ||||
502 | | ||||
502 | void KReportDesigner::removeSection(KReportSectionData::Section s) | 503 | void KReportDesigner::removeSection(KReportSectionData::Section s) | ||
503 | { | 504 | { | ||
504 | KReportDesignerSection* sec = section(s); | 505 | KReportDesignerSection* sec = section(s); | ||
505 | if (sec) { | 506 | if (sec) { | ||
506 | delete sec; | 507 | delete sec; | ||
507 | 508 | | |||
508 | switch (s) { | 509 | switch (s) { | ||
509 | case KReportSectionData::PageHeaderAny: | 510 | case KReportSectionData::PageHeaderAny: | ||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Line(s) | 558 | if (!sec) { | |||
558 | int idx = 0; | 559 | int idx = 0; | ||
559 | for (int i = 1; i <= s; ++i) { | 560 | for (int i = 1; i <= s; ++i) { | ||
560 | if (section((KReportSectionData::Section)i)) | 561 | if (section((KReportSectionData::Section)i)) | ||
561 | idx++; | 562 | idx++; | ||
562 | } | 563 | } | ||
563 | if (s > KReportSectionData::ReportHeader) | 564 | if (s > KReportSectionData::ReportHeader) | ||
564 | idx++; | 565 | idx++; | ||
565 | //kreportDebug() << idx; | 566 | //kreportDebug() << idx; | ||
566 | KReportDesignerSection *rs = new KReportDesignerSection(this); | 567 | KReportDesignerSection *rs = createSection(); | ||
567 | d->vboxlayout->insertWidget(idx, rs); | 568 | d->vboxlayout->insertWidget(idx, rs); | ||
568 | 569 | | |||
569 | switch (s) { | 570 | switch (s) { | ||
570 | case KReportSectionData::PageHeaderAny: | 571 | case KReportSectionData::PageHeaderAny: | ||
571 | rs->setTitle(tr("Page Header (Any)")); | 572 | rs->setTitle(tr("Page Header (Any)")); | ||
572 | d->pageHeaderAny = rs; | 573 | d->pageHeaderAny = rs; | ||
573 | break; | 574 | break; | ||
574 | case KReportSectionData::PageHeaderEven: | 575 | case KReportSectionData::PageHeaderEven: | ||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Line(s) | |||||
621 | case KReportSectionData::GroupFooter: | 622 | case KReportSectionData::GroupFooter: | ||
622 | case KReportSectionData::Detail: | 623 | case KReportSectionData::Detail: | ||
623 | break; | 624 | break; | ||
624 | } | 625 | } | ||
625 | 626 | | |||
626 | rs->show(); | 627 | rs->show(); | ||
627 | setModified(true); | 628 | setModified(true); | ||
628 | adjustSize(); | 629 | adjustSize(); | ||
629 | emit pagePropertyChanged(*d->set); | 630 | emit pagePropertyChanged(d->set); | ||
630 | } | 631 | } | ||
631 | } | 632 | } | ||
632 | 633 | | |||
633 | void KReportDesigner::setReportTitle(const QString & str) | 634 | void KReportDesigner::setReportTitle(const QString & str) | ||
634 | { | 635 | { | ||
635 | if (reportTitle() != str) { | 636 | if (reportTitle() != str) { | ||
636 | d->title->setValue(str); | 637 | d->title->setValue(str); | ||
637 | setModified(true); | 638 | setModified(true); | ||
638 | } | 639 | } | ||
639 | } | 640 | } | ||
640 | 641 | | |||
641 | KPropertySet * KReportDesigner::propertySet() const | 642 | KPropertySet* KReportDesigner::propertySet() const | ||
642 | { | 643 | { | ||
643 | return d->set; | 644 | return &d->set; | ||
644 | } | 645 | } | ||
645 | 646 | | |||
646 | KPropertySet* KReportDesigner::itemPropertySet() const | 647 | KPropertySet* KReportDesigner::selectedItemPropertySet() const | ||
647 | { | 648 | { | ||
648 | return d->itmset; | 649 | return d->itemSet; | ||
649 | } | 650 | } | ||
650 | 651 | | |||
651 | KReportDataSource *KReportDesigner::reportDataSource() const | 652 | KReportDataSource *KReportDesigner::reportDataSource() const | ||
652 | { | 653 | { | ||
653 | return d->dataSource; | 654 | return d->dataSource; | ||
654 | } | 655 | } | ||
655 | 656 | | |||
656 | KReportDesignerSectionDetail * KReportDesigner::detailSection() const | 657 | KReportDesignerSectionDetail * KReportDesigner::detailSection() const | ||
657 | { | 658 | { | ||
658 | return d->detail; | 659 | return d->detail; | ||
659 | } | 660 | } | ||
660 | 661 | | |||
661 | QString KReportDesigner::reportTitle() const | 662 | QString KReportDesigner::reportTitle() const | ||
662 | { | 663 | { | ||
663 | return d->title->value().toString(); | 664 | return d->title->value().toString(); | ||
664 | } | 665 | } | ||
665 | 666 | | |||
666 | bool KReportDesigner::isModified() const | 667 | bool KReportDesigner::isModified() const | ||
667 | { | 668 | { | ||
668 | return d->modified; | 669 | return d->modified; | ||
669 | } | 670 | } | ||
670 | 671 | | |||
671 | void KReportDesigner::setModified(bool mod) | 672 | void KReportDesigner::setModified(bool modified) | ||
672 | { | 673 | { | ||
673 | d->modified = mod; | 674 | d->modified = modified; | ||
674 | 675 | | |||
675 | if (d->modified) { | 676 | if (d->modified) { | ||
676 | emit dirty(); | 677 | emit dirty(); | ||
677 | } | 678 | } | ||
678 | } | 679 | } | ||
679 | 680 | | |||
680 | QStringList KReportDesigner::fieldNames() const | 681 | QStringList KReportDesigner::fieldNames() const | ||
681 | { | 682 | { | ||
Show All 13 Lines | 695 | if (d->dataSource) | |||
695 | qs << d->dataSource->fieldKeys(); | 696 | qs << d->dataSource->fieldKeys(); | ||
696 | 697 | | |||
697 | return qs; | 698 | return qs; | ||
698 | } | 699 | } | ||
699 | 700 | | |||
700 | void KReportDesigner::createProperties() | 701 | void KReportDesigner::createProperties() | ||
701 | { | 702 | { | ||
702 | QStringList keys, strings; | 703 | QStringList keys, strings; | ||
703 | d->set = new KPropertySet; | 704 | KReportDesigner::addMetaProperties(&d->set, | ||
704 | KReportDesigner::addMetaProperties(d->set, | | |||
705 | tr("Report", "Main report element"), QLatin1String("kreport-report-element")); | 705 | tr("Report", "Main report element"), QLatin1String("kreport-report-element")); | ||
706 | 706 | | |||
707 | connect(d->set, SIGNAL(propertyChanged(KPropertySet&,KProperty&)), | 707 | connect(&d->set, SIGNAL(propertyChanged(KPropertySet&,KProperty&)), | ||
708 | this, SLOT(slotPropertyChanged(KPropertySet&,KProperty&))); | 708 | this, SLOT(slotPropertyChanged(KPropertySet&,KProperty&))); | ||
709 | 709 | | |||
710 | d->title = new KProperty("title", QLatin1String("Report"), tr("Title"), tr("Report Title")); | 710 | d->title = new KProperty("title", QLatin1String("Report"), tr("Title"), tr("Report Title")); | ||
711 | 711 | | |||
712 | keys.clear(); | 712 | keys.clear(); | ||
713 | keys = KReportPageSize::pageFormatKeys(); | 713 | keys = KReportPageSize::pageFormatKeys(); | ||
714 | strings = KReportPageSize::pageFormatNames(); | 714 | strings = KReportPageSize::pageFormatNames(); | ||
715 | QString defaultKey = KReportPageSize::pageSizeKey(KReportPageSize::defaultSize()); | 715 | QString defaultKey = KReportPageSize::pageSizeKey(KReportPageSize::defaultSize()); | ||
Show All 27 Lines | 742 | d->topMargin = new KProperty("margin-top", KReportUnit(KReportUnit::Centimeter).fromUserValue(1.0), | |||
743 | tr("Top Margin"), tr("Top Margin"), KProperty::Double); | 743 | tr("Top Margin"), tr("Top Margin"), KProperty::Double); | ||
744 | d->bottomMargin = new KProperty("margin-bottom", KReportUnit(KReportUnit::Centimeter).fromUserValue(1.0), | 744 | d->bottomMargin = new KProperty("margin-bottom", KReportUnit(KReportUnit::Centimeter).fromUserValue(1.0), | ||
745 | tr("Bottom Margin"), tr("Bottom Margin"), KProperty::Double); | 745 | tr("Bottom Margin"), tr("Bottom Margin"), KProperty::Double); | ||
746 | d->leftMargin->setOption("unit", QLatin1String("cm")); | 746 | d->leftMargin->setOption("unit", QLatin1String("cm")); | ||
747 | d->rightMargin->setOption("unit", QLatin1String("cm")); | 747 | d->rightMargin->setOption("unit", QLatin1String("cm")); | ||
748 | d->topMargin->setOption("unit", QLatin1String("cm")); | 748 | d->topMargin->setOption("unit", QLatin1String("cm")); | ||
749 | d->bottomMargin->setOption("unit", QLatin1String("cm")); | 749 | d->bottomMargin->setOption("unit", QLatin1String("cm")); | ||
750 | 750 | | |||
751 | d->set->addProperty(d->title); | 751 | d->set.addProperty(d->title); | ||
752 | d->set->addProperty(d->pageSize); | 752 | d->set.addProperty(d->pageSize); | ||
753 | d->set->addProperty(d->orientation); | 753 | d->set.addProperty(d->orientation); | ||
754 | d->set->addProperty(d->unit); | 754 | d->set.addProperty(d->unit); | ||
755 | d->set->addProperty(d->gridSnap); | 755 | d->set.addProperty(d->gridSnap); | ||
756 | d->set->addProperty(d->showGrid); | 756 | d->set.addProperty(d->showGrid); | ||
757 | d->set->addProperty(d->gridDivisions); | 757 | d->set.addProperty(d->gridDivisions); | ||
758 | d->set->addProperty(d->leftMargin); | 758 | d->set.addProperty(d->leftMargin); | ||
759 | d->set->addProperty(d->rightMargin); | 759 | d->set.addProperty(d->rightMargin); | ||
760 | d->set->addProperty(d->topMargin); | 760 | d->set.addProperty(d->topMargin); | ||
761 | d->set->addProperty(d->bottomMargin); | 761 | d->set.addProperty(d->bottomMargin); | ||
762 | 762 | | |||
763 | #ifdef KREPORT_SCRIPTING | 763 | #ifdef KREPORT_SCRIPTING | ||
764 | d->script = new KProperty("script", QStringList(), QStringList(), QString(), tr("Object Script")); | 764 | d->script = new KProperty("script", QStringList(), QStringList(), QString(), tr("Object Script")); | ||
765 | d->set->addProperty(d->script); | 765 | d->set.addProperty(d->script); | ||
766 | #endif | 766 | #endif | ||
767 | 767 | | |||
768 | // KProperty* _customHeight; | 768 | // KProperty* _customHeight; | ||
769 | // KProperty* _customWidth; | 769 | // KProperty* _customWidth; | ||
770 | 770 | | |||
771 | } | 771 | } | ||
772 | 772 | | |||
773 | /** | 773 | /** | ||
774 | @brief Handle property changes | 774 | @brief Handle property changes | ||
775 | */ | 775 | */ | ||
776 | void KReportDesigner::slotPropertyChanged(KPropertySet &s, KProperty &p) | 776 | void KReportDesigner::slotPropertyChanged(KPropertySet &s, KProperty &p) | ||
777 | { | 777 | { | ||
778 | setModified(true); | 778 | setModified(true); | ||
779 | emit pagePropertyChanged(s); | 779 | emit pagePropertyChanged(s); | ||
780 | 780 | | |||
781 | if (p.name() == "page-unit") { | 781 | if (p.name() == "page-unit") { | ||
782 | d->hruler->setUnit(pageUnit()); | 782 | d->hruler->setUnit(pageUnit()); | ||
783 | QString newstr = d->set->property("page-unit").value().toString(); | 783 | QString newstr = d->set.property("page-unit").value().toString(); | ||
784 | 784 | | |||
785 | d->set->property("margin-left").setOption("unit", newstr); | 785 | d->set.property("margin-left").setOption("unit", newstr); | ||
786 | d->set->property("margin-right").setOption("unit", newstr); | 786 | d->set.property("margin-right").setOption("unit", newstr); | ||
787 | d->set->property("margin-top").setOption("unit", newstr); | 787 | d->set.property("margin-top").setOption("unit", newstr); | ||
788 | d->set->property("margin-bottom").setOption("unit", newstr); | 788 | d->set.property("margin-bottom").setOption("unit", newstr); | ||
789 | } | 789 | } | ||
790 | } | 790 | } | ||
791 | 791 | | |||
792 | void KReportDesigner::slotPageButton_Pressed() | 792 | void KReportDesigner::slotPageButton_Pressed() | ||
793 | { | 793 | { | ||
794 | #ifdef KREPORT_SCRIPTING | 794 | #ifdef KREPORT_SCRIPTING | ||
795 | if (d->dataSource) { | 795 | if (d->dataSource) { | ||
796 | QStringList sl = d->dataSource->scriptList(); | 796 | QStringList sl = d->dataSource->scriptList(); | ||
797 | sl.prepend(QLatin1String("")); | 797 | sl.prepend(QLatin1String("")); | ||
798 | d->script->setListData(sl, sl); | 798 | d->script->setListData(sl, sl); | ||
799 | } | 799 | } | ||
800 | changeSet(d->set); | 800 | changeSet(&d->set); | ||
801 | #endif | 801 | #endif | ||
802 | } | 802 | } | ||
803 | 803 | | |||
804 | QSize KReportDesigner::sizeHint() const | 804 | QSize KReportDesigner::sizeHint() const | ||
805 | { | 805 | { | ||
806 | int w = 0; | 806 | int w = 0; | ||
807 | int h = 0; | 807 | int h = 0; | ||
808 | 808 | | |||
Show All 30 Lines | |||||
839 | 839 | | |||
840 | h += d->hruler->height(); | 840 | h += d->hruler->height(); | ||
841 | 841 | | |||
842 | return QSize(w, h); | 842 | return QSize(w, h); | ||
843 | } | 843 | } | ||
844 | 844 | | |||
845 | int KReportDesigner::pageWidthPx() const | 845 | int KReportDesigner::pageWidthPx() const | ||
846 | { | 846 | { | ||
847 | QPageLayout layout = QPageLayout(QPageSize(KReportPageSize::pageSize(d->set->property("page-size").value().toString())), d->set->property("print-orientation").value().toString() == QLatin1String("portrait") ? QPageLayout::Portrait : QPageLayout::Landscape, QMarginsF(0,0,0,0));; | 847 | QPageLayout layout = QPageLayout( | ||
848 | QPageSize(KReportPageSize::pageSize(d->set.property("page-size").value().toString())), | ||||
849 | d->set.property("print-orientation").value().toString() | ||||
850 | == QLatin1String("portrait") ? QPageLayout::Portrait : QPageLayout::Landscape, QMarginsF(0,0,0,0)); | ||||
848 | 851 | | |||
849 | QSize pageSizePx = layout.fullRectPixels(KReportPrivate::dpiX()).size(); | 852 | QSize pageSizePx = layout.fullRectPixels(KReportPrivate::dpiX()).size(); | ||
850 | 853 | | |||
851 | int width = pageSizePx.width(); | 854 | int width = pageSizePx.width(); | ||
852 | width = width - POINT_TO_INCH(d->set->property("margin-left").value().toDouble()) * KReportPrivate::dpiX(); | 855 | width = width - POINT_TO_INCH(d->set.property("margin-left").value().toDouble()) * KReportPrivate::dpiX(); | ||
853 | width = width - POINT_TO_INCH(d->set->property("margin-right").value().toDouble()) * KReportPrivate::dpiX(); | 856 | width = width - POINT_TO_INCH(d->set.property("margin-right").value().toDouble()) * KReportPrivate::dpiX(); | ||
854 | 857 | | |||
855 | return width; | 858 | return width; | ||
856 | } | 859 | } | ||
857 | 860 | | |||
858 | void KReportDesigner::resizeEvent(QResizeEvent * event) | 861 | void KReportDesigner::resizeEvent(QResizeEvent * event) | ||
859 | { | 862 | { | ||
860 | Q_UNUSED(event); | 863 | Q_UNUSED(event); | ||
861 | d->hruler->setRulerLength(pageWidthPx()); | 864 | d->hruler->setRulerLength(pageWidthPx()); | ||
▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Line(s) | 918 | if (itemsSelected) { | |||
917 | QAction *a = new QAction(QIcon::fromTheme(QLatin1String("edit-cut")), tr("Cut"), this); | 920 | QAction *a = new QAction(QIcon::fromTheme(QLatin1String("edit-cut")), tr("Cut"), this); | ||
918 | connect(a, SIGNAL(triggered()), this, SLOT(slotEditCut())); | 921 | connect(a, SIGNAL(triggered()), this, SLOT(slotEditCut())); | ||
919 | pop.addAction(a); | 922 | pop.addAction(a); | ||
920 | //! @todo KF5 use KStandardAction | 923 | //! @todo KF5 use KStandardAction | ||
921 | a = new QAction(QIcon::fromTheme(QLatin1String("edit-copy")), tr("Copy"), this); | 924 | a = new QAction(QIcon::fromTheme(QLatin1String("edit-copy")), tr("Copy"), this); | ||
922 | connect(a, SIGNAL(triggered()), this, SLOT(slotEditCopy())); | 925 | connect(a, SIGNAL(triggered()), this, SLOT(slotEditCopy())); | ||
923 | pop.addAction(a); | 926 | pop.addAction(a); | ||
924 | } | 927 | } | ||
925 | if (!d->sectionData->copy_list.isEmpty()) { | 928 | if (!d->sectionData.copy_list.isEmpty()) { | ||
926 | QAction *a = new QAction(QIcon::fromTheme(QLatin1String("edit-paste")), tr("Paste"), this); | 929 | QAction *a = new QAction(QIcon::fromTheme(QLatin1String("edit-paste")), tr("Paste"), this); | ||
927 | connect(a, SIGNAL(triggered()), this, SLOT(slotEditPaste())); | 930 | connect(a, SIGNAL(triggered()), this, SLOT(slotEditPaste())); | ||
928 | pop.addAction(a); | 931 | pop.addAction(a); | ||
929 | } | 932 | } | ||
930 | 933 | | |||
931 | if (itemsSelected) { | 934 | if (itemsSelected) { | ||
932 | pop.addSeparator(); | 935 | pop.addSeparator(); | ||
933 | //! @todo KF5 use KStandard* | 936 | //! @todo KF5 use KStandard* | ||
Show All 31 Lines | 966 | if (d->releaseY >= v->scene()->height()) { | |||
965 | end.setY(v->scene()->height()); | 968 | end.setY(v->scene()->height()); | ||
966 | } | 969 | } | ||
967 | 970 | | |||
968 | if (d->releaseX >= v->scene()->width()) { | 971 | if (d->releaseX >= v->scene()->width()) { | ||
969 | d->releaseX = v->scene()->width(); | 972 | d->releaseX = v->scene()->width(); | ||
970 | end.setX(v->scene()->width()); | 973 | end.setX(v->scene()->width()); | ||
971 | } | 974 | } | ||
972 | 975 | | |||
973 | if (d->sectionData->mouseAction == ReportWriterSectionData::MA_Insert) { | 976 | if (d->sectionData.mouseAction == ReportWriterSectionData::MA_Insert) { | ||
974 | QGraphicsItem * item = 0; | 977 | QGraphicsItem * item = 0; | ||
975 | QString classString; | 978 | QString classString; | ||
976 | QString iconName; | 979 | QString iconName; | ||
977 | if (d->sectionData->insertItem == QLatin1String("org.kde.kreport.line")) { | 980 | if (d->sectionData.itemToInsert == QLatin1String("org.kde.kreport.line")) { | ||
978 | item = new KReportDesignerItemLine(v->designer(), v->scene(), pos, end); | 981 | item = new KReportDesignerItemLine(v->designer(), v->scene(), pos, end); | ||
979 | classString = tr("Line", "Report line element"); | 982 | classString = tr("Line", "Report line element"); | ||
980 | iconName = QLatin1String("kreport-line-element"); | 983 | iconName = QLatin1String("kreport-line-element"); | ||
981 | } | 984 | } | ||
982 | else { | 985 | else { | ||
983 | KReportPluginManager* pluginManager = KReportPluginManager::self(); | 986 | KReportPluginManager* pluginManager = KReportPluginManager::self(); | ||
984 | KReportPluginInterface *plug = pluginManager->plugin(d->sectionData->insertItem); | 987 | KReportPluginInterface *plug = pluginManager->plugin(d->sectionData.itemToInsert); | ||
985 | if (plug) { | 988 | if (plug) { | ||
986 | QObject *obj = plug->createDesignerInstance(v->designer(), v->scene(), pos); | 989 | QObject *obj = plug->createDesignerInstance(v->designer(), v->scene(), pos); | ||
987 | if (obj) { | 990 | if (obj) { | ||
988 | item = dynamic_cast<QGraphicsItem*>(obj); | 991 | item = dynamic_cast<QGraphicsItem*>(obj); | ||
989 | classString = plug->metaData()->name(); | 992 | classString = plug->metaData()->name(); | ||
990 | iconName = plug->metaData()->iconName(); | 993 | iconName = plug->metaData()->iconName(); | ||
991 | } | 994 | } | ||
992 | } | 995 | } | ||
993 | else { | 996 | else { | ||
994 | kreportWarning() << "attempted to insert an unknown item"; | 997 | kreportWarning() << "attempted to insert an unknown item"; | ||
995 | } | 998 | } | ||
996 | } | 999 | } | ||
997 | if (item) { | 1000 | if (item) { | ||
998 | item->setVisible(true); | 1001 | item->setVisible(true); | ||
999 | item->setSelected(true); | 1002 | item->setSelected(true); | ||
1000 | KReportItemBase* baseReportItem = dynamic_cast<KReportItemBase*>(item); | 1003 | KReportItemBase* baseReportItem = dynamic_cast<KReportItemBase*>(item); | ||
1001 | if (baseReportItem) { | 1004 | if (baseReportItem) { | ||
1002 | baseReportItem->setUnit(pageUnit()); | 1005 | baseReportItem->setUnit(pageUnit()); | ||
1003 | KPropertySet *set = baseReportItem->propertySet(); | 1006 | KPropertySet *set = baseReportItem->propertySet(); | ||
1004 | KReportDesigner::addMetaProperties(set, classString, iconName); | 1007 | KReportDesigner::addMetaProperties(set, classString, iconName); | ||
1005 | changeSet(set); | 1008 | changeSet(set); | ||
1006 | if (v && v->designer()) { | 1009 | if (v && v->designer()) { | ||
1007 | v->designer()->setModified(true); | 1010 | v->designer()->setModified(true); | ||
1008 | } | 1011 | } | ||
1009 | emit itemInserted(d->sectionData->insertItem); | 1012 | emit itemInserted(d->sectionData.itemToInsert); | ||
1010 | } | 1013 | } | ||
1011 | } | 1014 | } | ||
1012 | 1015 | | |||
1013 | d->sectionData->mouseAction = ReportWriterSectionData::MA_None; | 1016 | d->sectionData.mouseAction = ReportWriterSectionData::MA_None; | ||
1014 | d->sectionData->insertItem.clear(); | 1017 | d->sectionData.itemToInsert.clear(); | ||
1015 | unsetSectionCursor(); | 1018 | unsetSectionCursor(); | ||
1016 | } | 1019 | } | ||
1017 | } | 1020 | } | ||
1018 | } | 1021 | } | ||
1019 | 1022 | | |||
1020 | unsigned int KReportDesigner::selectionCount() const | 1023 | unsigned int KReportDesigner::selectionCount() const | ||
1021 | { | 1024 | { | ||
1022 | if (activeScene()) | 1025 | if (activeScene()) | ||
1023 | return activeScene()->selectedItems().count(); | 1026 | return activeScene()->selectedItems().count(); | ||
1024 | else | 1027 | else | ||
1025 | return 0; | 1028 | return 0; | ||
1026 | } | 1029 | } | ||
1027 | 1030 | | |||
1028 | void KReportDesigner::changeSet(KPropertySet *s) | 1031 | void KReportDesigner::changeSet(KPropertySet *s) | ||
1029 | { | 1032 | { | ||
1030 | //Set the checked state of the report properties button | 1033 | //Set the checked state of the report properties button | ||
1031 | if (s == d->set) | 1034 | if (s == &d->set) | ||
1032 | d->pageButton->setCheckState(Qt::Checked); | 1035 | d->pageButton->setCheckState(Qt::Checked); | ||
1033 | else | 1036 | else | ||
1034 | d->pageButton->setCheckState(Qt::Unchecked); | 1037 | d->pageButton->setCheckState(Qt::Unchecked); | ||
1035 | 1038 | | |||
1036 | d->itmset = s; | 1039 | d->itemSet = s; | ||
1037 | emit propertySetChanged(); | 1040 | emit propertySetChanged(); | ||
1038 | } | 1041 | } | ||
1039 | 1042 | | |||
1040 | // | 1043 | // | ||
1041 | // Actions | 1044 | // Actions | ||
1042 | // | 1045 | // | ||
1043 | 1046 | | |||
1044 | void KReportDesigner::slotItem(const QString &entity) | 1047 | void KReportDesigner::slotItem(const QString &entity) | ||
1045 | { | 1048 | { | ||
1046 | //kreportDebug() << entity; | 1049 | //kreportDebug() << entity; | ||
1047 | d->sectionData->mouseAction = ReportWriterSectionData::MA_Insert; | 1050 | d->sectionData.mouseAction = ReportWriterSectionData::MA_Insert; | ||
1048 | d->sectionData->insertItem = entity; | 1051 | d->sectionData.itemToInsert = entity; | ||
1049 | setSectionCursor(QCursor(Qt::CrossCursor)); | 1052 | setSectionCursor(QCursor(Qt::CrossCursor)); | ||
1050 | } | 1053 | } | ||
1051 | 1054 | | |||
1052 | void KReportDesigner::slotEditDelete() | 1055 | void KReportDesigner::slotEditDelete() | ||
1053 | { | 1056 | { | ||
1054 | QGraphicsItem * item = 0; | 1057 | QGraphicsItem * item = 0; | ||
1055 | bool modified = false; | 1058 | bool modified = false; | ||
1056 | while (selectionCount() > 0) { | 1059 | while (selectionCount() > 0) { | ||
1057 | item = activeScene()->selectedItems().value(0); | 1060 | item = activeScene()->selectedItems().value(0); | ||
1058 | if (item) { | 1061 | if (item) { | ||
1059 | QGraphicsScene * scene = item->scene(); | 1062 | QGraphicsScene * scene = item->scene(); | ||
1060 | delete item; | 1063 | delete item; | ||
1061 | scene->update(); | 1064 | scene->update(); | ||
1062 | d->sectionData->mouseAction = ReportWriterSectionData::MA_None; | 1065 | d->sectionData.mouseAction = ReportWriterSectionData::MA_None; | ||
1063 | modified = true; | 1066 | modified = true; | ||
1064 | } | 1067 | } | ||
1065 | } | 1068 | } | ||
1066 | activeScene()->selectedItems().clear(); | 1069 | activeScene()->selectedItems().clear(); | ||
1067 | 1070 | | |||
1068 | /*! @todo temporary: clears cut and copy lists to make sure we do not crash | 1071 | /*! @todo temporary: clears cut and copy lists to make sure we do not crash | ||
1069 | if weve deleted something in the list | 1072 | if weve deleted something in the list | ||
1070 | should really check if an item is in the list first | 1073 | should really check if an item is in the list first | ||
1071 | and remove it. */ | 1074 | and remove it. */ | ||
1072 | d->sectionData->cut_list.clear(); | 1075 | d->sectionData.cut_list.clear(); | ||
1073 | d->sectionData->copy_list.clear(); | 1076 | d->sectionData.copy_list.clear(); | ||
1074 | if (modified) { | 1077 | if (modified) { | ||
1075 | setModified(true); | 1078 | setModified(true); | ||
1076 | } | 1079 | } | ||
1077 | } | 1080 | } | ||
1078 | 1081 | | |||
1079 | void KReportDesigner::slotEditCut() | 1082 | void KReportDesigner::slotEditCut() | ||
1080 | { | 1083 | { | ||
1081 | if (selectionCount() > 0) { | 1084 | if (selectionCount() > 0) { | ||
1082 | //First delete any items that are curerntly in the list | 1085 | //First delete any items that are curerntly in the list | ||
1083 | //so as not to leak memory | 1086 | //so as not to leak memory | ||
1084 | qDeleteAll(d->sectionData->cut_list); | 1087 | qDeleteAll(d->sectionData.cut_list); | ||
1085 | d->sectionData->cut_list.clear(); | 1088 | d->sectionData.cut_list.clear(); | ||
1086 | 1089 | | |||
1087 | QGraphicsItem * item = activeScene()->selectedItems().first(); | 1090 | QGraphicsItem * item = activeScene()->selectedItems().first(); | ||
1088 | bool modified = false; | 1091 | bool modified = false; | ||
1089 | if (item) { | 1092 | if (item) { | ||
1090 | d->sectionData->copy_list.clear(); | 1093 | d->sectionData.copy_list.clear(); | ||
1091 | foreach(QGraphicsItem *item, activeScene()->selectedItems()) { | 1094 | foreach(QGraphicsItem *item, activeScene()->selectedItems()) { | ||
1092 | d->sectionData->cut_list.append(dynamic_cast<KReportDesignerItemBase*>(item)); | 1095 | d->sectionData.cut_list.append(dynamic_cast<KReportDesignerItemBase*>(item)); | ||
1093 | d->sectionData->copy_list.append(dynamic_cast<KReportDesignerItemBase*>(item)); | 1096 | d->sectionData.copy_list.append(dynamic_cast<KReportDesignerItemBase*>(item)); | ||
1094 | } | 1097 | } | ||
1095 | foreach(QGraphicsItem *item, activeScene()->selectedItems()) { | 1098 | foreach(QGraphicsItem *item, activeScene()->selectedItems()) { | ||
1096 | activeScene()->removeItem(item); | 1099 | activeScene()->removeItem(item); | ||
1097 | activeScene()->update(); | 1100 | activeScene()->update(); | ||
1098 | modified = true; | 1101 | modified = true; | ||
1099 | } | 1102 | } | ||
1100 | d->sectionData->selected_x_offset = 10; | 1103 | d->sectionData.selected_x_offset = 10; | ||
1101 | d->sectionData->selected_y_offset = 10; | 1104 | d->sectionData.selected_y_offset = 10; | ||
1102 | } | 1105 | } | ||
1103 | if (modified) { | 1106 | if (modified) { | ||
1104 | setModified(true); | 1107 | setModified(true); | ||
1105 | } | 1108 | } | ||
1106 | } | 1109 | } | ||
1107 | } | 1110 | } | ||
1108 | 1111 | | |||
1109 | void KReportDesigner::slotEditCopy() | 1112 | void KReportDesigner::slotEditCopy() | ||
1110 | { | 1113 | { | ||
1111 | if (selectionCount() < 1) | 1114 | if (selectionCount() < 1) | ||
1112 | return; | 1115 | return; | ||
1113 | 1116 | | |||
1114 | QGraphicsItem * item = activeScene()->selectedItems().first(); | 1117 | QGraphicsItem * item = activeScene()->selectedItems().first(); | ||
1115 | if (item) { | 1118 | if (item) { | ||
1116 | d->sectionData->copy_list.clear(); | 1119 | d->sectionData.copy_list.clear(); | ||
1117 | foreach(QGraphicsItem *item, activeScene()->selectedItems()) { | 1120 | foreach(QGraphicsItem *item, activeScene()->selectedItems()) { | ||
1118 | d->sectionData->copy_list.append(dynamic_cast<KReportDesignerItemBase*>(item)); | 1121 | d->sectionData.copy_list.append(dynamic_cast<KReportDesignerItemBase*>(item)); | ||
1119 | } | 1122 | } | ||
1120 | d->sectionData->selected_x_offset = 10; | 1123 | d->sectionData.selected_x_offset = 10; | ||
1121 | d->sectionData->selected_y_offset = 10; | 1124 | d->sectionData.selected_y_offset = 10; | ||
1122 | } | 1125 | } | ||
1123 | } | 1126 | } | ||
1124 | 1127 | | |||
1125 | void KReportDesigner::slotEditPaste() | 1128 | void KReportDesigner::slotEditPaste() | ||
1126 | { | 1129 | { | ||
1127 | // call the editPaste function passing it a reportsection | 1130 | // call the editPaste function passing it a reportsection | ||
1128 | slotEditPaste(activeScene()); | 1131 | slotEditPaste(activeScene()); | ||
1129 | } | 1132 | } | ||
1130 | 1133 | | |||
1131 | void KReportDesigner::slotEditPaste(QGraphicsScene * canvas) | 1134 | void KReportDesigner::slotEditPaste(QGraphicsScene * canvas) | ||
1132 | { | 1135 | { | ||
1133 | 1136 | | |||
1134 | // paste a new item of the copy we have in the specified location | 1137 | // paste a new item of the copy we have in the specified location | ||
1135 | if (!d->sectionData->copy_list.isEmpty()) { | 1138 | if (!d->sectionData.copy_list.isEmpty()) { | ||
1136 | QList<QGraphicsItem*> activeItems = canvas->selectedItems(); | 1139 | QList<QGraphicsItem*> activeItems = canvas->selectedItems(); | ||
1137 | QGraphicsItem *activeItem = 0; | 1140 | QGraphicsItem *activeItem = 0; | ||
1138 | if (activeItems.count() == 1) { | 1141 | if (activeItems.count() == 1) { | ||
1139 | activeItem = activeItems.first(); | 1142 | activeItem = activeItems.first(); | ||
1140 | } | 1143 | } | ||
1141 | canvas->clearSelection(); | 1144 | canvas->clearSelection(); | ||
1142 | d->sectionData->mouseAction = ReportWriterSectionData::MA_None; | 1145 | d->sectionData.mouseAction = ReportWriterSectionData::MA_None; | ||
1143 | 1146 | | |||
1144 | //! @todo this code sucks :) | 1147 | //! @todo this code sucks :) | ||
1145 | //! The setPos calls only work AFTER the name has been set ?!?!? | 1148 | //! The setPos calls only work AFTER the name has been set ?!?!? | ||
1146 | 1149 | | |||
1147 | foreach(KReportDesignerItemBase *item, d->sectionData->copy_list) { | 1150 | foreach(KReportDesignerItemBase *item, d->sectionData.copy_list) { | ||
1148 | KReportItemBase *obj = dynamic_cast<KReportItemBase*>(item); | 1151 | KReportItemBase *obj = dynamic_cast<KReportItemBase*>(item); | ||
1149 | const QString type = obj ? obj->typeName() : QLatin1String("object"); | 1152 | const QString type = obj ? obj->typeName() : QLatin1String("object"); | ||
1150 | //kreportDebug() << type; | 1153 | //kreportDebug() << type; | ||
1151 | KReportDesignerItemBase *ent = item->clone(); | 1154 | KReportDesignerItemBase *ent = item->clone(); | ||
1152 | KReportItemBase *new_obj = dynamic_cast<KReportItemBase*>(ent); | 1155 | KReportItemBase *new_obj = dynamic_cast<KReportItemBase*>(ent); | ||
1153 | if (new_obj) { | 1156 | if (new_obj) { | ||
1154 | new_obj->setEntityName(suggestEntityName(type)); | 1157 | new_obj->setEntityName(suggestEntityName(type)); | ||
1155 | if (activeItem) { | 1158 | if (activeItem) { | ||
1156 | new_obj->setPosition(KReportItemBase::positionFromScene(QPointF(activeItem->x() + 10, activeItem->y() + 10))); | 1159 | new_obj->setPosition(KReportItemBase::positionFromScene(QPointF(activeItem->x() + 10, activeItem->y() + 10))); | ||
1157 | } else { | 1160 | } else { | ||
1158 | new_obj->setPosition(KReportItemBase::positionFromScene(QPointF(0, 0))); | 1161 | new_obj->setPosition(KReportItemBase::positionFromScene(QPointF(0, 0))); | ||
1159 | } | 1162 | } | ||
1160 | changeSet(new_obj->propertySet()); | 1163 | changeSet(new_obj->propertySet()); | ||
1161 | } | 1164 | } | ||
1162 | QGraphicsItem *pasted_ent = dynamic_cast<QGraphicsItem*>(ent); | 1165 | QGraphicsItem *pasted_ent = dynamic_cast<QGraphicsItem*>(ent); | ||
1163 | if (pasted_ent) { | 1166 | if (pasted_ent) { | ||
1164 | pasted_ent->setSelected(true); | 1167 | pasted_ent->setSelected(true); | ||
1165 | canvas->addItem(pasted_ent); | 1168 | canvas->addItem(pasted_ent); | ||
1166 | pasted_ent->show(); | 1169 | pasted_ent->show(); | ||
1167 | d->sectionData->mouseAction = ReportWriterSectionData::MA_Grab; | 1170 | d->sectionData.mouseAction = ReportWriterSectionData::MA_Grab; | ||
1168 | setModified(true); | 1171 | setModified(true); | ||
1169 | } | 1172 | } | ||
1170 | } | 1173 | } | ||
1171 | } | 1174 | } | ||
1172 | } | 1175 | } | ||
1173 | void KReportDesigner::slotRaiseSelected() | 1176 | void KReportDesigner::slotRaiseSelected() | ||
1174 | { | 1177 | { | ||
1175 | dynamic_cast<KReportDesignerSectionScene*>(activeScene())->raiseSelected(); | 1178 | dynamic_cast<KReportDesignerSectionScene*>(activeScene())->raiseSelected(); | ||
Show All 14 Lines | 1192 | { | |||
1190 | if (d->activeScene && d->activeScene != a) | 1193 | if (d->activeScene && d->activeScene != a) | ||
1191 | d->activeScene->clearSelection(); | 1194 | d->activeScene->clearSelection(); | ||
1192 | d->activeScene = a; | 1195 | d->activeScene = a; | ||
1193 | 1196 | | |||
1194 | //Trigger an update so that the last scene redraws its title; | 1197 | //Trigger an update so that the last scene redraws its title; | ||
1195 | update(); | 1198 | update(); | ||
1196 | } | 1199 | } | ||
1197 | 1200 | | |||
1198 | KReportZoomHandler* KReportDesigner::zoomHandler() const | | |||
1199 | { | | |||
1200 | return d->zoom; | | |||
1201 | } | | |||
1202 | | ||||
1203 | QString KReportDesigner::suggestEntityName(const QString &n) const | 1201 | QString KReportDesigner::suggestEntityName(const QString &n) const | ||
1204 | { | 1202 | { | ||
1205 | KReportDesignerSection *sec; | 1203 | KReportDesignerSection *sec; | ||
1206 | int itemCount = 0; | 1204 | int itemCount = 0; | ||
1207 | //Count items in the main sections | 1205 | //Count items in the main sections | ||
1208 | for (int i = 1; i <= KReportSectionData::PageFooterAny; i++) { | 1206 | for (int i = 1; i <= KReportSectionData::PageFooterAny; i++) { | ||
1209 | sec = section((KReportSectionData::Section) i); | 1207 | sec = section((KReportSectionData::Section) i); | ||
1210 | if (sec) { | 1208 | if (sec) { | ||
▲ Show 20 Lines • Show All 323 Lines • Show Last 20 Lines |