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((int)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, tr("Line Weight")); | ||
staniek: Missing changes also here: 1.0 and step | |||||
76 | m_lineColor = new KProperty("line-color", QColor(Qt::black), tr("Line Color")); | 76 | 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); | 77 | m_lineStyle = new KProperty("line-style", (int)Qt::SolidLine, tr("Line Style"), tr("Line Style"), KProperty::LineStyle); | ||
78 | m_start.setName(QLatin1String("Start")); | 78 | m_start.setName(QLatin1String("Start")); | ||
79 | m_end.setName(QLatin1String("End")); | 79 | m_end.setName(QLatin1String("End")); | ||
80 | 80 | | |||
81 | m_set->addProperty(m_name); | 81 | m_set->addProperty(m_name); | ||
82 | m_set->addProperty(m_start.property()); | 82 | m_set->addProperty(m_start.property()); | ||
83 | m_set->addProperty(m_end.property()); | 83 | m_set->addProperty(m_end.property()); | ||
84 | m_set->addProperty(m_lineWeight); | 84 | m_set->addProperty(m_lineWeight); | ||
85 | m_set->addProperty(m_lineColor); | 85 | m_set->addProperty(m_lineColor); | ||
86 | m_set->addProperty(m_lineStyle); | 86 | m_set->addProperty(m_lineStyle); | ||
87 | } | 87 | } | ||
88 | 88 | | |||
89 | KReportLineStyle KReportItemLine::lineStyle() const | 89 | KReportLineStyle KReportItemLine::lineStyle() const | ||
90 | { | 90 | { | ||
91 | KReportLineStyle ls; | 91 | KReportLineStyle ls; | ||
92 | ls.setWidth(m_lineWeight->value().toInt()); | 92 | ls.setWidth(m_lineWeight->value().toInt()); | ||
staniek: Missing change toReal | |||||
93 | ls.setColor(m_lineColor->value().value<QColor>()); | 93 | ls.setColor(m_lineColor->value().value<QColor>()); | ||
94 | ls.setPenStyle((Qt::PenStyle)m_lineStyle->value().toInt()); | 94 | ls.setPenStyle((Qt::PenStyle)m_lineStyle->value().toInt()); | ||
95 | return ls; | 95 | return ls; | ||
96 | } | 96 | } | ||
97 | 97 | | |||
98 | int KReportItemLine::weight() const | 98 | int KReportItemLine::weight() const | ||
99 | { | 99 | { | ||
100 | return m_lineWeight->value().toInt(); | 100 | return m_lineWeight->value().toInt(); | ||
▲ Show 20 Lines • Show All 54 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.