Warning, /graphics/peruse/src/creator/qml/BookMetainfoPage.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  * Copyright (C) 2015 Dan Leinir Turthra Jensen <admin@leinir.dk>
0003  *
0004  * This library is free software; you can redistribute it and/or
0005  * modify it under the terms of the GNU Lesser General Public
0006  * License as published by the Free Software Foundation; either
0007  * version 2.1 of the License, or (at your option) version 3, or any
0008  * later version accepted by the membership of KDE e.V. (or its
0009  * successor approved by the membership of KDE e.V.), which shall
0010  * act as a proxy defined in Section 6 of version 3 of the license.
0011  *
0012  * This library is distributed in the hope that it will be useful,
0013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0015  * Lesser General Public License for more details.
0016  *
0017  * You should have received a copy of the GNU Lesser General Public
0018  * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
0019  *
0020  */
0021 
0022 import QtQuick 2.12
0023 import QtQuick.Controls 2.12 as QtControls
0024 import QtQuick.Dialogs 1.3
0025 
0026 import org.kde.kirigami 2.1 as Kirigami
0027 
0028 import "metainfoeditors"
0029 /**
0030  * @brief Page with form to edit the comic metadata.
0031  *
0032  * Most metadata entries are quite simple.
0033  *
0034  * Others, like Author, need a dedicated entry editor (AuthorEntryEditor).
0035  */
0036 Kirigami.ScrollablePage {
0037     id: root;
0038     property string categoryName: "bookMetaInfo";
0039     title: i18nc("title text for the book meta information editor sheet", "Edit Meta Information");
0040     property QtObject model;
0041 
0042     actions {
0043         main: saveAction;
0044     }
0045     Kirigami.Action {
0046         id: saveAction;
0047         text: i18nc("Saves the book to a file on disk", "Save Book");
0048         iconName: "document-save";
0049         onTriggered: {
0050             // Ensure there's a default language entry.
0051             if (root.model.acbfData.metaData.bookInfo.languageEntryList.indexOf("") === -1) {
0052                 root.model.acbfData.metaData.bookInfo.addLanguage("");
0053             }
0054             root.model.saveBook();
0055         }
0056     }
0057 
0058     Column {
0059         id: contentColumn;
0060         width: root.width - (root.leftPadding + root.rightPadding);
0061         height: childrenRect.height;
0062         spacing: Kirigami.Units.smallSpacing;
0063 
0064         Kirigami.Heading {
0065             width: parent.width;
0066             height: paintedHeight + Kirigami.Units.smallSpacing * 2;
0067             text: i18nc("label text for the edit field for the book title", "Title");
0068         }
0069 
0070         Item { width: parent.width; height: Kirigami.Units.smallSpacing; }
0071         QtControls.TextField {
0072             id: defaultTitle;
0073             width: parent.width;
0074             placeholderText: i18nc("placeholder text for default title text-input", "Write to add default title");
0075             text:root.model.acbfData ? root.model.acbfData.metaData.bookInfo.title("") : "";
0076             onTextChanged: {
0077                 root.model.acbfData.metaData.bookInfo.setTitle(defaultTitle.text, "");
0078                 root.model.setDirty();
0079             }
0080         }
0081 
0082         Kirigami.Heading {
0083             width: parent.width;
0084             height: paintedHeight + Kirigami.Units.smallSpacing * 2;
0085             text: i18nc("label text for the edit field for the default annotation", "Annotation");
0086         }
0087         Item { width: parent.width; height: Kirigami.Units.smallSpacing; }
0088         QtControls.TextArea {
0089             id: defaultAnnotation;
0090             width: parent.width;
0091             placeholderText: i18nc("placeholder text for default annotation text-area", "Write to add default annotation");
0092             wrapMode: TextEdit.Wrap
0093             text: root.model.acbfData ? root.model.acbfData.metaData.bookInfo.annotation("").join("\n\n") : "";
0094             onTextChanged: {
0095                 root.model.acbfData.metaData.bookInfo.setAnnotation(defaultAnnotation.text.split("\n\n"), "");
0096                 root.model.setDirty();
0097             }
0098         }
0099         Kirigami.Heading {
0100             width: parent.width;
0101             height: paintedHeight + Kirigami.Units.smallSpacing * 2;
0102             text: i18nc("label text for the edit field for the keyword list", "Keywords");
0103         }
0104         Item { width: parent.width; height: Kirigami.Units.smallSpacing; }
0105         QtControls.TextField {
0106             id: defaultKeywords;
0107             width: parent.width;
0108             placeholderText: i18nc("placeholder text for the add new keyword text entry", "Write a comma separated list of keywords.");
0109             text:root.model.acbfData ? root.model.acbfData.metaData.bookInfo.keywords("").join(", ") : "";
0110             onTextChanged: {
0111                 var keywords = defaultKeywords.text.split(",")
0112                 for (var i in keywords) {
0113                     keywords[i] = keywords[i].trim();
0114                 }
0115                 root.model.acbfData.metaData.bookInfo.setKeywords(keywords, "");
0116                 root.model.setDirty();
0117             }
0118         }
0119 
0120         Kirigami.Heading {
0121             width: parent.width;
0122             height: paintedHeight + Kirigami.Units.smallSpacing * 2;
0123             text: i18nc("label text for the edit field for the author list", "Authors (%1)", authorRepeater.count);
0124         }
0125         Repeater {
0126             id: authorRepeater;
0127             model: root.model.acbfData ? root.model.acbfData.metaData.bookInfo.authorNames : 0;
0128             delegate: QtControls.Label {
0129                 width: parent.width - removeAuthorButton.width - Kirigami.Units.smallSpacing;
0130                 text: modelData.length > 0 ? modelData : i18nc("The text used in place of an author's name if one has not been set", "(unnamed)");
0131                 QtControls.Button {
0132                     id: editAuthorButton;
0133                     anchors {
0134                         right: removeAuthorButton.left;
0135                         leftMargin: Kirigami.Units.smallSpacing;
0136                     }
0137                     contentItem: Kirigami.Icon {
0138                         source: "document-edit";
0139                     }
0140                     height: parent.height;
0141                     width: height;
0142                     onClicked: {
0143                         authorEditor.index = model.index;
0144                         authorEditor.open();
0145                     }
0146                 }
0147                 QtControls.Button {
0148                     id: removeAuthorButton;
0149                     anchors {
0150                         left: parent.right;
0151                         leftMargin: Kirigami.Units.smallSpacing;
0152                     }
0153                     contentItem: Kirigami.Icon {
0154                         source: "list-remove";
0155                     }
0156                     height: parent.height;
0157                     width: height;
0158                     onClicked: {
0159                         // When removing, set the model dirty first, and then remove the entry to avoid reference errors.
0160                         root.model.setDirty();
0161                         root.model.acbfData.metaData.bookInfo.removeAuthor(index);
0162                     }
0163                 }
0164             }
0165         }
0166         Item { width: parent.width; height: Kirigami.Units.smallSpacing; }
0167         QtControls.TextField {
0168             width: parent.width - addAuthorButton.width - Kirigami.Units.smallSpacing;
0169             placeholderText: i18nc("placeholder text for the add new author text entry", "Write to add new author (nickname)");
0170             Keys.onReturnPressed: addAuthor();
0171             function addAuthor() {
0172                 if(text !== "") {
0173                     // Just add an author where only the nickname is defined
0174                     root.model.acbfData.metaData.bookInfo.addAuthor("", "", "", "", "", text, [""], [""]);
0175                     root.model.setDirty();
0176                     text = "";
0177                 }
0178             }
0179 
0180             QtControls.Button {
0181                 id: addAuthorButton;
0182                 anchors {
0183                     left: parent.right;
0184                     leftMargin: Kirigami.Units.smallSpacing;
0185                 }
0186                 contentItem: Kirigami.Icon {
0187                     source: "list-add";
0188                 }
0189                 height: parent.height;
0190                 width: height;
0191                 onClicked: parent.addAuthor();
0192             }
0193         }
0194 
0195         Kirigami.Heading {
0196             width: parent.width;
0197             height: paintedHeight + Kirigami.Units.smallSpacing * 2;
0198             text: i18nc("label text for the edit field for the genre list", "Genres");
0199         }
0200         Repeater {
0201             model: root.model.acbfData ? root.model.acbfData.metaData.bookInfo.genres : 0;
0202             delegate: Item {
0203                 width: parent.width;
0204                 height: childrenRect.height;
0205                 QtControls.Label {
0206                     id: genreText;
0207                     width: parent.width - removeGenreButton.width - Kirigami.Units.smallSpacing;
0208                     text: modelData;
0209                     QtControls.Button {
0210                         id: removeGenreButton;
0211                         anchors {
0212                             left: parent.right;
0213                             leftMargin: Kirigami.Units.smallSpacing;
0214                         }
0215                         contentItem: Kirigami.Icon {
0216                             source: "list-remove";
0217                         }
0218                         height: parent.height;
0219                         width: height;
0220                         onClicked: {
0221                             root.model.setDirty();
0222                             root.model.acbfData.metaData.bookInfo.removeGenre(modelData);
0223                         }
0224                     }
0225                 }
0226                 QtControls.Slider {
0227                     anchors {
0228                         top: genreText.bottom;
0229                         topMargin: Kirigami.Units.smallSpacing;
0230                     }
0231                     from: 0;
0232                     to: 100;
0233                     stepSize: 1.0;
0234                     width: genreText.width;
0235                     value: root.model.acbfData.metaData.bookInfo.genrePercentage(modelData);
0236                     onValueChanged: {
0237                         if(value > 0 && value !== root.model.acbfData.metaData.bookInfo.genrePercentage(modelData)) {
0238                             root.model.acbfData.metaData.bookInfo.setGenre(modelData, value);
0239                             root.model.setDirty();
0240                         }
0241                     }
0242                 }
0243             }
0244         }
0245         Item { width: parent.width; height: Kirigami.Units.smallSpacing; }
0246         QtControls.ComboBox {
0247             width: parent.width - addGenreButton.width - Kirigami.Units.smallSpacing;
0248             model: root.model.acbfData ? root.model.acbfData.metaData.bookInfo.availableGenres().filter(checkGenreInUse) : 0;
0249             Keys.onReturnPressed: addGenre();
0250             function addGenre() {
0251                 root.model.acbfData.metaData.bookInfo.setGenre(currentText);
0252                 root.model.setDirty();
0253                 currentIndex=0;
0254             }
0255             function checkGenreInUse (genre) {
0256                 return root.model.acbfData.metaData.bookInfo.genres.indexOf(genre) === -1;
0257             }
0258 
0259             QtControls.Button {
0260                 id: addGenreButton;
0261                 anchors {
0262                     left: parent.right;
0263                     leftMargin: Kirigami.Units.smallSpacing;
0264                 }
0265                 contentItem: Kirigami.Icon {
0266                     source: "list-add";
0267                 }
0268                 height: parent.height;
0269                 width: height;
0270                 onClicked: parent.addGenre();
0271             }
0272         }
0273 
0274         Kirigami.Heading {
0275             width: parent.width;
0276             height: paintedHeight + Kirigami.Units.smallSpacing * 2;
0277             text: i18nc("label text for the edit field for the character list", "Characters");
0278         }
0279         Repeater {
0280             model: root.model.acbfData ? root.model.acbfData.metaData.bookInfo.characters : 0;
0281             delegate: QtControls.TextField {
0282                 width: parent.width - removeCharacterButton.width - Kirigami.Units.smallSpacing;
0283                 text: modelData;
0284                 onEditingFinished: root.model.acbfData.metaData.bookInfo.characters[index] = text;
0285                 QtControls.Button {
0286                     id: removeCharacterButton;
0287                     anchors {
0288                         left: parent.right;
0289                         leftMargin: Kirigami.Units.smallSpacing;
0290                     }
0291                     contentItem: Kirigami.Icon {
0292                         source: "list-remove";
0293                     }
0294                     height: parent.height;
0295                     width: height;
0296                     onClicked: {
0297                         root.model.setDirty();
0298                         root.model.acbfData.metaData.bookInfo.removeCharacter(modelData);
0299                     }
0300                 }
0301             }
0302         }
0303         Item { width: parent.width; height: Kirigami.Units.smallSpacing; }
0304         QtControls.TextField {
0305             width: parent.width - addCharacterButton.width - Kirigami.Units.smallSpacing;
0306             placeholderText: i18nc("placeholder text for the add new character text entry", "Write to add new character");
0307             Keys.onReturnPressed: addCharacter();
0308             function addCharacter() {
0309                 if(text !== "") {
0310                     root.model.acbfData.metaData.bookInfo.addCharacter(text);
0311                     root.model.setDirty();
0312                     text = "";
0313                 }
0314             }
0315 
0316             QtControls.Button {
0317                 id: addCharacterButton;
0318                 anchors {
0319                     left: parent.right;
0320                     leftMargin: Kirigami.Units.smallSpacing;
0321                 }
0322                 contentItem: Kirigami.Icon {
0323                     source: "list-add";
0324                 }
0325                 height: parent.height;
0326                 width: height;
0327                 onClicked: parent.addCharacter();
0328             }
0329         }
0330 
0331         Kirigami.Heading {
0332             width: parent.width;
0333             height: paintedHeight + Kirigami.Units.smallSpacing * 2;
0334             text: i18nc("label text for the edit field for the sequence list", "Sequence");
0335         }
0336         Repeater {
0337             id: sequenceListRepeater;
0338             model: root.model.acbfData ? root.model.acbfData.metaData.bookInfo.sequenceCount : 0;
0339             delegate: Item {
0340                 width: parent.width;
0341                 height: childrenRect.height;
0342 
0343                 function updateSeries() {
0344                     root.model.acbfData.metaData.bookInfo.sequence(modelData).title = seriesTextField.text;
0345                     if (numberField.value !== root.model.acbfData.metaData.bookInfo.sequence(modelData).number) {
0346                         root.model.acbfData.metaData.bookInfo.sequence(modelData).number = numberField.value;
0347                     }
0348                     if (volumeField.value !== root.model.acbfData.metaData.bookInfo.sequence(modelData).volume) {
0349                         root.model.acbfData.metaData.bookInfo.sequence(modelData).volume = volumeField.value;
0350                     }
0351                     root.model.setDirty();
0352                 }
0353 
0354                 QtControls.TextField {
0355                     id: seriesTextField;
0356                     width: parent.width - removeSequenceButton.width - Kirigami.Units.smallSpacing;
0357                     text: root.model.acbfData.metaData.bookInfo.sequence(modelData).title;
0358                     onEditingFinished: parent.updateSeries();
0359                 }
0360 
0361                 QtControls.Label {
0362                     text: i18nc("Label for sequence number","Number:");
0363                     id: sequenceNumberLabel;
0364                     height:numberField.height;
0365                     anchors {
0366                         top: seriesTextField.bottom;
0367                         topMargin: Kirigami.Units.smallSpacing;
0368                     }
0369                 }
0370                 QtControls.SpinBox {
0371                     anchors {
0372                         top: seriesTextField.bottom;
0373                         topMargin: Kirigami.Units.smallSpacing;
0374                         left: sequenceNumberLabel.right;
0375                         leftMargin: Kirigami.Units.smallSpacing;
0376                     }
0377                     value : root.model.acbfData.metaData.bookInfo.sequence(modelData).number;
0378                     width : ((seriesTextField.width+Kirigami.Units.smallSpacing)/2)-(sequenceNumberLabel.width+Kirigami.Units.smallSpacing);
0379                     id: numberField;
0380                     onValueChanged: parent.updateSeries();
0381                     from: 0;
0382                     to: 99999;
0383                     editable: true;
0384                 }
0385                 QtControls.Label {
0386                     text: i18nc("Label for sequence volume","Volume:");
0387                     id: sequenceVolumeLabel;
0388                     height:volumeField.height;
0389                     anchors {
0390                         left: numberField.right;
0391                         leftMargin: Kirigami.Units.smallSpacing;
0392                         top: seriesTextField.bottom;
0393                         topMargin: Kirigami.Units.smallSpacing;
0394                     }
0395 
0396                 }
0397                 QtControls.SpinBox {
0398                     anchors {
0399                         left: sequenceVolumeLabel.right;
0400                         leftMargin: Kirigami.Units.smallSpacing;
0401                         top: seriesTextField.bottom;
0402                         topMargin: Kirigami.Units.smallSpacing;
0403                     }
0404                     value : root.model.acbfData.metaData.bookInfo.sequence(modelData).volume;
0405                     width : (seriesTextField.width/2)-(Kirigami.Units.smallSpacing*1.5)-(sequenceVolumeLabel.width+Kirigami.Units.smallSpacing);
0406                     id: volumeField;
0407                     onValueChanged: parent.updateSeries();
0408                     from: 0;
0409                     to: 99999;
0410                     editable: true;
0411                 }
0412                 QtControls.Button {
0413                     id: removeSequenceButton;
0414                     anchors {
0415                         left: seriesTextField.right;
0416                         leftMargin: Kirigami.Units.smallSpacing;
0417                     }
0418                     contentItem: Kirigami.Icon {
0419                         source: "list-remove";
0420                     }
0421                     height: seriesTextField.height;
0422                     width: height;
0423                     onClicked: {
0424                         root.model.setDirty();
0425                         root.model.acbfData.metaData.bookInfo.removeSequence(index);
0426                     }
0427                 }
0428             }
0429         }
0430         Item { width: parent.width; height: Kirigami.Units.smallSpacing; }
0431         QtControls.TextField {
0432             width: parent.width - addSequenceButton.width - Kirigami.Units.smallSpacing;
0433             placeholderText: i18nc("placeholder text for the add new series text entry", "Write to add new series");
0434             Keys.onReturnPressed:addSequence();
0435             function addSequence() {
0436                 if(text !== "") {
0437                     root.model.acbfData.metaData.bookInfo.addSequence(0, text);
0438                     root.model.setDirty();
0439                     text = "";
0440                 }
0441             }
0442 
0443             QtControls.Button {
0444                 id: addSequenceButton;
0445                 anchors {
0446                     left: parent.right;
0447                     leftMargin: Kirigami.Units.smallSpacing;
0448                 }
0449                 contentItem: Kirigami.Icon {
0450                     source: "list-add";
0451                 }
0452                 height: parent.height;
0453                 width: height;
0454                 onClicked: parent.addSequence();
0455             }
0456         }
0457 
0458         Kirigami.Heading {
0459             width: parent.width;
0460             height: paintedHeight + Kirigami.Units.smallSpacing * 2;
0461             text: i18nc("label text for the edit field for the database reference list", "Database References");
0462         }
0463         Repeater {
0464             model: root.model.acbfData ? root.model.acbfData.metaData.bookInfo.databaseRefCount : 0;
0465             delegate: Item {
0466                 width: parent.width;
0467                 height: childrenRect.height;
0468 
0469                 function updateDatabaseRef() {
0470                     root.model.acbfData.metaData.bookInfo.databaseRef(modelData).reference = referenceTextField.text
0471                     root.model.acbfData.metaData.bookInfo.databaseRef(modelData).dbname = databaseNameField.text
0472                     root.model.acbfData.metaData.bookInfo.databaseRef(modelData).type = referenceTypeField.text
0473                     root.model.setDirty();
0474                 }
0475 
0476                 QtControls.TextField {
0477                     id: referenceTextField;
0478                     width: parent.width - removeReferenceButton.width - Kirigami.Units.smallSpacing;
0479                     text: root.model.acbfData.metaData.bookInfo.databaseRef(modelData).reference;
0480                     onEditingFinished: parent.updateDatabaseRef();
0481                 }
0482                 QtControls.TextField {
0483                     anchors {
0484                         top: referenceTextField.bottom;
0485                         topMargin: Kirigami.Units.smallSpacing;
0486                     }
0487                     width : (referenceTextField.width+Kirigami.Units.smallSpacing)/2;
0488                     id: databaseNameField;
0489                     text: root.model.acbfData.metaData.bookInfo.databaseRef(modelData).dbname;
0490                     onEditingFinished: parent.updateDatabaseRef();
0491                 }
0492                 QtControls.TextField {
0493                     anchors {
0494                         left: databaseNameField.right;
0495                         leftMargin: Kirigami.Units.smallSpacing;
0496                         top: referenceTextField.bottom;
0497                         topMargin: Kirigami.Units.smallSpacing;
0498                     }
0499                     width : (referenceTextField.width/2)-(Kirigami.Units.smallSpacing*1.5);
0500                     id: referenceTypeField;
0501                     text: root.model.acbfData.metaData.bookInfo.databaseRef(modelData).type;
0502                     placeholderText: i18nc("placeholder text for the add reference type text entry", "Write to add reference type");
0503                     onEditingFinished: parent.updateDatabaseRef();
0504                 }
0505                 QtControls.Button {
0506                     id: removeReferenceButton;
0507                     anchors {
0508                         left: referenceTextField.right;
0509                         leftMargin: Kirigami.Units.smallSpacing;
0510                     }
0511                     contentItem: Kirigami.Icon {
0512                         source: "list-remove";
0513                     }
0514                     height: referenceTextField.height;
0515                     width: height;
0516                     onClicked: {
0517                         root.model.setDirty();
0518                         root.model.acbfData.metaData.bookInfo.removeDatabaseRef(index);
0519                     }
0520                 }
0521             }
0522         }
0523         Item { width: parent.width; height: Kirigami.Units.smallSpacing; }
0524         Item {
0525              width: parent.width;
0526              height: childrenRect.height;
0527             function addReference() {
0528                 if(addReferenceField.text !== "" && addDatabaseNameField.text !== "") {
0529                     root.model.acbfData.metaData.bookInfo.addDatabaseRef(addReferenceField.text, addDatabaseNameField.text);
0530                     root.model.setDirty();
0531                     addReferenceField.text = "";
0532                     addDatabaseNameField.text = "";
0533                 }
0534             }
0535 
0536             QtControls.TextField {
0537                 id: addReferenceField
0538                 width: parent.width - addReferenceButton.width - Kirigami.Units.smallSpacing;
0539                 placeholderText: i18nc("placeholder text for the add new reference text entry", "Write to add new reference");
0540                 Keys.onReturnPressed: parent.addReference();
0541             }
0542             QtControls.TextField {
0543                 id: addDatabaseNameField
0544                 anchors {
0545                     top: addReferenceField.bottom;
0546                     topMargin: Kirigami.Units.smallSpacing;
0547                 }
0548                 width: parent.width - addReferenceButton.width - Kirigami.Units.smallSpacing;
0549                 placeholderText: i18nc("placeholder text for the add databasename text entry", "Write to add database name for new reference.");
0550                 Keys.onReturnPressed: parent.addReference();
0551             }
0552             QtControls.Button {
0553                 id: addReferenceButton;
0554                 anchors {
0555                     left: addReferenceField.right;
0556                     leftMargin: Kirigami.Units.smallSpacing;
0557                 }
0558                 contentItem: Kirigami.Icon {
0559                     source: "list-add";
0560                 }
0561                 height: addReferenceField.height;
0562                 width: height;
0563                 onClicked: parent.addReference();
0564             }
0565         }
0566 
0567         Kirigami.Heading {
0568             width: parent.width;
0569             height: paintedHeight + Kirigami.Units.smallSpacing * 2;
0570             text: i18nc("label text for the edit field for the content rating list", "Content Ratings");
0571         }
0572         Repeater {
0573             model: root.model.acbfData ? root.model.acbfData.metaData.bookInfo.contentRatingCount : 0;
0574             delegate: Item {
0575                 width: parent.width;
0576                 height: childrenRect.height;
0577 
0578                 function updateRating() {
0579                     root.model.acbfData.metaData.bookInfo.contentRating(modelData).rating = ratingNameField.text
0580                     root.model.acbfData.metaData.bookInfo.contentRating(modelData).type = systemNameField.text
0581                     root.model.setDirty();
0582                 }
0583 
0584                 QtControls.TextField {
0585                     width : (parent.width-removeRatingButton.width+Kirigami.Units.smallSpacing)/2;
0586                     id: ratingNameField;
0587                     text: root.model.acbfData.metaData.bookInfo.contentRating(modelData).rating;
0588                     placeholderText: i18nc("placeholder text for the add content rating text entry", "Write to add rating label.");
0589                     onEditingFinished: parent.updateRating();
0590                 }
0591                 QtControls.TextField {
0592                     anchors {
0593                         left: ratingNameField.right;
0594                         leftMargin: Kirigami.Units.smallSpacing;
0595                     }
0596                     width : ((parent.width-removeRatingButton.width)/2)-(Kirigami.Units.smallSpacing*1.5);
0597                     id: systemNameField;
0598                     text: root.model.acbfData.metaData.bookInfo.contentRating(modelData).type;
0599                     placeholderText: i18nc("placeholder text for the add content rating system text entry", "Write to add rating system.");
0600                     onEditingFinished: parent.updateRating();
0601                 }
0602                 QtControls.Button {
0603                     id: removeRatingButton;
0604                     anchors {
0605                         left: systemNameField.right;
0606                         leftMargin: Kirigami.Units.smallSpacing;
0607                     }
0608                     contentItem: Kirigami.Icon {
0609                         source: "list-remove";
0610                     }
0611                     height: systemNameField.height;
0612                     width: height;
0613                     onClicked: {
0614                         root.model.setDirty();
0615                         root.model.acbfData.metaData.bookInfo.removeContentRating(index);
0616                     }
0617                 }
0618             }
0619         }
0620         Item {
0621             width: parent.width;
0622             height: childrenRect.height;
0623             function addRating() {
0624                 if(addRatingField.text !== "" && addSystemField.text !== "") {
0625                     root.model.acbfData.metaData.bookInfo.addContentRating(addRatingField.text, addSystemField.text);
0626                     root.model.setDirty();
0627                     addRatingField.text = "";
0628                     addSystemField.text = "";
0629                 }
0630             }
0631             QtControls.TextField {
0632                 width : (parent.width-addRatingButton.width+Kirigami.Units.smallSpacing)/2;
0633                 id: addRatingField;
0634                 placeholderText: i18nc("placeholder text for the add content rating text entry", "Write to add rating label.");
0635                 onEditingFinished: parent.addRating();
0636             }
0637             QtControls.TextField {
0638                 anchors {
0639                     left: addRatingField.right;
0640                     leftMargin: Kirigami.Units.smallSpacing;
0641                 }
0642                 width : ((parent.width-addRatingButton.width)/2)-(Kirigami.Units.smallSpacing*1.5);
0643                 id: addSystemField;
0644                 placeholderText: i18nc("placeholder text for the add content rating system text entry", "Write to add rating system.");
0645                 onEditingFinished: parent.addRating();
0646             }
0647             QtControls.Button {
0648                 id: addRatingButton;
0649                 anchors {
0650                     left: addSystemField.right;
0651                     leftMargin: Kirigami.Units.smallSpacing;
0652                 }
0653                 contentItem: Kirigami.Icon {
0654                     source: "list-add";
0655                 }
0656                 height: addSystemField.height;
0657                 width: height;
0658                 onClicked: parent.addRating();
0659             }
0660         }
0661         Kirigami.Heading {
0662             width: parent.width;
0663             height: paintedHeight + Kirigami.Units.smallSpacing * 2;
0664             text: i18nc("label text for the form for reading direction.", "Reading Direction");
0665         }
0666         QtControls.CheckBox {
0667             width: parent.width;
0668             text: i18nc("label text for right to left checkbox.", "Right to left.");
0669             checked: root.model.acbfData.metaData.bookInfo.rightToLeft;
0670             onCheckStateChanged: root.model.acbfData.metaData.bookInfo.rightToLeft = checked;
0671         }
0672 
0673         Kirigami.Heading {
0674             width: parent.width;
0675             height: paintedHeight + Kirigami.Units.smallSpacing * 2;
0676             text: i18nc("label text for the form for the publishing info list", "Publisher Info");
0677         }
0678         QtControls.Label {
0679             text: i18nc("Label for publisher", "Publisher:");
0680         }
0681         QtControls.TextField {
0682             width : parent.width;
0683             id: publisher;
0684             placeholderText: i18nc("placeholder text for the publisher entry", "Write to add publisher");
0685             text: root.model.acbfData? root.model.acbfData.metaData.publishInfo.publisher: "";
0686             onEditingFinished: {
0687                 if (root.model.acbfData && text !=="") {
0688                     root.model.acbfData.metaData.publishInfo.publisher = text
0689                     root.model.setDirty();
0690                 }
0691             }
0692         }
0693         QtControls.Label {
0694             text: i18nc("Label for publishing date", "Publishing Date:");
0695         }
0696         Item {
0697             width : parent.width;
0698             id: publishingDate;
0699             height: childrenRect.height;
0700             property date publishingDate: root.model.acbfData.metaData.publishInfo.publishDate;
0701             function changePublishDate() {
0702                 root.model.acbfData.metaData.publishInfo.setPublishDateFromInts(pdYear.text, (pdMonth.currentIndex+1), pdDate.value);
0703                 root.model.setDirty();
0704             }
0705             QtControls.TextField {
0706                 id: pdYear
0707                 width: (parent.width-(Kirigami.Units.smallSpacing*2))/3;
0708                 text: parent.publishingDate.getFullYear();
0709                 onEditingFinished: parent.changePublishDate();
0710                 inputMask: "9999"
0711                 inputMethodHints: Qt.ImhFormattedNumbersOnly;
0712             }
0713             QtControls.ComboBox {
0714                 id: pdMonth
0715                 anchors {
0716                     left: pdYear.right;
0717                     margins: Kirigami.Units.smallSpacing;
0718                 }
0719                 model: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
0720                 width: (parent.width-(Kirigami.Units.smallSpacing*2))/3;
0721                 currentIndex: parent.publishingDate.getMonth();
0722                 displayText: Qt.locale().monthName(currentText, Locale.LongFormat);
0723                 onActivated: parent.changePublishDate();
0724                 delegate: QtControls.ItemDelegate {
0725                     text:Qt.locale().monthName(modelData, Locale.LongFormat);
0726                 }
0727             }
0728             QtControls.SpinBox {
0729                 id: pdDate
0730                 anchors {
0731                     left: pdMonth.right;
0732                     margins: Kirigami.Units.smallSpacing;
0733                 }
0734                 width: (parent.width-(Kirigami.Units.smallSpacing*2))/3;
0735                 height: pdMonth.height;
0736                 from: 1;
0737                 to: 31;
0738                 editable: true;
0739                 value: parent.publishingDate.getDate();
0740                 onValueChanged: parent.changePublishDate();
0741             }
0742         }
0743         QtControls.Label {
0744             text: i18nc("Label for city", "City:");
0745         }
0746         QtControls.TextField {
0747             width : parent.width;
0748             id: city;
0749             placeholderText: i18nc("placeholder text for the publishing city entry", "Write to add city");
0750             text: root.model.acbfData? root.model.acbfData.metaData.publishInfo.city: "";
0751             onEditingFinished: {
0752                 if (root.model.acbfData && text !=="") {
0753                     root.model.acbfData.metaData.publishInfo.city = text ;
0754                     root.model.setDirty();
0755                 }
0756             }
0757         }
0758         QtControls.Label {
0759             text: i18nc("Label for ISBN", "ISBN:");
0760         }
0761 
0762         QtControls.TextField {
0763             width : parent.width;
0764             id: isbn;
0765             placeholderText: i18nc("placeholder text for the publishing ISBN entry", "Write to add ISBN");
0766             text: root.model.acbfData? root.model.acbfData.metaData.publishInfo.isbn: "";
0767             onEditingFinished: {
0768                 if (root.model.acbfData && text !=="") {
0769                     root.model.acbfData.metaData.publishInfo.isbn = text
0770                     root.model.setDirty();
0771                 }
0772             }
0773         }
0774         QtControls.Label {
0775             text: i18nc("Label for license", "License:");
0776         }
0777         QtControls.TextField {
0778             width : parent.width;
0779             id: license;
0780             placeholderText: i18nc("placeholder text for the publishing license entry", "Write to add license");
0781             text: root.model.acbfData? root.model.acbfData.metaData.publishInfo.license: "";
0782             onEditingFinished: {
0783                 if (root.model.acbfData && text !=="") {
0784                     root.model.acbfData.metaData.publishInfo.license = text
0785                     root.model.setDirty();
0786                 }
0787             }
0788         }
0789         Kirigami.Heading {
0790             width: parent.width;
0791             height: paintedHeight + Kirigami.Units.smallSpacing * 2;
0792             text: i18nc("label text for the form for the document info list", "Document Authors");
0793         }
0794 
0795         Repeater {
0796             id: docAuthorRepeater;
0797             model: root.model.acbfData ? root.model.acbfData.metaData.documentInfo.authorNames : 0;
0798             delegate: QtControls.Label {
0799                 width: parent.width - removeDocAuthorButton.width - Kirigami.Units.smallSpacing;
0800                 text: modelData.length > 0 ? modelData : i18nc("The text used in place of an author's name if one has not been set", "(unnamed)");
0801                 QtControls.Button {
0802                     id: editDocAuthorButton;
0803                     anchors {
0804                         right: removeDocAuthorButton.left;
0805                         leftMargin: Kirigami.Units.smallSpacing;
0806                     }
0807                     contentItem: Kirigami.Icon {
0808                         source: "document-edit";
0809                     }
0810                     height: parent.height;
0811                     width: height;
0812                     onClicked: {
0813                         docAuthorEditor.index = model.index;
0814                         docAuthorEditor.open();
0815                     }
0816                 }
0817                 QtControls.Button {
0818                     id: removeDocAuthorButton;
0819                     anchors {
0820                         left: parent.right;
0821                         leftMargin: Kirigami.Units.smallSpacing;
0822                     }
0823                     contentItem: Kirigami.Icon {
0824                         source: "list-remove";
0825                     }
0826                     height: parent.height;
0827                     width: height;
0828                     onClicked: {
0829                         // When removing, set the model dirty first, and then remove the entry to avoid reference errors.
0830                         root.model.setDirty();
0831                         root.model.acbfData.metaData.documentInfo.removeAuthor(index);
0832                     }
0833                 }
0834             }
0835         }
0836         Item { width: parent.width; height: Kirigami.Units.smallSpacing; }
0837         QtControls.TextField {
0838             width: parent.width - addDocAuthorButton.width - Kirigami.Units.smallSpacing;
0839             placeholderText: i18nc("placeholder text for the add new author text entry", "Write to add new author (nickname)");
0840             Keys.onReturnPressed: addAuthor();
0841             function addAuthor() {
0842                 if(text !== "") {
0843                     // Just add an author where only the nickname is defined
0844                     root.model.acbfData.metaData.documentInfo.addAuthor("", "", "", "", "", text, [""], [""]);
0845                     root.model.setDirty();
0846                     text = "";
0847                 }
0848             }
0849 
0850             QtControls.Button {
0851                 id: addDocAuthorButton;
0852                 anchors {
0853                     left: parent.right;
0854                     leftMargin: Kirigami.Units.smallSpacing;
0855                 }
0856                 contentItem: Kirigami.Icon {
0857                     source: "list-add";
0858                 }
0859                 height: parent.height;
0860                 width: height;
0861                 onClicked: parent.addAuthor();
0862             }
0863         }
0864 
0865         Kirigami.Heading {
0866             width: parent.width;
0867             height: paintedHeight + Kirigami.Units.smallSpacing * 2;
0868             text: i18nc("label text for the form for the sources list", "Document Sources");
0869         }
0870 
0871         Repeater {
0872             model: root.model.acbfData ? root.model.acbfData.metaData.documentInfo.source : 0;
0873             delegate: Item {
0874                 width: parent.width;
0875                 height: childrenRect.height;
0876                 QtControls.TextField {
0877                     id: sourceText;
0878                     width: parent.width - removeSourceButton.width - Kirigami.Units.smallSpacing;
0879                     text: modelData;
0880                     onEditingFinished: root.model.acbfData.metaData.documentInfo.sources[index] = text;
0881                     QtControls.Button {
0882                         id: removeSourceButton;
0883                         anchors {
0884                             left: parent.right;
0885                             leftMargin: Kirigami.Units.smallSpacing;
0886                         }
0887                         contentItem: Kirigami.Icon {
0888                             source: "list-remove";
0889                         }
0890                         height: parent.height;
0891                         width: height;
0892                         onClicked: {
0893                             root.model.setDirty();
0894                             root.model.acbfData.metaData.documentInfo.removeSource(index);
0895                         }
0896                     }
0897                 }
0898             }
0899         }
0900         Item { width: parent.width; height: Kirigami.Units.smallSpacing; }
0901         QtControls.TextField {
0902             width: parent.width - addSourceButton.width - Kirigami.Units.smallSpacing;
0903             Keys.onReturnPressed: addEntry();
0904             function addEntry() {
0905                 if (text !== "") {
0906                     root.model.acbfData.metaData.documentInfo.source.push(text);
0907                     root.model.setDirty();
0908                     text = "";
0909                 }
0910             }
0911 
0912             QtControls.Button {
0913                 id: addSourceButton;
0914                 anchors {
0915                     left: parent.right;
0916                     leftMargin: Kirigami.Units.smallSpacing;
0917                 }
0918                 contentItem: Kirigami.Icon {
0919                     source: "list-add";
0920                 }
0921                 height: parent.height;
0922                 width: height;
0923                 onClicked: parent.addEntry();
0924             }
0925         }
0926 
0927         Kirigami.Heading {
0928             width: parent.width;
0929             height: paintedHeight + Kirigami.Units.smallSpacing * 2;
0930             text: i18nc("label text for the form for the history list", "Document History");
0931         }
0932 
0933         Repeater {
0934             model: root.model.acbfData ? root.model.acbfData.metaData.documentInfo.history : 0;
0935             delegate: Item {
0936                 width: parent.width;
0937                 height: childrenRect.height;
0938                 QtControls.TextField {
0939                     id: historyText;
0940                     width: parent.width - removeHistoryButton.width - Kirigami.Units.smallSpacing;
0941                     text: modelData;
0942                     onEditingFinished: root.model.acbfData.metaData.documentInfo.history[index] = text;
0943                     QtControls.Button {
0944                         id: removeHistoryButton;
0945                         anchors {
0946                             left: parent.right;
0947                             leftMargin: Kirigami.Units.smallSpacing;
0948                         }
0949                         contentItem: Kirigami.Icon {
0950                             source: "list-remove";
0951                         }
0952                         height: parent.height;
0953                         width: height;
0954                         onClicked: {
0955                             root.model.setDirty();
0956                             root.model.acbfData.metaData.documentInfo.removeHistoryLine(index);
0957                         }
0958                     }
0959                 }
0960             }
0961         }
0962         Item { width: parent.width; height: Kirigami.Units.smallSpacing; }
0963         QtControls.TextField {
0964             width: parent.width - addHistoryButton.width - Kirigami.Units.smallSpacing;
0965             Keys.onReturnPressed: addEntry();
0966             function addEntry() {
0967                 if (text !== "") {
0968                     root.model.acbfData.metaData.documentInfo.history.push(text);
0969                     root.model.setDirty();
0970                     text = "";
0971                 }
0972             }
0973 
0974             QtControls.Button {
0975                 id: addHistoryButton;
0976                 anchors {
0977                     left: parent.right;
0978                     leftMargin: Kirigami.Units.smallSpacing;
0979                 }
0980                 contentItem: Kirigami.Icon {
0981                     source: "list-add";
0982                 }
0983                 height: parent.height;
0984                 width: height;
0985                 onClicked: parent.addEntry();
0986             }
0987         }
0988         Item { width: parent.width; height: Kirigami.Units.smallSpacing; }
0989         Item {
0990             width: parent.width;
0991             height: childrenRect.height;
0992             QtControls.Label {
0993                 id: versionLabel;
0994                 height: versionSpinBox.height;
0995                 text: i18nc("Label for the document version spinbox","Document Version:");
0996             }
0997             QtControls.SpinBox {
0998                 id: versionSpinBox;
0999                 anchors {
1000                     top: versionLabel.top;
1001                     left: versionLabel.right;
1002                     leftMargin: Kirigami.Units.smallSpacing;
1003                 }
1004                 width: parent.width - (Kirigami.Units.smallSpacing*2) - versionLabel.width - addHistoryButton.width;
1005                 from:0;
1006                 to: 100 * 100;
1007                 stepSize: 100;
1008                 editable: true;
1009 
1010                 property int decimals: 2;
1011                 property real realValue: value / 100;
1012 
1013                 validator: DoubleValidator {
1014                         bottom: Math.min(versionSpinBox.from, versionSpinBox.to)
1015                         top:  Math.max(versionSpinBox.from, versionSpinBox.to)
1016                 }
1017 
1018                 textFromValue: function(value, locale) {
1019                         return Number(value / 100).toLocaleString(locale, 'f', decimals)
1020                 }
1021 
1022                 valueFromText: function(text, locale) {
1023                         return Number.fromLocaleString(locale, text) * 100
1024                 }
1025                 value: root.model.acbfData.metaData.documentInfo.version * 100;
1026 
1027                 onFocusChanged: {
1028                     if (root.model.acbfData.metaData.documentInfo.version*100!==value) {
1029                         root.model.acbfData.metaData.documentInfo.version = value/100;
1030                     }
1031                 }
1032             }
1033         }
1034         Kirigami.Heading {
1035             width: parent.width;
1036             height: paintedHeight + Kirigami.Units.smallSpacing * 2;
1037             text: i18nc("label text for the form for the body background color.", "General Page Background Color");
1038         }
1039         Rectangle {
1040             height: addHistoryButton.height;
1041             width: parent.width - height;
1042             radius: 3;
1043             border.color: Kirigami.Theme.disabledTextColor;
1044             border.width: 1;
1045             color: root.model.acbfData.body.bgcolor !== ""? root.model.acbfData.body.bgcolor: "#ffffff";
1046             MouseArea {
1047                 anchors.fill: parent;
1048                 onClicked: bodyBackgroundColorDialog.open();
1049                 hoverEnabled: true;
1050                 onEntered: parent.border.color = Kirigami.Theme.buttonHoverColor;
1051                 onExited: parent.border.color = Kirigami.Theme.disabledTextColor;
1052             }
1053         }
1054 
1055 
1056         AuthorEntryEditor {
1057             id: authorEditor;
1058             bookinfo: root.model.acbfData.metaData.bookInfo;
1059             onSave: {
1060                 root.model.acbfData.metaData.bookInfo.setAuthor(index, activity, language, firstName, middleName, lastName, nickName, homePage, email);
1061                 root.model.setDirty();
1062             }
1063         }
1064         AuthorEntryEditor {
1065             id: docAuthorEditor;
1066             bookinfo: root.model.acbfData.metaData.documentInfo;
1067             onSave: {
1068                 root.model.acbfData.metaData.documentInfo.setAuthor(index, activity, language, firstName, middleName, lastName, nickName, homePage, email);
1069                 root.model.setDirty();
1070             }
1071         }
1072         ColorDialog {
1073             id: bodyBackgroundColorDialog
1074             title: i18nc("@title color choosing dialog","Choose the general background color for this comic");
1075             color: root.model.acbfData.body.bgcolor !==""? root.model.acbfData.body.bgcolor: "#ffffff";
1076             onAccepted: {
1077                 root.model.acbfData.body.bgcolor = color;
1078             }
1079         }
1080     }
1081 }