forked from qt-creator/qt-creator
		
	That is, if the user specifies a custom base class, we check whether its constructor takes a "QObject *parent" parameter, and if it does, we give the derived class one as well. This is technically a heuristic, but the pattern is pretty stable in the Qt world. Fixes: QTCREATORBUG-25156 Change-Id: Ie64440929df61cca7258d6d692c5de62970f9a65 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
		
			
				
	
	
		
			67 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			67 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
%{Cpp:LicenseTemplate}\
 | 
						|
@if '%{Cpp:PragmaOnce}'
 | 
						|
#pragma once
 | 
						|
@else
 | 
						|
#ifndef %{GUARD}
 | 
						|
#define %{GUARD}
 | 
						|
@endif
 | 
						|
 | 
						|
%{JS: Cpp.includeStatement('%{Base}', Util.preferredSuffix('text/x-c++hdr'), ['QObject', 'QWidget', 'QMainWindow', 'QQuickItem', 'QSharedData'], '%{TargetPath}')}\
 | 
						|
%{JS: QtSupport.qtIncludes([ ( '%{IncludeQObject}' )          ? 'QtCore/%{IncludeQObject}'                 : '',
 | 
						|
                             ( '%{IncludeQWidget}' )          ? 'QtGui/%{IncludeQWidget}'                  : '',
 | 
						|
                             ( '%{IncludeQMainWindow}' )      ? 'QtGui/%{IncludeQMainWindow}'              : '',
 | 
						|
                             ( '%{IncludeQDeclarativeItem}' ) ? 'QtDeclarative/%{IncludeQDeclarativeItem}' : '',
 | 
						|
                             ( '%{IncludeQSharedData}' )      ? 'QtCore/QSharedDataPointer'                : '' ],
 | 
						|
                           [ ( '%{IncludeQObject}' )          ? 'QtCore/%{IncludeQObject}'                 : '',
 | 
						|
                             ( '%{IncludeQWidget}' )          ? 'QtWidgets/%{IncludeQWidget}'              : '',
 | 
						|
                             ( '%{IncludeQMainWindow}' )      ? 'QtWidgets/%{IncludeQMainWindow}'          : '',
 | 
						|
                             ( '%{IncludeQDeclarativeItem}' ) ? 'QtQuick1/%{IncludeQDeclarativeItem}'      : '',
 | 
						|
                             ( '%{IncludeQQuickItem}' )       ? 'QtDeclarative/%{IncludeQQuickItem}'       : '',
 | 
						|
                             ( '%{IncludeQSharedData}' )      ? 'QtCore/QSharedDataPointer'                : '' ])}\
 | 
						|
%{JS: Cpp.openNamespaces('%{Class}')}
 | 
						|
@if '%{IncludeQSharedData}'
 | 
						|
class %{CN}Data;
 | 
						|
 | 
						|
@endif
 | 
						|
@if '%{Base}'
 | 
						|
class %{CN} : public %{Base}
 | 
						|
@else
 | 
						|
class %{CN}
 | 
						|
@endif
 | 
						|
{
 | 
						|
@if '%{AddQObjectMacro}'
 | 
						|
     Q_OBJECT
 | 
						|
@endif
 | 
						|
public:
 | 
						|
@if '%{Base}' === 'QObject' || %{JS: Cpp.hasQObjectParent('%{Base}')}
 | 
						|
    explicit %{CN}(QObject *parent = nullptr);
 | 
						|
@elsif '%{Base}' === 'QWidget' || '%{Base}' === 'QMainWindow'
 | 
						|
    explicit %{CN}(QWidget *parent = nullptr);
 | 
						|
@else
 | 
						|
    %{CN}();
 | 
						|
@endif
 | 
						|
@if '%{IncludeQSharedData}'
 | 
						|
    %{CN}(const %{CN} &);
 | 
						|
    %{CN} &operator=(const %{CN} &);
 | 
						|
    ~%{CN}();
 | 
						|
@endif
 | 
						|
@if %{isQObject}
 | 
						|
 | 
						|
@if %{QtKeywordsEnabled}
 | 
						|
signals:
 | 
						|
@else
 | 
						|
Q_SIGNALS:
 | 
						|
@endif
 | 
						|
 | 
						|
@endif
 | 
						|
@if '%{IncludeQSharedData}'
 | 
						|
 | 
						|
private:
 | 
						|
    QSharedDataPointer<%{CN}Data> data;
 | 
						|
@endif
 | 
						|
};
 | 
						|
%{JS: Cpp.closeNamespaces('%{Class}')}
 | 
						|
@if ! '%{Cpp:PragmaOnce}'
 | 
						|
#endif // %{GUARD}
 | 
						|
@endif
 |