47 auto command = std::make_unique<CopyItemCommand>(child1, parent,
TagRow{
"tag1", 1});
51 auto copy = std::get<SessionItem*>(command->result());
52 EXPECT_FALSE(command->isObsolete());
53 EXPECT_TRUE(
copy !=
nullptr);
55 std::vector<SessionItem*> expected = {child0,
copy, child1};
56 EXPECT_EQ(parent->
getItems(
"tag1"), expected);
57 EXPECT_EQ(
copy->data<
double>(), 43.0);
61 expected = {child0, child1};
62 EXPECT_EQ(parent->
getItems(
"tag1"), expected);
63 EXPECT_FALSE(command->isObsolete());
81 auto command = std::make_unique<CopyItemCommand>(child0, parent,
TagRow{
"thickness", 0});
85 EXPECT_TRUE(command->isObsolete());
86 EXPECT_EQ(std::get<SessionItem*>(command->result()),
nullptr);
89 EXPECT_THROW(command->undo(), std::runtime_error);
Complex item holding mixed SessionItem types (single properties and other CompountItems).
T * addProperty(const std::string &name)
Adds property item of given type.
The main object representing an editable/displayable/serializable entity.
std::vector< SessionItem * > getItems(const std::string &tag) const
Returns all children stored at given tag.
void registerTag(const TagInfo &tagInfo, bool set_as_default=false)
Registers tag to hold items under given name.
bool setData(const T &value, int role=ItemDataRole::DATA, bool direct=false)
Sets data for a given role.
int childrenCount() const
Returns total number of children in all tags.
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.
static TagInfo universalTag(std::string name, std::vector< std::string > modelTypes={})
Constructs universal tag intended for unlimited amount of various items.
Aggregate to hold (tag, row) information for SessionModel.
TEST_F(CopyItemCommandTest, copyChild)
materialitems.h Collection of materials to populate MaterialModel.
@ copy
full deep copying with item identifiers regenerated