15 #ifndef BORNAGAIN_MVVM_VIEWMODEL_MVVM_VIEWMODEL_VIEWMODELBASE_H
16 #define BORNAGAIN_MVVM_VIEWMODEL_MVVM_VIEWMODEL_VIEWMODELBASE_H
18 #include "mvvm/viewmodel_export.h"
19 #include <QAbstractItemModel>
37 QModelIndex index(
int row,
int column,
38 const QModelIndex& parent = QModelIndex())
const override;
40 QModelIndex parent(
const QModelIndex& child)
const override;
42 int rowCount(
const QModelIndex& parent = QModelIndex())
const override;
44 int columnCount(
const QModelIndex& parent = QModelIndex())
const override;
46 QVariant data(
const QModelIndex& index,
int role = Qt::DisplayRole)
const override;
48 bool setData(
const QModelIndex& index,
const QVariant& value,
int role)
override;
52 ViewItem* itemFromIndex(
const QModelIndex& index)
const;
54 QModelIndex indexFromItem(
const ViewItem* item)
const;
60 void insertRow(
ViewItem* parent,
int row, std::vector<std::unique_ptr<ViewItem>> items);
62 void appendRow(
ViewItem* parent, std::vector<std::unique_ptr<ViewItem>> items);
64 Qt::ItemFlags flags(
const QModelIndex& index)
const override;
67 void setRootViewItem(std::unique_ptr<ViewItem> root_item);
70 std::unique_ptr<ViewModelBaseImpl>
p_impl;
Represents the view of SessionItem's data in a single cell of ViewModel.
Base class for all view models to show content of SessionModel in Qt views.
std::unique_ptr< ViewModelBaseImpl > p_impl
~ViewModelBase() override
Propagates changes from SessionModel to its ViewModelBase.
void removeRow(QGridLayout *layout, int row, bool deleteWidgets=true)
Removes row from grid layout (important: doesn't change row count).
materialitems.h Collection of materials to populate MaterialModel.