{
    "version": 1,
    "supportedProjectTypes": [ ],
    "id": "A.Class",
    "category": "O.C++",
    "trDescription": "Creates a C++ header and a source file for a new class that you can add to a C++ project.",
    "trDisplayName": "C++ Class",
    "trDisplayCategory": "C/C++",
    "iconText": "h/cpp",
    "enabled": "%{JS: value('Plugins').indexOf('CppEditor') >= 0}",

    "options":
    [
        { "key": "TargetPath", "value": "%{Path}" },
        { "key": "HdrPath", "value": "%{Path}/%{HdrFileName}" },
        { "key": "SrcPath", "value": "%{Path}/%{SrcFileName}" },
        { "key": "CN", "value": "%{JS: Cpp.className(value('Class'))}" },
        { "key": "Base", "value": "%{JS: value('BaseCB') === '' ? value('BaseEdit') : value('BaseCB')}" },
        { "key": "isQObject", "value": "%{JS: [ 'QObject', 'QWidget', 'QMainWindow', 'QQuickItem'].indexOf(value('Base')) >= 0 }" },
        { "key": "GUARD", "value": "%{JS: Cpp.headerGuard(value('HdrFileName'))}" },
        { "key": "SharedDataInit", "value": "%{JS: (value('IncludeQSharedData')) ? 'data(new %{CN}Data)' : '' }" },
        { "key": "Dependencies", "value": "%{JS: '' + (value('IncludeQObject') || value('IncludeQSharedData') || value('BaseCB') === 'QObject' ? ':Qt.core' : '') + (value('IncludeQWidget') || value('IncludeQMainWindow') || value('BaseCB') === 'QWidget' || value('BaseCB') === 'QMainWindow' ? ':Qt.widgets' : '') + (value('IncludeQQuickItem') || value('BaseCB') === 'QQuickItem' ? ':Qt.quick' : '')}"}
    ],

    "pages":
    [
        {
            "trDisplayName": "Define Class",
            "trShortTitle": "Details",
            "typeId": "Fields",
            "data" :
            [
                {
                    "name": "Class",
                    "trDisplayName": "Class name:",
                    "mandatory": true,
                    "type": "LineEdit",
                    "data": {
                        "trPlaceholder": "Fully qualified name, including namespaces",
                        "validator": "(?:(?:[a-zA-Z_][a-zA-Z_0-9]*::)*[a-zA-Z_][a-zA-Z_0-9]*|)",
                        "completion": "namespaces"
                    }
                },
                {
                    "name": "BaseCB",
                    "trDisplayName": "Base class:",
                    "type": "ComboBox",
                    "data":
                    {
                        "items": [ { "trKey": "<Custom>", "value": "" },
                                   "QObject", "QWidget", "QMainWindow", "QQuickItem" ]
                    }
                },
                {
                    "name": "BaseEdit",
                    "type": "LineEdit",
                    "enabled": "%{JS: value('BaseCB') === ''}",
                    "mandatory": false,
                    "data":
                    {
                        "text": "%{BaseCB}",
                        "disabledText": "%{BaseCB}",
                        "completion": "classes"
                    }
                },

                {
                    "name": "Sp1",
                    "type": "Spacer",
                    "data": { "factor": 2 }
                },
                {
                    "name": "IncludeQObject",
                    "trDisplayName": "Include QObject",
                    "type": "CheckBox",
                    "data":
                    {
                        "checkedValue": "QObject",
                        "uncheckedValue": "",
                        "checked": "%{JS: value('BaseCB') === 'QObject'}"
                    }
                },
                {
                    "name": "IncludeQWidget",
                    "trDisplayName": "Include QWidget",
                    "type": "CheckBox",
                    "data":
                    {
                        "checkedValue": "QWidget",
                        "uncheckedValue": "",
                        "checked": "%{JS: value('BaseCB') === 'QWidget'}"
                    }
                },
                {
                    "name": "IncludeQMainWindow",
                    "trDisplayName": "Include QMainWindow",
                    "type": "CheckBox",
                    "data":
                    {
                        "checkedValue": "QMainWindow",
                        "uncheckedValue": "",
                        "checked": "%{JS: value('BaseCB') === 'QMainWindow'}"
                    }
                },
                {
                    "name": "IncludeQQuickItem",
                    "trDisplayName": "Include QQuickItem",
                    "type": "CheckBox",
                    "data":
                    {
                        "checkedValue": "QQuickItem",
                        "uncheckedValue": "",
                        "checked": "%{JS: value('BaseCB') === 'QQuickItem'}"
                    }
                },
                {
                    "name": "IncludeQSharedData",
                    "trDisplayName": "Include QSharedData",
                    "type": "CheckBox",
                    "data":
                    {
                        "checkedValue": "QSharedData",
                        "uncheckedValue": "",
                        "checked": false
                    }
                },
                {
                    "name": "AddQObjectMacro",
                    "trDisplayName": "Add Q_OBJECT",
                    "type": "CheckBox",
                    "data":
                    {
                        "checkedValue": "AddQObjectMacro",
                        "uncheckedValue": "",
                        "checked": "%{JS: [ 'QObject', 'QWidget', 'QMainWindow', 'QQuickItem'].indexOf(value('Base')) >= 0 }"
                    }
                },
                {
                    "name": "AddQmlElementMacro",
                    "trDisplayName": "Add QML_ELEMENT",
                    "type": "CheckBox",
                    "data":
                    {
                        "checkedValue": "AddQmlElementMacro",
                        "uncheckedValue": "",
                        "checked": "%{JS: ['QQuickItem'].indexOf(value('Base')) >= 0 }"
                    }
                },
                {
                    "name": "Sp2",
                    "type": "Spacer"
                },

                {
                    "name": "HdrFileName",
                    "type": "LineEdit",
                    "trDisplayName": "Header file:",
                    "mandatory": true,
                    "data": { "text": "%{JS: Cpp.classToFileName(value('Class'), Cpp.cxxHeaderSuffix())}" }
                },
                {
                    "name": "SrcFileName",
                    "type": "LineEdit",
                    "trDisplayName": "Source file:",
                    "mandatory": true,
                    "data": { "text": "%{JS: Cpp.classToFileName(value('Class'), Cpp.cxxSourceSuffix())}" }
                },
                {
                    "name": "Path",
                    "type": "PathChooser",
                    "trDisplayName": "Path:",
                    "mandatory": true,
                    "data":
                    {
                        "kind": "directory",
                        "basePath": "%{InitialPath}",
                        "path": "%{InitialPath}"
                    }
                }
            ]
        },
        {
            "trDisplayName": "Project Management",
            "trShortTitle": "Summary",
            "typeId": "Summary"
        }
    ],

    "generators":
    [
        {
            "typeId": "File",
            "data":
            [
                {
                    "source": "file.h",
                    "target": "%{HdrPath}",
                    "openInEditor": true,
                    "options": [
                        { "key": "Cpp:License:FileName", "value": "%{HdrFileName}" },
                        { "key": "Cpp:License:ClassName", "value": "%{CN}" }
                    ]
                },
                {
                    "source": "file.cpp",
                    "target": "%{SrcPath}",
                    "openInEditor": true,
                    "options": [
                        { "key": "Cpp:License:FileName", "value": "%{SrcFileName}" },
                        { "key": "Cpp:License:ClassName", "value": "%{CN}" }
                    ]
                }
            ]
        }
    ]
}
