27 std::vector<std::unique_ptr<ViewItem>>
children;
35 void appendRow(std::vector<std::unique_ptr<ViewItem>> items)
40 void insertRow(
int row, std::vector<std::unique_ptr<ViewItem>> items)
43 throw std::runtime_error(
"Error in ViewItemImpl: attempt to insert empty row");
46 throw std::runtime_error(
"Error in ViewItemImpl: wrong number of columns.");
48 if (row < 0 || row >
rows)
49 throw std::runtime_error(
"Error in ViewItemImpl: invalid row index.");
52 std::make_move_iterator(items.begin()),
53 std::make_move_iterator(items.end()));
55 columns =
static_cast<int>(items.size());
61 if (row < 0 || row >=
rows)
62 throw std::runtime_error(
"Error in RefViewItem: invalid row index.");
65 auto end = std::next(begin,
columns);
74 if (row < 0 || row >=
rows)
75 throw std::runtime_error(
"Error in RefViewItem: wrong row)");
77 if (column < 0 || column >=
columns)
78 throw std::runtime_error(
"Error in RefViewItem: wrong column)");
98 std::vector<ViewItem*> result;
100 [](
const auto& x) { return x.get(); });
130 for (
auto& x : items)
132 p_impl->appendRow(std::move(items));
139 for (
auto& x : items)
141 p_impl->insertRow(
row, std::move(items));
184 return index >= 0 ? index /
parent()->
p_impl->columns : -1;
193 return index >= 0 ? index %
parent()->
p_impl->columns : -1;
204 if (qt_role == Qt::DisplayRole || qt_role == Qt::EditRole)
206 #if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
223 if (
p_impl->item && qt_role == Qt::EditRole)
233 Qt::ItemFlags result = Qt::ItemIsSelectable | Qt::ItemIsEnabled;
239 return p_impl->get_children();
The main object representing an editable/displayable/serializable entity.
T data(int role=ItemDataRole::DATA) const
Returns data of given type T for given role.
Represents the view of SessionItem's data in a single cell of ViewModel.
int columnCount() const
Returns the number of child item columns that the item has.
int row() const
Returns the row where the item is located in its parent's child table, or -1 if the item has no paren...
ViewItem * child(int row, int column) const
virtual QVariant data(int qt_role) const
Returns the data for given role according to Qt::ItemDataRole namespace definitions.
void setParent(ViewItem *parent)
ViewItem(SessionItem *item, int role)
void insertRow(int row, std::vector< std::unique_ptr< ViewItem >> items)
Insert a row of items at index 'row'.
std::vector< ViewItem * > children() const
void appendRow(std::vector< std::unique_ptr< ViewItem >> items)
Appends a row containing items.
virtual Qt::ItemFlags flags() const
Returns Qt's item flags.
int rowCount() const
Returns the number of child item rows that the item has.
int column() const
Returns the column where the item is located in its parent's child table, or -1 if the item has no pa...
ViewItem * parent() const
virtual bool setData(const QVariant &value, int qt_role)
Sets the data to underlying SessionItem.
void removeRow(int row)
Removes row of items at given 'row'. Items will be deleted.
std::unique_ptr< ViewItemImpl > p_impl
SessionItem * item() const
MVVM_VIEWMODEL_EXPORT QVariant TextColorRole(const SessionItem &item)
Returns text color for given item.
MVVM_VIEWMODEL_EXPORT QVariant ToolTipRole(const SessionItem &item)
Returns tooltip role for given item.
MVVM_MODEL_EXPORT Variant toCustomVariant(const Variant &standard)
Converts Qt variant to custom variant on board of SessionItem.
int IndexOfItem(It begin, It end, const T &item)
Returns index corresponding to the first occurance of the item in the container.
MVVM_MODEL_EXPORT Variant toQtVariant(const Variant &custom)
Converts custom variant to standard variant which Qt views will understand.
materialitems.h Collection of materials to populate MaterialModel.
QVariant ToolTipRole(const SessionItem &item, int ncol=0)
Returns tooltip for given item.
QVariant ForegroundRole(const SessionItem &item)
Returns text color for given item.
void appendRow(std::vector< std::unique_ptr< ViewItem >> items)
QVariant data() const
Returns item data associated with this RefViewItem.
int index_of_child(const ViewItem *child)
std::vector< std::unique_ptr< ViewItem > > children
int rows
buffer to hold rows x columns
ViewItemImpl(SessionItem *item, int role)
ViewItem * child(int row, int column) const
std::vector< ViewItem * > get_children() const
Returns vector of children.
ViewItem * parent_view_item
void insertRow(int row, std::vector< std::unique_ptr< ViewItem >> items)