File indexing completed on 2024-05-19 05:41:57
0001 // ct_lvtcgn_codegendialog.h -*-C++-*- 0002 0003 /* 0004 // Copyright 2023 Codethink Ltd <codethink@codethink.co.uk> 0005 // SPDX-License-Identifier: Apache-2.0 0006 // 0007 // Licensed under the Apache License, Version 2.0 (the "License"); 0008 // you may not use this file except in compliance with the License. 0009 // You may obtain a copy of the License at 0010 // 0011 // http://www.apache.org/licenses/LICENSE-2.0 0012 // 0013 // Unless required by applicable law or agreed to in writing, software 0014 // distributed under the License is distributed on an "AS IS" BASIS, 0015 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 0016 // See the License for the specific language governing permissions and 0017 // limitations under the License. 0018 */ 0019 0020 #ifndef _CT_LVTCGN_CODEGENDIALOG_H_INCLUDED 0021 #define _CT_LVTCGN_CODEGENDIALOG_H_INCLUDED 0022 0023 #include <ct_lvtcgn_generatecode.h> 0024 #include <lvtcgn_gui_export.h> 0025 #include <ui_ct_lvtcgn_codegendialog.h> 0026 0027 #include <QDialog> 0028 #include <QWidget> 0029 0030 #include <memory> 0031 #include <string> 0032 #include <vector> 0033 0034 namespace Codethink::lvtcgn::gui { 0035 0036 class LVTCGN_GUI_EXPORT CodeGenerationDialog : public QDialog { 0037 public: 0038 struct LVTCGN_GUI_EXPORT Detail { 0039 virtual ~Detail() = default; 0040 0041 virtual QString getExistingDirectory(QDialog& dialog, QString const& defaultPath = ""); 0042 virtual void handleOutputDirEmpty(Ui::CodeGenerationDialogUi& ui); 0043 virtual void codeGenerationIterationCallback(Ui::CodeGenerationDialogUi& ui, 0044 const mdl::CodeGeneration::CodeGenerationStep& step); 0045 virtual void handleCodeGenerationError(Ui::CodeGenerationDialogUi& ui, 0046 Codethink::lvtcgn::mdl::CodeGenerationError const& error); 0047 virtual void showErrorMessage(Ui::CodeGenerationDialogUi& ui, QString const& message); 0048 virtual QString executablePath() const; 0049 }; 0050 0051 private: 0052 struct Private; 0053 std::unique_ptr<Private> d; 0054 std::unique_ptr<Detail> impl; 0055 0056 protected: 0057 void runCodeGeneration(); 0058 void searchOutputDir(); 0059 void populateAvailableScriptsCombobox(); 0060 void openOutputDir() const; 0061 0062 public: 0063 explicit CodeGenerationDialog(mdl::ICodeGenerationDataProvider& dataProvider, 0064 std::unique_ptr<Detail> impl = nullptr, 0065 QWidget *parent = nullptr); 0066 ~CodeGenerationDialog() override; 0067 0068 void setOutputDir(const QString& dir); 0069 QString outputDir() const; 0070 QString selectedScriptPath() const; 0071 }; 0072 0073 } // namespace Codethink::lvtcgn::gui 0074 0075 #endif // CT_LVTCGN_CODEGENDIALOG_H_INCLUDED