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 | bool rightToLeft = false; | ||
54 | }; | 54 | }; | ||
55 | 55 | | |||
56 | BookInfo::BookInfo(Metadata* parent) | 56 | BookInfo::BookInfo(Metadata* parent) | ||
Context not available. | |||||
145 | } | 145 | } | ||
146 | 146 | | |||
147 | //ACBF 1.2 | 147 | //ACBF 1.2 | ||
148 | /* | 148 | // Therefore only write this one when it is useful. | ||
149 | writer->writeStartElement("characters"); | 149 | if (d->rightToLeft) { | ||
150 | writer->writeCharacters(d->readingDirection); | 150 | writer->writeStartElement("reading-direction"); | ||
151 | writer->writeEndElement(); | 151 | writer->writeCharacters("RTL"); | ||
152 | */ | 152 | writer->writeEndElement(); | ||
153 | } | ||||
153 | 154 | | |||
154 | writer->writeEndElement(); | 155 | writer->writeEndElement(); | ||
155 | } | 156 | } | ||
Context not available. | |||||
246 | } | 247 | } | ||
247 | else if(xmlReader->name() == QStringLiteral("reading-direction")) | 248 | else if(xmlReader->name() == QStringLiteral("reading-direction")) | ||
248 | { | 249 | { | ||
249 | setReadingDirection(xmlReader->readElementText(QXmlStreamReader::IncludeChildElements).toLower()); | 250 | QString direction = xmlReader->readElementText(QXmlStreamReader::IncludeChildElements).toLower(); | ||
251 | if (direction=="rtl") { | ||||
252 | setRightToLeft(true); | ||||
253 | } else { | ||||
254 | setRightToLeft(false); | ||||
255 | } | ||||
250 | } | 256 | } | ||
251 | else | 257 | else | ||
252 | { | 258 | { | ||
Context not available. | |||||
455 | emit charactersChanged(); | 461 | emit charactersChanged(); | ||
456 | } | 462 | } | ||
457 | 463 | | |||
464 | void BookInfo::setCharacters(QStringList characters) | ||||
465 | { | ||||
466 | d->characters = characters; | ||||
467 | emit charactersChanged(); | ||||
468 | } | ||||
469 | | ||||
458 | QList<QStringList> BookInfo::annotationsForAllLanguage() | 470 | QList<QStringList> BookInfo::annotationsForAllLanguage() | ||
459 | { | 471 | { | ||
460 | return d->annotation.values(); | 472 | return d->annotation.values(); | ||
Context not available. | |||||
467 | 479 | | |||
468 | QStringList BookInfo::annotation(QString language) | 480 | QStringList BookInfo::annotation(QString language) | ||
469 | { | 481 | { | ||
482 | if (d->annotation.isEmpty()) { | ||||
483 | return QStringList(""); | ||||
484 | } | ||||
470 | if (!d->annotation.keys().contains(language)) { | 485 | if (!d->annotation.keys().contains(language)) { | ||
471 | language = ""; | 486 | language = ""; | ||
472 | } | 487 | } | ||
Context not available. | |||||
496 | 511 | | |||
497 | QStringList BookInfo::keywords(QString language) | 512 | QStringList BookInfo::keywords(QString language) | ||
498 | { | 513 | { | ||
514 | if (d->keywords.isEmpty()) { | ||||
515 | return QStringList(""); | ||||
516 | } | ||||
517 | | ||||
499 | if (!d->keywords.keys().contains(language)) { | 518 | if (!d->keywords.keys().contains(language)) { | ||
500 | language = ""; | 519 | language = ""; | ||
501 | } | 520 | } | ||
Context not available. | |||||
536 | void BookInfo::addLanguage(Language* language) | 555 | void BookInfo::addLanguage(Language* language) | ||
537 | { | 556 | { | ||
538 | d->languages.append(language); | 557 | d->languages.append(language); | ||
558 | emit languageEntryListChanged(); | ||||
559 | } | ||||
560 | | ||||
561 | QStringList BookInfo::languageEntryList() | ||||
562 | { | ||||
563 | QStringList lang; | ||||
564 | for (int i=0; i<d->languages.size(); i++) { | ||||
565 | lang.append(d->languages.at(i)->language()); | ||||
566 | } | ||||
567 | return lang; | ||||
568 | } | ||||
569 | | ||||
570 | void BookInfo::addLanguage(QString language, bool show) | ||||
571 | { | ||||
572 | Language* lang = new Language(this); | ||||
573 | lang->setLanguage(language); | ||||
574 | lang->setShow(show); | ||||
575 | addLanguage(lang); | ||||
539 | } | 576 | } | ||
540 | 577 | | |||
541 | void BookInfo::removeLanguage(Language* language) | 578 | void BookInfo::removeLanguage(Language* language) | ||
542 | { | 579 | { | ||
543 | d->languages.removeAll(language); | 580 | d->languages.removeAll(language); | ||
581 | emit languageEntryListChanged(); | ||||
582 | } | ||||
583 | | ||||
584 | void BookInfo::removeLanguage(int index) | ||||
585 | { | ||||
586 | removeLanguage(d->languages.at(index)); | ||||
544 | } | 587 | } | ||
545 | 588 | | |||
546 | QList<Sequence *> BookInfo::sequence() | 589 | QList<Sequence *> BookInfo::sequence() | ||
Context not available. | |||||
551 | void BookInfo::addSequence(Sequence* sequence) | 594 | void BookInfo::addSequence(Sequence* sequence) | ||
552 | { | 595 | { | ||
553 | d->sequence.append(sequence); | 596 | d->sequence.append(sequence); | ||
597 | emit sequenceCountChanged(); | ||||
598 | } | ||||
599 | | ||||
600 | void BookInfo::addSequence(int number, QString title, int volume) | ||||
601 | { | ||||
602 | Sequence* sequence = new Sequence(this); | ||||
603 | sequence->setNumber(number); | ||||
604 | sequence->setTitle(title); | ||||
605 | sequence->setVolume(volume); | ||||
606 | addSequence(sequence); | ||||
554 | } | 607 | } | ||
555 | 608 | | |||
556 | void BookInfo::removeSequence(Sequence* sequence) | 609 | void BookInfo::removeSequence(Sequence* sequence) | ||
557 | { | 610 | { | ||
558 | d->sequence.removeAll(sequence); | 611 | d->sequence.removeAll(sequence); | ||
612 | emit sequenceCountChanged(); | ||||
613 | } | ||||
614 | | ||||
615 | void BookInfo::removeSequence(int index) | ||||
616 | { | ||||
617 | removeSequence(sequence(index)); | ||||
618 | } | ||||
619 | | ||||
620 | Sequence *BookInfo::sequence(int index) const | ||||
621 | { | ||||
622 | return d->sequence.at(index); | ||||
623 | } | ||||
624 | | ||||
625 | int BookInfo::sequenceCount() const | ||||
626 | { | ||||
627 | | ||||
628 | return d->sequence.size(); | ||||
559 | } | 629 | } | ||
560 | 630 | | |||
561 | QList<DatabaseRef *> BookInfo::databaseRef() | 631 | QList<DatabaseRef *> BookInfo::databaseRef() | ||
Context not available. | |||||
567 | void BookInfo::addDatabaseRef(DatabaseRef* databaseRef) | 637 | void BookInfo::addDatabaseRef(DatabaseRef* databaseRef) | ||
568 | { | 638 | { | ||
569 | d->databaseRef.append(databaseRef); | 639 | d->databaseRef.append(databaseRef); | ||
640 | emit databaseRefCountChanged(); | ||||
641 | } | ||||
642 | | ||||
643 | void BookInfo::addDatabaseRef(QString reference, QString dbname, QString type) | ||||
644 | { | ||||
645 | DatabaseRef* dRef = new DatabaseRef(this); | ||||
646 | dRef->setReference(reference); | ||||
647 | dRef->setDbname(dbname); | ||||
648 | dRef->setType(type); | ||||
649 | addDatabaseRef(dRef); | ||||
570 | } | 650 | } | ||
571 | 651 | | |||
572 | void BookInfo::removeDatabaseRef(DatabaseRef* databaseRef) | 652 | void BookInfo::removeDatabaseRef(DatabaseRef* databaseRef) | ||
573 | { | 653 | { | ||
574 | d->databaseRef.removeAll(databaseRef); | 654 | d->databaseRef.removeAll(databaseRef); | ||
655 | emit databaseRefCountChanged(); | ||||
656 | } | ||||
657 | | ||||
658 | void BookInfo::removeDatabaseRef(int index) | ||||
659 | { | ||||
660 | removeDatabaseRef(databaseRef(index)); | ||||
661 | } | ||||
662 | | ||||
663 | DatabaseRef *BookInfo::databaseRef(int index) | ||||
664 | { | ||||
665 | return d->databaseRef.at(index); | ||||
666 | } | ||||
667 | | ||||
668 | int BookInfo::databaseRefCount() | ||||
669 | { | ||||
670 | return d->databaseRef.size(); | ||||
575 | } | 671 | } | ||
576 | 672 | | |||
577 | QList<ContentRating *> BookInfo::contentRating() | 673 | QList<ContentRating *> BookInfo::contentRating() | ||
Context not available. | |||||
582 | void BookInfo::addContentRating(ContentRating* contentRating) | 678 | void BookInfo::addContentRating(ContentRating* contentRating) | ||
583 | { | 679 | { | ||
584 | d->contentRating.append(contentRating); | 680 | d->contentRating.append(contentRating); | ||
681 | emit contentRatingCountChanged(); | ||||
682 | } | ||||
683 | | ||||
684 | void BookInfo::addContentRating(QString rating, QString type) | ||||
685 | { | ||||
686 | ContentRating* CR = new ContentRating(this); | ||||
687 | CR->setRating(rating); | ||||
688 | CR->setType(type); | ||||
689 | addContentRating(CR); | ||||
585 | } | 690 | } | ||
586 | 691 | | |||
587 | void BookInfo::removeContentRating(ContentRating* contentRating) | 692 | void BookInfo::removeContentRating(ContentRating* contentRating) | ||
588 | { | 693 | { | ||
589 | d->contentRating.removeAll(contentRating); | 694 | d->contentRating.removeAll(contentRating); | ||
695 | emit contentRatingCountChanged(); | ||||
590 | } | 696 | } | ||
591 | QString BookInfo::readingDirection() const | 697 | | ||
698 | void BookInfo::removeContentRating(int index) | ||||
592 | { | 699 | { | ||
593 | return d->readingDirection; | 700 | removeContentRating(contentRating(index)); | ||
594 | } | 701 | } | ||
595 | 702 | | |||
596 | void BookInfo::setReadingDirection(const QString& readingDirection) { | 703 | ContentRating *BookInfo::contentRating(int index) | ||
597 | if (readingDirection == "ltr" || | 704 | { | ||
598 | readingDirection == "rtl") { | 705 | return d->contentRating.at(index); | ||
599 | d->readingDirection = readingDirection; | 706 | } | ||
600 | } | 707 | | ||
708 | int BookInfo::contentRatingCount() | ||||
709 | { | ||||
710 | return d->contentRating.size(); | ||||
711 | } | ||||
712 | bool BookInfo::rightToLeft() const | ||||
713 | { | ||||
714 | return d->rightToLeft; | ||||
715 | } | ||||
716 | | ||||
717 | void BookInfo::setRightToLeft(const bool& rtl) { | ||||
718 | d->rightToLeft = rtl; | ||||
719 | emit rightToLeftChanged(); | ||||
601 | } | 720 | } | ||
Context not available. |