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 class ModelTableDelegate : public QItemDelegate
49 {
50 Q_OBJECT
51 public:
52 explicit ModelTableDelegate(DesignSortFilterProxyModel* model, QObject* parent = nullptr);
53 void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
54 bool editorEvent(QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index) override;
56 protected:
60 };
61 class DesignPropertyTableView : public QTableView
62 {
63 public:
64 explicit DesignPropertyTableView(QWidget* parent = nullptr);
66 [[nodiscard]] DesignTableModel* model() const { return m_table_model->model(); }
67 QSize minimumSizeHint() const override;
68 void refreshAll();
70 protected:
71 void dataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight, const QVector<int>& roles) override;
72 void rowsInserted(const QModelIndex& parent, int start, int end) override;
73 protected:
75 };
76 class NDEVR_API DesignPropertyTable : public QWidget
77 {
78 Q_OBJECT
79 public:
80 explicit DesignPropertyTable(QWidget* parent = nullptr);
81 explicit DesignPropertyTable(QTModelManager* manager, QWidget* parent = nullptr);
82 virtual ~DesignPropertyTable();
83 void setup();
84 void filterAndSetList(Buffer<UUID> models);
85 void setList(const Buffer<UUID>& models);
86 void addListItem(const UUID& id);
87 void setupTable();
88 bool event(QEvent* event) override;
89 void updateRow(uint04 row);
90 void setTypeAddedFilter(const String& type);
91 void setAddedFilter(const std::function<bool(const Model&)>& callback);
92 void addNewButton(std::function<void(Button*)> callback, const TranslatedString& new_title = _t("Add New"), const String& add_icon = "plus");
93 void addOpenButton(std::function<void(Button*)> callback, const TranslatedString& new_title = _t("Open"), const String& add_icon = "open");
94 void addWidget(QWidget* widget);
95 virtual void setModelManager(QTModelManager* manager);
96 void setColumnVisible(uint04 column, bool visible);
97 uint04 addColumn(DesignObject::DesignProperty property, bool is_editable = true);
98 uint04 addColumn(const DesignParameter& parameter, bool is_editable = true);
99 uint04 addColumn(const TranslatedString& custom_column_name, const DesignParameter& parameter, bool is_editable = true);
100 uint04 addParentPathColumn(const TranslatedString& custom_column_name = TranslatedString());
101 uint04 addMaterialDataColumn(const TranslatedString& custom_column_name = TranslatedString());
102 uint04 addColumn(const TranslatedString& name, const String& icon, const std::function<void(UUID)>& callback);
103 uint04 addColumn(const ModelTableColumnSpec& column);
104 void showSearch(bool show_search);
105 void setEditable(bool editable);
106 void setColumnEditable(uint04 column, bool editable);
107 bool isEditable();
108 Buffer<UUID> selectedIDs() const;
109 void setSelectedCallback(const std::function<void(Model, PopupInfo)>& callback) { m_sort_model->setSelectedCallback(callback); };
110 void setSortCallback(const std::function<bool(const Model& a, const Model& b)>& callback);
111 const std::function<void(Model, PopupInfo)>& selectedCallback() const { return m_sort_model->selectedCallback(); };
112 signals:
114 protected slots:
115 void selected(QModelIndex index);
116 void contextMenu(const QPoint &pos);
117 protected:
126 };
127}
128
#define NDEVR_API
Definition DLLInfo.h:67
#define _t(english_string)
Definition Translator.h:87
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:64
Definition Button.h:60
DesignProperty
Definition DesignObject.h:94
Definition DesignObjectSearchWidget.h:43
Definition DesignParameter.h:42
Definition DesignPropertyTable.h:77
Button * m_edit_button
Definition DesignPropertyTable.h:120
QHBoxLayout * m_bottom_button_layout
Definition DesignPropertyTable.h:121
DesignObjectSearchWidget * m_search_text
Definition DesignPropertyTable.h:119
DesignTableModel * m_view_model
Definition DesignPropertyTable.h:124
DesignSortFilterProxyModel * m_sort_model
Definition DesignPropertyTable.h:125
QWidget * m_search_widget
Definition DesignPropertyTable.h:118
const std::function< void(Model, PopupInfo)> & selectedCallback() const
Definition DesignPropertyTable.h:111
QTModelManager * m_manager
Definition DesignPropertyTable.h:123
DesignPropertyTableView * m_table_view
Definition DesignPropertyTable.h:122
void setSelectedCallback(const std::function< void(Model, PopupInfo)> &callback)
Definition DesignPropertyTable.h:109
Definition DesignPropertyTable.h:62
QSize minimumSizeHint() const override
Definition DesignPropertyTable.cpp:222
DesignPropertyTableView(QWidget *parent=nullptr)
Definition DesignPropertyTable.cpp:181
DesignTableModel * model() const
Definition DesignPropertyTable.h:66
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector< int > &roles) override
Definition DesignPropertyTable.cpp:188
DesignSortFilterProxyModel * m_table_model
Definition DesignPropertyTable.h:74
Buffer< UUID > selectedIDs() const
Definition DesignPropertyTable.cpp:245
void setProxyModel(DesignSortFilterProxyModel *model)
Definition DesignPropertyTable.cpp:216
void rowsInserted(const QModelIndex &parent, int start, int end) override
Definition DesignPropertyTable.cpp:198
void refreshAll()
Definition DesignPropertyTable.cpp:241
Definition DesignTableModel.h:184
DesignTableModel * model()
Definition DesignTableModel.cpp:1015
Definition DesignTableModel.h:116
Definition MaterialWidget.h:44
Definition Model.h:54
Definition DesignPropertyTable.h:49
void setModel(DesignSortFilterProxyModel *model)
Definition DesignPropertyTable.h:55
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
Definition DesignPropertyTable.cpp:25
MaterialWidget * m_draw_material_widget
Definition DesignPropertyTable.h:58
bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) override
Definition DesignPropertyTable.cpp:78
MaterialWidget * m_click_material_widget
Definition DesignPropertyTable.h:59
DesignSortFilterProxyModel * m_table_model
Definition DesignPropertyTable.h:57
ModelTableDelegate(DesignSortFilterProxyModel *model, QObject *parent=nullptr)
Definition DesignPropertyTable.cpp:18
Definition QTModelManager.h:94
Definition String.h:40
Definition TranslatedString.h:9
Definition UUID.h:66
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:120
Definition DesignTableModel.h:49
Definition PopupInfo.h:10