本文整理汇总了C++中models::ArtworkMetadata::getKeywords方法的典型用法代码示例。如果您正苦于以下问题:C++ ArtworkMetadata::getKeywords方法的具体用法?C++ ArtworkMetadata::getKeywords怎么用?C++ ArtworkMetadata::getKeywords使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models::ArtworkMetadata
的用法示例。
在下文中一共展示了ArtworkMetadata::getKeywords方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: caseSensitiveTest
void ReplaceTests::caseSensitiveTest() {
const int itemsToGenerate = 10;
DECLARE_MODELS_AND_GENERATE(itemsToGenerate);
QString replaceFrom = "rePLace";
QString replaceTo = "Replaced";
QString initString = "ReplaceMe";
QString finalString = "ReplacedMe";
auto flags = Common::SearchFlags::Description |
Common::SearchFlags::Title |
Common::SearchFlags::Keywords;
for (int i = 0; i < itemsToGenerate; i++) {
Models::ArtworkMetadata *metadata = artItemsModelMock.getArtwork(i);
metadata->initialize(initString, initString, QStringList() << initString);
}
auto artWorksInfo = filteredItemsModel.getSearchablePreviewOriginalItems(replaceFrom, flags);
std::shared_ptr<Commands::FindAndReplaceCommand> replaceCommand(
new Commands::FindAndReplaceCommand(artWorksInfo, replaceFrom, replaceTo, flags));
auto result = commandManagerMock.processCommand(replaceCommand);
for (int i = 0; i < itemsToGenerate; i++) {
Models::ArtworkMetadata *metadata = artItemsModelMock.getArtwork(i);
QCOMPARE(metadata->getDescription(), finalString);
QCOMPARE(metadata->getTitle(), finalString);
QCOMPARE(metadata->getKeywords()[0], finalString);
QVERIFY(metadata->isModified());
}
}
示例2: replaceKeywordsTest
void ReplaceTests::replaceKeywordsTest() {
const int itemsToGenerate = 10;
DECLARE_MODELS_AND_GENERATE(itemsToGenerate);
QString replaceFrom = "keywordOld";
QString replaceTo = "keywordNew";
QString replaceToLower = replaceTo.toLower();
auto flags = Common::SearchFlags::CaseSensitive |
Common::SearchFlags::Description |
Common::SearchFlags::Title |
Common::SearchFlags::Keywords;
for (int i = 0; i < itemsToGenerate; i++) {
Models::ArtworkMetadata *metadata = artItemsModelMock.getArtwork(i);
metadata->initialize(QString("title"), QString("description"),
QStringList() << replaceToLower << "dummyKey" << replaceFrom);
}
auto artWorksInfo = filteredItemsModel.getSearchablePreviewOriginalItems(replaceFrom, flags);
std::shared_ptr<Commands::FindAndReplaceCommand> replaceCommand(
new Commands::FindAndReplaceCommand(artWorksInfo, replaceFrom, replaceTo, flags));
auto result = commandManagerMock.processCommand(replaceCommand);
for (int i = 0; i < itemsToGenerate; i++) {
Models::ArtworkMetadata *metadata = artItemsModelMock.getArtwork(i);
QCOMPARE(metadata->getDescription(), QString("description"));
QCOMPARE(metadata->getTitle(), QString("title"));
QStringList test = metadata->getKeywords();
QStringList gold;
gold << replaceToLower << "dummyKey";
qSort(gold.begin(), gold.end());
qSort(test.begin(), test.end());
QCOMPARE(gold, test);
QVERIFY(metadata->isModified());
}
}
示例3: doTest
int ClearMetadataTest::doTest() {
Models::ArtItemsModel *artItemsModel = m_CommandManager->getArtItemsModel();
QList<QUrl> files;
files << getImagePathForTest("images-for-tests/pixmap/seagull-for-clear.jpg");
int addedCount = artItemsModel->addLocalArtworks(files);
VERIFY(addedCount == files.length(), "Failed to add file");
MetadataIO::MetadataIOCoordinator *ioCoordinator = m_CommandManager->getMetadataIOCoordinator();
SignalWaiter waiter;
QObject::connect(ioCoordinator, SIGNAL(metadataReadingFinished()), &waiter, SIGNAL(finished()));
ioCoordinator->continueReading(true);
if (!waiter.wait(20)) {
VERIFY(false, "Timeout exceeded for reading metadata.");
}
VERIFY(!ioCoordinator->getHasErrors(), "Errors in IO Coordinator while reading");
Models::ArtworkMetadata *metadata = artItemsModel->getArtwork(0);
const QStringList &keywords = metadata->getKeywords();
QStringList expectedKeywords = QString("picture,seagull,bird").split(',');
VERIFY(expectedKeywords == keywords, "Keywords are not the same!");
VERIFY(metadata->getDescription() == "Seagull description", "Description is not the same!");
VERIFY(metadata->getTitle() == "Seagull title", "Title is not the same!");
Models::FilteredArtItemsProxyModel *filteredModel = m_CommandManager->getFilteredArtItemsModel();
metadata->setIsSelected(true);
filteredModel->removeMetadataInSelected();
bool doOverwrite = true, dontSaveBackups = false;
QObject::connect(ioCoordinator, SIGNAL(metadataWritingFinished()), &waiter, SIGNAL(finished()));
artItemsModel->saveSelectedArtworks(QVector<int>() << 0, doOverwrite, dontSaveBackups);
if (!waiter.wait(20)) {
VERIFY(false, "Timeout exceeded for writing metadata.");
}
VERIFY(!ioCoordinator->getHasErrors(), "Errors in IO Coordinator while writing");
filteredModel->removeSelectedArtworks();
addedCount = artItemsModel->addLocalArtworks(files);
VERIFY(addedCount == files.length(), "Failed to add file after removal");
ioCoordinator->continueReading(true);
if (!waiter.wait(20)) {
VERIFY(false, "Timeout exceeded for reading metadata.");
}
VERIFY(!ioCoordinator->getHasErrors(), "Errors in IO Coordinator while reading");
metadata = artItemsModel->getArtwork(0);
VERIFY(metadata->getBasicModel()->isDescriptionEmpty(), "Description was not empty");
VERIFY(metadata->getBasicModel()->isTitleEmpty(), "Title was not empty");
VERIFY(metadata->getBasicModel()->areKeywordsEmpty(), "Keywords were not empty");
return 0;
}