File indexing completed on 2024-05-05 04:39:49
0001 /* 0002 SPDX-FileCopyrightText: 2008 Hamish Rodda <rodda@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-only 0005 */ 0006 0007 #ifndef KDEVPLATFORM_PLUGIN_OUTPUTPAGE_H 0008 #define KDEVPLATFORM_PLUGIN_OUTPUTPAGE_H 0009 0010 #include <KTextEditor/Cursor> 0011 0012 #include <QWidget> 0013 #include <QUrl> 0014 0015 #include "ipagefocus.h" 0016 0017 namespace KDevelop { 0018 0019 class TemplateRenderer; 0020 class SourceFileTemplate; 0021 class CreateClassAssistant; 0022 0023 /** 0024 * Assistant page for setting the output location of generated source code 0025 */ 0026 class OutputPage : public QWidget, public IPageFocus 0027 { 0028 Q_OBJECT 0029 0030 public: 0031 explicit OutputPage(QWidget* parent); 0032 ~OutputPage() override; 0033 0034 /** 0035 * Creates form widgets according to the number of output files of the template @p fileTemplate. 0036 * File identifiers and labels are read from @p fileTemplate, but not the actual URLs. 0037 * 0038 * This function is useful to prevent UI flickering that occurs when adding widgets while the page is visible. 0039 * It can be called immediately after the template is selected, before the user specified anything for the generated code. 0040 */ 0041 void prepareForm(const KDevelop::SourceFileTemplate& fileTemplate); 0042 /** 0043 * Loads file URLs from the template @p fileTemplate. 0044 * This function only sets URLs and file positions to widgets created by prepareForm(), 0045 * so be sure to call prepareForm() before calling this function. 0046 * 0047 * @param fileTemplate the template archive with the generated files 0048 * @param baseUrl the directory where the files are to be generated 0049 * @param renderer used to render any variables in output URLs 0050 */ 0051 void loadFileTemplate(const KDevelop::SourceFileTemplate& fileTemplate, const QUrl& baseUrl, 0052 KDevelop::TemplateRenderer* renderer); 0053 0054 /** 0055 * Returns the file URLs, as specified by the user. 0056 */ 0057 QHash<QString, QUrl> fileUrls() const; 0058 /** 0059 * Returns the positions within files where code is to be generated. 0060 */ 0061 QHash<QString, KTextEditor::Cursor> filePositions() const; 0062 0063 void setFocusToFirstEditWidget() override; 0064 0065 Q_SIGNALS: 0066 /** 0067 * @copydoc ClassIdentifierPage::isValid 0068 */ 0069 void isValid(bool valid); 0070 0071 private: 0072 friend struct OutputPagePrivate; 0073 struct OutputPagePrivate* const d; 0074 }; 0075 0076 } 0077 0078 #endif // KDEVPLATFORM_PLUGIN_OUTPUTPAGE_H