Changeset View
Changeset View
Standalone View
Standalone View
src/items/label/KReportLabelPlugin.cpp
Show First 20 Lines • Show All 64 Lines • ▼ Show 20 Line(s) | |||||
65 | } | 65 | } | ||
66 | 66 | | |||
67 | bool KReportLabelPlugin::loadElement(KReportElement *el, const QDomElement &dom, KReportDesignReadingStatus *status) | 67 | bool KReportLabelPlugin::loadElement(KReportElement *el, const QDomElement &dom, KReportDesignReadingStatus *status) | ||
68 | { | 68 | { | ||
69 | if (!KReportPluginInterface::loadElement(el, dom, status)) { | 69 | if (!KReportPluginInterface::loadElement(el, dom, status)) { | ||
70 | return false; | 70 | return false; | ||
71 | } | 71 | } | ||
72 | KReportLabelElement label(*el); | 72 | KReportLabelElement label(*el); | ||
73 | label.setText(KReportUtils::attr(dom, "report:caption", QString())); | 73 | label.setText(KReportUtils::attr(dom, QLatin1String("report:caption"), QString())); | ||
74 | QString s = KReportUtils::attr(dom, "report:horizontal-align", QString()); | 74 | QString s = KReportUtils::attr(dom, QLatin1String("report:horizontal-align"), QString()); | ||
75 | Qt::Alignment alignment = KReportUtils::horizontalAlignment(s, label.alignment() & Qt::AlignHorizontal_Mask); | 75 | Qt::Alignment alignment = KReportUtils::horizontalAlignment( | ||
76 | s = KReportUtils::attr(dom, "report:vertical-align", QString()); | 76 | s, label.alignment() & Qt::AlignHorizontal_Mask); | ||
77 | s = KReportUtils::attr(dom, QLatin1String("report:vertical-align"), QString()); | ||||
77 | alignment |= KReportUtils::verticalAlignment(s, label.alignment() & Qt::AlignVertical_Mask); | 78 | alignment |= KReportUtils::verticalAlignment(s, label.alignment() & Qt::AlignVertical_Mask); | ||
78 | label.setAlignment(alignment); | 79 | label.setAlignment(alignment); | ||
79 | 80 | | |||
80 | const QDomElement textStyleDom = dom.firstChildElement(QLatin1String("report:text-style")); | 81 | const QDomElement textStyleDom = dom.firstChildElement(QLatin1String("report:text-style")); | ||
81 | QFont font(label.font()); | 82 | QFont font(label.font()); | ||
82 | KReportUtils::readFontAttributes(textStyleDom, &font); | 83 | KReportUtils::readFontAttributes(textStyleDom, &font); | ||
83 | label.setFont(font); | 84 | label.setFont(font); | ||
84 | 85 | | |||
85 | const QDomElement lineStyleDom = dom.firstChildElement(QLatin1String("report:line-style")); | 86 | const QDomElement lineStyleDom | ||
87 | = dom.firstChildElement(QLatin1String("report:line-style")); | ||||
86 | KReportLineStyle borderStyle(label.borderStyle()); | 88 | KReportLineStyle borderStyle(label.borderStyle()); | ||
87 | s = KReportUtils::attr(lineStyleDom, "report:line-style", QString()); | 89 | s = KReportUtils::attr(lineStyleDom, QLatin1String("report:line-style"), QString()); | ||
88 | borderStyle.setPenStyle(KReportUtils::penStyle(s, borderStyle.penStyle())); | 90 | borderStyle.setPenStyle(KReportUtils::penStyle(s, borderStyle.penStyle())); | ||
89 | borderStyle.setColor(KReportUtils::attr(lineStyleDom, "report:line-color", borderStyle.color())); | 91 | borderStyle.setColor(KReportUtils::attr( | ||
92 | lineStyleDom, QLatin1String("report:line-color"), borderStyle.color())); | ||||
90 | // border-line-width could be better name but it's too late... | 93 | // border-line-width could be better name but it's too late... | ||
91 | borderStyle.setWeight(KReportUtils::attr(lineStyleDom, "report:line-weight", borderStyle.weight())); | 94 | borderStyle.setWeight(KReportUtils::attr( | ||
95 | lineStyleDom, QLatin1String("report:line-weight"), borderStyle.weight())); | ||||
92 | label.setBorderStyle(borderStyle); | 96 | label.setBorderStyle(borderStyle); | ||
93 | return true; | 97 | return true; | ||
94 | } | 98 | } | ||
95 | 99 | | |||
96 | #ifdef KREPORT_SCRIPTING | 100 | #ifdef KREPORT_SCRIPTING | ||
97 | QObject* KReportLabelPlugin::createScriptInstance(KReportItemBase *item) | 101 | QObject* KReportLabelPlugin::createScriptInstance(KReportItemBase *item) | ||
98 | { | 102 | { | ||
99 | KReportItemLabel *label = dynamic_cast<KReportItemLabel*>(item); | 103 | KReportItemLabel *label = dynamic_cast<KReportItemLabel*>(item); | ||
100 | if (label) { | 104 | if (label) { | ||
101 | return new Scripting::Label(label); | 105 | return new Scripting::Label(label); | ||
102 | } | 106 | } | ||
103 | return nullptr; | 107 | return nullptr; | ||
104 | } | 108 | } | ||
105 | #endif | 109 | #endif | ||
106 | 110 | | |||
107 | #include "KReportLabelPlugin.moc" | 111 | #include "KReportLabelPlugin.moc" |