当前位置: 首页>>代码示例>>C++>>正文


C++ ArtworkMetadata::initialize方法代码示例

本文整理汇总了C++中models::ArtworkMetadata::initialize方法的典型用法代码示例。如果您正苦于以下问题:C++ ArtworkMetadata::initialize方法的具体用法?C++ ArtworkMetadata::initialize怎么用?C++ ArtworkMetadata::initialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models::ArtworkMetadata的用法示例。


在下文中一共展示了ArtworkMetadata::initialize方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: filterDescriptionTest

void FilteredModelTests::filterDescriptionTest() {
    DECLARE_MODELS_AND_GENERATE(10);
    Models::SettingsModel settingsModel;
    settingsModel.setSearchUsingAnd(false);
    commandManagerMock.InjectDependency(&settingsModel);

    for (int i = 0; i < 10; ++i) {
        Models::ArtworkMetadata *metadata = artItemsModelMock.getArtwork(i);

        if (i % 2) {
            metadata->initialize("title", "description", QStringList() << "keyword1" << "keyword2");
        } else {
            metadata->initialize("", "", QStringList());
        }
    }

    filteredItemsModel.setSearchTerm("desc");
    QCOMPARE(filteredItemsModel.getItemsCount(), 5);

    filteredItemsModel.setSearchTerm("!desc");
    QCOMPARE(filteredItemsModel.getItemsCount(), 0);

    filteredItemsModel.setSearchTerm("description");
    QCOMPARE(filteredItemsModel.getItemsCount(), 5);

    // strict match does not work for description/title
    filteredItemsModel.setSearchTerm("!description");
    QCOMPARE(filteredItemsModel.getItemsCount(), 0);
}
开发者ID:RostaTasha,项目名称:xpiks,代码行数:29,代码来源:filteredmodel_tests.cpp

示例2: filterTitleAndKeywordsTest

void FilteredModelTests::filterTitleAndKeywordsTest() {
    DECLARE_MODELS_AND_GENERATE(10);
    Models::SettingsModel settingsModel;
    settingsModel.setSearchUsingAnd(false);
    commandManagerMock.InjectDependency(&settingsModel);

    for (int i = 0; i < 10; ++i) {
        Models::ArtworkMetadata *metadata = artItemsModelMock.getArtwork(i);

        if (i % 2 == 0) {
            metadata->initialize("title", "description", QStringList() << "keyword1" << "mess1");
        } else {
            metadata->initialize("title", "description", QStringList() << "keyword2" << "mess2");
        }
    }

    filteredItemsModel.setSearchTerm("keyword1 tit");
    QCOMPARE(filteredItemsModel.getItemsCount(), 10);

    filteredItemsModel.setSearchTerm("!keyword tit");
    QCOMPARE(filteredItemsModel.getItemsCount(), 10);

    settingsModel.setSearchUsingAnd(true);

    filteredItemsModel.setSearchTerm("!keyword tit");
    QCOMPARE(filteredItemsModel.getItemsCount(), 0);

    filteredItemsModel.setSearchTerm("!keyword2 title");
    QCOMPARE(filteredItemsModel.getItemsCount(), 5);
}
开发者ID:RostaTasha,项目名称:xpiks,代码行数:30,代码来源:filteredmodel_tests.cpp

示例3: readingFinishedHandler

    void MetadataIOCoordinator::readingFinishedHandler(bool ignoreBackups) {
        Q_ASSERT(m_CanProcessResults);
        m_CanProcessResults = false;

        const QHash<QString, ImportDataResult> &importResult = m_ReadingWorker->getImportResult();
        const QVector<Models::ArtworkMetadata*> &itemsToRead = m_ReadingWorker->getItemsToRead();

        LOG_DEBUG  << "Setting imported metadata...";
        int size = itemsToRead.size();
        for (int i = 0; i < size; ++i) {
            Models::ArtworkMetadata *metadata = itemsToRead.at(i);
            const QString &filepath = metadata->getFilepath();

            if (importResult.contains(filepath)) {
                const ImportDataResult &importResultItem = importResult.value(filepath);
                metadata->initialize(importResultItem.Title,
                                     importResultItem.Description,
                                     importResultItem.Keywords);

                Models::ImageArtwork *image = dynamic_cast<Models::ImageArtwork*>(metadata);
                if (image != NULL) {
                    image->setImageSize(importResultItem.ImageSize);
                    image->setDateTimeOriginal(importResultItem.DateTimeOriginal);
                }

                metadata->setFileSize(importResultItem.FileSize);
            }
        }

        afterImportHandler(itemsToRead, ignoreBackups);

        LOG_DEBUG << "Metadata import finished";
        emit metadataReadingFinished();
    }
