API Documentation
Loading...
Searching...
No Matches
QTModelManagerView.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: NDEVR
28File: QTModelManagerView
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include <NDEVR/QTModelManager.h>
34
35#include <NDEVR/Model.h>
36#include <QAbstractItemModel>
37#include <QIcon>
38namespace NDEVR
39{
40 /**--------------------------------------------------------------------------------------------------
41 \brief A Qt compatible ItemModel for interfacing with a DesignObjectLookup.
42 **/
43 class NDEVR_API QTModelManagerView final : public QAbstractItemModel
44 {
45 Q_OBJECT
46 protected:
48 {
52 QString name;
54 QString tooltip;
56 bool is_visible = true;
57 bool is_visible_recursive = true;
58 bool is_selected = false;
59 };
60 public:
61 QTModelManagerView(QTModelManager* manager, QObject *parent = nullptr);
63 virtual ~QTModelManagerView() = default;
64 UUID getID(const QModelIndex& model_index) const;
65 Model model(const QModelIndex& model_index) const;
66 Model model(uint04 row, const QModelIndex& parent) const;
67 bool hasCached(const UUID& id) const;
68 QModelIndex getIndex(const Model& model) const;
69 QModelIndex getIndex(const UUID& id) const;
70 QIcon::Mode iconMode(const QModelIndex& index) const;
71 ModelCache createCache(const Model& model, bool recursive, bool parent_visible) const;
72 void updateModel3DVisible(const UUID& id, bool visible);
73 void recursiveCacheRemove(const UUID& id);
74 virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override;
75 int columnCount(const QModelIndex& parent = QModelIndex()) const override;
76 bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
77 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
78 Qt::ItemFlags flags(const QModelIndex &index) const override;
79 //bool hasChildren(const QModelIndex &parent = QModelIndex()) const override;
80 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
81 QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
82 QModelIndex parent(const QModelIndex& index) const override;
83 void setRootModels(const Buffer<UUID>& roots);
84 const Buffer<UUID>& rootModels() const { return m_root_models; }
85 void setIsRootFilter(const std::function<bool(const Model&)>& filter) { m_root_filter = filter; }
86 void addModel(UUID id);
87 QVariant data(const UUID& id, int role) const;
88 void refreshAll();
89 protected slots:
90 void clearAll();
93 void objectSelected(Buffer<UUID> id, bool selected);
94 void modelFocussed(UUID id, bool selected);
96 void modelUpdatedSlot(const Buffer<UUID>& updated_ids);
99
100 protected:
101
108 std::function<bool(const Model&)> m_root_filter;
109 };
110}
#define NDEVR_API
Definition DLLInfo.h:50
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:56
A hash-based key-value store, useful for quick associative lookups. Key features include:
Definition Dictionary.h:61
A core class that represents a node on model heirarchy. This node may contain a Geometry or one or mo...
Definition Model.h:58
A wrapper around DesignObjectLookup that provides signal and slot functionality and adds rendering ca...
Definition QTModelManager.h:105
A Qt compatible ItemModel for interfacing with a DesignObjectLookup.
Definition QTModelManagerView.h:44
void modelUpdated(UUID id)
Buffer< UUID > m_index_ids
Definition QTModelManagerView.h:106
QModelIndex getIndex(const UUID &id) const
void topLevelChanged(Buffer< UUID > id)
void modelFocussed(UUID id, bool selected)
QTModelManager & manager()
Dictionary< UUID, ModelCache > m_cached_indices
Definition QTModelManagerView.h:107
void modelDeleted(Buffer< UUID > id)
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const override
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Qt::ItemFlags flags(const QModelIndex &index) const override
UUID m_project_id
Definition QTModelManagerView.h:105
void recursiveCacheRemove(const UUID &id)
void objectSelected(Buffer< UUID > id, bool selected)
Model model(uint04 row, const QModelIndex &parent) const
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
void updateModel3DVisible(const UUID &id, bool visible)
QModelIndex getIndex(const Model &model) const
Buffer< UUID > m_root_models
Definition QTModelManagerView.h:104
virtual ~QTModelManagerView()=default
void modelUpdatedSlot(const Buffer< UUID > &updated_ids)
void setRootModels(const Buffer< UUID > &roots)
ModelCache createCache(const Model &model, bool recursive, bool parent_visible) const
bool hasCached(const UUID &id) const
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
void projectChanged(UUID id)
QVariant data(const UUID &id, int role) const
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
std::function< bool(const Model &)> m_root_filter
Definition QTModelManagerView.h:108
QTModelManager * m_manager
Definition QTModelManagerView.h:103
UUID m_tree_capture_id
Definition QTModelManagerView.h:102
int columnCount(const QModelIndex &parent=QModelIndex()) const override
QTModelManagerView(QTModelManager *manager, QObject *parent=nullptr)
QModelIndex parent(const QModelIndex &index) const override
void setIsRootFilter(const std::function< bool(const Model &)> &filter)
Definition QTModelManagerView.h:85
void modelAdded(Buffer< UUID > id)
QIcon::Mode iconMode(const QModelIndex &index) const
Model model(const QModelIndex &model_index) const
const Buffer< UUID > & rootModels() const
Definition QTModelManagerView.h:84
UUID getID(const QModelIndex &model_index) const
Represents a color in the RGB space with optional alpha transparency.
Definition RGBColor.h:54
The core String class for the NDEVR API.
Definition String.h:69
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
Definition UUID.h:60
Definition ACIColor.h:37
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:96
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved 'invali...
Definition BaseValues.hpp:233
Definition QTModelManagerView.h:48
String icon
Definition QTModelManagerView.h:53
Buffer< UUID > children
Definition QTModelManagerView.h:50
QString tooltip
Definition QTModelManagerView.h:54
uint04 cache_index
Definition QTModelManagerView.h:49
QString name
Definition QTModelManagerView.h:52