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 class NDEVR_API ProxyModelViewFilter : public QSortFilterProxyModel
43 {
44 Q_OBJECT
45 public:
46 explicit ProxyModelViewFilter(QTModelManager* manager, QObject* parent = nullptr);
47 explicit ProxyModelViewFilter(QTModelManagerView* view, QObject* parent = nullptr);
48 QTModelManager& manager() const;
49 UUID getID(const QModelIndex& index) const;
50 Model model(const QModelIndex& index) const;
51 QModelIndex getIndex(const Model& model) const;
52 QModelIndex getIndex(const UUID& id) const;
53 void setVisibleFilter(const std::function<bool(const Model&)>& filter);
54 void setIsRootFilter(const std::function<bool(const Model&)>& filter);
55 QIcon::Mode iconMode(const QModelIndex& index) const;
56 void setRootModels(const Buffer<UUID>& ids);
57 void setAllowEdits(bool allow);
58 void setGreyHidden(bool grey_hidden);
59 void setShowSelected(bool show_selected);
60 void refreshAll();
61 void invalidate();
62 void setCustomHeader(const TranslatedString& header_title, const String& header_icon);
63 Qt::CheckState checkState(const Model& model) const;
64 void setAllowSelections(bool allow);
65 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
66 Qt::ItemFlags flags(const QModelIndex& index) const override;
67 QVariant data(const QModelIndex& proxyIndex, int role = Qt::DisplayRole) const override;
68 bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
69 void setCheckState(const Model& model, Qt::CheckState check_state);
70 void clearCheckStates();
71 void selectAllVisible();
72 void setSelectedModelRoots(const Buffer<UUID>& roots, bool only_visible_children);
73 void setCheckStateRecursive(const Model& model, Qt::CheckState check_state);
74 void setCheckStateAll(Qt::CheckState check_state);
75 void setCheckStateAll(GeometryType type, Qt::CheckState check_state);
76 void setCheckStateAll(const String& model_type, GeometryType type, Qt::CheckState check_state);
77 void setCheckStateAll(const String& model_type, Qt::CheckState check_state);
78 void setCheckStateAll(const std::function<bool(const Model& model)>& model_type, Qt::CheckState check_state);
79 Buffer<UUID> getSelectedModelRoots() const;
80 Buffer<UUID> getModelRoots() const;
81 virtual bool lessThan(const QModelIndex& left, const QModelIndex& right) const override;
82 bool hasIndex(const UUID& id) const;
83 protected slots:
84 void modelUpdatedSlot(const Buffer<UUID>& updated_ids);
85 protected:
86 void _autosetCheckState(const Model& parent, Qt::CheckState default_check_state);
87 bool filterAcceptsRow(int row, const QModelIndex& parent) const override;
88 bool isTreeVisible(const Model& m) const;
89 bool calculateTreeVisible(const Model& m) const;
90 private:
91 std::function<bool(const Model&)> m_visible_filter;
92 mutable Dictionary<UUID, Qt::CheckState> m_check_states;
93 mutable Dictionary<UUID, bool> m_visible_states;
94 QTModelManagerView* m_view;
95 TranslatedString m_custom_header_title;
96 String m_custom_header_icon;
97 bool m_allow_selections;
98 bool m_allow_edits;
99 bool m_grey_hidden;
100 bool m_show_selected;
101 };
102
103}
104
#define NDEVR_API
Definition DLLInfo.h:67
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:59
A hash-based key-value store, useful for quick associative lookups.
Definition Dictionary.h:59
Definition Model.h:54
Definition ProxyModelViewFilter.h:43
Definition QTModelManager.h:94
Definition QTModelManagerView.h:41
The core String class for the software.
Definition String.h:47
Any text displayed to the user should be defined as a TranslatedString which allows the.
Definition TranslatedString.h:13
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
Definition UUID.h:62
Definition ACIColor.h:37
GeometryType
Definition DesignObjectBase.h:86