本文整理汇总了C++中Tags::append方法的典型用法代码示例。如果您正苦于以下问题:C++ Tags::append方法的具体用法?C++ Tags::append怎么用?C++ Tags::append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tags
的用法示例。
在下文中一共展示了Tags::append方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_tag_item
void TestTags::test_tag_item() {
Tags tags;
tags.append("Work");
tags.append("Home");
Person *person = new Person;
person->setName("Moe stein");
person->save();
tags.tag(RelationalObjectRef(person), tags.getObjectRef(0));
QMap<int, QString> item_tags = tags.itemTags(RelationalObjectRef(person));
QCOMPARE(item_tags.size(), 1);
QVERIFY(item_tags.contains(1));
QCOMPARE(item_tags.value(1), QString("Work"));
tags.tag(RelationalObjectRef(person), tags.getObjectRef(1));
item_tags = tags.itemTags(RelationalObjectRef(person));
QCOMPARE(item_tags.size(), 2);
QVERIFY(item_tags.contains(2));
QCOMPARE(item_tags.value(2), QString("Home"));
tags.tag(RelationalObjectRef(person), tags.getObjectRef(1));
item_tags = tags.itemTags(RelationalObjectRef(person));
QCOMPARE(item_tags.size(), 2);
tags.untag(RelationalObjectRef(person), tags.getObjectRef(0));
item_tags = tags.itemTags(RelationalObjectRef(person));
QCOMPARE(item_tags.size(), 1);
QVERIFY(not item_tags.contains(1));
delete person;
}
示例2: toTags
ItemTagsLoader::Tags ItemTagsLoader::toTags(const QStringList &tagList)
{
Tags tags;
for (const auto &tagText : tagList) {
QString tagName = tagText.trimmed();
Tag tag = findMatchingTag(tagName, m_tags);
if (isTagValid(tag)) {
if (tag.match.isEmpty()) {
tag.name = tagName;
} else {
const QRegExp re(tag.match);
tag.name = QString(tagName).replace(re, tag.name);
}
} else {
tag.name = tagName;
// Get default tag style from theme.
const QSettings settings;
tag.color = settings.value("Theme/num_fg").toString();
}
tags.append(tag);
}
return tags;
}
示例3: test_item_tags_model
void TestTags::test_item_tags_model() {
Tags tags;
tags.append("Work");
tags.append("Home");
Person *person = new Person;
person->setName("Moe stein");
person->save();
RelationalObjectRef person_ref(person);
RelationalObjectRef tag1 = tags.getObjectRef(0);
RelationalObjectRef tag2 = tags.getObjectRef(1);
ItemTags *item_tags = tags.itemTagsModelFactory(person_ref);
item_tags->tag(tag1);
QCOMPARE(item_tags->rowCount(), 1);
item_tags->untag(tag2);
QCOMPARE(item_tags->rowCount(), 1);
item_tags->tag(tag2);
QCOMPARE(item_tags->rowCount(), 2);
item_tags->untag(tag1);
QCOMPARE(item_tags->rowCount(), 1);
item_tags->untag(tag2);
QCOMPARE(item_tags->rowCount(), 0);
delete item_tags;
delete person;
}