Review Request 118918: Support QML built-in types (rect, point, Font, etc)

Denis Steckelmacher steckdenis at yahoo.fr
Wed Jun 25 07:57:41 UTC 2014



> On June 24, 2014, 9:35 p.m., Sven Brauch wrote:
> > duchain/declarationbuilder.cpp, line 1122
> > <https://git.reviewboard.kde.org/r/118918/diff/2/?file=284451#file284451line1122>
> >
> >     Where does this C++ style name come from ...? What file is it read from?

QML module files use the C++ type names. For instance, this snippet comes from QtQuick.Controls_1.0.qml:

Component {
    name: "QQuickStyleItem"
    prototype: "QQuickItem"
    ...
    Property { name: "font"; type: "QFont"; isReadonly: true }
}

"QFont" cannot be kept as is, because the Qt documentation says that the "font" property of StyleItems is of type "Font". The line you highlight therefore replaces "QFont" with "Font" so that every font-like property will have the same type. Moreover, QML properties and values have a definite type, so maybe it would be possible, one day, to have strict type checking in QML. If this happens, having properties of type "QFont" and values of type "font" would be a bit difficult to handle.

Having Font inheriting from QFont or the other way around is also possible, but which type should inherit from the other? The two are conceptually exactly the same, hence the renaming.


- Denis


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/118918/#review60914
-----------------------------------------------------------


On June 24, 2014, 1:46 p.m., Denis Steckelmacher wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://git.reviewboard.kde.org/r/118918/
> -----------------------------------------------------------
> 
> (Updated June 24, 2014, 1:46 p.m.)
> 
> 
> Review request for KDevelop.
> 
> 
> Repository: kdev-qmljs
> 
> 
> Description
> -------
> 
> The QML language contains several built-in types, listed on this page: http://qt-project.org/doc/qt-5/qtqml-typesystem-basictypes.html. These types are not declared inside any module, so this patch adds a "built-in" module that declares these types.
> 
> Because most of the QML built-in types also exist in a C++ version (rect = QRect, Font = QFont, etc), this patch also adds a small translation layer between the C++ type names and the QML type names. This way, QML modules (that use the C++ names) can declares properties that will end up having the right type. A property declared of type "QRect" will have the type "rect", and all the attributes expected by the user.
> 
> 
> Diffs
> -----
> 
>   qmlplugins/builtins_1.0.qml PRE-CREATION 
>   tests/files/test.qml a36cfdb 
>   qmlplugins/QtQuick_2.0.qml 6d20f7a 
>   qmlplugins/QtQuick_1.0.qml 50c08b9 
>   codecompletion/tests/qmlcompletiontest.cpp e129b09 
>   duchain/declarationbuilder.cpp aab8aeb 
> 
> Diff: https://git.reviewboard.kde.org/r/118918/diff/
> 
> 
> Testing
> -------
> 
> A new code-completion unit test has been added. It ensures that typing "font." in a QML component having a font property of type Font displays the properties of QFont. The unit tests don't test all the type names and all the attributes of the types (it would be huge), but Font is the most interesting type.
> 
> 
> Thanks,
> 
> Denis Steckelmacher
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20140625/62c1ecb9/attachment-0001.html>


More information about the KDevelop-devel mailing list