本文整理汇总了C++中tellico::data::EntryPtr类的典型用法代码示例。如果您正苦于以下问题:C++ EntryPtr类的具体用法?C++ EntryPtr怎么用?C++ EntryPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了EntryPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testPerson
void MusicBrainzFetcherTest::testPerson() {
Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Album, Tellico::Fetch::Person,
m_fieldValues.value(QLatin1String("artist")));
Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::MusicBrainzFetcher(this));
Tellico::Data::EntryList results = DO_FETCH1(fetcher, request, 20);
QVERIFY(results.size() > 0);
Tellico::Data::EntryPtr entry; // results can be randomly ordered, loop until we find the one we want
foreach(Tellico::Data::EntryPtr test, results) {
if(test->field(QLatin1String("title")).toLower() == m_fieldValues.value(QLatin1String("title"))) {
entry = test;
break;
} else {
qDebug() << "skipping" << test->title();
}
}
QVERIFY(entry);
QHashIterator<QString, QString> i(m_fieldValues);
while(i.hasNext()) {
i.next();
QString result = entry->field(i.key()).toLower();
QCOMPARE(result, i.value().toLower());
}
QVERIFY(!entry->field(QLatin1String("track")).isEmpty());
QVERIFY(!entry->field(QLatin1String("cover")).isEmpty());
}
示例2: testGhost
void AnimenfoFetcherTest::testGhost() {
KConfig config(QFINDTESTDATA("tellicotest.config"), KConfig::SimpleConfig);
QString groupName = QLatin1String("AnimeNfo.com");
if(!config.hasGroup(groupName)) {
QSKIP("This test requires a config file.", SkipAll);
}
KConfigGroup cg(&config, groupName);
Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Book, Tellico::Fetch::Keyword, "Ghost in the Shell");
Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::AnimeNfoFetcher(this));
fetcher->readConfig(cg, cg.name());
Tellico::Data::EntryList results = DO_FETCH(fetcher, request);
QCOMPARE(results.size(), 1);
// the first entry had better be the right one
Tellico::Data::EntryPtr entry = results.at(0);
QVERIFY(entry);
QCOMPARE(entry->field("title"), QLatin1String("Kokaku Kido Tai"));
QCOMPARE(entry->field("pub_year"), QLatin1String("1991"));
QCOMPARE(entry->field("genre"), QLatin1String("Action; Science-Fiction"));
QCOMPARE(entry->field("publisher"), QLatin1String("Kodansha"));
QCOMPARE(entry->field("origtitle"), QString::fromUtf8("攻殻機動隊"));
QCOMPARE(entry->field("author"), QString::fromUtf8("Shiro Masamune (士郎 正宗)"));
QCOMPARE(entry->field("alttitle"), QLatin1String("Ghost in the Shell"));
QVERIFY(!entry->field("cover").isEmpty());
QVERIFY(!entry->field("animenfo").isEmpty());
}
示例3: compareEntry
void GoogleBookFetcherTest::compareEntry(Tellico::Data::EntryPtr entry) {
QCOMPARE(entry->field(QLatin1String("title")), QLatin1String("Practical RDF"));
QCOMPARE(entry->field(QLatin1String("isbn")), QLatin1String("0-596-55051-0"));
QCOMPARE(entry->field(QLatin1String("author")), QLatin1String("Shelley Powers"));
QCOMPARE(entry->field(QLatin1String("publisher")), QLatin1String("O'Reilly Media, Inc."));
QCOMPARE(entry->field(QLatin1String("pages")), QLatin1String("352"));
QCOMPARE(entry->field(QLatin1String("pub_year")), QLatin1String("2003"));
QVERIFY(entry->field(QLatin1String("keyword")).contains(QLatin1String("Computers")));
QVERIFY(entry->field(QLatin1String("keyword")).contains(QLatin1String("XML")));
QVERIFY(!entry->field(QLatin1String("cover")).isEmpty());
QVERIFY(!entry->field(QLatin1String("comments")).isEmpty());
}
示例4: startUpdate
void Fetcher::startUpdate(Tellico::Data::EntryPtr entry_) {
Q_ASSERT(entry_);
Q_ASSERT(entry_->collection());
m_request = updateRequest(entry_);
m_request.collectionType = entry_->collection()->type();
if(!m_request.isNull()) {
search();
} else {
myDebug() << "insufficient info to search";
emit signalDone(this); // always need to emit this if not continuing with the search
}
// updateEntry(entry_);
}
示例5: testCoverArt
// test grabbing cover art from coverartarchive.org
void MusicBrainzFetcherTest::testCoverArt() {
Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Album, Tellico::Fetch::Title,
QLatin1String("Laulut ja tarinat"));
Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::MusicBrainzFetcher(this));
Tellico::Data::EntryList results = DO_FETCH1(fetcher, request, 1);
QVERIFY(!results.isEmpty());
Tellico::Data::EntryPtr entry = results.at(0);
QCOMPARE(entry->title(), QLatin1String("Laulut ja tarinat"));
QEXPECT_FAIL("", "MusicBrainz covers from coverartarchive are failing", Abort);
QVERIFY(!entry->field(QLatin1String("cover")).isEmpty());
}
示例6: testMegami
void AnimenfoFetcherTest::testMegami() {
KConfig config(QFINDTESTDATA("tellicotest.config"), KConfig::SimpleConfig);
QString groupName = QLatin1String("AnimeNfo.com");
if(!config.hasGroup(groupName)) {
QSKIP("This test requires a config file.", SkipAll);
}
KConfigGroup cg(&config, groupName);
Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Video, Tellico::Fetch::Keyword, "Aa! Megami-sama!");
Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::AnimeNfoFetcher(this));
fetcher->readConfig(cg, cg.name());
Tellico::Data::EntryList results = DO_FETCH1(fetcher, request, 1);
QCOMPARE(results.size(), 1);
// the first entry had better be the right one
Tellico::Data::EntryPtr entry = results.at(0);
QVERIFY(entry);
QCOMPARE(entry->field("title"), QLatin1String("Aa! Megami-sama!: Together Forever"));
QCOMPARE(entry->field("year"), QLatin1String("2011"));
QCOMPARE(entry->field("episodes"), QLatin1String("2"));
QCOMPARE(entry->field("studio"), QLatin1String("AIC (Anime International Company)"));
QCOMPARE(entry->field("origtitle"), QString::fromUtf8("ああっ女神さまっ ~ いつも二人で"));
QVERIFY(entry->field("plot").startsWith(QLatin1String("Keiichi finds out")));
QVERIFY(!entry->field("cover").isEmpty());
}
示例7: testTitle
void MusicBrainzFetcherTest::testTitle() {
Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Album, Tellico::Fetch::Title,
m_fieldValues.value(QLatin1String("title")));
Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::MusicBrainzFetcher(this));
Tellico::Data::EntryList results = DO_FETCH1(fetcher, request, 1);
QCOMPARE(results.size(), 1);
Tellico::Data::EntryPtr entry = results.at(0);
QHashIterator<QString, QString> i(m_fieldValues);
while(i.hasNext()) {
i.next();
QString result = entry->field(i.key()).toLower();
QCOMPARE(result, i.value().toLower());
}
QVERIFY(!entry->field(QLatin1String("track")).isEmpty());
QVERIFY(!entry->field(QLatin1String("cover")).isEmpty());
}
示例8: importer
void DeliciousTest::testMusic2() {
QUrl url = QUrl::fromLocalFile(QFINDTESTDATA("data/delicious2_music.xml"));
Tellico::Import::DeliciousImporter importer(url);
Tellico::Data::CollPtr coll = importer.collection();
QVERIFY(coll);
QCOMPARE(coll->type(), Tellico::Data::Collection::Album);
QCOMPARE(coll->entryCount(), 3);
Tellico::Data::EntryPtr entry = coll->entryById(2);
QVERIFY(entry);
QCOMPARE(entry->field("title"), QLatin1String("The Ultimate Sin"));
QCOMPARE(entry->field("artist"), QLatin1String("Ozzy Osbourne"));
QCOMPARE(entry->field("year"), QLatin1String("1987"));
QCOMPARE(entry->field("medium"), QLatin1String("Compact Disc"));
QCOMPARE(entry->field("label"), QLatin1String("Epic Aus/Zoom"));
QCOMPARE(entry->field("pur_price"), QLatin1String("$15.98"));
QCOMPARE(entry->field("pur_date"), QLatin1String("2009-01-17"));
QCOMPARE(entry->field("rating"), QLatin1String("3.5"));
QCOMPARE(entry->field("keyword"), QLatin1String("Hard Rock & Metal; Rock"));
}
示例9: testKeyword
void MusicBrainzFetcherTest::testKeyword() {
// the total test case ends up exceeding the throttle limit so pause for a second
QTest::qWait(1000);
Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Album, Tellico::Fetch::Keyword,
m_fieldValues.value(QLatin1String("title")));
Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::MusicBrainzFetcher(this));
Tellico::Data::EntryList results = DO_FETCH1(fetcher, request, 1);
QCOMPARE(results.size(), 1);
Tellico::Data::EntryPtr entry = results.at(0);
QHashIterator<QString, QString> i(m_fieldValues);
while(i.hasNext()) {
i.next();
QString result = entry->field(i.key()).toLower();
QCOMPARE(result, i.value().toLower());
}
QVERIFY(!entry->field(QLatin1String("track")).isEmpty());
QVERIFY(!entry->field(QLatin1String("cover")).isEmpty());
}
示例10: testArticle
void DBLPFetcherTest::testArticle() {
Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Bibtex, Tellico::Fetch::Keyword,
QLatin1String("Nontrivial independent sets of bipartite graphs"));
Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::DBLPFetcher(this));
Tellico::Data::EntryList results = DO_FETCH1(fetcher, request, 1);
QCOMPARE(results.size(), 1);
Tellico::Data::EntryPtr entry = results.at(0);
QCOMPARE(entry->field(QLatin1String("title")), QLatin1String("Nontrivial independent sets of bipartite graphs and cross-intersecting families."));
QCOMPARE(entry->field(QLatin1String("author")), QLatin1String("Jun Wang; Huajun Zhang"));
QCOMPARE(entry->field(QLatin1String("year")), QLatin1String("2013"));
QCOMPARE(entry->field(QLatin1String("pages")), QLatin1String("129-141"));
QCOMPARE(entry->field(QLatin1String("volume")), QLatin1String("120"));
QCOMPARE(entry->field(QLatin1String("number")), QLatin1String("1"));
QCOMPARE(entry->field(QLatin1String("journal")), QLatin1String("J. Comb. Theory, Ser. A (JCT)"));
QCOMPARE(entry->field(QLatin1String("booktitle")), QLatin1String(""));
QCOMPARE(entry->field(QLatin1String("url")), QLatin1String("http://dx.doi.org/10.1016/j.jcta.2012.07.005"));
QCOMPARE(entry->field(QLatin1String("doi")), QLatin1String("10.1016/j.jcta.2012.07.005"));
QCOMPARE(entry->field(QLatin1String("entry-type")), QLatin1String("article"));
QCOMPARE(entry->field(QLatin1String("bibtex-key")), QLatin1String("WangZ13"));
}
示例11: testProceedings
void DBLPFetcherTest::testProceedings() {
Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Bibtex, Tellico::Fetch::Keyword,
QLatin1String("Chip and PIN is Broken"));
Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::DBLPFetcher(this));
Tellico::Data::EntryList results = DO_FETCH1(fetcher, request, 1);
QCOMPARE(results.size(), 1);
Tellico::Data::EntryPtr entry = results.at(0);
QCOMPARE(entry->field(QLatin1String("title")), QLatin1String("Chip and PIN is Broken."));
QCOMPARE(entry->field(QLatin1String("author")), QLatin1String("Steven J. Murdoch; Saar Drimer; Ross J. Anderson; Mike Bond"));
QCOMPARE(entry->field(QLatin1String("year")), QLatin1String("2010"));
QCOMPARE(entry->field(QLatin1String("pages")), QLatin1String("433-446"));
QCOMPARE(entry->field(QLatin1String("booktitle")), QLatin1String("IEEE Symposium on Security and Privacy"));
QCOMPARE(entry->field(QLatin1String("url")), QLatin1String("http://dx.doi.org/10.1109/SP.2010.33"));
QCOMPARE(entry->field(QLatin1String("doi")), QLatin1String("10.1109/SP.2010.33"));
QCOMPARE(entry->field(QLatin1String("entry-type")), QLatin1String("inproceedings"));
QCOMPARE(entry->field(QLatin1String("bibtex-key")), QLatin1String("MurdochDAB10"));
}
示例12: testImport
void RisTest::testImport() {
KUrl url(QString::fromLatin1(KDESRCDIR) + "/data/test.ris");
KUrl::List urls;
urls << url;
Tellico::Import::RISImporter importer(urls);
Tellico::Data::CollPtr coll = importer.collection();
QVERIFY(!coll.isNull());
QCOMPARE(coll->type(), Tellico::Data::Collection::Bibtex);
QCOMPARE(coll->entryCount(), 2);
QCOMPARE(coll->title(), QLatin1String("Bibliography"));
Tellico::Data::EntryPtr entry = coll->entryById(2);
QVERIFY(!entry.isNull());
QCOMPARE(entry->field("entry-type"), QLatin1String("article"));
QCOMPARE(entry->field("year"), QLatin1String("2002"));
QCOMPARE(entry->field("pages"), QLatin1String("1057-1119"));
QCOMPARE(Tellico::FieldFormat::splitValue(entry->field("author")).count(), 3);
QCOMPARE(Tellico::FieldFormat::splitValue(entry->field("author")).first(), QLatin1String("Koglin,M."));
Tellico::Data::BibtexCollection* bColl = dynamic_cast<Tellico::Data::BibtexCollection*>(coll.data());
QVERIFY(bColl);
QCOMPARE(bColl->fieldByBibtexName("entry-type")->name(), QLatin1String("entry-type"));
}
示例13: slotCancel
}
void EntryMerger::slotCancel() {
m_cancelled = true;
}
void EntryMerger::slotCleanup() {
Kernel::self()->removeEntries(m_entriesToRemove);
Controller::self()->slotUpdateSelection(m_entriesLeft);
StatusBar::self()->clearStatus();
ProgressManager::self()->setDone(this);
Kernel::self()->endCommandGroup();
deleteLater();
}
bool EntryMerger::cleanMerge(Tellico::Data::EntryPtr e1, Tellico::Data::EntryPtr e2) const {
// figure out if there's a clean merge possible
foreach(Data::FieldPtr field, e1->collection()->fields()) {
// do not care about id and dates
if(field->name() == QLatin1String("id") ||
field->name() == QLatin1String("cdate") ||
field->name() == QLatin1String("mdate")) {
continue;
}
QString val1 = e1->field(field);
QString val2 = e2->field(field);
if(val1 != val2 && !val1.isEmpty() && !val2.isEmpty()) {
return false;
}
}
return true;
示例14: testHachimitsu
void AnimenfoFetcherTest::testHachimitsu() {
KConfig config(QFINDTESTDATA("tellicotest.config"), KConfig::SimpleConfig);
QString groupName = QLatin1String("AnimeNfo.com");
if(!config.hasGroup(groupName)) {
QSKIP("This test requires a config file.", SkipAll);
}
KConfigGroup cg(&config, groupName);
Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Video, Tellico::Fetch::Keyword, "Hachimitsu to Clover");
Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::AnimeNfoFetcher(this));
fetcher->readConfig(cg, cg.name());
Tellico::Data::EntryList results = DO_FETCH1(fetcher, request, 1);
QCOMPARE(results.size(), 1);
// the first entry had better be the right one
Tellico::Data::EntryPtr entry = results.at(0);
QVERIFY(entry);
QCOMPARE(entry->field("title"), QLatin1String("Hachimitsu to Clover"));
QCOMPARE(entry->field("year"), QLatin1String("2005"));
QCOMPARE(entry->field("episodes"), QLatin1String("26"));
QCOMPARE(entry->field("keyword"), QLatin1String("TV"));
QCOMPARE(entry->field("genre"), QLatin1String("Comedy; Drama; Romance"));
QCOMPARE(entry->field("studio"), QLatin1String("J.C.STAFF"));
QCOMPARE(entry->field("origtitle"), QString::fromUtf8("ハチミツとクローバー"));
QCOMPARE(entry->field("director"), QString::fromUtf8("Kasai Kenichi (カサヰ ケンイチ)"));
QCOMPARE(entry->field("writer"), QString::fromUtf8("Kuroda Yosuke (黒田洋介)"));
QCOMPARE(entry->field("alttitle"), QLatin1String("Honey and Clover"));
QCOMPARE(entry->field("animenfo-rating"), QLatin1String("9"));
QVERIFY(entry->field("plot").startsWith(QLatin1String("Takemoto, Mayama, and Morita are students")));
QVERIFY(!entry->field("cover").isEmpty());
QVERIFY(!entry->field("animenfo").isEmpty());
QStringList castList = Tellico::FieldFormat::splitTable(entry->field("cast"));
QCOMPARE(castList.count(), 7);
QCOMPARE(castList.at(0), QString::fromUtf8("Kudo Haruka (工藤晴香)::Hanamoto Hagumi"));
}
示例15: score
int EntryComparison::score(Tellico::Data::EntryPtr e1, Tellico::Data::EntryPtr e2, Tellico::Data::FieldPtr f) {
if(!e1 || !e2 || !f) {
return 0;
}
QString s1 = e1->field(f).toLower();
QString s2 = e2->field(f).toLower();
if(s1.isEmpty() || s2.isEmpty()) {
return 0;
}
// complicated string matching, here are the cases I want to match
// "bend it like beckham" == "bend it like beckham (widescreen edition)"
// "the return of the king" == "return of the king"
if(s1 == s2) {
return 5;
}
// special case for isbn
if(f->name() == QLatin1String("isbn") && ISBNValidator::isbn10(s1) == ISBNValidator::isbn10(s2)) {
return 5;
}
if(f->name() == QLatin1String("lccn") && LCCNValidator::formalize(s1) == LCCNValidator::formalize(s2)) {
return 5;
}
if(f->name() == QLatin1String("url") && e1->collection() && e1->collection()->type() == Data::Collection::File) {
// versions before 1.2.7 could have saved the url without the protocol
if(QUrl(s1) == QUrl(s2) ||
(f->property(QLatin1String("relative")) == QLatin1String("true") &&
s_documentUrl.resolved(QUrl(s1)) == s_documentUrl.resolved(QUrl(s2)))) {
return 5;
}
}
if (f->name() == QLatin1String("imdb")) {
// imdb might be a different host since we query akas.imdb.com and normally it is www.imdb.com
QUrl us1 = QUrl::fromUserInput(s1);
QUrl us2 = QUrl::fromUserInput(s2);
us1.setHost(QString());
us2.setHost(QString());
if(us1 == us2) {
return 5;
}
}
if(f->name() == QLatin1String("arxiv")) {
// normalize and unVersion arxiv ID
s1.remove(QRegExp(QLatin1String("^arxiv:")));
s1.remove(QRegExp(QLatin1String("v\\d+$")));
s2.remove(QRegExp(QLatin1String("^arxiv:")));
s2.remove(QRegExp(QLatin1String("v\\d+$")));
if(s1 == s2) {
return 5;
}
}
if(f->formatType() == FieldFormat::FormatName) {
const QString s1n = e1->formattedField(f, FieldFormat::ForceFormat);
const QString s2n = e2->formattedField(f, FieldFormat::ForceFormat);
if(s1n == s2n) {
return 5;
}
}
// try removing punctuation
QRegExp notAlphaNum(QLatin1String("[^\\s\\w]"));
QString s1a = s1;
s1a.remove(notAlphaNum);
QString s2a = s2;
s2a.remove(notAlphaNum);
if(!s1a.isEmpty() && s1a == s2a) {
// myDebug() << "match without punctuation";
return 5;
}
FieldFormat::stripArticles(s1);
FieldFormat::stripArticles(s2);
if(!s1.isEmpty() && s1 == s2) {
// myDebug() << "match without articles";
return 3;
}
// try removing everything between parentheses
QRegExp rx(QLatin1String("\\s*\\(.*\\)\\s*"));
s1.remove(rx);
s2.remove(rx);
if(!s1.isEmpty() && s1 == s2) {
// myDebug() << "match without parentheses";
return 2;
}
if(f->hasFlag(Data::Field::AllowMultiple)) {
QStringList sl1 = FieldFormat::splitValue(e1->field(f));
QStringList sl2 = FieldFormat::splitValue(e2->field(f));
int matches = 0;
for(QStringList::ConstIterator it = sl1.constBegin(); it != sl1.constEnd(); ++it) {
matches += sl2.count(*it);
}
if(matches == 0 && f->formatType() == FieldFormat::FormatName) {
sl1 = FieldFormat::splitValue(e1->formattedField(f, FieldFormat::ForceFormat));
sl2 = FieldFormat::splitValue(e2->formattedField(f, FieldFormat::ForceFormat));
for(QStringList::ConstIterator it = sl1.constBegin(); it != sl1.constEnd(); ++it) {
matches += sl2.count(*it);
}
}
return matches;
}
return 0;
}