@@ -35,7 +35,7 public: | |||
|
35 | 35 | StaticLabelFormatMatcherDeleter() {} |
|
36 | 36 | ~StaticLabelFormatMatcherDeleter() { delete labelFormatMatcher; } |
|
37 | 37 | }; |
|
38 | StaticLabelFormatMatcherDeleter staticLabelFormatMatcherDeleter; | |
|
38 | static StaticLabelFormatMatcherDeleter staticLabelFormatMatcherDeleter; | |
|
39 | 39 | |
|
40 | 40 | ChartAxisElement::ChartAxisElement(QAbstractAxis *axis, QGraphicsItem *item, bool intervalAxis) |
|
41 | 41 | : ChartElement(item), |
@@ -36,22 +36,6 | |||
|
36 | 36 | |
|
37 | 37 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
38 | 38 | |
|
39 | static QGraphicsTextItem *dummyTextItem = 0; | |
|
40 | static const char *truncateMatchString = "&#?[0-9a-zA-Z]*;$"; | |
|
41 | static QRegExp *truncateMatcher = 0; | |
|
42 | ||
|
43 | class StaticDummyTextDeleter | |
|
44 | { | |
|
45 | public: | |
|
46 | StaticDummyTextDeleter() {} | |
|
47 | ~StaticDummyTextDeleter() | |
|
48 | { | |
|
49 | delete dummyTextItem; | |
|
50 | delete truncateMatcher; | |
|
51 | } | |
|
52 | }; | |
|
53 | StaticDummyTextDeleter staticDummyTextDeleter; | |
|
54 | ||
|
55 | 39 | ChartPresenter::ChartPresenter(QChart *chart, QChart::ChartType type) |
|
56 | 40 | : QObject(chart), |
|
57 | 41 | m_chart(chart), |
@@ -396,12 +380,11 ChartTitle *ChartPresenter::titleElement() | |||
|
396 | 380 | |
|
397 | 381 | QRectF ChartPresenter::textBoundingRect(const QFont &font, const QString &text, qreal angle) |
|
398 | 382 | { |
|
399 | if (!dummyTextItem) | |
|
400 | dummyTextItem = new QGraphicsTextItem; | |
|
383 | static QGraphicsTextItem dummyTextItem; | |
|
401 | 384 | |
|
402 |
dummyTextItem |
|
|
403 |
dummyTextItem |
|
|
404 |
QRectF boundingRect = dummyTextItem |
|
|
385 | dummyTextItem.setFont(font); | |
|
386 | dummyTextItem.setHtml(text); | |
|
387 | QRectF boundingRect = dummyTextItem.boundingRect(); | |
|
405 | 388 | |
|
406 | 389 | // Take rotation into account |
|
407 | 390 | if (angle) { |
@@ -426,8 +409,9 QString ChartPresenter::truncatedText(const QFont &font, const QString &text, qr | |||
|
426 | 409 | // It can be assumed that almost any amount of string manipulation is faster |
|
427 | 410 | // than calculating one bounding rectangle, so first prepare a list of truncated strings |
|
428 | 411 | // to try. |
|
429 | if (!truncateMatcher) | |
|
430 |
|
|
|
412 | static const char *truncateMatchString = "&#?[0-9a-zA-Z]*;$"; | |
|
413 | static QRegExp truncateMatcher(truncateMatchString); | |
|
414 | ||
|
431 | 415 | QVector<QString> testStrings(text.length()); |
|
432 | 416 | int count(0); |
|
433 | 417 | static QLatin1Char closeTag('>'); |
@@ -442,7 +426,7 QString ChartPresenter::truncatedText(const QFont &font, const QString &text, qr | |||
|
442 | 426 | if (lastChar == closeTag) |
|
443 | 427 | chopIndex = truncatedString.lastIndexOf(openTag); |
|
444 | 428 | else if (lastChar == semiColon) |
|
445 |
chopIndex = truncateMatcher |
|
|
429 | chopIndex = truncateMatcher.indexIn(truncatedString, 0); | |
|
446 | 430 | |
|
447 | 431 | if (chopIndex != -1) |
|
448 | 432 | chopCount = truncatedString.length() - chopIndex; |
@@ -693,28 +693,25 QChartPrivate::~QChartPrivate() | |||
|
693 | 693 | // so that default theme initialization will always set these properly. |
|
694 | 694 | QPen &QChartPrivate::defaultPen() |
|
695 | 695 | { |
|
696 |
static QPen |
|
|
697 |
|
|
|
698 | defaultPen = new QPen(QColor(1, 2, 0), 0.93247536); | |
|
699 | return *defaultPen; | |
|
696 | static QPen defaultPen(QColor(1, 2, 0), 0.93247536); | |
|
697 | return defaultPen; | |
|
700 | 698 | } |
|
701 | 699 | |
|
702 | 700 | QBrush &QChartPrivate::defaultBrush() |
|
703 | 701 | { |
|
704 |
static QBrush |
|
|
705 |
|
|
|
706 | defaultBrush = new QBrush(QColor(1, 2, 0), Qt::Dense7Pattern); | |
|
707 | return *defaultBrush; | |
|
702 | static QBrush defaultBrush(QColor(1, 2, 0), Qt::Dense7Pattern); | |
|
703 | return defaultBrush; | |
|
708 | 704 | } |
|
709 | 705 | |
|
710 | 706 | QFont &QChartPrivate::defaultFont() |
|
711 | 707 | { |
|
712 |
static |
|
|
713 |
|
|
|
714 | defaultFont = new QFont(); | |
|
715 |
defaultFont |
|
|
708 | static bool defaultFontInitialized(false); | |
|
709 | static QFont defaultFont; | |
|
710 | if (!defaultFontInitialized) { | |
|
711 | defaultFont.setPointSizeF(8.34563465); | |
|
712 | defaultFontInitialized = true; | |
|
716 | 713 | } |
|
717 |
return |
|
|
714 | return defaultFont; | |
|
718 | 715 | } |
|
719 | 716 | |
|
720 | 717 | void QChartPrivate::init() |
General Comments 0
You need to be logged in to leave comments.
Login now