File indexing completed on 2024-05-05 04:39:49

0001 /*
0002     SPDX-FileCopyrightText: 2012 Miha Čančula <miha@noughmad.eu>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #ifndef KDEVPLATFORM_PLUGIN_TEMPLATEOPTIONSPAGE_H
0008 #define KDEVPLATFORM_PLUGIN_TEMPLATEOPTIONSPAGE_H
0009 
0010 #include <QWidget>
0011 #include <QVariantHash>
0012 
0013 #include "ipagefocus.h"
0014 
0015 
0016 namespace KDevelop
0017 {
0018 
0019 class TemplateRenderer;
0020 
0021 class SourceFileTemplate;
0022 
0023 class TemplateClassAssistant;
0024 
0025 /**
0026  * @brief Shows a page for configuring options specified by a class template
0027  * 
0028  * Templates can include a file that specify configuration options. 
0029  * These can be set by the user before creating the class and are passed to the template.
0030  * 
0031  * @sa SourceFileTemplate::customOptions()
0032  **/
0033 class TemplateOptionsPage : public QWidget, public IPageFocus
0034 {
0035     Q_OBJECT
0036     Q_PROPERTY(QVariantHash templateOptions READ templateOptions)
0037 
0038 public:
0039     /**
0040      * @brief Create a new template options page
0041      *
0042      * @param parent the parent template class assistant
0043      **/
0044     explicit TemplateOptionsPage(QWidget* parent);
0045     /**
0046      * Destructor
0047      **/
0048     ~TemplateOptionsPage() override;
0049 
0050     /**
0051      * Parses template archive file and creates the UI for setting template options.
0052      *
0053      * @param fileTemplate The template archive file
0054      * @param renderer A Grantlee wrapper used to render all the templates
0055      **/
0056     void load(const SourceFileTemplate& fileTemplate, TemplateRenderer* renderer);
0057     /**
0058      * @property templateOptions
0059      * 
0060      * The user-set options. Keys are the options' names, and values are their values. 
0061      *
0062      **/
0063     QVariantHash templateOptions() const;
0064 
0065     void setFocusToFirstEditWidget() override;
0066 
0067 private:
0068     class TemplateOptionsPagePrivate* const d;
0069 };
0070 
0071 }
0072 
0073 #endif // KDEVPLATFORM_PLUGIN_TEMPLATEOPTIONSPAGE_H