Changeset View
Changeset View
Standalone View
Standalone View
src/wrtembed/KReportDesigner.cpp
Show All 12 Lines | |||||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | * Lesser General Public License for more details. | 14 | * Lesser General Public License for more details. | ||
15 | * | 15 | * | ||
16 | * You should have received a copy of the GNU Lesser General Public | 16 | * You should have received a copy of the GNU Lesser General Public | ||
17 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | 17 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | #include "KReportDesigner.h" | 20 | #include "KReportDesigner.h" | ||
21 | #include "KReportDesign_p.h" | ||||
22 | #include "KReportDesignerItemLine.h" | ||||
21 | #include "KReportDesignerSection.h" | 23 | #include "KReportDesignerSection.h" | ||
24 | #include "KReportDesignerSectionDetail.h" | ||||
25 | #include "KReportDesignerSectionDetailGroup.h" | ||||
22 | #include "KReportDesignerSectionScene.h" | 26 | #include "KReportDesignerSectionScene.h" | ||
23 | #include "KReportDesignerSectionView.h" | 27 | #include "KReportDesignerSectionView.h" | ||
24 | #include "KReportDesignerSectionDetailGroup.h" | | |||
25 | #include "KReportPropertiesButton.h" | | |||
26 | #include "KReportSectionEditor.h" | | |||
27 | #include "KReportDesignerSectionDetail.h" | | |||
28 | #include "KReportDesignerItemLine.h" | | |||
29 | #include "KReportRuler_p.h" | | |||
30 | #include "KReportZoomHandler_p.h" | | |||
31 | #include "KReportPageSize.h" | 28 | #include "KReportPageSize.h" | ||
32 | #include "KReportUtils_p.h" | | |||
33 | #include "KReportUtils.h" | | |||
34 | #include "KReportPluginInterface.h" | 29 | #include "KReportPluginInterface.h" | ||
35 | #include "KReportPluginManager.h" | 30 | #include "KReportPluginManager.h" | ||
36 | #include "KReportSection.h" | | |||
37 | #include "KReportPluginMetaData.h" | 31 | #include "KReportPluginMetaData.h" | ||
32 | #include "KReportPropertiesButton.h" | ||||
33 | #include "KReportRuler_p.h" | ||||
34 | #include "KReportSection.h" | ||||
35 | #include "KReportSectionEditor.h" | ||||
36 | #include "KReportUtils.h" | ||||
37 | #include "KReportUtils_p.h" | ||||
38 | #include "KReportZoomHandler_p.h" | ||||
38 | #include "kreport_debug.h" | 39 | #include "kreport_debug.h" | ||
39 | #ifdef KREPORT_SCRIPTING | 40 | #ifdef KREPORT_SCRIPTING | ||
40 | #include "KReportScriptSource.h" | 41 | #include "KReportScriptSource.h" | ||
41 | #endif | 42 | #endif | ||
42 | 43 | | |||
43 | #include <KStandardShortcut> | 44 | #include <KStandardShortcut> | ||
44 | #include <KStandardGuiItem> | 45 | #include <KStandardGuiItem> | ||
45 | #include <QLayout> | 46 | #include <QLayout> | ||
▲ Show 20 Lines • Show All 162 Lines • ▼ Show 20 Line(s) | 194 | { | |||
208 | d->vboxlayout->setMargin(0); | 209 | d->vboxlayout->setMargin(0); | ||
209 | d->vboxlayout->setSizeConstraint(QLayout::SetFixedSize); | 210 | d->vboxlayout->setSizeConstraint(QLayout::SetFixedSize); | ||
210 | 211 | | |||
211 | //Create nice rulers | 212 | //Create nice rulers | ||
212 | d->hruler = new KReportRuler(this, Qt::Horizontal, d->zoomHandler); | 213 | d->hruler = new KReportRuler(this, Qt::Horizontal, d->zoomHandler); | ||
213 | 214 | | |||
214 | d->pageButton = new KReportPropertiesButton(this); | 215 | d->pageButton = new KReportPropertiesButton(this); | ||
215 | 216 | | |||
216 | d->hruler->setUnit(KReportUnit(KReportUnit::Centimeter)); | | |||
217 | | ||||
218 | d->grid->addWidget(d->pageButton, 0, 0); | 217 | d->grid->addWidget(d->pageButton, 0, 0); | ||
219 | d->grid->addWidget(d->hruler, 0, 1); | 218 | d->grid->addWidget(d->hruler, 0, 1); | ||
220 | d->grid->addLayout(d->vboxlayout, 1, 0, 1, 2); | 219 | d->grid->addLayout(d->vboxlayout, 1, 0, 1, 2); | ||
221 | 220 | | |||
222 | d->pageButton->setMaximumSize(QSize(19, 22)); | 221 | d->pageButton->setMaximumSize(QSize(19, 22)); | ||
223 | d->pageButton->setMinimumSize(QSize(19, 22)); | 222 | d->pageButton->setMinimumSize(QSize(19, 22)); | ||
224 | 223 | | |||
225 | d->detail = new KReportDesignerSectionDetail(this); | 224 | d->detail = new KReportDesignerSectionDetail(this); | ||
▲ Show 20 Lines • Show All 495 Lines • ▼ Show 20 Line(s) | 712 | { | |||
721 | d->title = new KProperty("title", QLatin1String("Report"), tr("Title"), tr("Report Title")); | 720 | d->title = new KProperty("title", QLatin1String("Report"), tr("Title"), tr("Report Title")); | ||
722 | 721 | | |||
723 | keys.clear(); | 722 | keys.clear(); | ||
724 | keys = KReportPageSize::pageFormatKeys(); | 723 | keys = KReportPageSize::pageFormatKeys(); | ||
725 | strings = KReportPageSize::pageFormatNames(); | 724 | strings = KReportPageSize::pageFormatNames(); | ||
726 | QString defaultKey = KReportPageSize::pageSizeKey(KReportPageSize::defaultSize()); | 725 | QString defaultKey = KReportPageSize::pageSizeKey(KReportPageSize::defaultSize()); | ||
727 | d->pageSize = new KProperty("page-size", keys, strings, defaultKey, tr("Page Size")); | 726 | d->pageSize = new KProperty("page-size", keys, strings, defaultKey, tr("Page Size")); | ||
728 | 727 | | |||
729 | keys.clear(); strings.clear(); | 728 | keys.clear(); | ||
729 | strings.clear(); | ||||
730 | keys << QLatin1String("portrait") << QLatin1String("landscape"); | 730 | keys << QLatin1String("portrait") << QLatin1String("landscape"); | ||
731 | strings << tr("Portrait") << tr("Landscape"); | 731 | strings << tr("Portrait") << tr("Landscape"); | ||
732 | d->orientation = new KProperty("print-orientation", keys, strings, QLatin1String("portrait"), tr("Page Orientation")); | 732 | d->orientation = new KProperty("print-orientation", keys, strings, QLatin1String("portrait"), tr("Page Orientation")); | ||
733 | 733 | | |||
734 | keys.clear(); strings.clear(); | 734 | QList<KReportUnit::Type> types(KReportUnit::allTypes()); | ||
735 | 735 | types.removeOne(KReportUnit::Type::Pixel); | |||
736 | strings = KReportUnit::listOfUnitNameForUi(KReportUnit::HidePixel); | 736 | keys = KReportUnit::symbols(types); | ||
737 | QString unit; | 737 | strings = KReportUnit::descriptions(types); | ||
738 | foreach(const QString &un, strings) { | | |||
739 | unit = un.mid(un.indexOf(QLatin1String("(")) + 1, 2); | | |||
740 | keys << unit; | | |||
741 | } | | |||
742 | | ||||
743 | d->unit = new KProperty("page-unit", keys, strings, QLatin1String("cm"), tr("Page Unit")); | 738 | d->unit = new KProperty("page-unit", keys, strings, QLatin1String("cm"), tr("Page Unit")); | ||
744 | 739 | | |||
745 | d->showGrid = new KProperty("grid-visible", true, tr("Show Grid")); | 740 | d->showGrid = new KProperty("grid-visible", true, tr("Show Grid")); | ||
746 | d->gridSnap = new KProperty("grid-snap", true, tr("Snap to Grid")); | 741 | d->gridSnap = new KProperty("grid-snap", true, tr("Snap to Grid")); | ||
747 | d->gridDivisions = new KProperty("grid-divisions", 4, tr("Grid Divisions")); | 742 | d->gridDivisions = new KProperty("grid-divisions", 4, tr("Grid Divisions")); | ||
748 | 743 | | |||
749 | d->leftMargin = new KProperty("margin-left", KReportUnit(KReportUnit::Centimeter).fromUserValue(1.0), | 744 | d->leftMargin = new KProperty("margin-left", KReportUnit(KReportUnit::Type::Centimeter).fromUserValue(1.0), | ||
750 | tr("Left Margin"), tr("Left Margin"), KProperty::Double); | 745 | tr("Left Margin"), tr("Left Margin"), KProperty::Double); | ||
751 | d->rightMargin = new KProperty("margin-right", KReportUnit(KReportUnit::Centimeter).fromUserValue(1.0), | 746 | d->rightMargin = new KProperty("margin-right", KReportUnit(KReportUnit::Type::Centimeter).fromUserValue(1.0), | ||
752 | tr("Right Margin"), tr("Right Margin"), KProperty::Double); | 747 | tr("Right Margin"), tr("Right Margin"), KProperty::Double); | ||
753 | d->topMargin = new KProperty("margin-top", KReportUnit(KReportUnit::Centimeter).fromUserValue(1.0), | 748 | d->topMargin = new KProperty("margin-top", KReportUnit(KReportUnit::Type::Centimeter).fromUserValue(1.0), | ||
754 | tr("Top Margin"), tr("Top Margin"), KProperty::Double); | 749 | tr("Top Margin"), tr("Top Margin"), KProperty::Double); | ||
755 | d->bottomMargin = new KProperty("margin-bottom", KReportUnit(KReportUnit::Centimeter).fromUserValue(1.0), | 750 | d->bottomMargin = new KProperty("margin-bottom", KReportUnit(KReportUnit::Type::Centimeter).fromUserValue(1.0), | ||
756 | tr("Bottom Margin"), tr("Bottom Margin"), KProperty::Double); | 751 | tr("Bottom Margin"), tr("Bottom Margin"), KProperty::Double); | ||
757 | d->leftMargin->setOption("unit", QLatin1String("cm")); | 752 | d->leftMargin->setOption("unit", QLatin1String("cm")); | ||
758 | d->rightMargin->setOption("unit", QLatin1String("cm")); | 753 | d->rightMargin->setOption("unit", QLatin1String("cm")); | ||
759 | d->topMargin->setOption("unit", QLatin1String("cm")); | 754 | d->topMargin->setOption("unit", QLatin1String("cm")); | ||
760 | d->bottomMargin->setOption("unit", QLatin1String("cm")); | 755 | d->bottomMargin->setOption("unit", QLatin1String("cm")); | ||
761 | 756 | | |||
762 | d->set.addProperty(d->title); | 757 | d->set.addProperty(d->title); | ||
763 | d->set.addProperty(d->pageSize); | 758 | d->set.addProperty(d->pageSize); | ||
▲ Show 20 Lines • Show All 128 Lines • ▼ Show 20 Line(s) | |||||
892 | void KReportDesigner::deleteDetail() | 887 | void KReportDesigner::deleteDetail() | ||
893 | { | 888 | { | ||
894 | delete d->detail; | 889 | delete d->detail; | ||
895 | d->detail = nullptr; | 890 | d->detail = nullptr; | ||
896 | } | 891 | } | ||
897 | 892 | | |||
898 | KReportUnit KReportDesigner::pageUnit() const | 893 | KReportUnit KReportDesigner::pageUnit() const | ||
899 | { | 894 | { | ||
900 | QString u; | 895 | const QString symbol = d->unit->value().toString(); | ||
901 | bool found; | 896 | KReportUnit unit(KReportUnit::symbolToType(symbol)); | ||
902 | 897 | return unit.isValid() ? unit : DEFAULT_UNIT; | |||
903 | u = d->unit->value().toString(); | | |||
904 | | ||||
905 | KReportUnit unit = KReportUnit::fromSymbol(u, &found); | | |||
906 | if (!found) { | | |||
907 | unit = KReportUnit(KReportUnit::Centimeter); | | |||
908 | } | | |||
909 | | ||||
910 | return unit; | | |||
911 | } | 898 | } | ||
912 | 899 | | |||
913 | void KReportDesigner::setGridOptions(bool vis, int div) | 900 | void KReportDesigner::setGridOptions(bool vis, int div) | ||
914 | { | 901 | { | ||
915 | d->showGrid->setValue(QVariant(vis)); | 902 | d->showGrid->setValue(QVariant(vis)); | ||
916 | d->gridDivisions->setValue(div); | 903 | d->gridDivisions->setValue(div); | ||
917 | } | 904 | } | ||
918 | 905 | | |||
▲ Show 20 Lines • Show All 624 Lines • Show Last 20 Lines |