Add file templ: QObject, QAbstractItemModel, QWidget, QDialog (pimpl & not)
ClosedPublic

Authored by kossebau on Nov 30 2017, 1:10 AM.

Details

Summary

Having templates for both private and public API (pimpl or not) versions for
subclassing common base Qt classes helps to speed up creation of new code.

Diff Detail

Repository
R32 KDevelop
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
kossebau created this revision.Nov 30 2017, 1:10 AM
Restricted Application added a subscriber: kdevelop-devel. · View Herald TranscriptNov 30 2017, 1:10 AM
kossebau requested review of this revision.Nov 30 2017, 1:10 AM

Code generation with file templates sadly has regressed a little again with 5.2, so results are not yet perfect::
a) Abstract virtual methods are not generated as overriding, but still abstract (since 5.2)
b) Some template code copied around is assuming properties which got removed from codegen code. Snippets like this currently are dead code, fix yet to be done (so template code kept for consistency in templates)

{% if method.type %}
return {{ method.default_return_value }};
{% endif %}

type should be returnType these days, and default_return_value once got removed without replacement, might need to be done via the grantlee filter similar to filter arg_type.

But the templates themselves in the patch here should be fine also once the regressions are fixed.

mwolff accepted this revision.Nov 30 2017, 9:40 AM
mwolff added a subscriber: mwolff.

I'm not using this feature myself, but trust you on that part

Code generation with file templates sadly has regressed a little again with 5.2, so results are not yet perfect::

We should extend and/or fix our unit tests then :)

This revision is now accepted and ready to land.Nov 30 2017, 9:40 AM
This revision was automatically updated to reflect the committed changes.
apol added a subscriber: apol.Nov 30 2017, 2:36 PM

Do we really need all these templates? Maybe we can make sure the file creator has a good insight of the class we are extending...

In D9063#173740, @apol wrote:

Do we really need all these templates? Maybe we can make sure the file creator has a good insight of the class we are extending...

Agreed that would be better, in my list for Santa "Developer" Claus would be making codegen smarter, e.g. for all the Qt specific stuff.
Until someone has coded that though, these templates serve and have served for me as intermediate solution ...