Changeset View
Changeset View
Standalone View
Standalone View
src/common/KReportItemLine.cpp
Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Line(s) | 32 | { | |||
---|---|---|---|---|---|
48 | 48 | | |||
49 | for (int i = 0; i < nl.count(); i++) { | 49 | for (int i = 0; i < nl.count(); i++) { | ||
50 | node = nl.item(i); | 50 | node = nl.item(i); | ||
51 | n = node.nodeName(); | 51 | n = node.nodeName(); | ||
52 | 52 | | |||
53 | if (n == QLatin1String("report:line-style")) { | 53 | if (n == QLatin1String("report:line-style")) { | ||
54 | KReportLineStyle ls; | 54 | KReportLineStyle ls; | ||
55 | if (parseReportLineStyleData(node.toElement(), &ls)) { | 55 | if (parseReportLineStyleData(node.toElement(), &ls)) { | ||
56 | m_lineWeight->setValue(ls.width()); | 56 | m_lineWeight->setValue(ls.width()); | ||
staniek: Why to cast if KReportLineStyle::width is qreal?
All our 5 KProperty("line-weight") are double… | |||||
in 3.0 m_lineWeight = new KProperty("line-weight", 1, tr("Line Weight")); piggz: in 3.0
m_lineWeight = new KProperty("line-weight", 1, tr("Line Weight"));
| |||||
This is true. My question would be: what's better: to suddenly start supporting qreal in 3.1 or "fixing" the support for qreal in 3.0.2 which would be used for a while since its release before 3.1 replaces it. So make the change earlier or later? User that redesigns a report using 3.0.2 loses the precision back to integer. Because we have code like elemSource.attribute(QLatin1String("report:line-weight"), QLatin1String("0")).toInt() in 3.0 though. How about making the change for 3.0.2 calling it a fix. staniek: This is true. My question would be: what's better: to suddenly start supporting qreal in 3.1… | |||||
staniek: `(int)` not needed here? | |||||
57 | m_lineColor->setValue(ls.color()); | 57 | m_lineColor->setValue(ls.color()); | ||
58 | m_lineStyle->setValue(int(ls.penStyle())); | 58 | m_lineStyle->setValue(static_cast<int>(ls.penStyle())); | ||
59 | } | 59 | } | ||
60 | } else { | 60 | } else { | ||
61 | kreportWarning() << "while parsing line element encountered unknown element: " << n; | 61 | kreportWarning() << "while parsing line element encountered unknown element: " << n; | ||
62 | } | 62 | } | ||
63 | } | 63 | } | ||
64 | } | 64 | } | ||
65 | 65 | | |||
66 | KReportItemLine::~KReportItemLine() | 66 | KReportItemLine::~KReportItemLine() | ||
67 | { | 67 | { | ||
68 | delete m_set; | 68 | delete m_set; | ||
69 | } | 69 | } | ||
70 | 70 | | |||
71 | void KReportItemLine::createProperties() | 71 | void KReportItemLine::createProperties() | ||
72 | { | 72 | { | ||
73 | m_set = new KPropertySet; | 73 | m_set = new KPropertySet; | ||
74 | 74 | | |||
75 | m_lineWeight = new KProperty("line-weight", 1, tr("Line Weight")); | 75 | m_lineWeight = new KProperty("line-weight", 1.0, tr("Line Weight")); | ||
76 | m_lineWeight->setOption("step", 1.0); | ||||
77 | | ||||
staniek: Missing changes also here: 1.0 and step | |||||
76 | m_lineColor = new KProperty("line-color", QColor(Qt::black), tr("Line Color")); | 78 | m_lineColor = new KProperty("line-color", QColor(Qt::black), tr("Line Color")); | ||
77 | m_lineStyle = new KProperty("line-style", (int)Qt::SolidLine, tr("Line Style"), tr("Line Style"), KProperty::LineStyle); | 79 | m_lineStyle = new KProperty("line-style", (int)Qt::SolidLine, tr("Line Style"), tr("Line Style"), KProperty::LineStyle); | ||
78 | m_start.setName(QLatin1String("Start")); | 80 | m_start.setName(QLatin1String("Start")); | ||
79 | m_end.setName(QLatin1String("End")); | 81 | m_end.setName(QLatin1String("End")); | ||
80 | 82 | | |||
81 | m_set->addProperty(m_name); | 83 | m_set->addProperty(m_name); | ||
82 | m_set->addProperty(m_start.property()); | 84 | m_set->addProperty(m_start.property()); | ||
83 | m_set->addProperty(m_end.property()); | 85 | m_set->addProperty(m_end.property()); | ||
84 | m_set->addProperty(m_lineWeight); | 86 | m_set->addProperty(m_lineWeight); | ||
85 | m_set->addProperty(m_lineColor); | 87 | m_set->addProperty(m_lineColor); | ||
86 | m_set->addProperty(m_lineStyle); | 88 | m_set->addProperty(m_lineStyle); | ||
87 | } | 89 | } | ||
88 | 90 | | |||
89 | KReportLineStyle KReportItemLine::lineStyle() const | 91 | KReportLineStyle KReportItemLine::lineStyle() const | ||
90 | { | 92 | { | ||
91 | KReportLineStyle ls; | 93 | KReportLineStyle ls; | ||
92 | ls.setWidth(m_lineWeight->value().toInt()); | 94 | ls.setWidth(m_lineWeight->value().toReal()); | ||
staniek: Missing change toReal | |||||
93 | ls.setColor(m_lineColor->value().value<QColor>()); | 95 | ls.setColor(m_lineColor->value().value<QColor>()); | ||
94 | ls.setPenStyle((Qt::PenStyle)m_lineStyle->value().toInt()); | 96 | ls.setPenStyle((Qt::PenStyle)m_lineStyle->value().toInt()); | ||
95 | return ls; | 97 | return ls; | ||
96 | } | 98 | } | ||
97 | 99 | | |||
98 | int KReportItemLine::weight() const | 100 | qreal KReportItemLine::weight() const | ||
99 | { | 101 | { | ||
100 | return m_lineWeight->value().toInt(); | 102 | return m_lineWeight->value().toReal(); | ||
101 | } | 103 | } | ||
102 | 104 | | |||
103 | void KReportItemLine::setWeight(int w) | 105 | void KReportItemLine::setWeight(qreal w) | ||
104 | { | 106 | { | ||
105 | m_lineWeight->setValue(w); | 107 | m_lineWeight->setValue(w); | ||
106 | } | 108 | } | ||
107 | 109 | | |||
108 | QString KReportItemLine::typeName() const | 110 | QString KReportItemLine::typeName() const | ||
109 | { | 111 | { | ||
110 | return QLatin1String("line"); | 112 | return QLatin1String("line"); | ||
111 | } | 113 | } | ||
▲ Show 20 Lines • Show All 43 Lines • Show Last 20 Lines |
Why to cast if KReportLineStyle::width is qreal?
All our 5 KProperty("line-weight") are double and have correct 1.0 value by default.