Feature: Add QObject interface class template
ClosedPublic

Authored by kossebau on Jan 30 2017, 2:14 AM.

Details

Summary

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.

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 updated this revision to Diff 10687.Jan 30 2017, 2:14 AM
kossebau retitled this revision from to Feature: Add QObject interface class template.
kossebau updated this object.
kossebau added a reviewer: KDevelop.
Restricted Application added a subscriber: kdevelop-devel. · View Herald TranscriptJan 30 2017, 2:14 AM
mwolff added a subscriber: mwolff.Jan 30 2017, 9:54 AM

can you paste the result of this template? I'm not good at parsing grantlee in my head

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()
{
}
mwolff accepted this revision.Jan 30 2017, 4:36 PM
mwolff added a reviewer: mwolff.

lgtm

file_templates/classes/qt_interface/interface.cpp
28

use = default();

here as well, C++11 is old enough by now, imo

This revision is now accepted and ready to land.Jan 30 2017, 4:36 PM
This revision was automatically updated to reflect the committed changes.
kossebau marked an inline comment as done.
apol added a subscriber: apol.Jan 30 2017, 11:20 PM

So the difference between this and the normal QObject template is the usage of Q_DECLARE_INTERFACE?

In D4338#81632, @apol wrote:

So the difference between this and the normal QObject template is the usage of Q_DECLARE_INTERFACE?

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!