Add declarative QQuickTextMetrics API from QQuickFontMetrics invokables
authorMitch Curtis <mitch.curtis@digia.com>
Tue, 5 Aug 2014 15:42:54 +0000 (17:42 +0200)
committerMitch Curtis <mitch.curtis@digia.com>
Fri, 8 Aug 2014 08:42:47 +0000 (10:42 +0200)
commit94669499fd943fc72095afd739a21cd8e675f14f
treed902820ebbc41f75699326fa1cf887ee49fc6746
parentc0e47716c402da2333bfa4082c7b40e3b376135c
Add declarative QQuickTextMetrics API from QQuickFontMetrics invokables

This allows use of a declarative API for the functions in QFontMetricsF
which take parameters. This solves the problem of QML expressions that
use QML methods not being re-evaluated when the internal data changes,
by allowing the user to set the arguments as properties of a
TextMetrics object, that would otherwise have to be passed to QML
methods.

For example:

    FontMetrics {
        id: fontMetrics
    }

    property rect r: fontMetrics.boundingRect("Blah")

At some point, the font of the FontMetrics object is changed, but r
will still represent the original bounding rect. Instead, the user will
now write:

    TextMetrics {
        id: textMetrics
        text: "Blah"
    }

    property rect r: textMetrics.boundingRect

The QML methods remain in QQuickFontMetrics for those who need an
imperative API.

[ChangeLog][QtQuick] Added QQuickTextMetrics, which provides a
declarative API for the functions in QFontMetricsF which take
arguments.

Change-Id: I019dc4639531906fc751ba61281cc1c695742287
Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
src/quick/util/qquickfontmetrics.cpp
src/quick/util/qquicktextmetrics.cpp [new file with mode: 0644]
src/quick/util/qquicktextmetrics_p.h [new file with mode: 0644]
src/quick/util/qquickutilmodule.cpp
src/quick/util/util.pri
tests/auto/quick/qquicktextmetrics/qquicktextmetrics.pro [new file with mode: 0644]
tests/auto/quick/qquicktextmetrics/tst_qquicktextmetrics.cpp [new file with mode: 0644]