Changeset View
Changeset View
Standalone View
Standalone View
src/items/check/KReportItemCheck.cpp
Show All 33 Lines | |||||
34 | 34 | | |||
35 | KReportItemCheckBox::KReportItemCheckBox(const QDomNode &element) | 35 | KReportItemCheckBox::KReportItemCheckBox(const QDomNode &element) | ||
36 | { | 36 | { | ||
37 | createProperties(); | 37 | createProperties(); | ||
38 | QDomNodeList nl = element.childNodes(); | 38 | QDomNodeList nl = element.childNodes(); | ||
39 | QString n; | 39 | QString n; | ||
40 | QDomNode node; | 40 | QDomNode node; | ||
41 | 41 | | |||
42 | m_name->setValue(element.toElement().attribute(QLatin1String("report:name"))); | 42 | nameProperty()->setValue(element.toElement().attribute(QLatin1String("report:name"))); | ||
43 | m_controlSource->setValue(element.toElement().attribute(QLatin1String("report:item-data-source"))); | 43 | m_controlSource->setValue(element.toElement().attribute(QLatin1String("report:item-data-source"))); | ||
44 | Z = element.toElement().attribute(QLatin1String("report:z-index")).toDouble(); | 44 | setZ(element.toElement().attribute(QLatin1String("report:z-index")).toDouble()); | ||
45 | m_foregroundColor->setValue(QColor(element.toElement().attribute(QLatin1String("fo:foreground-color")))); | 45 | m_foregroundColor->setValue(QColor(element.toElement().attribute(QLatin1String("fo:foreground-color")))); | ||
46 | m_checkStyle->setValue(element.toElement().attribute(QLatin1String("report:check-style"))); | 46 | m_checkStyle->setValue(element.toElement().attribute(QLatin1String("report:check-style"))); | ||
47 | m_staticValue->setValue(QVariant(element.toElement().attribute(QLatin1String("report:value"))).toBool()); | 47 | m_staticValue->setValue(QVariant(element.toElement().attribute(QLatin1String("report:value"))).toBool()); | ||
48 | 48 | | |||
49 | parseReportRect(element.toElement(), &m_pos, &m_size); | 49 | parseReportRect(element.toElement()); | ||
50 | 50 | | |||
51 | for (int i = 0; i < nl.count(); i++) { | 51 | for (int i = 0; i < nl.count(); i++) { | ||
52 | node = nl.item(i); | 52 | node = nl.item(i); | ||
53 | n = node.nodeName(); | 53 | n = node.nodeName(); | ||
54 | 54 | | |||
55 | if (n == QLatin1String("report:line-style")) { | 55 | if (n == QLatin1String("report:line-style")) { | ||
56 | KReportLineStyle ls; | 56 | KReportLineStyle ls; | ||
57 | if (parseReportLineStyleData(node.toElement(), &ls)) { | 57 | if (parseReportLineStyleData(node.toElement(), &ls)) { | ||
58 | m_lineWeight->setValue(ls.width()); | 58 | m_lineWeight->setValue(ls.width()); | ||
59 | m_lineColor->setValue(ls.color()); | 59 | m_lineColor->setValue(ls.color()); | ||
60 | m_lineStyle->setValue(QPen(ls.penStyle())); | 60 | m_lineStyle->setValue(QPen(ls.penStyle())); | ||
61 | } | 61 | } | ||
62 | } else { | 62 | } else { | ||
63 | kreportpluginWarning() << "while parsing check element encountered unknow element: " << n; | 63 | kreportpluginWarning() << "while parsing check element encountered unknow element: " << n; | ||
64 | } | 64 | } | ||
65 | } | 65 | } | ||
66 | 66 | | |||
67 | } | 67 | } | ||
68 | 68 | | |||
69 | KReportItemCheckBox::~KReportItemCheckBox() | 69 | KReportItemCheckBox::~KReportItemCheckBox() | ||
70 | { | 70 | { | ||
71 | delete m_set; | | |||
72 | } | 71 | } | ||
73 | 72 | | |||
74 | void KReportItemCheckBox::createProperties() | 73 | void KReportItemCheckBox::createProperties() | ||
75 | { | 74 | { | ||
76 | m_set = new KPropertySet; | | |||
77 | | ||||
78 | QStringList keys, strings; | 75 | QStringList keys, strings; | ||
79 | 76 | | |||
80 | keys << QLatin1String("Cross") << QLatin1String("Tick") << QLatin1String("Dot"); | 77 | keys << QLatin1String("Cross") << QLatin1String("Tick") << QLatin1String("Dot"); | ||
81 | strings << tr("Cross") << tr("Tick") << tr("Dot"); | 78 | strings << tr("Cross") << tr("Tick") << tr("Dot"); | ||
82 | m_checkStyle = new KProperty("check-style", keys, strings, QLatin1String("Cross"), tr("Style")); | 79 | m_checkStyle = new KProperty("check-style", keys, strings, QLatin1String("Cross"), tr("Style")); | ||
83 | 80 | | |||
84 | m_controlSource = new KProperty("item-data-source", QStringList(), QStringList(), QString(), tr("Data Source")); | 81 | m_controlSource = new KProperty("item-data-source", QStringList(), QStringList(), QString(), tr("Data Source")); | ||
85 | m_controlSource->setOption("extraValueAllowed", QLatin1String("true")); | 82 | m_controlSource->setOption("extraValueAllowed", QLatin1String("true")); | ||
86 | 83 | | |||
87 | m_foregroundColor = new KProperty("foreground-color", QColor(Qt::black), tr("Foreground Color")); | 84 | m_foregroundColor = new KProperty("foreground-color", QColor(Qt::black), tr("Foreground Color")); | ||
88 | 85 | | |||
89 | m_lineWeight = new KProperty("line-weight", 1, tr("Line Weight")); | 86 | m_lineWeight = new KProperty("line-weight", 1, tr("Line Weight")); | ||
90 | m_lineColor = new KProperty("line-color", QColor(Qt::black), tr("Line Color")); | 87 | m_lineColor = new KProperty("line-color", QColor(Qt::black), tr("Line Color")); | ||
91 | m_lineStyle = new KProperty("line-style", QPen(Qt::SolidLine), tr("Line Style"), tr("Line Style"), KProperty::LineStyle); | 88 | m_lineStyle = new KProperty("line-style", QPen(Qt::SolidLine), tr("Line Style"), tr("Line Style"), KProperty::LineStyle); | ||
92 | m_staticValue = new KProperty("value", QVariant(false), tr("Value"), tr("Value used if not bound to a field")); | 89 | m_staticValue = new KProperty("value", QVariant(false), tr("Value"), tr("Value used if not bound to a field")); | ||
93 | 90 | | |||
94 | addDefaultProperties(); | 91 | propertySet()->addProperty(m_controlSource); | ||
95 | m_set->addProperty(m_controlSource); | 92 | propertySet()->addProperty(m_staticValue); | ||
96 | m_set->addProperty(m_staticValue); | 93 | propertySet()->addProperty(m_checkStyle); | ||
97 | m_set->addProperty(m_checkStyle); | 94 | propertySet()->addProperty(m_foregroundColor); | ||
98 | m_set->addProperty(m_foregroundColor); | 95 | propertySet()->addProperty(m_lineWeight); | ||
99 | m_set->addProperty(m_lineWeight); | 96 | propertySet()->addProperty(m_lineColor); | ||
100 | m_set->addProperty(m_lineColor); | 97 | propertySet()->addProperty(m_lineStyle); | ||
101 | m_set->addProperty(m_lineStyle); | | |||
102 | } | 98 | } | ||
103 | 99 | | |||
104 | KReportLineStyle KReportItemCheckBox::lineStyle() | 100 | KReportLineStyle KReportItemCheckBox::lineStyle() | ||
105 | { | 101 | { | ||
106 | KReportLineStyle ls; | 102 | KReportLineStyle ls; | ||
107 | ls.setWidth(m_lineWeight->value().toInt()); | 103 | ls.setWidth(m_lineWeight->value().toInt()); | ||
108 | ls.setColor(m_lineColor->value().value<QColor>()); | 104 | ls.setColor(m_lineColor->value().value<QColor>()); | ||
109 | ls.setPenStyle((Qt::PenStyle)m_lineStyle->value().toInt()); | 105 | ls.setPenStyle((Qt::PenStyle)m_lineStyle->value().toInt()); | ||
Show All 11 Lines | 116 | { | |||
121 | return QLatin1String("check"); | 117 | return QLatin1String("check"); | ||
122 | } | 118 | } | ||
123 | 119 | | |||
124 | int KReportItemCheckBox::renderSimpleData(OROPage *page, OROSection *section, const QPointF &offset, | 120 | int KReportItemCheckBox::renderSimpleData(OROPage *page, OROSection *section, const QPointF &offset, | ||
125 | const QVariant &data, KReportScriptHandler *script) | 121 | const QVariant &data, KReportScriptHandler *script) | ||
126 | { | 122 | { | ||
127 | OROCheck *chk = new OROCheck(); | 123 | OROCheck *chk = new OROCheck(); | ||
128 | 124 | | |||
129 | chk->setPosition(m_pos.toScene() + offset); | 125 | chk->setPosition(scenePosition(position()) + offset); | ||
130 | chk->setSize(m_size.toScene()); | 126 | chk->setSize(sceneSize(size())); | ||
131 | 127 | | |||
132 | chk->setLineStyle(lineStyle()); | 128 | chk->setLineStyle(lineStyle()); | ||
133 | chk->setForegroundColor(m_foregroundColor->value().value<QColor>()); | 129 | chk->setForegroundColor(m_foregroundColor->value().value<QColor>()); | ||
134 | chk->setCheckType(m_checkStyle->value().toString()); | 130 | chk->setCheckType(m_checkStyle->value().toString()); | ||
135 | 131 | | |||
136 | QString str; | 132 | QString str; | ||
137 | bool v = false; | 133 | bool v = false; | ||
138 | QString cs = itemDataSource(); | 134 | QString cs = itemDataSource(); | ||
Show All 24 Lines | 144 | #endif | |||
163 | chk->setValue(v); | 159 | chk->setValue(v); | ||
164 | 160 | | |||
165 | if (page) { | 161 | if (page) { | ||
166 | page->addPrimitive(chk); | 162 | page->addPrimitive(chk); | ||
167 | } | 163 | } | ||
168 | 164 | | |||
169 | if (section) { | 165 | if (section) { | ||
170 | OROCheck *chk2 = dynamic_cast<OROCheck*>(chk->clone()); | 166 | OROCheck *chk2 = dynamic_cast<OROCheck*>(chk->clone()); | ||
171 | chk2->setPosition(m_pos.toPoint()); | 167 | chk2->setPosition(scenePosition(position())); | ||
172 | section->addPrimitive(chk2); | 168 | section->addPrimitive(chk2); | ||
173 | } | 169 | } | ||
174 | 170 | | |||
175 | if (!page) { | 171 | if (!page) { | ||
176 | delete chk; | 172 | delete chk; | ||
177 | } | 173 | } | ||
178 | 174 | | |||
179 | return 0; //Item doesn't stretch the section height | 175 | return 0; //Item doesn't stretch the section height | ||
Show All 11 Lines |