Changeset View
Changeset View
Standalone View
Standalone View
src/items/text/KReportItemText.cpp
Show All 12 Lines | |||||
13 | * | 13 | * | ||
14 | * You should have received a copy of the GNU Lesser General Public | 14 | * You should have received a copy of the GNU Lesser General Public | ||
15 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | 15 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
16 | */ | 16 | */ | ||
17 | 17 | | |||
18 | #include "KReportItemText.h" | 18 | #include "KReportItemText.h" | ||
19 | #include "KReportRenderObjects.h" | 19 | #include "KReportRenderObjects.h" | ||
20 | #include "kreportplugin_debug.h" | 20 | #include "kreportplugin_debug.h" | ||
21 | #include "KReportUtils.h" | ||||
21 | 22 | | |||
22 | #include <KPropertyListData> | 23 | #include <KPropertyListData> | ||
23 | #include <KPropertySet> | 24 | #include <KPropertySet> | ||
24 | 25 | | |||
25 | #include <QPrinter> | 26 | #include <QPrinter> | ||
26 | #include <QApplication> | 27 | #include <QApplication> | ||
27 | #include <QPalette> | 28 | #include <QPalette> | ||
28 | #include <QFontMetrics> | 29 | #include <QFontMetrics> | ||
29 | #include <QDomNodeList> | 30 | #include <QDomNodeList> | ||
30 | #include <QRegularExpression> | 31 | #include <QRegularExpression> | ||
31 | 32 | | |||
32 | KReportItemText::KReportItemText() | 33 | KReportItemText::KReportItemText() | ||
33 | : m_bottomPadding(0.0) | 34 | : m_bottomPadding(0.0) | ||
34 | { | 35 | { | ||
35 | createProperties(); | 36 | createProperties(); | ||
36 | } | 37 | } | ||
37 | 38 | | |||
38 | KReportItemText::KReportItemText(const QDomNode & element) | 39 | KReportItemText::KReportItemText(const QDomNode & element) | ||
39 | : KReportItemText() | 40 | : KReportItemText() | ||
40 | { | 41 | { | ||
41 | nameProperty()->setValue(element.toElement().attribute(QLatin1String("report:name"))); | 42 | nameProperty()->setValue(KReportUtils::readNameAttribute(element.toElement())); | ||
42 | m_controlSource->setValue(element.toElement().attribute(QLatin1String("report:item-data-source"))); | 43 | m_controlSource->setValue(element.toElement().attribute(QLatin1String("report:item-data-source"))); | ||
43 | m_itemValue->setValue(element.toElement().attribute(QLatin1String("report:value"))); | 44 | m_itemValue->setValue(element.toElement().attribute(QLatin1String("report:value"))); | ||
44 | setZ(element.toElement().attribute(QLatin1String("report:z-index")).toDouble()); | 45 | setZ(element.toElement().attribute(QLatin1String("report:z-index")).toDouble()); | ||
45 | m_horizontalAlignment->setValue(element.toElement().attribute(QLatin1String("report:horizontal-align"))); | 46 | m_horizontalAlignment->setValue(element.toElement().attribute(QLatin1String("report:horizontal-align"))); | ||
46 | m_verticalAlignment->setValue(element.toElement().attribute(QLatin1String("report:vertical-align"))); | 47 | m_verticalAlignment->setValue(element.toElement().attribute(QLatin1String("report:vertical-align"))); | ||
47 | m_bottomPadding = element.toElement().attribute(QLatin1String("report:bottom-padding")).toDouble(); | 48 | m_bottomPadding = element.toElement().attribute(QLatin1String("report:bottom-padding")).toDouble(); | ||
48 | 49 | | |||
49 | parseReportRect(element.toElement()); | 50 | parseReportRect(element.toElement()); | ||
▲ Show 20 Lines • Show All 83 Lines • ▼ Show 20 Line(s) | 110 | { | |||
133 | 134 | | |||
134 | m_lineWeight = new KProperty("line-weight", 1.0, tr("Line Weight")); | 135 | m_lineWeight = new KProperty("line-weight", 1.0, tr("Line Weight")); | ||
135 | m_lineWeight->setOption("step", 1.0); | 136 | m_lineWeight->setOption("step", 1.0); | ||
136 | m_lineColor = new KProperty("line-color", QColor(Qt::black), tr("Line Color")); | 137 | m_lineColor = new KProperty("line-color", QColor(Qt::black), tr("Line Color")); | ||
137 | m_lineStyle = new KProperty("line-style", static_cast<int>(Qt::NoPen), tr("Line Style"), QString(), KProperty::LineStyle); | 138 | m_lineStyle = new KProperty("line-style", static_cast<int>(Qt::NoPen), tr("Line Style"), QString(), KProperty::LineStyle); | ||
138 | m_backgroundOpacity = new KProperty("background-opacity", QVariant(0), tr("Background Opacity")); | 139 | m_backgroundOpacity = new KProperty("background-opacity", QVariant(0), tr("Background Opacity")); | ||
139 | m_backgroundOpacity->setOption("max", 100); | 140 | m_backgroundOpacity->setOption("max", 100); | ||
140 | m_backgroundOpacity->setOption("min", 0); | 141 | m_backgroundOpacity->setOption("min", 0); | ||
141 | m_backgroundOpacity->setOption("unit", QLatin1String("%")); | 142 | m_backgroundOpacity->setOption("suffix", QLatin1String("%")); | ||
142 | 143 | | |||
143 | propertySet()->addProperty(m_controlSource); | 144 | propertySet()->addProperty(m_controlSource); | ||
144 | propertySet()->addProperty(m_itemValue); | 145 | propertySet()->addProperty(m_itemValue); | ||
145 | propertySet()->addProperty(m_horizontalAlignment); | 146 | propertySet()->addProperty(m_horizontalAlignment); | ||
146 | propertySet()->addProperty(m_verticalAlignment); | 147 | propertySet()->addProperty(m_verticalAlignment); | ||
147 | propertySet()->addProperty(m_font); | 148 | propertySet()->addProperty(m_font); | ||
148 | propertySet()->addProperty(m_backgroundColor); | 149 | propertySet()->addProperty(m_backgroundColor); | ||
149 | propertySet()->addProperty(m_foregroundColor); | 150 | propertySet()->addProperty(m_foregroundColor); | ||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Line(s) | 203 | { | |||
225 | 226 | | |||
226 | if (qstrValue.length()) { | 227 | if (qstrValue.length()) { | ||
227 | QRectF rect = trf; | 228 | QRectF rect = trf; | ||
228 | 229 | | |||
229 | int pos = 0; | 230 | int pos = 0; | ||
230 | QChar separator; | 231 | QChar separator; | ||
231 | QRegularExpression re(QLatin1String("\\s")); | 232 | QRegularExpression re(QLatin1String("\\s")); | ||
232 | QPrinter prnt(QPrinter::HighResolution); | 233 | QPrinter prnt(QPrinter::HighResolution); | ||
233 | QFontMetrics fm(font(), &prnt); | 234 | QFontMetricsF fm(font(), &prnt); | ||
234 | 235 | | |||
235 | // int intRectWidth = (int)(trf.width() * prnt.resolution()) - 10; | 236 | // int intRectWidth = (int)(trf.width() * prnt.resolution()) - 10; | ||
236 | int intRectWidth = (int)((size().width() / 72) * prnt.resolution()); | 237 | int intRectWidth = (int)((size().width() / 72) * prnt.resolution()); | ||
237 | int intLineCounter = 0; | 238 | int intLineCounter = 0; | ||
238 | qreal intBaseTop = trf.top(); | 239 | qreal intBaseTop = trf.top(); | ||
239 | qreal intRectHeight = trf.height(); | 240 | qreal intRectHeight = trf.height(); | ||
240 | 241 | | |||
241 | while (qstrValue.length()) { | 242 | while (qstrValue.length()) { | ||
▲ Show 20 Lines • Show All 80 Lines • Show Last 20 Lines |