API Documentation
Loading...
Searching...
No Matches
DesignPropertyTable.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: DesignPropertyTable
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/DesignTableModel.h>
35#include <NDEVR/Button.h>
36#include <NDEVR/Translator.h>
37#include <QWidget>
38#include <QTableView>
39#include <functional>
40#include <QItemDelegate>
41class QHBoxLayout;
42namespace NDEVR
43{
44 class QTModelManager;
45 class QCustomTableWidget;
46 class DesignObjectSearchWidget;
47 class MaterialWidget;
48 /**--------------------------------------------------------------------------------------------------
49 \brief A QItemDelegate for showing model properties in a QTableView
50 **/
51 class ModelTableDelegate : public QItemDelegate
52 {
53 Q_OBJECT
54 public:
55 explicit ModelTableDelegate(DesignSortFilterProxyModel* model, QObject* parent = nullptr);
56 void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
57 bool editorEvent(QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index) override;
59 protected:
63 };
64 /**--------------------------------------------------------------------------------------------------
65 \brief A QTableView for showing Model or DesignObject properties
66 **/
67 class DesignPropertyTableView : public QTableView
68 {
69 public:
70 explicit DesignPropertyTableView(QWidget* parent = nullptr);
72 [[nodiscard]] DesignTableModel* model() const { return m_table_model->model(); }
73 QSize minimumSizeHint() const override;
74 void refreshAll();
76 protected:
77 void dataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight, const QVector<int>& roles) override;
78 void rowsInserted(const QModelIndex& parent, int start, int end) override;
79 protected:
81 };
82 /**--------------------------------------------------------------------------------------------------
83 \brief A base class for tables wishing to show columns of DesignObject properties.
84 **/
85 class NDEVR_API DesignPropertyTable : public QWidget
86 {
87 Q_OBJECT
88 public:
89 explicit DesignPropertyTable(QWidget* parent = nullptr);
90 explicit DesignPropertyTable(QTModelManager* manager, QWidget* parent = nullptr);
92 void setup();
94 void setList(const Buffer<UUID>& models);
95 void addListItem(const UUID& id);
96 void setupTable();
97 bool event(QEvent* event) override;
98 void updateRow(uint04 row);
99 void setTypeAddedFilter(const String& type);
100 void setAddedFilter(const std::function<bool(const Model&)>& callback);
101 void addNewButton(std::function<void(Button*)> callback, const TranslatedString& new_title = _t("Add New"), const String& add_icon = "plus");
102 void addOpenButton(std::function<void(Button*)> callback, const TranslatedString& new_title = _t("Open"), const String& add_icon = "open");
103 void addWidget(QWidget* widget);
104 virtual void setModelManager(QTModelManager* manager);
105 void setColumnVisible(uint04 column, bool visible);
106 uint04 addColumn(DesignObject::DesignProperty property, bool is_editable = true);
107 uint04 addColumn(const DesignParameter& parameter, bool is_editable = true);
108 uint04 addColumn(const TranslatedString& custom_column_name, const DesignParameter& parameter, bool is_editable = true);
111 uint04 addColumn(const TranslatedString& name, const String& icon, const std::function<void(UUID)>& callback);
113 void showSearch(bool show_search);
114 void setEditable(bool editable);
115 void setColumnEditable(uint04 column, bool editable);
118 void setSelectedCallback(const std::function<void(Model, PopupInfo)>& callback) { m_sort_model->setSelectedCallback(callback); };
119 void setSortCallback(const std::function<bool(const Model& a, const Model& b)>& callback);
120 const std::function<void(Model, PopupInfo)>& selectedCallback() const { return m_sort_model->selectedCallback(); };
121 signals:
123 protected slots:
124 void selected(QModelIndex index);
125 void contextMenu(const QPoint &pos);
126 protected:
135 };
136}
137
#define NDEVR_API
Definition DLLInfo.h:50
#define _t(english_string)
Definition Translator.h:90
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:56
A core widget that allows the user to click one of many button types.
Definition Button.h:66
DesignProperty
Values stored in the property database.
Definition DesignObject.h:93
Allows the user to enter search terms for filtering out tables or other views.
Definition DesignObjectSearchWidget.h:46
A definition of data that is logically stored in the Model heirarchy. Data could be a property of a M...
Definition DesignParameter.h:46
A base class for tables wishing to show columns of DesignObject properties.
Definition DesignPropertyTable.h:86
Button * m_edit_button
Definition DesignPropertyTable.h:129
uint04 addParentPathColumn(const TranslatedString &custom_column_name=TranslatedString())
void setList(const Buffer< UUID > &models)
void setColumnVisible(uint04 column, bool visible)
uint04 addColumn(const ModelTableColumnSpec &column)
DesignPropertyTable(QWidget *parent=nullptr)
void addWidget(QWidget *widget)
void contextMenu(const QPoint &pos)
void filterAndSetList(Buffer< UUID > models)
QHBoxLayout * m_bottom_button_layout
Definition DesignPropertyTable.h:130
void setAddedFilter(const std::function< bool(const Model &)> &callback)
DesignObjectSearchWidget * m_search_text
Definition DesignPropertyTable.h:128
uint04 addColumn(const DesignParameter &parameter, bool is_editable=true)
DesignTableModel * m_view_model
Definition DesignPropertyTable.h:133
void addListItem(const UUID &id)
bool event(QEvent *event) override
void setColumnEditable(uint04 column, bool editable)
void setSortCallback(const std::function< bool(const Model &a, const Model &b)> &callback)
void setEditable(bool editable)
virtual void setModelManager(QTModelManager *manager)
uint04 addColumn(const TranslatedString &name, const String &icon, const std::function< void(UUID)> &callback)
DesignSortFilterProxyModel * m_sort_model
Definition DesignPropertyTable.h:134
void showSearch(bool show_search)
QWidget * m_search_widget
Definition DesignPropertyTable.h:127
uint04 addColumn(DesignObject::DesignProperty property, bool is_editable=true)
Buffer< UUID > selectedIDs() const
void addOpenButton(std::function< void(Button *)> callback, const TranslatedString &new_title=_t("Open"), const String &add_icon="open")
uint04 addColumn(const TranslatedString &custom_column_name, const DesignParameter &parameter, bool is_editable=true)
const std::function< void(Model, PopupInfo)> & selectedCallback() const
Definition DesignPropertyTable.h:120
QTModelManager * m_manager
Definition DesignPropertyTable.h:132
DesignPropertyTableView * m_table_view
Definition DesignPropertyTable.h:131
void setSelectedCallback(const std::function< void(Model, PopupInfo)> &callback)
Definition DesignPropertyTable.h:118
void updateRow(uint04 row)
DesignPropertyTable(QTModelManager *manager, QWidget *parent=nullptr)
void setTypeAddedFilter(const String &type)
uint04 addMaterialDataColumn(const TranslatedString &custom_column_name=TranslatedString())
void selected(QModelIndex index)
void addNewButton(std::function< void(Button *)> callback, const TranslatedString &new_title=_t("Add New"), const String &add_icon="plus")
A QTableView for showing Model or DesignObject properties.
Definition DesignPropertyTable.h:68
QSize minimumSizeHint() const override
DesignPropertyTableView(QWidget *parent=nullptr)
DesignTableModel * model() const
Definition DesignPropertyTable.h:72
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector< int > &roles) override
DesignSortFilterProxyModel * m_table_model
Definition DesignPropertyTable.h:80
Buffer< UUID > selectedIDs() const
void setProxyModel(DesignSortFilterProxyModel *model)
void rowsInserted(const QModelIndex &parent, int start, int end) override
Provides the ability to pull data from a DesignObjectLookup for display in tables within the NDEVR AP...
Definition DesignTableModel.h:195
Provides the ability to pull data from a DesignObjectLookup for display in tables within the NDEVR AP...
Definition DesignTableModel.h:124
A simple widget showing some visual properties of a Material or Model.
Definition MaterialWidget.h:47
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 QItemDelegate for showing model properties in a QTableView.
Definition DesignPropertyTable.h:52
void setModel(DesignSortFilterProxyModel *model)
Definition DesignPropertyTable.h:58
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
MaterialWidget * m_draw_material_widget
Definition DesignPropertyTable.h:61
bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) override
MaterialWidget * m_click_material_widget
Definition DesignPropertyTable.h:62
DesignSortFilterProxyModel * m_table_model
Definition DesignPropertyTable.h:60
ModelTableDelegate(DesignSortFilterProxyModel *model, QObject *parent=nullptr)
A wrapper around DesignObjectLookup that provides signal and slot functionality and adds rendering ca...
Definition QTModelManager.h:105
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
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:96
Provides the ability to pull specific data from a DesignObjectLookup for display in a column of a tab...
Definition DesignTableModel.h:53
Class which is used to pass arguments and requests for creating a popup dialog or widget....
Definition PopupInfo.h:15