Changeset View
Changeset View
Standalone View
Standalone View
src/common/KReportItemLine.cpp
Show All 15 Lines | |||||
16 | */ | 16 | */ | ||
17 | 17 | | |||
18 | #include "KReportItemLine.h" | 18 | #include "KReportItemLine.h" | ||
19 | #include "KReportRenderObjects.h" | 19 | #include "KReportRenderObjects.h" | ||
20 | #include "kreport_debug.h" | 20 | #include "kreport_debug.h" | ||
21 | 21 | | |||
22 | #include <KPropertySet> | 22 | #include <KPropertySet> | ||
23 | 23 | | |||
24 | #include <QCoreApplication> | ||||
24 | #include <QDomNode> | 25 | #include <QDomNode> | ||
25 | 26 | | |||
26 | KReportItemLine::KReportItemLine() | 27 | KReportItemLine::KReportItemLine() | ||
27 | { | 28 | { | ||
28 | createProperties(); | 29 | createProperties(); | ||
29 | } | 30 | } | ||
30 | 31 | | |||
31 | KReportItemLine::KReportItemLine(const QDomNode & element) | 32 | KReportItemLine::KReportItemLine(const QDomNode & element) | ||
32 | { | 33 | { | ||
33 | createProperties(); | 34 | createProperties(); | ||
34 | QDomNodeList nl = element.childNodes(); | 35 | QDomNodeList nl = element.childNodes(); | ||
35 | QString n; | 36 | QString n; | ||
36 | QDomNode node; | 37 | QDomNode node; | ||
37 | QPointF _s, _e; | 38 | QPointF _s, _e; | ||
38 | 39 | | |||
39 | nameProperty()->setValue(element.toElement().attribute(QLatin1String("report:name"))); | 40 | nameProperty()->setValue(element.toElement().attribute(QLatin1String("report:name"))); | ||
40 | setZ(element.toElement().attribute(QLatin1String("report:z-index")).toDouble()); | 41 | setZ(element.toElement().attribute(QLatin1String("report:z-index")).toDouble()); | ||
41 | 42 | | |||
42 | _s.setX(KReportUnit::parseValue(element.toElement().attribute(QLatin1String("svg:x1"), QLatin1String("1cm")))); | 43 | _s.setX(KReportUnit::parseValue(element.toElement().attribute(QLatin1String("svg:x1"), QLatin1String("1cm")))); | ||
43 | _s.setY(KReportUnit::parseValue(element.toElement().attribute(QLatin1String("svg:y1"), QLatin1String("1cm")))); | 44 | _s.setY(KReportUnit::parseValue(element.toElement().attribute(QLatin1String("svg:y1"), QLatin1String("1cm")))); | ||
44 | _e.setX(KReportUnit::parseValue(element.toElement().attribute(QLatin1String("svg:x2"), QLatin1String("1cm")))); | 45 | _e.setX(KReportUnit::parseValue(element.toElement().attribute(QLatin1String("svg:x2"), QLatin1String("1cm")))); | ||
45 | _e.setY(KReportUnit::parseValue(element.toElement().attribute(QLatin1String("svg:y2"), QLatin1String("2cm")))); | 46 | _e.setY(KReportUnit::parseValue(element.toElement().attribute(QLatin1String("svg:y2"), QLatin1String("2cm")))); | ||
46 | m_start.setPointPos(_s); | 47 | m_start->setValue(_s); | ||
47 | m_end.setPointPos(_e); | 48 | m_end->setValue(_e); | ||
48 | 49 | | |||
49 | for (int i = 0; i < nl.count(); i++) { | 50 | for (int i = 0; i < nl.count(); i++) { | ||
50 | node = nl.item(i); | 51 | node = nl.item(i); | ||
51 | n = node.nodeName(); | 52 | n = node.nodeName(); | ||
52 | 53 | | |||
53 | if (n == QLatin1String("report:line-style")) { | 54 | if (n == QLatin1String("report:line-style")) { | ||
54 | KReportLineStyle ls; | 55 | KReportLineStyle ls; | ||
55 | if (parseReportLineStyleData(node.toElement(), &ls)) { | 56 | if (parseReportLineStyleData(node.toElement(), &ls)) { | ||
56 | m_lineWeight->setValue(ls.width()); | 57 | m_lineWeight->setValue(ls.width()); | ||
57 | m_lineColor->setValue(ls.color()); | 58 | m_lineColor->setValue(ls.color()); | ||
58 | m_lineStyle->setValue(int(ls.penStyle())); | 59 | m_lineStyle->setValue(int(ls.penStyle())); | ||
59 | } | 60 | } | ||
60 | } else { | 61 | } else { | ||
61 | kreportWarning() << "while parsing line element encountered unknow element: " << n; | 62 | kreportWarning() << "while parsing line element encountered unknow element: " << n; | ||
62 | } | 63 | } | ||
63 | } | 64 | } | ||
64 | } | 65 | } | ||
65 | 66 | | |||
66 | KReportItemLine::~KReportItemLine() | 67 | KReportItemLine::~KReportItemLine() | ||
67 | { | 68 | { | ||
68 | } | 69 | } | ||
69 | 70 | | |||
70 | void KReportItemLine::createProperties() | 71 | void KReportItemLine::createProperties() | ||
71 | { | 72 | { | ||
72 | m_lineWeight = new KProperty("line-weight", 1, tr("Line Weight")); | 73 | m_start = new KProperty("startposition", QPointF(), QCoreApplication::translate("StartPosition", "Start Position")); | ||
74 | m_end = new KProperty("endposition", QPointF(), QCoreApplication::translate("EndPosition", "End Position")); | ||||
75 | | ||||
76 | m_lineWeight = new KProperty("line-weight", 1.0, tr("Line Weight")); | ||||
73 | m_lineColor = new KProperty("line-color", QColor(Qt::black), tr("Line Color")); | 77 | m_lineColor = new KProperty("line-color", QColor(Qt::black), tr("Line Color")); | ||
74 | m_lineStyle = new KProperty("line-style", (int)Qt::SolidLine, tr("Line Style"), tr("Line Style"), KProperty::LineStyle); | 78 | m_lineStyle = new KProperty("line-style", (int)Qt::SolidLine, tr("Line Style"), tr("Line Style"), KProperty::LineStyle); | ||
75 | m_start.setName(QLatin1String("Start")); | | |||
76 | m_end.setName(QLatin1String("End")); | | |||
77 | 79 | | |||
78 | propertySet()->addProperty(m_start.property()); | 80 | //Remove the unused properies from KReportItemBase | ||
79 | propertySet()->addProperty(m_end.property()); | 81 | propertySet()->removeProperty("size"); | ||
82 | propertySet()->removeProperty("position"); | ||||
83 | | ||||
84 | propertySet()->addProperty(m_start); | ||||
85 | propertySet()->addProperty(m_end); | ||||
80 | propertySet()->addProperty(m_lineWeight); | 86 | propertySet()->addProperty(m_lineWeight); | ||
81 | propertySet()->addProperty(m_lineColor); | 87 | propertySet()->addProperty(m_lineColor); | ||
82 | propertySet()->addProperty(m_lineStyle); | 88 | propertySet()->addProperty(m_lineStyle); | ||
83 | } | 89 | } | ||
84 | 90 | | |||
85 | KReportLineStyle KReportItemLine::lineStyle() const | 91 | KReportLineStyle KReportItemLine::lineStyle() const | ||
86 | { | 92 | { | ||
87 | KReportLineStyle ls; | 93 | KReportLineStyle ls; | ||
Show All 20 Lines | |||||
108 | 114 | | |||
109 | int KReportItemLine::renderSimpleData(OROPage *page, OROSection *section, const QPointF &offset, | 115 | int KReportItemLine::renderSimpleData(OROPage *page, OROSection *section, const QPointF &offset, | ||
110 | const QVariant &data, KReportScriptHandler *script) | 116 | const QVariant &data, KReportScriptHandler *script) | ||
111 | { | 117 | { | ||
112 | Q_UNUSED(script) | 118 | Q_UNUSED(script) | ||
113 | Q_UNUSED(data) | 119 | Q_UNUSED(data) | ||
114 | 120 | | |||
115 | OROLine * ln = new OROLine(); | 121 | OROLine * ln = new OROLine(); | ||
116 | QPointF s = m_start.toScene(); | 122 | QPointF s = scenePosition(m_start->value().toPointF()); | ||
117 | QPointF e = m_end.toScene(); | 123 | QPointF e = scenePosition(m_end->value().toPointF()); | ||
118 | 124 | | |||
119 | s += offset; | 125 | s += offset; | ||
120 | e += offset; | 126 | e += offset; | ||
121 | 127 | | |||
122 | ln->setStartPoint(s); | 128 | ln->setStartPoint(s); | ||
123 | ln->setEndPoint(e); | 129 | ln->setEndPoint(e); | ||
124 | ln->setLineStyle(lineStyle()); | 130 | ln->setLineStyle(lineStyle()); | ||
125 | if (page) page->insertPrimitive(ln); | 131 | if (page) page->insertPrimitive(ln); | ||
126 | 132 | | |||
127 | OROLine *l2 = dynamic_cast<OROLine*>(ln->clone()); | 133 | OROLine *l2 = dynamic_cast<OROLine*>(ln->clone()); | ||
128 | l2->setStartPoint(m_start.toPoint()); | 134 | l2->setStartPoint(m_start->value().toPointF()); | ||
129 | l2->setEndPoint(m_end.toPoint()); | 135 | l2->setEndPoint(m_end->value().toPointF()); | ||
130 | if (section) section->addPrimitive(l2); | 136 | if (section) section->addPrimitive(l2); | ||
131 | 137 | | |||
132 | return 0; | 138 | return 0; | ||
133 | } | 139 | } | ||
134 | 140 | | |||
135 | void KReportItemLine::setUnit(const KReportUnit &u) | 141 | void KReportItemLine::setUnit(const KReportUnit &u) | ||
136 | { | 142 | { | ||
137 | m_start.setUnit(u); | 143 | m_start->setOption("unit", u.symbol()); | ||
138 | m_end.setUnit(u); | 144 | m_end->setOption("unit", u.symbol()); | ||
139 | } | 145 | } | ||
140 | 146 | | |||
141 | KReportPosition KReportItemLine::startPosition() const | 147 | QPointF KReportItemLine::startPosition() const | ||
142 | { | 148 | { | ||
143 | return m_start; | 149 | return m_start->value().toPointF(); | ||
144 | } | 150 | } | ||
145 | 151 | | |||
146 | KReportPosition KReportItemLine::endPosition() const | 152 | QPointF KReportItemLine::endPosition() const | ||
147 | { | 153 | { | ||
148 | return m_end; | 154 | return m_end->value().toPointF(); | ||
149 | } | 155 | } | ||
150 | 156 | |