Allows to kickstart creating new Qt-style interfaces.
The current template dialog does not allow to control
the destructor methods used, so the template enforces
a public destructor.
Details
Details
- Reviewers
mwolff - Group Reviewers
KDevelop - Commits
- R32:0fc944055544: Feature: Add QObject interface class template
Diff Detail
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.
Comment Actions
can you paste the result of this template? I'm not good at parsing grantlee in my head
Comment Actions
For the input
- Class Basics page: Identifier -> "IFooable"
- Class Members page: "QString bar"
- Template Options page: Interface identifier -> "org.foo.IFooable
this is generated:
ifooable.h:
/* * <one line to give the library's name and an idea of what it does.> * Copyright (C) 2017 Hans Entwickler <email> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifndef IFOOABLE_H #define IFOOABLE_H #include <QtPlugin> class IFooable { public: virtual ~IFooable(); virtual QString bar() const = 0; virtual void setBar(const QString& bar) = 0; }; Q_DECLARE_INTERFACE(IFooable, "org.foo.IFooable") #endif // IFOOABLE_H
ifooable.cpp:
/* * <one line to give the library's name and an idea of what it does.> * Copyright (C) 2017 Hans Entwickler <email> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ #include "ifooable.h" IFooable::~IFooable() { }
Comment Actions
lgtm
file_templates/classes/qt_interface/interface.cpp | ||
---|---|---|
27 ↗ | (On Diff #10687) | use = default(); here as well, C++11 is old enough by now, imo |
Comment Actions
So the difference between this and the normal QObject template is the usage of Q_DECLARE_INTERFACE?
Comment Actions
Also different:
- include of <QtPlugin>
- no subclassing from QObject and related Q- macros
The naming of the template could see some improvement possibly, proposals welcome!