Changeset View
Changeset View
Standalone View
Standalone View
src/items/label/KReportItemLabel.cpp
Show All 31 Lines | |||||
32 | 32 | | |||
33 | KReportItemLabel::KReportItemLabel(const QDomNode & element) | 33 | KReportItemLabel::KReportItemLabel(const QDomNode & element) | ||
34 | { | 34 | { | ||
35 | createProperties(); | 35 | createProperties(); | ||
36 | QDomNodeList nl = element.childNodes(); | 36 | QDomNodeList nl = element.childNodes(); | ||
37 | QString n; | 37 | QString n; | ||
38 | QDomNode node; | 38 | QDomNode node; | ||
39 | 39 | | |||
40 | m_name->setValue(element.toElement().attribute(QLatin1String("report:name"))); | 40 | nameProperty()->setValue(element.toElement().attribute(QLatin1String("report:name"))); | ||
41 | m_text->setValue(element.toElement().attribute(QLatin1String("report:caption"))); | 41 | m_text->setValue(element.toElement().attribute(QLatin1String("report:caption"))); | ||
42 | Z = element.toElement().attribute(QLatin1String("report:z-index")).toDouble(); | 42 | setZ(element.toElement().attribute(QLatin1String("report:z-index")).toDouble()); | ||
43 | m_horizontalAlignment->setValue(element.toElement().attribute(QLatin1String("report:horizontal-align"))); | 43 | m_horizontalAlignment->setValue(element.toElement().attribute(QLatin1String("report:horizontal-align"))); | ||
44 | m_verticalAlignment->setValue(element.toElement().attribute(QLatin1String("report:vertical-align"))); | 44 | m_verticalAlignment->setValue(element.toElement().attribute(QLatin1String("report:vertical-align"))); | ||
45 | 45 | | |||
46 | parseReportRect(element.toElement(), &m_pos, &m_size); | 46 | parseReportRect(element.toElement()); | ||
47 | 47 | | |||
48 | for (int i = 0; i < nl.count(); i++) { | 48 | for (int i = 0; i < nl.count(); i++) { | ||
49 | node = nl.item(i); | 49 | node = nl.item(i); | ||
50 | n = node.nodeName(); | 50 | n = node.nodeName(); | ||
51 | 51 | | |||
52 | if (n == QLatin1String("report:text-style")) { | 52 | if (n == QLatin1String("report:text-style")) { | ||
53 | KRTextStyleData ts; | 53 | KRTextStyleData ts; | ||
54 | if (parseReportTextStyleData(node.toElement(), &ts)) { | 54 | if (parseReportTextStyleData(node.toElement(), &ts)) { | ||
Show All 13 Lines | |||||
68 | } else { | 68 | } else { | ||
69 | kreportpluginWarning() << "while parsing label element encountered unknow element: " << n; | 69 | kreportpluginWarning() << "while parsing label element encountered unknow element: " << n; | ||
70 | } | 70 | } | ||
71 | } | 71 | } | ||
72 | } | 72 | } | ||
73 | 73 | | |||
74 | KReportItemLabel::~KReportItemLabel() | 74 | KReportItemLabel::~KReportItemLabel() | ||
75 | { | 75 | { | ||
76 | delete m_set; | | |||
77 | } | 76 | } | ||
78 | 77 | | |||
79 | QString KReportItemLabel::text() const | 78 | QString KReportItemLabel::text() const | ||
80 | { | 79 | { | ||
81 | return m_text->value().toString(); | 80 | return m_text->value().toString(); | ||
82 | } | 81 | } | ||
83 | 82 | | |||
84 | void KReportItemLabel::setText(const QString& t) | 83 | void KReportItemLabel::setText(const QString& t) | ||
85 | { | 84 | { | ||
86 | m_text->setValue(t); | 85 | m_text->setValue(t); | ||
87 | } | 86 | } | ||
88 | 87 | | |||
89 | void KReportItemLabel::createProperties() | 88 | void KReportItemLabel::createProperties() | ||
90 | { | 89 | { | ||
91 | m_set = new KPropertySet; | | |||
92 | | ||||
93 | m_text = new KProperty("caption", QLatin1String("Label"), tr("Caption")); | 90 | m_text = new KProperty("caption", QLatin1String("Label"), tr("Caption")); | ||
94 | QStringList keys, strings; | 91 | QStringList keys, strings; | ||
95 | 92 | | |||
96 | keys << QLatin1String("left") << QLatin1String("center") << QLatin1String("right"); | 93 | keys << QLatin1String("left") << QLatin1String("center") << QLatin1String("right"); | ||
97 | strings << tr("Left") << tr("Center") << tr("Right"); | 94 | strings << tr("Left") << tr("Center") << tr("Right"); | ||
98 | m_horizontalAlignment = new KProperty("horizontal-align", keys, strings, QLatin1String("left"), tr("Horizontal Alignment")); | 95 | m_horizontalAlignment = new KProperty("horizontal-align", keys, strings, QLatin1String("left"), tr("Horizontal Alignment")); | ||
99 | 96 | | |||
100 | keys.clear(); | 97 | keys.clear(); | ||
Show All 11 Lines | |||||
112 | m_backgroundOpacity->setOption("max", 100); | 109 | m_backgroundOpacity->setOption("max", 100); | ||
113 | m_backgroundOpacity->setOption("min", 0); | 110 | m_backgroundOpacity->setOption("min", 0); | ||
114 | m_backgroundOpacity->setOption("unit", QLatin1String("%")); | 111 | m_backgroundOpacity->setOption("unit", QLatin1String("%")); | ||
115 | 112 | | |||
116 | m_lineWeight = new KProperty("line-weight", 1, tr("Line Weight")); | 113 | m_lineWeight = new KProperty("line-weight", 1, tr("Line Weight")); | ||
117 | m_lineColor = new KProperty("line-color", QColor(Qt::black), tr("Line Color")); | 114 | m_lineColor = new KProperty("line-color", QColor(Qt::black), tr("Line Color")); | ||
118 | m_lineStyle = new KProperty("line-style", QPen(Qt::NoPen), tr("Line Style"), tr("Line Style"), KProperty::LineStyle); | 115 | m_lineStyle = new KProperty("line-style", QPen(Qt::NoPen), tr("Line Style"), tr("Line Style"), KProperty::LineStyle); | ||
119 | 116 | | |||
120 | addDefaultProperties(); | 117 | propertySet()->addProperty(m_text); | ||
121 | m_set->addProperty(m_text); | 118 | propertySet()->addProperty(m_horizontalAlignment); | ||
122 | m_set->addProperty(m_horizontalAlignment); | 119 | propertySet()->addProperty(m_verticalAlignment); | ||
123 | m_set->addProperty(m_verticalAlignment); | 120 | propertySet()->addProperty(m_font); | ||
124 | m_set->addProperty(m_font); | 121 | propertySet()->addProperty(m_backgroundColor); | ||
125 | m_set->addProperty(m_backgroundColor); | 122 | propertySet()->addProperty(m_foregroundColor); | ||
126 | m_set->addProperty(m_foregroundColor); | 123 | propertySet()->addProperty(m_backgroundOpacity); | ||
127 | m_set->addProperty(m_backgroundOpacity); | 124 | propertySet()->addProperty(m_lineWeight); | ||
128 | m_set->addProperty(m_lineWeight); | 125 | propertySet()->addProperty(m_lineColor); | ||
129 | m_set->addProperty(m_lineColor); | 126 | propertySet()->addProperty(m_lineStyle); | ||
130 | m_set->addProperty(m_lineStyle); | | |||
131 | } | 127 | } | ||
132 | 128 | | |||
133 | Qt::Alignment KReportItemLabel::textFlags() const | 129 | Qt::Alignment KReportItemLabel::textFlags() const | ||
134 | { | 130 | { | ||
135 | Qt::Alignment align; | 131 | Qt::Alignment align; | ||
136 | QString t; | 132 | QString t; | ||
137 | t = m_horizontalAlignment->value().toString(); | 133 | t = m_horizontalAlignment->value().toString(); | ||
138 | if (t == QLatin1String("center")) | 134 | if (t == QLatin1String("center")) | ||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Line(s) | |||||
180 | 176 | | |||
181 | int KReportItemLabel::renderSimpleData(OROPage *page, OROSection *section, const QPointF &offset, | 177 | int KReportItemLabel::renderSimpleData(OROPage *page, OROSection *section, const QPointF &offset, | ||
182 | const QVariant &data, KReportScriptHandler *script) | 178 | const QVariant &data, KReportScriptHandler *script) | ||
183 | { | 179 | { | ||
184 | Q_UNUSED(data) | 180 | Q_UNUSED(data) | ||
185 | Q_UNUSED(script) | 181 | Q_UNUSED(script) | ||
186 | 182 | | |||
187 | OROTextBox * tb = new OROTextBox(); | 183 | OROTextBox * tb = new OROTextBox(); | ||
188 | tb->setPosition(m_pos.toScene() + offset); | 184 | tb->setPosition(scenePosition(position()) + offset); | ||
189 | tb->setSize(m_size.toScene()); | 185 | tb->setSize(sceneSize(size())); | ||
190 | tb->setFont(font()); | 186 | tb->setFont(font()); | ||
191 | tb->setText(text()); | 187 | tb->setText(text()); | ||
192 | tb->setFlags(textFlags()); | 188 | tb->setFlags(textFlags()); | ||
193 | tb->setTextStyle(textStyle()); | 189 | tb->setTextStyle(textStyle()); | ||
194 | tb->setLineStyle(lineStyle()); | 190 | tb->setLineStyle(lineStyle()); | ||
195 | 191 | | |||
196 | if (page) { | 192 | if (page) { | ||
197 | page->addPrimitive(tb); | 193 | page->addPrimitive(tb); | ||
198 | } | 194 | } | ||
199 | 195 | | |||
200 | if (section) { | 196 | if (section) { | ||
201 | OROPrimitive *clone = tb->clone(); | 197 | OROPrimitive *clone = tb->clone(); | ||
202 | clone->setPosition(m_pos.toScene()); | 198 | clone->setPosition(scenePosition(position())); | ||
203 | section->addPrimitive(clone); | 199 | section->addPrimitive(clone); | ||
204 | } | 200 | } | ||
205 | 201 | | |||
206 | if (!page) { | 202 | if (!page) { | ||
207 | delete tb; | 203 | delete tb; | ||
208 | } | 204 | } | ||
209 | 205 | | |||
210 | return 0; //Item doesn't stretch the section height | 206 | return 0; //Item doesn't stretch the section height | ||
211 | } | 207 | } | ||
212 | 208 | |