API Documentation
Loading...
Searching...
No Matches
ProxyModelViewFilter.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: ProxyModelViewFilter
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/QTModelManager.h>
35#include <NDEVR/QTModelManagerView.h>
36#include <QDate>
37#include <QSortFilterProxyModel>
38
39namespace NDEVR
40{
41 class Model;
42 /**--------------------------------------------------------------------------------------------------
43 \brief Filters and sorts Models from a ModelManager for views such as in a table or in a tree view.
44 **/
45 class NDEVR_API ProxyModelViewFilter : public QSortFilterProxyModel
46 {
47 Q_OBJECT
48 public:
49 explicit ProxyModelViewFilter(QTModelManager* manager, QObject* parent = nullptr);
50 explicit ProxyModelViewFilter(QTModelManagerView* view, QObject* parent = nullptr);
52 UUID getID(const QModelIndex& index) const;
53 Model model(const QModelIndex& index) const;
54 QModelIndex getIndex(const Model& model) const;
55 QModelIndex getIndex(const UUID& id) const;
56 void setVisibleFilter(const std::function<bool(const Model&)>& filter);
57 void setIsRootFilter(const std::function<bool(const Model&)>& filter);
58 QIcon::Mode iconMode(const QModelIndex& index) const;
59 void setRootModels(const Buffer<UUID>& ids);
60 void setAllowEdits(bool allow);
61 void setGreyHidden(bool grey_hidden);
62 void setShowSelected(bool show_selected);
63 void refreshAll();
64 void invalidate();
65 void setCustomHeader(const TranslatedString& header_title, const String& header_icon);
66 Qt::CheckState checkState(const Model& model) const;
67 void setAllowSelections(bool allow);
68 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
69 Qt::ItemFlags flags(const QModelIndex& index) const override;
70 QVariant data(const QModelIndex& proxyIndex, int role = Qt::DisplayRole) const override;
71 bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
72 void setCheckState(const Model& model, Qt::CheckState check_state);
75 void setSelectedModelRoots(const Buffer<UUID>& roots, bool only_visible_children);
76 void setCheckStateRecursive(const Model& model, Qt::CheckState check_state);
77 void setCheckStateAll(Qt::CheckState check_state);
78 void setCheckStateAll(GeometryType type, Qt::CheckState check_state);
79 void setCheckStateAll(const String& model_type, GeometryType type, Qt::CheckState check_state);
80 void setCheckStateAll(const String& model_type, Qt::CheckState check_state);
81 void setCheckStateAll(const std::function<bool(const Model& model)>& model_type, Qt::CheckState check_state);
84 virtual bool lessThan(const QModelIndex& left, const QModelIndex& right) const override;
85 bool hasIndex(const UUID& id) const;
86 private slots:
87 void modelUpdatedSlot(const Buffer<UUID>& updated_ids);
88 private:
89 void _autosetCheckState(const Model& parent, Qt::CheckState default_check_state);
90 bool filterAcceptsRow(int row, const QModelIndex& parent) const override;
91 bool isTreeVisible(const Model& m) const;
92 bool calculateTreeVisible(const Model& m) const;
93 private:
94 std::function<bool(const Model&)> m_visible_filter;
95 mutable Dictionary<UUID, Qt::CheckState> m_check_states;
96 mutable Dictionary<UUID, bool> m_visible_states;
97 QTModelManagerView* m_view;
98 TranslatedString m_custom_header_title;
99 String m_custom_header_icon;
100 bool m_allow_selections;
101 bool m_allow_edits;
102 bool m_grey_hidden;
103 bool m_show_selected;
104 };
105
106}
107
#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
Filters and sorts Models from a ModelManager for views such as in a table or in a tree view.
Definition ProxyModelViewFilter.h:46
QModelIndex getIndex(const UUID &id) const
void setShowSelected(bool show_selected)
Buffer< UUID > getModelRoots() const
void setCheckStateAll(const String &model_type, Qt::CheckState check_state)
void setGreyHidden(bool grey_hidden)
void setVisibleFilter(const std::function< bool(const Model &)> &filter)
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
void setCheckStateRecursive(const Model &model, Qt::CheckState check_state)
void setCheckState(const Model &model, Qt::CheckState check_state)
ProxyModelViewFilter(QTModelManagerView *view, QObject *parent=nullptr)
Qt::ItemFlags flags(const QModelIndex &index) const override
QModelIndex getIndex(const Model &model) const
ProxyModelViewFilter(QTModelManager *manager, QObject *parent=nullptr)
void setRootModels(const Buffer< UUID > &ids)
void setCheckStateAll(GeometryType type, Qt::CheckState check_state)
QVariant data(const QModelIndex &proxyIndex, int role=Qt::DisplayRole) const override
virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const override
void setAllowEdits(bool allow)
Buffer< UUID > getSelectedModelRoots() const
bool hasIndex(const UUID &id) const
QTModelManager & manager() const
UUID getID(const QModelIndex &index) const
void setCustomHeader(const TranslatedString &header_title, const String &header_icon)
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
void setCheckStateAll(const std::function< bool(const Model &model)> &model_type, Qt::CheckState check_state)
Model model(const QModelIndex &index) const
void setCheckStateAll(Qt::CheckState check_state)
void setSelectedModelRoots(const Buffer< UUID > &roots, bool only_visible_children)
void setIsRootFilter(const std::function< bool(const Model &)> &filter)
void setAllowSelections(bool allow)
Qt::CheckState checkState(const Model &model) const
QIcon::Mode iconMode(const QModelIndex &index) const
void setCheckStateAll(const String &model_type, GeometryType type, Qt::CheckState check_state)
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
The core String class for the NDEVR API.
Definition String.h:69
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
Definition TranslatedString.h:13
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
GeometryType
Definition DesignObjectBase.h:86