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

0001 /*
0002  * Copyright (C) 2020 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.Layouts 1.4
0024 import QtQuick.Controls 2.12 as QtControls
0025 
0026 import org.kde.kirigami 2.13 as Kirigami
0027 
0028 import org.kde.peruse 0.1 as Peruse
0029 /**
0030  * @brief the page which shows the references contained within the book
0031  */
0032 Kirigami.ScrollablePage {
0033     id: root;
0034     property string categoryName: "bookReferences";
0035     title: i18nc("title text for the references page", "References");
0036     property QtObject model;
0037 
0038     actions {
0039         main: newReferenceAction;
0040     }
0041     Kirigami.Action {
0042         id: newReferenceAction;
0043         text: i18nc("Action which when triggered adds a new reference to the book and opens the reference editor", "New Reference");
0044         icon.name: "list-add";
0045         onTriggered: {
0046             var newReference = model.acbfData.references.addReference(
0047                 i18nc("The default ID for new references", "Unnamed Reference"),
0048                 i18nc("The default text for new references", "<p>Enter the body of your reference document here.</p>\n<p>This is what links look like: <a href=\"destination\">Some Link</a></p>"));
0049             pageStack.push(referenceEditor, { reference: newReference, model: root.model });
0050         }
0051     }
0052     Component {
0053         id: referenceEditor;
0054         BookReferenceEditor { }
0055     }
0056 
0057     Kirigami.CardsListView {
0058         id: referencesList;
0059         Layout.fillWidth: true;
0060         model: Peruse.FilterProxy {
0061             filterRole: 259; // TypeRole
0062             filterInt: 0; // ReferenceType
0063             sortRole: 258; // OriginalIndexRole
0064             sourceModel: Peruse.IdentifiedObjectModel { document: root.model.acbfData; }
0065         }
0066         header: ColumnLayout {
0067             width: referencesList.width - Kirigami.Units.largeSpacing * 4;
0068             Item { height: Kirigami.Units.largeSpacing; Layout.fillWidth: true; }
0069             RowLayout {
0070                 Layout.fillWidth: true;
0071                 Item { height: Kirigami.Units.gridUnit; Layout.fillWidth: true; }
0072                 Kirigami.AbstractCard {
0073                     header: Kirigami.Heading {
0074                         text: referencesList.count === 0
0075                             ? i18nc("title text for a card which informs the user there are no references, and what references are", "No References")
0076                             : i18nc("title text for a card which informs what references are", "References");
0077                         Layout.fillWidth: true;
0078                         elide: Text.ElideRight;
0079                     }
0080                     contentItem: QtControls.Label {
0081                         Layout.fillWidth: true;
0082                         wrapMode: Text.Wrap;
0083                         text: referencesList.count === 0
0084                             ? i18nc("Help text for the references page, when there are no references", "There is no reference information in your book yet. You can create a new reference piece by clicking on the New Reference control. References are collections of paragraphs of text, which you can fill with simple formatting (strong, emphasis, and other simple layouting like that), as well as links to both internal things (other references or one of the pieces of binary data), or to an external resource, such as a website.")
0085                             : i18nc("Help text for the references page, when there are already references defined", "Create a new reference piece by clicking on the New Reference control. References are collections of paragraphs of text, which you can fill with simple formatting (strong, emphasis, and other simple layouting like that), as well as links to both internal things (other references or one of the pieces of binary data), or to an external resource, such as a website.");
0086                     }
0087                 }
0088                 Item { height: Kirigami.Units.gridUnit; Layout.fillWidth: true; }
0089             }
0090         }
0091         delegate: Kirigami.AbstractCard {
0092             id: referenceDelegate;
0093             header: RowLayout {
0094                 Layout.fillWidth: true;
0095                 Kirigami.Heading {
0096                     Layout.fillWidth: true;
0097                     text: model.id;
0098                     elide: Text.ElideRight;
0099                 }
0100                 QtControls.ToolButton {
0101                     text: i18nc("swap the position of this page with the previous one", "Move Up");
0102                     icon.name: "go-up"
0103                     enabled: model.originalIndex > 0;
0104                     visible: enabled;
0105                     onClicked: { root.model.acbfData.references.swapReferencesByIndex(model.originalIndex, model.originalIndex - 1); }
0106                 }
0107                 QtControls.ToolButton {
0108                     text: i18nc("swap the position of this page with the next one", "Move Down");
0109                     icon.name: "go-down"
0110                     enabled: model.originalIndex < referencesList.count - 1;
0111                     visible: enabled;
0112                     onClicked: { root.model.acbfData.references.swapReferencesByIndex(model.originalIndex, model.originalIndex + 1); }
0113                 }
0114                 Item {
0115                     height: Kirigami.Units.largeSpacing
0116                     width: Kirigami.Units.largeSpacing
0117                 }
0118                 QtControls.ToolButton {
0119                     icon.name: "document-edit";
0120                     onClicked: pageStack.push(referenceEditor, { reference: model.object, model: root.model });
0121                 }
0122             }
0123             contentItem: QtControls.Label {
0124                 Layout.fillWidth: true;
0125                 text: model.object.paragraphs.length > 0 ? model.object.paragraphs.join("\n") : "";
0126             }
0127         }
0128     }
0129 }