File indexing completed on 2024-05-19 05:42:14
0001 // ct_lvtwdg_packagetreemodel.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 INCLUDED_LVTMDL_PACKAGETREEEMODEL 0021 #define INCLUDED_LVTMDL_PACKAGETREEEMODEL 0022 0023 //@PURPOSE: Defines a data model for tree views, containing the 0024 // elements of all namespaces. 0025 // 0026 //@CLASSES: 0027 // lvtmdl::PackageTreeModel: 0028 // 0029 //@DESCRIPTION: This component prepares the data of a 0030 // namespace to be displayed on a tree view 0031 // 0032 /// Usage: 0033 ///------ 0034 /// Create a model and pass the Dbo::Session to it, 0035 /// then plug the model onto a view. 0036 /// 0037 /// You should manually connect to expand and collapse 0038 /// from the treeview Expanded() and Collapsed() signals 0039 /// as we need that information to fetch the data from 0040 /// the namespaces. 0041 0042 #include <ct_lvtmdl_basetreemodel.h> 0043 0044 #include <any> 0045 #include <memory> 0046 0047 #include <lvtmdl_export.h> 0048 0049 namespace Codethink::lvtldr { 0050 class NodeStorage; 0051 } 0052 0053 namespace Codethink::lvtmdl { 0054 0055 class LVTMDL_EXPORT PackageTreeModel : public BaseTreeModel 0056 // This class represents the model of a namespace tree containing 0057 // all inner namespaces and classes. 0058 { 0059 // DATA TYPES 0060 struct PackageTreeModelPrivate; 0061 0062 public: 0063 // CREATORS 0064 explicit PackageTreeModel(lvtldr::NodeStorage& nodeStorage); 0065 // CONSTRUCTOR 0066 0067 ~PackageTreeModel(); 0068 0069 void reload() override; 0070 0071 void fetchMore(const QModelIndex& parent) override; 0072 0073 private: 0074 QStandardItem *itemForLakosianNode(Codethink::lvtldr::LakosianNode *node); 0075 // returns the QStandardItem for the specific Physical Node, or null. 0076 0077 // DATA 0078 std::unique_ptr<PackageTreeModelPrivate> d; 0079 friend PackageTreeModelPrivate; 0080 }; 0081 0082 } // end namespace Codethink::lvtmdl 0083 0084 #endif