NDEVR
API Documentation
ModelTableColumnSpec

Provides the ability to pull specific data from a DesignObjectLookup for display in a column of a table. More...

Collaboration diagram for ModelTableColumnSpec:
[legend]

Classes

struct  RelativePathObject
 Describes a single step in a relative path traversal, optionally filtering by type. More...

Public Types

enum  ModelTableType { e_design_parameter , e_model_material , e_custom_callback }
 The type of data a table column displays. More...
enum  RelativePath {
  e_parent , e_last_child , e_child_index = 10 , e_child_0 = e_child_index ,
  e_child_1 , e_child_2 , e_child_3 , e_child_4 ,
  e_child_5 , e_child_6 , e_child_7
}
 Specifies a relative path from a design object to a related object in the hierarchy. More...

Public Member Functions

 ModelTableColumnSpec ()
 Default constructor.
 ModelTableColumnSpec (const DesignParameter &parameter)
 Constructs a design parameter column.
 ModelTableColumnSpec (const DesignParameter &parameter, Buffer< RelativePathObject > relative_mode)
 Constructs a design parameter column with a relative path to the data source.
 ModelTableColumnSpec (const std::function< void(UUID)> &callback)
 Constructs a custom callback column.
 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 (ModelTableType type)
 Constructs a column of the specified type.
QVariant data (const DesignObject &obj, int role=Qt::DisplayRole) const
 Returns the data for the given object and role.
DesignObject getTarget (const DesignObject &a, bool try_to_create) const
 Resolves the target design object by following the relative path.
TranslatedString headerTitle () const
 Returns the column header title.
bool isCheckEditable () const
 Returns whether this column supports checkbox editing.
bool isSortEqual (const DesignObject &a, const DesignObject &b) const
 Returns whether two design objects have equal sort values for this column.
bool isSortLessThan (const DesignObject &a, const DesignObject &b) const
 Returns whether the first design object sorts before the second for this column.
bool isTextEditable () const
 Returns whether this column supports inline text editing.
bool isValid () const
 Returns whether this column specification is valid.
bool setData (const DesignObject &obj, const QVariant &value, int role)
 Sets data on the given object for the specified role.
StringAllocatingView stringDisplayData (const DesignObject &obj) const
 Returns the string representation of the column data for the given object.

Public Attributes

std::function< void(UUID)> callback
 The callback invoked when a button column is clicked.
ModelTableType column_type
 The type of data this column displays.
TranslatedString custom_column_name
 Custom header name override.
String custom_icon
 Icon name for button columns.
TranslatedString custom_text
 Custom display text for button columns.
DesignParameter design_parameter
 The design parameter displayed by this column.
bool is_clicked = false
 Whether the button in this column is currently in a clicked state.
bool is_currently_editable = false
 Whether this column is currently in an editable state.
bool is_editable
 Whether this column allows editing.
uint04 max_decimal_places
 Maximum number of decimal places for numeric display.
uint04 min_decimal_places
 Minimum number of decimal places for numeric display.
Buffer< RelativePathObjectrelative_path
 The relative path from the row object to the actual data source.

Protected Member Functions

QVariant parameterData (const DesignObject &obj, int role) const
 Returns data from the design parameter for the given object and role.

Detailed Description

Provides the ability to pull specific data from a DesignObjectLookup for display in a column of a table.


Definition at line 52 of file DesignTableModel.h.

Member Enumeration Documentation

◆ ModelTableType

The type of data a table column displays.

Enumerator
e_design_parameter 

Column displays a design parameter value.

e_model_material 

Column displays a material swatch.

e_custom_callback 

Column displays a button that invokes a custom callback.

Definition at line 57 of file DesignTableModel.h.

◆ RelativePath

Specifies a relative path from a design object to a related object in the hierarchy.

Enumerator
e_parent 

Navigate to the parent object.

e_last_child 

Navigate to the last child object.

e_child_index 

Base index for child navigation by position.

e_child_0 

Navigate to child at index 0.

e_child_1 

Navigate to child at index 1.

e_child_2 

Navigate to child at index 2.

e_child_3 

Navigate to child at index 3.

e_child_4 

Navigate to child at index 4.

e_child_5 

Navigate to child at index 5.

e_child_6 

Navigate to child at index 6.

e_child_7 

Navigate to child at index 7.

Definition at line 66 of file DesignTableModel.h.

Constructor & Destructor Documentation

