Changeset View
Changeset View
Standalone View
Standalone View
src/acbf/AcbfBookinfo.cpp
Context not available. | |||||
50 | QList<Sequence*> sequence; | 50 | QList<Sequence*> sequence; | ||
---|---|---|---|---|---|
51 | QList<DatabaseRef*> databaseRef; | 51 | QList<DatabaseRef*> databaseRef; | ||
52 | QList<ContentRating*> contentRating; | 52 | QList<ContentRating*> contentRating; | ||
53 | QString readingDirection; | ||||
53 | }; | 54 | }; | ||
54 | 55 | | |||
55 | BookInfo::BookInfo(Metadata* parent) | 56 | BookInfo::BookInfo(Metadata* parent) | ||
Context not available. | |||||
142 | Q_FOREACH(ContentRating* rating, d->contentRating) { | 143 | Q_FOREACH(ContentRating* rating, d->contentRating) { | ||
143 | rating->toXml(writer); | 144 | rating->toXml(writer); | ||
144 | } | 145 | } | ||
146 | | ||||
147 | //ACBF 1.2 | ||||
148 | /* | ||||
149 | writer->writeStartElement("characters"); | ||||
150 | writer->writeCharacters(d->readingDirection); | ||||
151 | writer->writeEndElement(); | ||||
152 | */ | ||||
145 | 153 | | |||
146 | writer->writeEndElement(); | 154 | writer->writeEndElement(); | ||
147 | } | 155 | } | ||
Context not available. | |||||
236 | newContentRating->fromXml(xmlReader); | 244 | newContentRating->fromXml(xmlReader); | ||
237 | d->contentRating.append(newContentRating); | 245 | d->contentRating.append(newContentRating); | ||
238 | } | 246 | } | ||
247 | else if(xmlReader->name() == QStringLiteral("reading-direction")) | ||||
248 | { | ||||
249 | setReadingDirection(xmlReader->readElementText(QXmlStreamReader::IncludeChildElements).toLower()); | ||||
250 | } | ||||
239 | else | 251 | else | ||
240 | { | 252 | { | ||
241 | qWarning() << Q_FUNC_INFO << "currently unsupported subsection:" << xmlReader->name(); | 253 | qWarning() << Q_FUNC_INFO << "currently unsupported subsection:" << xmlReader->name(); | ||
Context not available. | |||||
245 | if (xmlReader->hasError()) { | 257 | if (xmlReader->hasError()) { | ||
246 | qWarning() << Q_FUNC_INFO << "Failed to read ACBF XML document at token" << xmlReader->name() << "(" << xmlReader->lineNumber() << ":" << xmlReader->columnNumber() << ") The reported error was:" << xmlReader->errorString(); | 258 | qWarning() << Q_FUNC_INFO << "Failed to read ACBF XML document at token" << xmlReader->name() << "(" << xmlReader->lineNumber() << ":" << xmlReader->columnNumber() << ") The reported error was:" << xmlReader->errorString(); | ||
247 | } | 259 | } | ||
248 | qDebug() << Q_FUNC_INFO << "Created book information for the book with the titles" << d->title.values();; | 260 | qDebug() << Q_FUNC_INFO << "Created book information for the book with the titles" << d->title.values(); | ||
249 | return !xmlReader->hasError(); | 261 | return !xmlReader->hasError(); | ||
250 | } | 262 | } | ||
251 | 263 | | |||
Context not available. | |||||
268 | return d->author.at(index); | 280 | return d->author.at(index); | ||
269 | } | 281 | } | ||
270 | 282 | | |||
271 | void BookInfo::addAuthor(QString activity, QString language, QString firstName, QString middleName, QString lastName, QString nickName, QString homePage, QString email) | 283 | void BookInfo::addAuthor(QString activity, QString language, QString firstName, QString middleName, QString lastName, QString nickName, QStringList homePages, QStringList emails) | ||
272 | { | 284 | { | ||
273 | Author* author = new Author(metadata()); | 285 | Author* author = new Author(metadata()); | ||
274 | author->setActivity(activity); | 286 | author->setActivity(activity); | ||
Context not available. | |||||
277 | author->setMiddleName(middleName); | 289 | author->setMiddleName(middleName); | ||
278 | author->setLastName(lastName); | 290 | author->setLastName(lastName); | ||
279 | author->setNickName(nickName); | 291 | author->setNickName(nickName); | ||
280 | author->setHomePage(homePage); | 292 | author->setHomePages(homePages); | ||
281 | author->setEmail(email); | 293 | author->setEmails(emails); | ||
282 | d->author.append(author); | 294 | d->author.append(author); | ||
283 | emit authorsChanged(); | 295 | emit authorsChanged(); | ||
284 | } | 296 | } | ||
285 | 297 | | |||
286 | void BookInfo::setAuthor(int index, QString activity, QString language, QString firstName, QString middleName, QString lastName, QString nickName, QString homePage, QString email) | 298 | void BookInfo::setAuthor(int index, QString activity, QString language, QString firstName, QString middleName, QString lastName, QString nickName, QStringList homePages, QStringList emails) | ||
287 | { | 299 | { | ||
288 | Author* author = d->author.at(index); | 300 | Author* author = d->author.at(index); | ||
289 | author->setActivity(activity); | 301 | author->setActivity(activity); | ||
Context not available. | |||||
292 | author->setMiddleName(middleName); | 304 | author->setMiddleName(middleName); | ||
293 | author->setLastName(lastName); | 305 | author->setLastName(lastName); | ||
294 | author->setNickName(nickName); | 306 | author->setNickName(nickName); | ||
295 | author->setHomePage(homePage); | 307 | author->setHomePages(homePages); | ||
296 | author->setEmail(email); | 308 | author->setEmails(emails); | ||
297 | emit authorsChanged(); | 309 | emit authorsChanged(); | ||
298 | } | 310 | } | ||
299 | 311 | | |||
Context not available. | |||||
327 | 339 | | |||
328 | QString BookInfo::title(QString language) | 340 | QString BookInfo::title(QString language) | ||
329 | { | 341 | { | ||
330 | if(language.isEmpty()) { | 342 | if (d->title.count()==0) { | ||
331 | language = "en"; | 343 | return ""; | ||
344 | } | ||||
345 | if (!d->title.keys().contains(language)) { | ||||
346 | language = ""; | ||||
332 | } | 347 | } | ||
333 | return d->title.value(language); | 348 | | ||
349 | if(language.isEmpty() && d->title[language].isEmpty() && d->languages.count()>0) { | ||||
350 | language = d->languages.at(0)->language(); | ||||
351 | } | ||||
352 | | ||||
353 | QString title = d->title.value(language); | ||||
354 | | ||||
355 | if (title.isEmpty()) { | ||||
356 | title = d->title.values().at(0); | ||||
357 | } | ||||
358 | | ||||
359 | return title; | ||||
334 | } | 360 | } | ||
335 | 361 | | |||
336 | void BookInfo::setTitle(QString title, QString language) | 362 | void BookInfo::setTitle(QString title, QString language) | ||
Context not available. | |||||
381 | QStringList BookInfo::availableGenres() | 407 | QStringList BookInfo::availableGenres() | ||
382 | { | 408 | { | ||
383 | return { | 409 | return { | ||
384 | QStringLiteral("science_fiction"), | 410 | QStringLiteral("adult"), | ||
385 | QStringLiteral("fantasy"), | | |||
386 | QStringLiteral("adventure"), | 411 | QStringLiteral("adventure"), | ||
387 | QStringLiteral("horror"), | 412 | QStringLiteral("alternative"), // (abstract, underground ...) | ||
388 | QStringLiteral("mystery"), | 413 | QStringLiteral("artbook"), // 1.2 | ||
414 | QStringLiteral("biography"), // (biographical comics) | ||||
415 | QStringLiteral("caricature"), | ||||
416 | QStringLiteral("children"), | ||||
417 | QStringLiteral("computer"), // (computers related) | ||||
389 | QStringLiteral("crime"), | 418 | QStringLiteral("crime"), | ||
390 | QStringLiteral("military"), // (war ...) | 419 | QStringLiteral("education"), // (education and science) | ||
391 | QStringLiteral("real_life"), | 420 | QStringLiteral("fantasy"), | ||
392 | QStringLiteral("superhero"), // (e.g. Superman, Spiderman … or Super Villains) | 421 | QStringLiteral("history"), // (historical comics) | ||
422 | QStringLiteral("horror"), | ||||
393 | QStringLiteral("humor"), | 423 | QStringLiteral("humor"), | ||
394 | QStringLiteral("western"), | | |||
395 | QStringLiteral("manga"), | 424 | QStringLiteral("manga"), | ||
425 | QStringLiteral("military"), // (war ...) | ||||
426 | QStringLiteral("mystery"), | ||||
427 | QStringLiteral("non-fiction"), | ||||
396 | QStringLiteral("politics"), | 428 | QStringLiteral("politics"), | ||
397 | QStringLiteral("caricature"), | 429 | QStringLiteral("real_life"), | ||
398 | QStringLiteral("sports"), | | |||
399 | QStringLiteral("history"), // (historical comics) | | |||
400 | QStringLiteral("biography"), // (biographical comics) | | |||
401 | QStringLiteral("education"), // (education and science) | | |||
402 | QStringLiteral("computer"), // (computers related) | | |||
403 | QStringLiteral("religion"), | 430 | QStringLiteral("religion"), | ||
404 | QStringLiteral("romance"), | 431 | QStringLiteral("romance"), | ||
405 | QStringLiteral("children"), | 432 | QStringLiteral("science_fiction"), | ||
406 | QStringLiteral("non-fiction"), | 433 | QStringLiteral("sports"), | ||
407 | QStringLiteral("adult"), | 434 | QStringLiteral("superhero"), // (e.g. Superman, Spiderman … or Super Villains) | ||
408 | QStringLiteral("alternative"), // (abstract, underground ...) | 435 | QStringLiteral("western"), | ||
409 | QStringLiteral("other") | 436 | QStringLiteral("other") | ||
410 | }; | 437 | }; | ||
411 | } | 438 | } | ||
Context not available. | |||||
440 | 467 | | |||
441 | QStringList BookInfo::annotation(QString language) | 468 | QStringList BookInfo::annotation(QString language) | ||
442 | { | 469 | { | ||
443 | return d->annotation.value(language); | 470 | if (!d->annotation.keys().contains(language)) { | ||
471 | language = ""; | ||||
472 | } | ||||
473 | | ||||
474 | if(language.isEmpty() && d->annotation.value(language).count()==0) { | ||||
475 | language = d->languages.at(0)->language(); | ||||
476 | } | ||||
477 | | ||||
478 | QStringList annotation = d->annotation.value(language); | ||||
479 | | ||||
480 | if (annotation.count()==0) { | ||||
481 | annotation = d->annotation.values().at(0); | ||||
482 | } | ||||
483 | | ||||
484 | return annotation; | ||||
444 | } | 485 | } | ||
445 | 486 | | |||
446 | void BookInfo::setAnnotation(QStringList annotation, QString language) | 487 | void BookInfo::setAnnotation(QStringList annotation, QString language) | ||
Context not available. | |||||
455 | 496 | | |||
456 | QStringList BookInfo::keywords(QString language) | 497 | QStringList BookInfo::keywords(QString language) | ||
457 | { | 498 | { | ||
458 | return d->keywords.value(language); | 499 | if (!d->keywords.keys().contains(language)) { | ||
500 | language = ""; | ||||
501 | } | ||||
502 | | ||||
503 | if(language.isEmpty() && d->keywords.value(language).count()==0) { | ||||
504 | language = d->languages.at(0)->language(); | ||||
505 | } | ||||
506 | | ||||
507 | QStringList keywords = d->keywords.value(language); | ||||
508 | | ||||
509 | if (keywords.count()==0) { | ||||
510 | keywords = d->keywords.values().at(0); | ||||
511 | } | ||||
512 | | ||||
513 | return keywords; | ||||
459 | } | 514 | } | ||
460 | 515 | | |||
461 | void BookInfo::setKeywords(QStringList keywords, QString language) | 516 | void BookInfo::setKeywords(QStringList keywords, QString language) | ||
Context not available. | |||||
508 | return d->databaseRef; | 563 | return d->databaseRef; | ||
509 | } | 564 | } | ||
510 | 565 | | |||
566 | | ||||
511 | void BookInfo::addDatabaseRef(DatabaseRef* databaseRef) | 567 | void BookInfo::addDatabaseRef(DatabaseRef* databaseRef) | ||
512 | { | 568 | { | ||
513 | d->databaseRef.append(databaseRef); | 569 | d->databaseRef.append(databaseRef); | ||
Context not available. | |||||
532 | { | 588 | { | ||
533 | d->contentRating.removeAll(contentRating); | 589 | d->contentRating.removeAll(contentRating); | ||
534 | } | 590 | } | ||
591 | QString BookInfo::readingDirection() const | ||||
592 | { | ||||
593 | return d->readingDirection; | ||||
594 | } | ||||
595 | | ||||
596 | void BookInfo::setReadingDirection(const QString& readingDirection) { | ||||
597 | if (readingDirection == "ltr" || | ||||
598 | readingDirection == "rtl") { | ||||
599 | d->readingDirection = readingDirection; | ||||
600 | } | ||||
601 | } | ||||
Context not available. |