53 QSignalSpy spyInsert(&viewmodel, &ViewModelBase::rowsInserted);
54 QSignalSpy spyRemove(&viewmodel, &ViewModelBase::rowsRemoved);
58 EXPECT_EQ(viewmodel.
rowCount(QModelIndex()), 1);
61 EXPECT_EQ(spyRemove.count(), 0);
62 EXPECT_EQ(spyInsert.count(), 1);
65 EXPECT_EQ(spyRemove.count(), 1);
66 EXPECT_EQ(spyInsert.count(), 1);
68 EXPECT_EQ(viewmodel.
rowCount(QModelIndex()), 0);
79 QSignalSpy spyInsert(&viewmodel, &ViewModelBase::rowsInserted);
80 QSignalSpy spyRemove(&viewmodel, &ViewModelBase::rowsRemoved);
85 EXPECT_EQ(viewmodel.
rowCount(QModelIndex()), 1);
87 EXPECT_EQ(spyRemove.count(), 0);
88 EXPECT_EQ(spyInsert.count(), 1);
92 EXPECT_EQ(viewmodel.
rowCount(QModelIndex()), 1);
94 EXPECT_EQ(spyRemove.count(), 0);
95 EXPECT_EQ(spyInsert.count(), 2);
98 auto multilayer_index = viewmodel.
index(0, 0, QModelIndex());
99 auto layer_index = viewmodel.
index(0, 0, multilayer_index);
104 EXPECT_EQ(viewmodel.
rowCount(multilayer_index), 1);
105 EXPECT_EQ(viewmodel.
columnCount(multilayer_index), 2);
106 EXPECT_EQ(viewmodel.
rowCount(layer_index), 0);
111 EXPECT_EQ(spyRemove.count(), 1);
112 EXPECT_EQ(spyInsert.count(), 2);
113 EXPECT_EQ(viewmodel.
rowCount(multilayer_index), 0);
114 EXPECT_EQ(viewmodel.
columnCount(multilayer_index), 0);
127 QSignalSpy spyInsert(&viewmodel, &ViewModelBase::rowsInserted);
128 QSignalSpy spyRemove(&viewmodel, &ViewModelBase::rowsRemoved);
131 EXPECT_EQ(viewmodel.
rowCount(QModelIndex()), 0);
132 EXPECT_EQ(viewmodel.
columnCount(QModelIndex()), 0);
137 EXPECT_EQ(viewmodel.
rowCount(QModelIndex()), 1);
138 EXPECT_EQ(viewmodel.
columnCount(QModelIndex()), 2);
139 EXPECT_EQ(spyRemove.count(), 0);
140 EXPECT_EQ(spyInsert.count(), 1);
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.
void removeItem(SessionItem *parent, const TagRow &tagrow)
Removes given row from parent.
View model to show top level items of SessionModel in Qt trees and tables.
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
int rowCount(const QModelIndex &parent=QModelIndex()) const override
int columnCount(const QModelIndex &parent=QModelIndex()) const override
void setRootSessionItem(SessionItem *item)
SessionItem * sessionItemFromIndex(const QModelIndex &index) const
Tests for TopItemsViewModel class.
Represents a layer, with thickness and color, and possibly populated with particles.
Represents multilayer with collection of layers.
materialitems.h Collection of materials to populate MaterialModel.
TEST_F(TopItemsViewModelTest, initialState)