34#include <NDEVR/DesignObject.h>
35#include <NDEVR/DesignParameter.h>
36#include <QSortFilterProxyModel>
37#include <QAbstractTableModel>
244 [[nodiscard]]
int rowCount(
const QModelIndex& parent = QModelIndex())
const override;
250 [[nodiscard]]
int columnCount(
const QModelIndex& parent = QModelIndex())
const override;
262 [[nodiscard]] QVariant
data(
const QModelIndex& index,
int role = Qt::DisplayRole)
const override;
269 [[nodiscard]] QVariant
userData(
const QModelIndex& index,
int role)
const;
289 [[nodiscard]]
bool setData(
const QModelIndex& index,
const QVariant& value,
int role)
override;
297 [[nodiscard]] QVariant
headerData(
int section, Qt::Orientation orientation,
int role = Qt::DisplayRole)
const override;
374 [[nodiscard]] Qt::ItemFlags
flags(
const QModelIndex& index)
const override;
546 void sort(Qt::SortOrder order = Qt::DescendingOrder);
552 void sort(
int column, Qt::SortOrder order = Qt::DescendingOrder)
override;
558 void sortBy(
NDPO property, Qt::SortOrder order = Qt::DescendingOrder);
576 void onSelected(
const QModelIndex& index,
const QRect& rect);
665 virtual bool filterAcceptsRow(
int sourceRow,
const QModelIndex& sourceParent)
const override;
672 virtual bool lessThan(
const QModelIndex& left,
const QModelIndex& right)
const override;
The equivelent of std::vector but with a bit more control.
A low-level database object that can be used to access general stored properties within the NDEVR Mod...
A definition of data that is logically stored in the Model hierarchy.
ModelTableColumnSpec columnSpec(const QModelIndex &index)
Returns the column specification for the given proxy index.
void sortBy(ModelTableColumnSpec spec, Qt::SortOrder order=Qt::DescendingOrder)
Sorts the table by a single column specification.
void sort(int column, Qt::SortOrder order=Qt::DescendingOrder) override
Sorts the table by the given column.
void setColumnEditable(uint04 column, bool is_editable)
Sets whether a specific column is editable.
TranslatedString searchByTitle() const
Returns the display title of the current search parameter.
QTModelManager * modelManager() const
Returns the model manager from the underlying table model.
void sort(Qt::SortOrder order=Qt::DescendingOrder)
Sorts the table using the current sort specifications.
ModelTableColumnSpec m_current_search_parameter
The currently active search parameter.
virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override
Returns whether the row at the given source index passes the current filter.
DesignTableModel * model()
Returns the underlying DesignTableModel.
ModelTableColumnSpec m_search_parameter
The user-configured search parameter.
DesignSortFilterProxyModel(DesignTableModel *model, QObject *parent=nullptr)
Constructs a DesignSortFilterProxyModel wrapping the given table model.
Model getModel(const QModelIndex &index)
Returns the Model for the row of the given proxy index.
void setSearchString(const StringView &search_string)
Sets the search string used for filtering rows.
Buffer< ModelTableColumnSpec > m_sort_by
The column specifications used for sorting.
void sortBy(const Buffer< ModelTableColumnSpec > &specs, Qt::SortOrder order=Qt::DescendingOrder)
Sorts the table by multiple column specifications as tiebreakers.
String m_search_string
The current search/filter text.
bool isSpecialCallbackIndex(const QModelIndex &index) const
Returns whether the given proxy index represents a custom callback column.
void sortBy(NDPO property, Qt::SortOrder order=Qt::DescendingOrder)
Sorts the table by the given NDPO property.
std::function< void(Model, PopupInfo)> m_selected_callback
Callback invoked when a row is selected.
bool isEditable() const
Returns whether the table is currently editable.
virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const override
Compares two source model indices for sorting.
std::function< bool(const Model &a, const Model &b)> m_sort_function
Custom sort comparison function.
DesignTableModel * m_design_model
The underlying DesignTableModel.
bool modelIsShown(const DynamicPointer< QTDesignObject > &a) const
Returns whether the given design object should be shown after filtering.
void searchByParameterChangedSignal()
Emitted when the search-by parameter changes.
void setIsEditable(bool is_editable)
Sets whether the table is editable.
ModelTableColumnSpec currentSearchParameter() const
Returns the currently active search parameter column specification.
void setSortCallback(const std::function< bool(const Model &a, const Model &b)> &callback)
Sets a custom sort comparison callback for ordering rows.
const std::function< void(Model, PopupInfo)> & selectedCallback() const
Returns the current selection callback.
void setSearchParameter(const ModelTableColumnSpec &search_parameter)
Sets the column parameter used for search filtering.
void onSelected(const QModelIndex &index, const QRect &rect)
Handles a row selection event on the proxy model.
void setSelectedCallback(const std::function< void(Model, PopupInfo)> &callback)
Sets the callback invoked when a row is selected.
bool isMaterialIndex(const QModelIndex &index) const
Returns whether the given proxy index represents a material column.
UUID getUUID(const QModelIndex &index)
Returns the UUID for the row of the given proxy index.
Provides the ability to pull data from a DesignObjectLookup for display in tables within the NDEVR AP...
virtual void objectAdded(const Buffer< UUID > &ids)
Called when new design objects are added to the model manager.
bool isSpecialCallbackIndex(const QModelIndex &index) const
Returns whether the given index represents a custom callback column.
bool isObjectAllowed(const UUID &object) const
Returns whether the given object UUID passes the added filter.
void onSelected(QModelIndex index, const QRect &rect)
Handles a row selection event, invoking the selected callback.
void setup()
Performs initial setup, connecting to the model manager signals.
Qt::ItemFlags flags(const QModelIndex &index) const override
Returns the item flags for the given index.
const ModelTableColumnSpec & getColumnSpec(uint04 column) const
Returns the column specification for the given column index.
uint04 addGrandparentNameColumn(const TranslatedString &custom_column_name=TranslatedString())
Adds a column showing the grandparent name of each object.
void setIsEditable(bool is_editable)
Sets whether the table is editable.
virtual void modelUpdated(const Buffer< UUID > &ids)
Called when existing design objects are updated.
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Returns the data for the given index and role.
bool isMaterialIndex(const QModelIndex &index) const
Returns whether the given index represents a material column.
Buffer< BitFlag > m_callback_clicked
Tracks which callback buttons have been clicked per row.
QTModelManager * modelManager() const
Returns the model manager.
QTResourceListener * m_angle_listener
Listener for angle unit changes.
QTModelManager * m_manager
The model manager providing design objects.
void setColumnEditable(uint04 column, bool is_editable)
Sets whether a specific column is editable.
bool m_is_editable
Whether the table is currently editable.
QTResourceListener * m_orientation_listener
Listener for orientation unit changes.
Buffer< UUID > m_models
List of all model UUIDs displayed in the table.
void setList(const Buffer< UUID > &models)
Sets the list of object UUIDs to display as rows.
Model getModel(QModelIndex index) const
Returns the Model for the row of the given index.
uint04 addColumn(const TranslatedString &name, const StringView &icon, const std::function< void(UUID)> &callback)
Adds a button column with a label, icon, and click callback.
std::function< bool(const Model &)> m_added_filter
Filter callback for added/valid objects.
uint04 addColumn(const DesignParameter ¶meter, bool is_editable)
Adds a column displaying the given design parameter.
QVariant userData(const QModelIndex &index, int role) const
Returns custom user-role data for the given index.
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of rows in the table.
uint04 addColumn(NDPO property, bool is_editable)
Adds a column displaying the given NDPO property.
void modelUpdatedSlot(const Buffer< UUID > &ids)
Slot connected to the model manager's model-updated signal.
bool setData(const QModelIndex &index, const QVariant &value, int role) override
Sets data at the given index for the specified role.
virtual void objectDeleted(const Buffer< UUID > &ids)
Called when design objects are deleted from the model manager.
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Returns the header data for the given section, orientation, and role.
void setModelManager(QTModelManager *manager)
Sets the model manager and connects its signals.
bool canAddObject(const Model &object) const
Returns whether the given Model can be added to the table.
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of columns in the table.
void setAddedFilter(const std::function< bool(const Model &)> &callback)
Sets a filter callback applied when objects are added to the table.
DesignObject getObject(QModelIndex index, int row) const
Returns the DesignObject for the given row number.
UUID getUUID(QModelIndex index, int row) const
Returns the UUID for the given row number.
DesignObject getObject(QModelIndex index) const
Returns the DesignObject for the row of the given index.
DesignTableModel(QObject *parent=nullptr)
Constructs a DesignTableModel.
DynamicPointer< QTDesignObject > getDesignObject(QModelIndex index, int row) const
Returns the QTDesignObject for the given row number.
void objectDeletedSlot(const Buffer< UUID > &ids)
Slot connected to the model manager's object-deleted signal.
Buffer< ModelTableColumnSpec > m_columns
The column specifications for the table.
uint04 addColumn(const ModelTableColumnSpec &column)
Adds a column from a fully specified ModelTableColumnSpec.
QTResourceListener * m_coord_listener
Listener for coordinate unit changes.
UUID getUUID(QModelIndex index) const
Returns the UUID for the row of the given index.
bool isObjectAllowed(const Model &object) const
Returns whether the given Model passes the added filter.
uint04 addParentPathColumn(const TranslatedString &custom_column_name=TranslatedString())
Adds a column showing the parent path of each object.
DynamicPointer< QTDesignObject > getDesignObject(QModelIndex index) const
Returns the QTDesignObject for the row of the given index.
void objectAddedSlot(const Buffer< UUID > &ids)
Slot connected to the model manager's object-added signal.
void refreshAll()
Forces a full refresh of all rows and columns.
bool isEditable() const
Returns whether the table is currently editable.
uint04 addMaterialDataColumn(const TranslatedString &custom_column_name=TranslatedString())
Adds a column showing the material of each object.
uint04 addParentDataColumn(const DesignParameter ¶m, bool is_editable, const TranslatedString &custom_column_name=TranslatedString())
Adds a column showing a parent design parameter value.
void updateColumn(uint04 index)
Updates a single column specification at the given index.
Provides a modifiable pointer that has shared ownership of a dynamically allocated object.
A core class that represents a node on model hierarchy.
A pointer to a DesignObject within a QTModelManager that receives and emits update signals based on t...
A wrapper around DesignObjectLookup that provides signal and slot functionality and adds rendering ca...
A ResourceListener which will always be executed on the main UI thread and can be tied to a Qt Object...
This class is like a string view, but may optionally store the data internally Useful if the return t...
The core String View class for the NDEVR API.
The core String class for the NDEVR API.
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
The primary namespace for the NDEVR SDK.
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
NDPO
NDPO - NDEVR Design Property Object: Values stored in the property database.
constexpr int model_table_is_selected_index
Custom role index indicating whether a row is selected.
constexpr int model_table_is_clicked_index
Custom role index indicating whether a cell button has been clicked.
RelativePathObject(RelativePath path, StringView type)
Constructs a RelativePathObject with a path direction and type filter.
String type
Optional type filter for the target object.
RelativePath path
The direction to navigate.
RelativePathObject(RelativePath path)
Constructs a RelativePathObject with a path direction.
std::function< void(DesignObject &)> create_callback
A callback for creating the missing child, if it does not exist.
Provides the ability to pull specific data from a DesignObjectLookup for display in a column of a tab...
bool is_clicked
Whether the button in this column is currently in a clicked state.
StringAllocatingView stringDisplayData(const DesignObject &obj) const
Returns the string representation of the column data for the given object.
bool setData(const DesignObject &obj, const QVariant &value, int role)
Sets data on the given object for the specified role.
uint04 max_decimal_places
Maximum number of decimal places for numeric display.
RelativePath
Specifies a relative path from a design object to a related object in the hierarchy.
@ e_last_child
Navigate to the last child object.
@ e_child_5
Navigate to child at index 5.
@ e_child_7
Navigate to child at index 7.
@ e_child_2
Navigate to child at index 2.
@ e_child_3
Navigate to child at index 3.
@ e_parent
Navigate to the parent object.
@ e_child_6
Navigate to child at index 6.
@ e_child_1
Navigate to child at index 1.
@ e_child_0
Navigate to child at index 0.
@ e_child_4
Navigate to child at index 4.
@ e_child_index
Base index for child navigation by position.
bool isSortEqual(const DesignObject &a, const DesignObject &b) const
Returns whether two design objects have equal sort values for this column.
bool isTextEditable() const
Returns whether this column supports inline text editing.
bool isSortLessThan(const DesignObject &a, const DesignObject &b) const
Returns whether the first design object sorts before the second for this column.
ModelTableColumnSpec(const DesignParameter ¶meter)
Constructs a design parameter column.
TranslatedString headerTitle() const
Returns the column header title.
DesignObject getTarget(const DesignObject &a, bool try_to_create) const
Resolves the target design object by following the relative path.
bool isValid() const
Returns whether this column specification is valid.
ModelTableType column_type
The type of data this column displays.
std::function< void(UUID)> callback
The callback invoked when a button column is clicked.
TranslatedString custom_column_name
Custom header name override.
QVariant data(const DesignObject &obj, int role=Qt::DisplayRole) const
Returns the data for the given object and role.
ModelTableColumnSpec(const TranslatedString &text, const StringView &icon, const std::function< void(UUID)> &callback)
Constructs a button column with a label, icon, and click callback.
ModelTableColumnSpec(const DesignParameter ¶meter, Buffer< RelativePathObject > relative_mode)
Constructs a design parameter column with a relative path to the data source.
bool isCheckEditable() const
Returns whether this column supports checkbox editing.
QVariant parameterData(const DesignObject &obj, int role) const
Returns data from the design parameter for the given object and role.
TranslatedString custom_text
Custom display text for button columns.
ModelTableColumnSpec(const std::function< void(UUID)> &callback)
Constructs a custom callback column.
String custom_icon
Icon name for button columns.
bool is_currently_editable
Whether this column is currently in an editable state.
ModelTableType
The type of data a table column displays.
@ e_model_material
Column displays a material swatch.
@ e_custom_callback
Column displays a button that invokes a custom callback.
@ e_design_parameter
Column displays a design parameter value.
ModelTableColumnSpec()
Default constructor.
DesignParameter design_parameter
The design parameter displayed by this column.
uint04 min_decimal_places
Minimum number of decimal places for numeric display.
bool is_editable
Whether this column allows editing.
ModelTableColumnSpec(ModelTableType type)
Constructs a column of the specified type.
Buffer< RelativePathObject > relative_path
The relative path from the row object to the actual data source.