27 const std::string property_name(
"name");
45 const int expected = 42;
46 auto propertyItem = item.
addProperty(property_name, expected);
51 EXPECT_EQ(propertyItem->displayName(), property_name);
52 EXPECT_EQ(propertyItem->data<
int>(), expected);
60 auto propertyItem = item.
addProperty(property_name, 41);
62 const int expected = 42;
65 EXPECT_EQ(item.
property<
int>(property_name), expected);
66 EXPECT_EQ(propertyItem->data<
int>(), expected);
73 const double expected = 42.1;
74 auto propertyItem = item.
addProperty(property_name, expected);
79 EXPECT_EQ(propertyItem->displayName(), property_name);
80 EXPECT_EQ(propertyItem->data<
double>(), expected);
86 EXPECT_FALSE(limits.hasLowerLimit());
87 EXPECT_FALSE(limits.hasUpperLimit());
93 auto propertyItem = item.
addProperty(property_name, 41.11);
95 const double expected = 42.0;
98 EXPECT_EQ(item.
property<
double>(property_name), expected);
99 EXPECT_EQ(propertyItem->data<
double>(), expected);
106 auto propertyItem = item.
addProperty(property_name,
"abc");
111 EXPECT_EQ(propertyItem->data<std::string>(), std::string(
"abc"));
119 auto propertyItem = item.
addProperty(property_name,
"aaa");
121 const char* expected{
"bbb"};
124 EXPECT_EQ(item.
property<std::string>(property_name), std::string(expected));
125 EXPECT_EQ(propertyItem->data<std::string>(), std::string(expected));
132 auto propertyItem = item.
addProperty(property_name, std::string(
"abc"));
137 EXPECT_EQ(propertyItem->data<std::string>(), std::string(
"abc"));
145 auto propertyItem = item.
addProperty(property_name, std::string(
"aaa"));
147 const std::string expected{
"bbb"};
150 EXPECT_EQ(item.
property<std::string>(property_name), expected);
151 EXPECT_EQ(propertyItem->data<std::string>(), expected);
158 const bool expected =
true;
159 auto propertyItem = item.
addProperty(property_name, expected);
164 EXPECT_EQ(propertyItem->data<
bool>(), expected);
172 auto propertyItem = item.
addProperty(property_name,
false);
174 const bool expected =
true;
177 EXPECT_EQ(item.
property<
bool>(property_name), expected);
178 EXPECT_EQ(propertyItem->data<
bool>(), expected);
183 const std::string tag =
"tag";
199 const std::string tag =
"tag";
212 std::vector<PropertyItem*> expected = {property1, property2};
213 EXPECT_EQ(items, expected);
221 const std::string tag =
"tag";
238 child0->setDisplayName(
"Jekyll");
239 child1->setDisplayName(
"Hyde");
240 EXPECT_EQ(child0->displayName(),
"Jekyll");
241 EXPECT_EQ(child1->displayName(),
"Hyde");
250 EXPECT_TRUE(item.
children().empty());
251 auto propertyItem = item.
addProperty(property_name,
false);
252 EXPECT_EQ(item.
children(), std::vector<SessionItem*>({propertyItem}));
Test of CompountItem machinery (property children etc).
Complex item holding mixed SessionItem types (single properties and other CompountItems).
T * addProperty(const std::string &name)
Adds property item of given type.
Item to carry concrete editable entity (e.g.
The main object representing an editable/displayable/serializable entity.
void registerTag(const TagInfo &tagInfo, bool set_as_default=false)
Registers tag to hold items under given name.
std::vector< T * > items(const std::string &tag) const
Returns all items under given tag casted to specific type.
int childrenCount() const
Returns total number of children in all tags.
std::vector< SessionItem * > children() const
Returns vector of children formed from all chidlren from all tags.
T property(const std::string &tag) const
Returns data stored in property item.
bool insertItem(SessionItem *item, const TagRow &tagrow)
Insert item into given tag under the given row.
T * item(const std::string &tag) const
Returns first item under given tag casted to a specified type.
void setProperty(const std::string &tag, const T &value)
Sets value to property item.
static TagInfo universalTag(std::string name, std::vector< std::string > modelTypes={})
Constructs universal tag intended for unlimited amount of various items.
static TagRow append(const std::string &tag_name={})
Returns TagRow corresponding to the append to tag_name.
TEST_F(CompoundItemTest, initialState)
const model_type PropertyType
const model_type CompoundItemType
const int LIMITS
possibly limits on item's data
MVVM_MODEL_EXPORT bool IsIntVariant(const Variant &variant)
Returns true in the case of double value based variant.
MVVM_MODEL_EXPORT bool HasTag(const SessionItem &item, const std::string &tag)
Returns true if given item has registered tag.
MVVM_MODEL_EXPORT bool IsDoubleVariant(const Variant &variant)
Returns true in the case of double value based variant.
MVVM_MODEL_EXPORT bool IsStdStringVariant(const Variant &variant)
Returns true in the case of double value based variant.
MVVM_MODEL_EXPORT bool IsBoolVariant(const Variant &variant)
Returns true in the case of double value based variant.
materialitems.h Collection of materials to populate MaterialModel.