Changeset View
Changeset View
Standalone View
Standalone View
src/items/text/KReportItemText.cpp
Show All 20 Lines | |||||
21 | 21 | | |||
22 | #include <KPropertySet> | 22 | #include <KPropertySet> | ||
23 | 23 | | |||
24 | #include <QPrinter> | 24 | #include <QPrinter> | ||
25 | #include <QApplication> | 25 | #include <QApplication> | ||
26 | #include <QPalette> | 26 | #include <QPalette> | ||
27 | #include <QFontMetrics> | 27 | #include <QFontMetrics> | ||
28 | #include <QDomNodeList> | 28 | #include <QDomNodeList> | ||
29 | #include <QRegularExpression> | ||||
29 | 30 | | |||
30 | KReportItemText::KReportItemText() | 31 | KReportItemText::KReportItemText() | ||
31 | : KReportItemText(QDomNode()) | 32 | : KReportItemText(QDomNode()) | ||
32 | { | 33 | { | ||
33 | } | 34 | } | ||
34 | 35 | | |||
35 | KReportItemText::KReportItemText(const QDomNode & element) : m_bottomPadding(0.0) | 36 | KReportItemText::KReportItemText(const QDomNode & element) : m_bottomPadding(0.0) | ||
36 | { | 37 | { | ||
▲ Show 20 Lines • Show All 183 Lines • ▼ Show 20 Line(s) | 200 | { | |||
220 | QRectF trf(pos, siz); | 221 | QRectF trf(pos, siz); | ||
221 | qreal intStretch = trf.top() - offset.y(); | 222 | qreal intStretch = trf.top() - offset.y(); | ||
222 | 223 | | |||
223 | if (qstrValue.length()) { | 224 | if (qstrValue.length()) { | ||
224 | QRectF rect = trf; | 225 | QRectF rect = trf; | ||
225 | 226 | | |||
226 | int pos = 0; | 227 | int pos = 0; | ||
227 | QChar separator; | 228 | QChar separator; | ||
228 | QRegExp re(QLatin1String("\\s")); | 229 | QRegularExpression re(QLatin1String("\\s")); | ||
229 | QPrinter prnt(QPrinter::HighResolution); | 230 | QPrinter prnt(QPrinter::HighResolution); | ||
230 | QFontMetrics fm(font(), &prnt); | 231 | QFontMetrics fm(font(), &prnt); | ||
231 | 232 | | |||
232 | // int intRectWidth = (int)(trf.width() * prnt.resolution()) - 10; | 233 | // int intRectWidth = (int)(trf.width() * prnt.resolution()) - 10; | ||
233 | int intRectWidth = (int)((size().width() / 72) * prnt.resolution()); | 234 | int intRectWidth = (int)((size().width() / 72) * prnt.resolution()); | ||
234 | int intLineCounter = 0; | 235 | int intLineCounter = 0; | ||
235 | qreal intBaseTop = trf.top(); | 236 | qreal intBaseTop = trf.top(); | ||
236 | qreal intRectHeight = trf.height(); | 237 | qreal intRectHeight = trf.height(); | ||
237 | 238 | | |||
238 | while (qstrValue.length()) { | 239 | while (qstrValue.length()) { | ||
239 | int idx = re.indexIn(qstrValue, pos); | 240 | QRegularExpressionMatch match = re.match(qstrValue); | ||
241 | int idx = match.capturedStart(pos); | ||||
240 | if (idx == -1) { | 242 | if (idx == -1) { | ||
241 | idx = qstrValue.length(); | 243 | idx = qstrValue.length(); | ||
242 | separator = QLatin1Char('\n'); | 244 | separator = QLatin1Char('\n'); | ||
243 | } else | 245 | } else | ||
244 | separator = qstrValue.at(idx); | 246 | separator = qstrValue.at(idx); | ||
245 | 247 | | |||
246 | if (fm.boundingRect(qstrValue.left(idx)).width() < intRectWidth || pos == 0) { | 248 | if (fm.boundingRect(qstrValue.left(idx)).width() < intRectWidth || pos == 0) { | ||
247 | pos = idx + 1; | 249 | pos = idx + 1; | ||
▲ Show 20 Lines • Show All 70 Lines • Show Last 20 Lines |