mirror of
https://github.com/slint-ui/slint.git
synced 2025-09-30 22:01:13 +00:00
Print an warning in stderr when modifying read-only model
... and improve the documentation of Model
This commit is contained in:
parent
ab522eb147
commit
e1be599bc0
3 changed files with 92 additions and 12 deletions
|
@ -431,11 +431,17 @@ public:
|
|||
/// Returns the data for a particular row. This function should be called with `row <
|
||||
/// row_count()`.
|
||||
virtual ModelData row_data(int i) const = 0;
|
||||
/// Sets the data for a particular row. This function should be called with `row < row_count()`.
|
||||
/// If the model cannot support data changes, then it is ok to do nothing (default
|
||||
/// implementation). If the model can update the data, the implementation should also call
|
||||
/// row_changed.
|
||||
virtual void set_row_data(int, const ModelData &) {};
|
||||
/// Sets the data for a particular row.
|
||||
///
|
||||
/// This function should only be called with `row < row_count()`.
|
||||
///
|
||||
/// If the model cannot support data changes, then it is ok to do nothing.
|
||||
/// The default implementation will print a warning to stderr.
|
||||
///
|
||||
/// If the model can update the data, it should also call `row_changed`
|
||||
virtual void set_row_data(int, const ModelData &) {
|
||||
std::cerr << "Model::set_row_data was called on a read-only model" << std::endl;
|
||||
};
|
||||
|
||||
/// \private
|
||||
/// Internal function called by the view to register itself
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue