File indexing completed on 2024-05-19 05:41:57
0001 // ct_lvtcgn_codegentreemodel.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_COGEDENTREEMODEL_H_INCLUDED 0021 #define _CT_LVTCGN_COGEDENTREEMODEL_H_INCLUDED 0022 0023 #include <lvtcgn_gui_export.h> 0024 0025 #include <QList> 0026 #include <QStandardItemModel> 0027 #include <QVariant> 0028 0029 namespace Codethink::lvtcgn::mdl { 0030 class ICodeGenerationDataProvider; 0031 class IPhysicalEntityInfo; 0032 } // namespace Codethink::lvtcgn::mdl 0033 0034 namespace Codethink::lvtcgn::gui { 0035 0036 enum CodeGenerationDataRole { EntityNameRole = Qt::UserRole, InfoReferenceRole = Qt::UserRole + 1 }; 0037 0038 class LVTCGN_GUI_EXPORT CodeGenerationEntitiesTreeModel : public QStandardItemModel { 0039 public: 0040 enum class RecursiveExec { ContinueSearch, StopSearch }; 0041 0042 explicit CodeGenerationEntitiesTreeModel(mdl::ICodeGenerationDataProvider& dataProvider, QObject *parent = 0); 0043 void refreshContents(); 0044 void recursiveExec(std::function<RecursiveExec(QStandardItem *)> f); 0045 0046 private: 0047 void populateItemAndChildren(mdl::IPhysicalEntityInfo& info, QStandardItem *parent); 0048 void updateAllChildrenState(QStandardItem *item); 0049 void updateParentState(QStandardItem *item); 0050 0051 mdl::ICodeGenerationDataProvider& dataProvider; 0052 0053 bool itemChangedCascadeUpdate = true; 0054 // Helper boolean to control cascade updates in the itemChanged signal 0055 }; 0056 0057 } // namespace Codethink::lvtcgn::gui 0058 0059 #endif