◆ ModelTableColumnSpec() [1/5]

ModelTableColumnSpec::ModelTableColumnSpec ( const std::function< void(UUID)> & callback)
explicit

Constructs a custom callback column.

Parameters
[in]callbackThe function called with the object UUID when clicked.

References callback.

◆ ModelTableColumnSpec() [2/5]

ModelTableColumnSpec::ModelTableColumnSpec ( const DesignParameter & parameter)
explicit

Constructs a design parameter column.

Parameters
[in]parameterThe design parameter to display.

◆ ModelTableColumnSpec() [3/5]

ModelTableColumnSpec::ModelTableColumnSpec ( const DesignParameter & parameter,
Buffer< RelativePathObject > relative_mode )
explicit

Constructs a design parameter column with a relative path to the data source.

Parameters
[in]parameterThe design parameter to display.
[in]relative_modeThe relative path from the row object to the data source.

◆ ModelTableColumnSpec() [4/5]

ModelTableColumnSpec::ModelTableColumnSpec ( ModelTableType type)
explicit

Constructs a column of the specified type.

Parameters
[in]typeThe table column type.

◆ ModelTableColumnSpec() [5/5]

ModelTableColumnSpec::ModelTableColumnSpec ( const TranslatedString & text,
const StringView & icon,
const std::function< void(UUID)> & callback )

Constructs a button column with a label, icon, and click callback.

Parameters
[in]textThe button label text.
[in]iconThe icon name.
[in]callbackThe function called with the object UUID when clicked.

References callback.

Member Function Documentation

◆ data()

QVariant ModelTableColumnSpec::data ( const DesignObject & obj,
int role = Qt::DisplayRole ) const
nodiscard

Returns the data for the given object and role.

Parameters
[in]objThe design object.
[in]roleThe Qt data role.
Returns
The data as a QVariant.

◆ getTarget()

DesignObject ModelTableColumnSpec::getTarget ( const DesignObject & a,
bool try_to_create ) const
nodiscard

Resolves the target design object by following the relative path.

Parameters
[in]aThe starting design object.
[in]try_to_createWhether to create missing children via callbacks.
Returns
The resolved target DesignObject.

◆ headerTitle()

TranslatedString ModelTableColumnSpec::headerTitle ( ) const
nodiscard

Returns the column header title.

Returns
The translated header title.

◆ isCheckEditable()

bool ModelTableColumnSpec::isCheckEditable ( ) const
nodiscard

Returns whether this column supports checkbox editing.

Returns
True if check-editable.

◆ isSortEqual()

bool ModelTableColumnSpec::isSortEqual ( const DesignObject & a,
const DesignObject & b ) const
nodiscard

Returns whether two design objects have equal sort values for this column.

Parameters
[in]aThe first design object.
[in]bThe second design object.
Returns
True if they sort equally.

◆ isSortLessThan()

bool ModelTableColumnSpec::isSortLessThan ( const DesignObject & a,
const DesignObject & b ) const
nodiscard

Returns whether the first design object sorts before the second for this column.

Parameters
[in]aThe first design object.
[in]bThe second design object.
Returns
True if a sorts before b.

◆ isTextEditable()

bool ModelTableColumnSpec::isTextEditable ( ) const
nodiscard

Returns whether this column supports inline text editing.

Returns
True if text-editable.

◆ isValid()

bool ModelTableColumnSpec::isValid ( ) const
nodiscard

Returns whether this column specification is valid.

Returns
True if valid.

◆ parameterData()

QVariant ModelTableColumnSpec::parameterData ( const DesignObject & obj,
int role ) const
nodiscardprotected

Returns data from the design parameter for the given object and role.

Parameters
[in]objThe design object.
[in]roleThe Qt data role.
Returns
The parameter data as a QVariant.

◆ setData()

bool ModelTableColumnSpec::setData ( const DesignObject & obj,
const QVariant & value,
int role )
nodiscard

Sets data on the given object for the specified role.

Parameters
[in]objThe design object.
[in]valueThe new value.
[in]roleThe Qt data role.
Returns
True if the data was set successfully.

◆ stringDisplayData()

StringAllocatingView ModelTableColumnSpec::stringDisplayData ( const DesignObject & obj) const
nodiscard

Returns the string representation of the column data for the given object.

Parameters
[in]objThe design object.
Returns
The display string.

The documentation for this struct was generated from the following file: