29 return Factory::CreateController<TopItemsStrategy, LabelDataRowStrategy>(model, viewModel);
51 auto viewModel = Factory::CreateViewModel<AllChildrenStrategy, LabelDataRowStrategy>(&model);
52 EXPECT_EQ(viewModel->rowCount(), 0);
53 EXPECT_EQ(viewModel->columnCount(), 0);
54 EXPECT_EQ(viewModel->sessionItemFromIndex(QModelIndex()), model.
rootItem());
65 auto viewModel = Factory::CreateViewModel<AllChildrenStrategy, LabelDataRowStrategy>(&model);
67 EXPECT_EQ(viewModel->rowCount(), 1);
68 EXPECT_EQ(viewModel->columnCount(), 2);
71 QModelIndex labelIndex = viewModel->index(0, 0);
72 QModelIndex dataIndex = viewModel->index(0, 1);
75 auto labelItem =
dynamic_cast<ViewLabelItem*
>(viewModel->itemFromIndex(labelIndex));
76 ASSERT_TRUE(labelItem !=
nullptr);
77 EXPECT_EQ(labelItem->item(), propertyItem);
79 auto dataItem =
dynamic_cast<ViewDataItem*
>(viewModel->itemFromIndex(dataIndex));
80 ASSERT_TRUE(dataItem !=
nullptr);
81 EXPECT_EQ(dataItem->item(), propertyItem);
92 CustomModel viewModel(&model);
94 EXPECT_EQ(viewModel.rowCount(), 1);
95 EXPECT_EQ(viewModel.columnCount(), 2);
98 QModelIndex labelIndex = viewModel.index(0, 0);
99 QModelIndex dataIndex = viewModel.index(0, 1);
102 auto labelItem =
dynamic_cast<ViewLabelItem*
>(viewModel.itemFromIndex(labelIndex));
103 ASSERT_TRUE(labelItem !=
nullptr);
104 EXPECT_EQ(labelItem->item(), propertyItem);
106 auto dataItem =
dynamic_cast<ViewDataItem*
>(viewModel.itemFromIndex(dataIndex));
107 ASSERT_TRUE(dataItem !=
nullptr);
108 EXPECT_EQ(dataItem->item(), propertyItem);
Item to carry concrete editable entity (e.g.
bool setData(const T &value, int role=ItemDataRole::DATA, bool direct=false)
Sets data for a given role.
Main class to hold hierarchy of SessionItem objects.
SessionItem * rootItem() const
Returns root item of the model.
T * insertItem(SessionItem *parent=nullptr, const TagRow &tagrow={})
Inserts item into given parent under given tagrow.
Represents data role of SessionItem in any cell of Qt's trees and tables.
Represents display name of SessionItem in any cell of Qt's trees and tables.
Base class for all view models to show content of SessionModel in Qt views.
Main class to represent content of SessionModel in Qt's trees and tables.
CustomModel(SessionModel *model)
materialitems.h Collection of materials to populate MaterialModel.
TEST_F(ViewModelFactoryTest, createDefaultViewModelInitial)
Creating DefaultViewModel using strategies.