本文整理汇总了C++中tellico::data::EntryPtr::collection方法的典型用法代码示例。如果您正苦于以下问题:C++ EntryPtr::collection方法的具体用法?C++ EntryPtr::collection怎么用?C++ EntryPtr::collection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tellico::data::EntryPtr
的用法示例。
在下文中一共展示了EntryPtr::collection方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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_);
}
示例2: 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;
}
示例3: 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;
}