开发者ID:RostaTasha,项目名称:xpiks,代码行数:34,代码来源:metadataiocoordinator.cpp

示例4: 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());
    }
}
开发者ID:RostaTasha,项目名称:xpiks,代码行数:31,代码来源:replace_tests.cpp

示例5: readingFinishedHandler

    void MetadataIOCoordinator::readingFinishedHandler(bool ignoreBackups) {
        Q_ASSERT(m_CanProcessResults);
        m_CanProcessResults = false;

        const QHash<QString, ImportDataResult> &importResult = m_ReadingWorker->getImportResult();
        const QVector<Models::ArtworkMetadata*> &itemsToRead = m_ReadingWorker->getArtworksToImport();

        qDebug() << "Setting imported metadata...";
        int size = itemsToRead.size();
        for (int i = 0; i < size; ++i) {
            Models::ArtworkMetadata *metadata = itemsToRead.at(i);
            const QString &filepath = metadata->getFilepath();

            if (importResult.contains(filepath)) {
                const ImportDataResult &importResultItem = importResult.value(filepath);
                metadata->initialize(importResultItem.Title,
                                     importResultItem.Description,
                                     importResultItem.Keywords);
                metadata->setSize(importResultItem.Size);
            }
        }

        afterImportHandler(itemsToRead, ignoreBackups);

        qDebug() << "Metadata import finished";
        emit metadataReadingFinished();
    }
开发者ID:snikolau,项目名称:xpiks,代码行数:27,代码来源:metadataiocoordinator.cpp

示例6: setSelectedForZippingTest

void FilteredModelTests::setSelectedForZippingTest() {
    DECLARE_MODELS_AND_GENERATE(10);
    Models::ZipArchiver zipArchiver;
    commandManagerMock.InjectDependency(&zipArchiver);

    for (int i = 0; i < 10; ++i) {
        Models::ArtworkMetadata *metadata = artItemsModelMock.getArtwork(i);
        metadata->initialize("title", "description", QStringList() << "keyword1" << "keyword2");

        if (i % 2) {
            metadata->setIsSelected(true);
        }
    }

    filteredItemsModel.setSelectedForZipping();

    const QVector<Models::ArtworkMetadata*> &artworks = zipArchiver.getArtworkList();
    QCOMPARE(artworks.length(), 5);
}
开发者ID:RostaTasha,项目名称:xpiks,代码行数:19,代码来源:filteredmodel_tests.cpp

示例7: removeMetadataDeletesMetadataTest

void FilteredModelTests::removeMetadataDeletesMetadataTest() {
    DECLARE_MODELS_AND_GENERATE(10);

    for (int i = 0; i < 10; ++i) {
        Models::ArtworkMetadata *metadata = artItemsModelMock.getArtwork(i);
        metadata->initialize("title", "description", QStringList() << "keyword1" << "keyword2");
        metadata->setIsSelected(true);
    }

    filteredItemsModel.removeMetadataInSelected();

    for (int i = 0; i < 10; ++i) {
        Mocks::ArtworkMetadataMock *metadata = artItemsModelMock.getMockArtwork(i);
        QVERIFY(metadata->isDescriptionEmpty());
        QVERIFY(metadata->isTitleEmpty());
        QVERIFY(metadata->areKeywordsEmpty());
        QVERIFY(metadata->isModified());
    }
}
开发者ID:RostaTasha,项目名称:xpiks,代码行数:19,代码来源:filteredmodel_tests.cpp

示例8: 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());
    }
}
开发者ID:RostaTasha,项目名称:xpiks,代码行数:40,代码来源:replace_tests.cpp


注:本文中的models::ArtworkMetadata::initialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。