Changeset View
Changeset View
Standalone View
Standalone View
src/items/field/KReportItemField.cpp
Show All 35 Lines | |||||
36 | 36 | | |||
37 | KReportItemField::KReportItemField(const QDomNode & element) | 37 | KReportItemField::KReportItemField(const QDomNode & element) | ||
38 | { | 38 | { | ||
39 | createProperties(); | 39 | createProperties(); | ||
40 | QDomNodeList nl = element.childNodes(); | 40 | QDomNodeList nl = element.childNodes(); | ||
41 | QString n; | 41 | QString n; | ||
42 | QDomNode node; | 42 | QDomNode node; | ||
43 | 43 | | |||
44 | m_name->setValue(element.toElement().attribute(QLatin1String("report:name"))); | 44 | nameProperty()->setValue(element.toElement().attribute(QLatin1String("report:name"))); | ||
45 | m_controlSource->setValue(element.toElement().attribute(QLatin1String("report:item-data-source"))); | 45 | m_controlSource->setValue(element.toElement().attribute(QLatin1String("report:item-data-source"))); | ||
46 | m_itemValue->setValue(element.toElement().attribute(QLatin1String("report:value"))); | 46 | m_itemValue->setValue(element.toElement().attribute(QLatin1String("report:value"))); | ||
47 | Z = element.toElement().attribute(QLatin1String("report:z-index")).toDouble(); | 47 | setZ(element.toElement().attribute(QLatin1String("report:z-index")).toDouble()); | ||
48 | m_horizontalAlignment->setValue(element.toElement().attribute(QLatin1String("report:horizontal-align"))); | 48 | m_horizontalAlignment->setValue(element.toElement().attribute(QLatin1String("report:horizontal-align"))); | ||
49 | m_verticalAlignment->setValue(element.toElement().attribute(QLatin1String("report:vertical-align"))); | 49 | m_verticalAlignment->setValue(element.toElement().attribute(QLatin1String("report:vertical-align"))); | ||
50 | 50 | | |||
51 | m_canGrow->setValue(element.toElement().attribute(QLatin1String("report:can-grow"))); | 51 | m_canGrow->setValue(element.toElement().attribute(QLatin1String("report:can-grow"))); | ||
52 | m_wordWrap->setValue(element.toElement().attribute(QLatin1String("report:word-wrap"))); | 52 | m_wordWrap->setValue(element.toElement().attribute(QLatin1String("report:word-wrap"))); | ||
53 | 53 | | |||
54 | parseReportRect(element.toElement(), &m_pos, &m_size); | 54 | parseReportRect(element.toElement()); | ||
55 | 55 | | |||
56 | for (int i = 0; i < nl.count(); i++) { | 56 | for (int i = 0; i < nl.count(); i++) { | ||
57 | node = nl.item(i); | 57 | node = nl.item(i); | ||
58 | n = node.nodeName(); | 58 | n = node.nodeName(); | ||
59 | 59 | | |||
60 | if (n == QLatin1String("report:text-style")) { | 60 | if (n == QLatin1String("report:text-style")) { | ||
61 | KRTextStyleData ts; | 61 | KRTextStyleData ts; | ||
62 | if (parseReportTextStyleData(node.toElement(), &ts)) { | 62 | if (parseReportTextStyleData(node.toElement(), &ts)) { | ||
Show All 13 Lines | |||||
76 | } else { | 76 | } else { | ||
77 | kreportpluginWarning() << "while parsing field element encountered unknow element: " << n; | 77 | kreportpluginWarning() << "while parsing field element encountered unknow element: " << n; | ||
78 | } | 78 | } | ||
79 | } | 79 | } | ||
80 | } | 80 | } | ||
81 | 81 | | |||
82 | KReportItemField::~KReportItemField() | 82 | KReportItemField::~KReportItemField() | ||
83 | { | 83 | { | ||
84 | delete m_set; | | |||
85 | } | 84 | } | ||
86 | 85 | | |||
87 | void KReportItemField::createProperties() | 86 | void KReportItemField::createProperties() | ||
88 | { | 87 | { | ||
89 | m_set = new KPropertySet; | | |||
90 | | ||||
91 | QStringList keys, strings; | 88 | QStringList keys, strings; | ||
92 | 89 | | |||
93 | m_controlSource = new KProperty("item-data-source", QStringList(), QStringList(), QString(), tr("Data Source")); | 90 | m_controlSource = new KProperty("item-data-source", QStringList(), QStringList(), QString(), tr("Data Source")); | ||
94 | m_controlSource->setOption("extraValueAllowed", QLatin1String("true")); | 91 | m_controlSource->setOption("extraValueAllowed", QLatin1String("true")); | ||
95 | 92 | | |||
96 | m_itemValue = new KProperty("value", QString(), tr("Value"), tr("Value used if not bound to a field")); | 93 | m_itemValue = new KProperty("value", QString(), tr("Value"), tr("Value used if not bound to a field")); | ||
97 | 94 | | |||
98 | keys << QLatin1String("left") << QLatin1String("center") << QLatin1String("right"); | 95 | keys << QLatin1String("left") << QLatin1String("center") << QLatin1String("right"); | ||
Show All 26 Lines | |||||
125 | //! @todo I do not think we need these | 122 | //! @todo I do not think we need these | ||
126 | #if 0 //Field Totals | 123 | #if 0 //Field Totals | ||
127 | m_trackTotal = new KProperty("trackTotal", QVariant(false), futureI18n("Track Total")); | 124 | m_trackTotal = new KProperty("trackTotal", QVariant(false), futureI18n("Track Total")); | ||
128 | m_trackBuiltinFormat = new KProperty("trackBuiltinFormat", QVariant(false), futureI18n("Track Builtin Format")); | 125 | m_trackBuiltinFormat = new KProperty("trackBuiltinFormat", QVariant(false), futureI18n("Track Builtin Format")); | ||
129 | _useSubTotal = new KProperty("useSubTotal", QVariant(false), futureI18n("Use Sub Total"_)); | 126 | _useSubTotal = new KProperty("useSubTotal", QVariant(false), futureI18n("Use Sub Total"_)); | ||
130 | _trackTotalFormat = new KProperty("trackTotalFormat", QString(), futureI18n("Track Total Format")); | 127 | _trackTotalFormat = new KProperty("trackTotalFormat", QString(), futureI18n("Track Total Format")); | ||
131 | #endif | 128 | #endif | ||
132 | 129 | | |||
133 | addDefaultProperties(); | 130 | propertySet()->addProperty(m_controlSource); | ||
134 | m_set->addProperty(m_controlSource); | 131 | propertySet()->addProperty(m_itemValue); | ||
135 | m_set->addProperty(m_itemValue); | 132 | propertySet()->addProperty(m_horizontalAlignment); | ||
136 | m_set->addProperty(m_horizontalAlignment); | 133 | propertySet()->addProperty(m_verticalAlignment); | ||
137 | m_set->addProperty(m_verticalAlignment); | 134 | propertySet()->addProperty(m_font); | ||
138 | m_set->addProperty(m_font); | 135 | propertySet()->addProperty(m_backgroundColor); | ||
139 | m_set->addProperty(m_backgroundColor); | 136 | propertySet()->addProperty(m_foregroundColor); | ||
140 | m_set->addProperty(m_foregroundColor); | 137 | propertySet()->addProperty(m_backgroundOpacity); | ||
141 | m_set->addProperty(m_backgroundOpacity); | 138 | propertySet()->addProperty(m_lineWeight); | ||
142 | m_set->addProperty(m_lineWeight); | 139 | propertySet()->addProperty(m_lineColor); | ||
143 | m_set->addProperty(m_lineColor); | 140 | propertySet()->addProperty(m_lineStyle); | ||
144 | m_set->addProperty(m_lineStyle); | 141 | propertySet()->addProperty(m_wordWrap); | ||
145 | m_set->addProperty(m_wordWrap); | 142 | propertySet()->addProperty(m_canGrow); | ||
146 | m_set->addProperty(m_canGrow); | | |||
147 | 143 | | |||
148 | //_set->addProperty ( _trackTotal ); | 144 | //_set->addProperty ( _trackTotal ); | ||
149 | //_set->addProperty ( _trackBuiltinFormat ); | 145 | //_set->addProperty ( _trackBuiltinFormat ); | ||
150 | //_set->addProperty ( _useSubTotal ); | 146 | //_set->addProperty ( _useSubTotal ); | ||
151 | //_set->addProperty ( _trackTotalFormat ); | 147 | //_set->addProperty ( _trackTotalFormat ); | ||
152 | } | 148 | } | ||
153 | 149 | | |||
154 | int KReportItemField::textFlags() const | 150 | int KReportItemField::textFlags() const | ||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Line(s) | |||||
214 | { | 210 | { | ||
215 | return QLatin1String("field"); | 211 | return QLatin1String("field"); | ||
216 | } | 212 | } | ||
217 | 213 | | |||
218 | int KReportItemField::renderSimpleData(OROPage *page, OROSection *section, const QPointF &offset, | 214 | int KReportItemField::renderSimpleData(OROPage *page, OROSection *section, const QPointF &offset, | ||
219 | const QVariant &data, KReportScriptHandler *script) | 215 | const QVariant &data, KReportScriptHandler *script) | ||
220 | { | 216 | { | ||
221 | OROTextBox * tb = new OROTextBox(); | 217 | OROTextBox * tb = new OROTextBox(); | ||
222 | tb->setPosition(m_pos.toScene() + offset); | 218 | tb->setPosition(scenePosition(position()) + offset); | ||
223 | tb->setSize(m_size.toScene()); | 219 | tb->setSize(sceneSize(size())); | ||
224 | tb->setFont(font()); | 220 | tb->setFont(font()); | ||
225 | tb->setFlags(textFlags()); | 221 | tb->setFlags(textFlags()); | ||
226 | tb->setTextStyle(textStyle()); | 222 | tb->setTextStyle(textStyle()); | ||
227 | tb->setLineStyle(lineStyle()); | 223 | tb->setLineStyle(lineStyle()); | ||
228 | tb->setCanGrow(m_canGrow->value().toBool()); | 224 | tb->setCanGrow(m_canGrow->value().toBool()); | ||
229 | tb->setWordWrap(m_wordWrap->value().toBool()); | 225 | tb->setWordWrap(m_wordWrap->value().toBool()); | ||
230 | 226 | | |||
231 | QString str; | 227 | QString str; | ||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Line(s) | 243 | #endif | |||
274 | } | 270 | } | ||
275 | 271 | | |||
276 | if (page) { | 272 | if (page) { | ||
277 | page->addPrimitive(tb); | 273 | page->addPrimitive(tb); | ||
278 | } | 274 | } | ||
279 | 275 | | |||
280 | if (section) { | 276 | if (section) { | ||
281 | OROPrimitive *clone = tb->clone(); | 277 | OROPrimitive *clone = tb->clone(); | ||
282 | clone->setPosition(m_pos.toScene()); | 278 | clone->setPosition(scenePosition(position())); | ||
283 | section->addPrimitive(clone); | 279 | section->addPrimitive(clone); | ||
284 | } | 280 | } | ||
285 | int height = m_pos.toScene().y() + tb->size().height(); | 281 | int height = scenePosition(position()).y() + tb->size().height(); | ||
286 | //If there is no page to add the item to, delete it now because it wont be deleted later | 282 | //If there is no page to add the item to, delete it now because it wont be deleted later | ||
287 | if (!page) { | 283 | if (!page) { | ||
288 | delete tb; | 284 | delete tb; | ||
289 | } | 285 | } | ||
290 | return height; | 286 | return height; | ||
291 | } | 287 | } |