Changeset View
Changeset View
Standalone View
Standalone View
src/creator/qml/BookMetainfoPage.qml
Context not available. | |||||
44 | id: saveAndCloseAction; | 44 | id: saveAndCloseAction; | ||
---|---|---|---|---|---|
45 | text: i18nc("Saves the remaining unsaved edited fields and closes the metainfo editor", "Save and Close Editor"); | 45 | text: i18nc("Saves the remaining unsaved edited fields and closes the metainfo editor", "Save and Close Editor"); | ||
46 | iconName: "dialog-ok"; | 46 | iconName: "dialog-ok"; | ||
47 | shortcut: "Esc"; | ||||
47 | onTriggered: { | 48 | onTriggered: { | ||
49 | // Save the default title/annotation/keywords. | ||||
50 | root.model.acbfData.metaData.bookInfo.setTitle(defaultTitle.text, ""); | ||||
51 | root.model.acbfData.metaData.bookInfo.setAnnotation(defaultAnnotation.text.split("\n\n"), ""); | ||||
52 | var keywords = defaultKeywords.text.split(",") | ||||
53 | for (var i in keywords) { | ||||
54 | keywords[i] = keywords[i].trim(); | ||||
55 | } | ||||
56 | root.model.acbfData.metaData.bookInfo.setKeywords(keywords, ""); | ||||
57 | // Ensure there's a default language entry. | ||||
58 | if (root.model.acbfData.metaData.bookInfo.languageEntryList.indexOf("") === -1) { | ||||
59 | root.model.acbfData.metaData.bookInfo.addLanguage(""); | ||||
60 | } | ||||
61 | | ||||
48 | root.model.setDirty(); | 62 | root.model.setDirty(); | ||
49 | pageStack.pop(); | 63 | pageStack.pop(); | ||
50 | } | 64 | } | ||
Context not available. | |||||
55 | width: root.width - (root.leftPadding + root.rightPadding); | 69 | width: root.width - (root.leftPadding + root.rightPadding); | ||
56 | height: childrenRect.height; | 70 | height: childrenRect.height; | ||
57 | spacing: Kirigami.Units.smallSpacing; | 71 | spacing: Kirigami.Units.smallSpacing; | ||
72 | | ||||
58 | Kirigami.Heading { | 73 | Kirigami.Heading { | ||
59 | width: parent.width; | 74 | width: parent.width; | ||
60 | height: paintedHeight + Kirigami.Units.smallSpacing * 2; | 75 | height: paintedHeight + Kirigami.Units.smallSpacing * 2; | ||
61 | text: i18nc("label text for the edit field for the book title", "Titles"); | 76 | text: i18nc("label text for the edit field for the book title", "Title"); | ||
62 | } | 77 | } | ||
63 | Repeater { | 78 | | ||
64 | model: root.model.acbfData ? root.model.acbfData.metaData.bookInfo.titleLanguages : 0; | 79 | Item { width: parent.width; height: Kirigami.Units.smallSpacing; } | ||
65 | delegate: LanguageTextEntryEditor { | 80 | QtControls.TextField { | ||
66 | width: contentColumn.width; | 81 | id: defaultTitle; | ||
67 | title: modelData === "" ? i18nc("label text for the the book title with no language (default)", "Default title") : modelData; | 82 | width: parent.width; | ||
68 | text: root.model.acbfData.metaData.bookInfo.title(modelData); | 83 | placeholderText: i18nc("placeholder text for default title text-input", "Write to add default title"); | ||
69 | onSaveRequested: { | 84 | text:root.model.acbfData ? root.model.acbfData.metaData.bookInfo.title("") : ""; | ||
70 | root.model.acbfData.metaData.bookInfo.setTitle(text, modelData); | | |||
71 | root.model.setDirty(); | | |||
72 | } | | |||
73 | onRemoveRequested: { | | |||
74 | root.model.acbfData.metaData.bookInfo.setTitle("", modelData); | | |||
75 | root.model.setDirty(); | | |||
76 | } | | |||
77 | removePossible: title === modelData; | | |||
78 | } | | |||
79 | } | 85 | } | ||
80 | QtControls.Button { | 86 | | ||
81 | anchors.right: parent.right; | 87 | Kirigami.Heading { | ||
82 | width: parent.with; | 88 | width: parent.width; | ||
83 | contentItem: Kirigami.Icon { | 89 | height: paintedHeight + Kirigami.Units.smallSpacing * 2; | ||
84 | source: "list-add"; | 90 | text: i18nc("label text for the edit field for the default annotation", "Annotation"); | ||
85 | } | 91 | } | ||
86 | text: i18nc("Text on the button for adding new titles", "Add a title in another language"); | 92 | Item { width: parent.width; height: Kirigami.Units.smallSpacing; } | ||
93 | QtControls.TextArea { | ||||
94 | id: defaultAnnotation; | ||||
95 | width: parent.width; | ||||
96 | placeholderText: i18nc("placeholder text for default annotiation text-area", "Write to add default annotation"); | ||||
97 | text:root.model.acbfData ? root.model.acbfData.metaData.bookInfo.annotation("").join("\n\n") : ""; | ||||
98 | } | ||||
99 | Kirigami.Heading { | ||||
100 | width: parent.width; | ||||
101 | height: paintedHeight + Kirigami.Units.smallSpacing * 2; | ||||
102 | text: i18nc("label text for the edit field for the keyword list", "Keywords"); | ||||
103 | } | ||||
104 | Item { width: parent.width; height: Kirigami.Units.smallSpacing; } | ||||
105 | QtControls.TextField { | ||||
106 | id: defaultKeywords; | ||||
107 | width: parent.width; | ||||
108 | placeholderText: i18nc("placeholder text for the add new keyword text entry", "Write a comma seperated list of keywords."); | ||||
109 | text:root.model.acbfData ? root.model.acbfData.metaData.bookInfo.keywords("").join(", ") : ""; | ||||
87 | } | 110 | } | ||
88 | 111 | | |||
89 | Kirigami.Heading { | 112 | Kirigami.Heading { | ||
Context not available. | |||||
125 | height: parent.height; | 148 | height: parent.height; | ||
126 | width: height; | 149 | width: height; | ||
127 | onClicked: { | 150 | onClicked: { | ||
128 | root.model.acbfData.metaData.bookInfo.removeAuthor(modelData); | 151 | // When removing, set the model dirty first, and then remove the entry to avoid reference errors. | ||
129 | root.model.setDirty(); | 152 | root.model.setDirty(); | ||
153 | root.model.acbfData.metaData.bookInfo.removeAuthor(index); | ||||
130 | } | 154 | } | ||
131 | } | 155 | } | ||
132 | } | 156 | } | ||
Context not available. | |||||
135 | QtControls.TextField { | 159 | QtControls.TextField { | ||
136 | width: parent.width - addAuthorButton.width - Kirigami.Units.smallSpacing; | 160 | width: parent.width - addAuthorButton.width - Kirigami.Units.smallSpacing; | ||
137 | placeholderText: i18nc("placeholder text for the add new author text entry", "Write to add new author (nickname)"); | 161 | placeholderText: i18nc("placeholder text for the add new author text entry", "Write to add new author (nickname)"); | ||
162 | Keys.onReturnPressed: addAuthor(); | ||||
163 | function addAuthor() { | ||||
164 | if(text !== "") { | ||||
165 | // Just add an author where only the nickname is defined | ||||
166 | root.model.acbfData.metaData.bookInfo.addAuthor("", "", "", "", "", text, [""], [""]); | ||||
167 | root.model.setDirty(); | ||||
168 | text = ""; | ||||
169 | } | ||||
170 | } | ||||
171 | | ||||
138 | QtControls.Button { | 172 | QtControls.Button { | ||
139 | id: addAuthorButton; | 173 | id: addAuthorButton; | ||
140 | anchors { | 174 | anchors { | ||
Context not available. | |||||
146 | } | 180 | } | ||
147 | height: parent.height; | 181 | height: parent.height; | ||
148 | width: height; | 182 | width: height; | ||
149 | onClicked: { | 183 | onClicked: parent.addAuthor(); | ||
150 | if(parent.text !== "") { | | |||
151 | // Just add an author where only the nickname is defined | | |||
152 | root.model.acbfData.metaData.bookInfo.addAuthor("", "", "", "", "", parent.text, [""], [""]); | | |||
153 | root.model.setDirty(); | | |||
154 | parent.text = ""; | | |||
155 | } | | |||
156 | } | | |||
157 | } | 184 | } | ||
158 | } | 185 | } | ||
159 | 186 | | |||
Context not available. | |||||
167 | delegate: Item { | 194 | delegate: Item { | ||
168 | width: parent.width; | 195 | width: parent.width; | ||
169 | height: childrenRect.height; | 196 | height: childrenRect.height; | ||
170 | QtControls.TextField { | 197 | QtControls.Label { | ||
171 | id: genreText; | 198 | id: genreText; | ||
172 | width: parent.width - removeGenreButton.width - Kirigami.Units.smallSpacing; | 199 | width: parent.width - removeGenreButton.width - Kirigami.Units.smallSpacing; | ||
173 | text: modelData; | 200 | text: modelData; | ||
Context not available. | |||||
183 | height: parent.height; | 210 | height: parent.height; | ||
184 | width: height; | 211 | width: height; | ||
185 | onClicked: { | 212 | onClicked: { | ||
186 | root.model.acbfData.metaData.bookInfo.removeGenre(modelData); | | |||
187 | root.model.setDirty(); | 213 | root.model.setDirty(); | ||
214 | root.model.acbfData.metaData.bookInfo.removeGenre(modelData); | ||||
188 | } | 215 | } | ||
189 | } | 216 | } | ||
190 | } | 217 | } | ||
Context not available. | |||||
208 | } | 235 | } | ||
209 | } | 236 | } | ||
210 | Item { width: parent.width; height: Kirigami.Units.smallSpacing; } | 237 | Item { width: parent.width; height: Kirigami.Units.smallSpacing; } | ||
211 | QtControls.TextField { | 238 | QtControls.ComboBox { | ||
212 | width: parent.width - addCharacterButton.width - Kirigami.Units.smallSpacing; | 239 | width: parent.width - addGenreButton.width - Kirigami.Units.smallSpacing; | ||
213 | placeholderText: i18nc("placeholder text for the add new genre text entry", "Write to add new genre"); | 240 | model: root.model.acbfData ? root.model.acbfData.metaData.bookInfo.availableGenres().filter(checkGenreInUse) : 0; | ||
241 | Keys.onReturnPressed: addGenre(); | ||||
242 | function addGenre() { | ||||
243 | root.model.acbfData.metaData.bookInfo.setGenre(currentText); | ||||
244 | root.model.setDirty(); | ||||
245 | currentIndex=0; | ||||
246 | } | ||||
247 | function checkGenreInUse (genre) { | ||||
248 | return root.model.acbfData.metaData.bookInfo.genres.indexOf(genre) === -1; | ||||
249 | } | ||||
250 | | ||||
214 | QtControls.Button { | 251 | QtControls.Button { | ||
215 | id: addGenreButton; | 252 | id: addGenreButton; | ||
216 | anchors { | 253 | anchors { | ||
Context not available. | |||||
222 | } | 259 | } | ||
223 | height: parent.height; | 260 | height: parent.height; | ||
224 | width: height; | 261 | width: height; | ||
225 | onClicked: { | 262 | onClicked: parent.addGenre(); | ||
226 | if(parent.text !== "") { | | |||
227 | root.model.acbfData.metaData.bookInfo.setGenre(parent.text); | | |||
228 | root.model.setDirty(); | | |||
229 | parent.text = ""; | | |||
230 | } | | |||
231 | } | | |||
232 | } | 263 | } | ||
233 | } | 264 | } | ||
234 | 265 | | |||
Context not available. | |||||
242 | delegate: QtControls.TextField { | 273 | delegate: QtControls.TextField { | ||
243 | width: parent.width - removeCharacterButton.width - Kirigami.Units.smallSpacing; | 274 | width: parent.width - removeCharacterButton.width - Kirigami.Units.smallSpacing; | ||
244 | text: modelData; | 275 | text: modelData; | ||
276 | onEditingFinished: root.model.acbfData.metaData.bookInfo.characters[index] = text; | ||||
245 | QtControls.Button { | 277 | QtControls.Button { | ||
246 | id: removeCharacterButton; | 278 | id: removeCharacterButton; | ||
247 | anchors { | 279 | anchors { | ||
Context not available. | |||||
254 | height: parent.height; | 286 | height: parent.height; | ||
255 | width: height; | 287 | width: height; | ||
256 | onClicked: { | 288 | onClicked: { | ||
257 | root.model.acbfData.metaData.bookInfo.removeCharacter(modelData); | | |||
258 | root.model.setDirty(); | 289 | root.model.setDirty(); | ||
290 | root.model.acbfData.metaData.bookInfo.removeCharacter(modelData); | ||||
259 | } | 291 | } | ||
260 | } | 292 | } | ||
261 | } | 293 | } | ||
Context not available. | |||||
264 | QtControls.TextField { | 296 | QtControls.TextField { | ||
265 | width: parent.width - addCharacterButton.width - Kirigami.Units.smallSpacing; | 297 | width: parent.width - addCharacterButton.width - Kirigami.Units.smallSpacing; | ||
266 | placeholderText: i18nc("placeholder text for the add new character text entry", "Write to add new character"); | 298 | placeholderText: i18nc("placeholder text for the add new character text entry", "Write to add new character"); | ||
299 | Keys.onReturnPressed: addCharacter(); | ||||
300 | function addCharacter() { | ||||
301 | if(text !== "") { | ||||
302 | root.model.acbfData.metaData.bookInfo.addCharacter(text); | ||||
303 | root.model.setDirty(); | ||||
304 | text = ""; | ||||
305 | } | ||||
306 | } | ||||
307 | | ||||
267 | QtControls.Button { | 308 | QtControls.Button { | ||
268 | id: addCharacterButton; | 309 | id: addCharacterButton; | ||
269 | anchors { | 310 | anchors { | ||
Context not available. | |||||
275 | } | 316 | } | ||
276 | height: parent.height; | 317 | height: parent.height; | ||
277 | width: height; | 318 | width: height; | ||
278 | onClicked: { | 319 | onClicked: parent.addCharacter(); | ||
279 | if(parent.text !== "") { | 320 | } | ||
280 | root.model.acbfData.metaData.bookInfo.addCharacter(parent.text); | 321 | } | ||
322 | | ||||
323 | Kirigami.Heading { | ||||
324 | width: parent.width; | ||||
325 | height: paintedHeight + Kirigami.Units.smallSpacing * 2; | ||||
326 | text: i18nc("label text for the edit field for the sequence list", "Sequence"); | ||||
327 | } | ||||
328 | Repeater { | ||||
329 | id: sequenceListRepeater; | ||||
330 | model: root.model.acbfData ? root.model.acbfData.metaData.bookInfo.sequenceCount : 0; | ||||
331 | delegate: Item { | ||||
332 | width: parent.width; | ||||
333 | height: childrenRect.height; | ||||
334 | | ||||
335 | function updateSeries() { | ||||
336 | root.model.acbfData.metaData.bookInfo.sequence(modelData).title = seriesTextField.text; | ||||
337 | if (numberField.value !== root.model.acbfData.metaData.bookInfo.sequence(modelData).number) { | ||||
338 | root.model.acbfData.metaData.bookInfo.sequence(modelData).number = numberField.value; | ||||
339 | } | ||||
340 | if (volumeField.value !== root.model.acbfData.metaData.bookInfo.sequence(modelData).volume) { | ||||
341 | root.model.acbfData.metaData.bookInfo.sequence(modelData).volume = volumeField.value; | ||||
342 | } | ||||
343 | root.model.setDirty(); | ||||
344 | } | ||||
345 | | ||||
346 | QtControls.TextField { | ||||
347 | id: seriesTextField; | ||||
348 | width: parent.width - removeSequenceButton.width - Kirigami.Units.smallSpacing; | ||||
349 | text: root.model.acbfData.metaData.bookInfo.sequence(modelData).title; | ||||
350 | onEditingFinished: parent.updateSeries(); | ||||
351 | } | ||||
352 | QtControls.SpinBox { | ||||
353 | anchors { | ||||
354 | top: seriesTextField.bottom; | ||||
355 | topMargin: Kirigami.Units.smallSpacing; | ||||
356 | } | ||||
357 | value : root.model.acbfData.metaData.bookInfo.sequence(modelData).number; | ||||
358 | width : (seriesTextField.width+Kirigami.Units.smallSpacing)/2; | ||||
359 | id: numberField; | ||||
360 | onValueChanged: parent.updateSeries(); | ||||
361 | } | ||||
362 | QtControls.SpinBox { | ||||
363 | anchors { | ||||
364 | left: numberField.right; | ||||
365 | leftMargin: Kirigami.Units.smallSpacing; | ||||
366 | top: seriesTextField.bottom; | ||||
367 | topMargin: Kirigami.Units.smallSpacing; | ||||
368 | } | ||||
369 | value : root.model.acbfData.metaData.bookInfo.sequence(modelData).volume; | ||||
370 | width : (seriesTextField.width/2)-(Kirigami.Units.smallSpacing*1.5); | ||||
371 | id: volumeField; | ||||
372 | onValueChanged: parent.updateSeries(); | ||||
373 | } | ||||
374 | QtControls.Button { | ||||
375 | id: removeSequenceButton; | ||||
376 | anchors { | ||||
377 | left: seriesTextField.right; | ||||
378 | leftMargin: Kirigami.Units.smallSpacing; | ||||
379 | } | ||||
380 | contentItem: Kirigami.Icon { | ||||
381 | source: "list-remove"; | ||||
382 | } | ||||
383 | height: seriesTextField.height; | ||||
384 | width: height; | ||||
385 | onClicked: { | ||||
281 | root.model.setDirty(); | 386 | root.model.setDirty(); | ||
282 | parent.text = ""; | 387 | root.model.acbfData.metaData.bookInfo.removeSequence(index); | ||
283 | } | 388 | } | ||
284 | } | 389 | } | ||
285 | } | 390 | } | ||
286 | } | 391 | } | ||
392 | Item { width: parent.width; height: Kirigami.Units.smallSpacing; } | ||||
393 | QtControls.TextField { | ||||
394 | width: parent.width - addSequenceButton.width - Kirigami.Units.smallSpacing; | ||||
395 | placeholderText: i18nc("placeholder text for the add new series text entry", "Write to add new series"); | ||||
396 | Keys.onReturnPressed:addSequence(); | ||||
397 | function addSequence() { | ||||
398 | if(text !== "") { | ||||
399 | root.model.acbfData.metaData.bookInfo.addSequence(0, text); | ||||
400 | root.model.setDirty(); | ||||
401 | text = ""; | ||||
402 | } | ||||
403 | } | ||||
404 | | ||||
405 | QtControls.Button { | ||||
406 | id: addSequenceButton; | ||||
407 | anchors { | ||||
408 | left: parent.right; | ||||
409 | leftMargin: Kirigami.Units.smallSpacing; | ||||
410 | } | ||||
411 | contentItem: Kirigami.Icon { | ||||
412 | source: "list-add"; | ||||
413 | } | ||||
414 | height: parent.height; | ||||
415 | width: height; | ||||
416 | onClicked: parent.addSequence(); | ||||
417 | } | ||||
418 | } | ||||
419 | | ||||
420 | Kirigami.Heading { | ||||
421 | width: parent.width; | ||||
422 | height: paintedHeight + Kirigami.Units.smallSpacing * 2; | ||||
423 | text: i18nc("label text for the edit field for the database reference list", "Database References"); | ||||
424 | } | ||||
425 | Repeater { | ||||
426 | model: root.model.acbfData ? root.model.acbfData.metaData.bookInfo.databaseRefCount : 0; | ||||
427 | delegate: Item { | ||||
428 | width: parent.width; | ||||
429 | height: childrenRect.height; | ||||
430 | | ||||
431 | function updateDatabaseRef() { | ||||
432 | root.model.acbfData.metaData.bookInfo.databaseRef(modelData).reference = referenceTextField.text | ||||
433 | root.model.acbfData.metaData.bookInfo.databaseRef(modelData).dbname = databaseNameField.text | ||||
434 | root.model.acbfData.metaData.bookInfo.databaseRef(modelData).type = referenceTypeField.text | ||||
435 | root.model.setDirty(); | ||||
436 | } | ||||
437 | | ||||
438 | QtControls.TextField { | ||||
439 | id: referenceTextField; | ||||
440 | width: parent.width - removeReferenceButton.width - Kirigami.Units.smallSpacing; | ||||
441 | text: root.model.acbfData.metaData.bookInfo.databaseRef(modelData).reference; | ||||
442 | onEditingFinished: parent.updateDatabaseRef(); | ||||
443 | } | ||||
444 | QtControls.TextField { | ||||
445 | anchors { | ||||
446 | top: referenceTextField.bottom; | ||||
447 | topMargin: Kirigami.Units.smallSpacing; | ||||
448 | } | ||||
449 | width : (referenceTextField.width+Kirigami.Units.smallSpacing)/2; | ||||
450 | id: databaseNameField; | ||||
451 | text: root.model.acbfData.metaData.bookInfo.databaseRef(modelData).dbname; | ||||
452 | onEditingFinished: parent.updateDatabaseRef(); | ||||
453 | } | ||||
454 | QtControls.TextField { | ||||
455 | anchors { | ||||
456 | left: databaseNameField.right; | ||||
457 | leftMargin: Kirigami.Units.smallSpacing; | ||||
458 | top: referenceTextField.bottom; | ||||
459 | topMargin: Kirigami.Units.smallSpacing; | ||||
460 | } | ||||
461 | width : (referenceTextField.width/2)-(Kirigami.Units.smallSpacing*1.5); | ||||
462 | id: referenceTypeField; | ||||
463 | text: root.model.acbfData.metaData.bookInfo.databaseRef(modelData).type; | ||||
464 | placeholderText: i18nc("placeholder text for the add reference type text entry", "Write to add reference type"); | ||||
465 | onEditingFinished: parent.updateDatabaseRef(); | ||||
466 | } | ||||
467 | QtControls.Button { | ||||
468 | id: removeReferenceButton; | ||||
469 | anchors { | ||||
470 | left: referenceTextField.right; | ||||
471 | leftMargin: Kirigami.Units.smallSpacing; | ||||
472 | } | ||||
473 | contentItem: Kirigami.Icon { | ||||
474 | source: "list-remove"; | ||||
475 | } | ||||
476 | height: referenceTextField.height; | ||||
477 | width: height; | ||||
478 | onClicked: { | ||||
479 | root.model.setDirty(); | ||||
480 | root.model.acbfData.metaData.bookInfo.removeDatabaseRef(index); | ||||
481 | } | ||||
482 | } | ||||
483 | } | ||||
484 | } | ||||
485 | Item { width: parent.width; height: Kirigami.Units.smallSpacing; } | ||||
486 | Item { | ||||
487 | width: parent.width; | ||||
488 | height: childrenRect.height; | ||||
489 | function addReference() { | ||||
490 | if(addReferenceField.text !== "" && addDatabaseNameField.text !== "") { | ||||
491 | root.model.acbfData.metaData.bookInfo.addDatabaseRef(addReferenceField.text, addDatabaseNameField.text); | ||||
492 | root.model.setDirty(); | ||||
493 | addReferenceField.text = ""; | ||||
494 | addDatabaseNameField.text = ""; | ||||
495 | } | ||||
496 | } | ||||
497 | | ||||
498 | QtControls.TextField { | ||||
499 | id: addReferenceField | ||||
500 | width: parent.width - addReferenceButton.width - Kirigami.Units.smallSpacing; | ||||
501 | placeholderText: i18nc("placeholder text for the add new reference text entry", "Write to add new reference"); | ||||
502 | Keys.onReturnPressed: parent.addReference(); | ||||
503 | } | ||||
504 | QtControls.TextField { | ||||
505 | id: addDatabaseNameField | ||||
506 | anchors { | ||||
507 | top: addReferenceField.bottom; | ||||
508 | topMargin: Kirigami.Units.smallSpacing; | ||||
509 | } | ||||
510 | width: parent.width - addReferenceButton.width - Kirigami.Units.smallSpacing; | ||||
511 | placeholderText: i18nc("placeholder text for the add databasename text entry", "Write to add database name for new reference."); | ||||
512 | Keys.onReturnPressed: parent.addReference(); | ||||
513 | } | ||||
514 | QtControls.Button { | ||||
515 | id: addReferenceButton; | ||||
516 | anchors { | ||||
517 | left: addReferenceField.right; | ||||
518 | leftMargin: Kirigami.Units.smallSpacing; | ||||
519 | } | ||||
520 | contentItem: Kirigami.Icon { | ||||
521 | source: "list-add"; | ||||
522 | } | ||||
523 | height: addReferenceField.height; | ||||
524 | width: height; | ||||
525 | onClicked: parent.addReference(); | ||||
526 | } | ||||
527 | } | ||||
528 | | ||||
529 | Kirigami.Heading { | ||||
530 | width: parent.width; | ||||
531 | height: paintedHeight + Kirigami.Units.smallSpacing * 2; | ||||
532 | text: i18nc("label text for the edit field for the content rating list", "Content Ratings"); | ||||
533 | } | ||||
534 | Repeater { | ||||
535 | model: root.model.acbfData ? root.model.acbfData.metaData.bookInfo.contentRatingCount : 0; | ||||
536 | delegate: Item { | ||||
537 | width: parent.width; | ||||
538 | height: childrenRect.height; | ||||
539 | | ||||
540 | function updateRating() { | ||||
541 | root.model.acbfData.metaData.bookInfo.contentRating(modelData).rating = ratingNameField.text | ||||
542 | root.model.acbfData.metaData.bookInfo.contentRating(modelData).type = systemNameField.text | ||||
543 | root.model.setDirty(); | ||||
544 | } | ||||
545 | | ||||
546 | QtControls.TextField { | ||||
547 | width : (parent.width-removeRatingButton.width+Kirigami.Units.smallSpacing)/2; | ||||
548 | id: ratingNameField; | ||||
549 | text: root.model.acbfData.metaData.bookInfo.contentRating(modelData).rating; | ||||
550 | onEditingFinished: parent.updateRating(); | ||||
551 | } | ||||
552 | QtControls.TextField { | ||||
553 | anchors { | ||||
554 | left: ratingNameField.right; | ||||
555 | leftMargin: Kirigami.Units.smallSpacing; | ||||
556 | } | ||||
557 | width : ((parent.width-removeRatingButton.width)/2)-(Kirigami.Units.smallSpacing*1.5); | ||||
558 | id: systemNameField; | ||||
559 | text: root.model.acbfData.metaData.bookInfo.contentRating(modelData).type; | ||||
560 | placeholderText: i18nc("placeholder text for the add reference type text entry", "Write to add reference type"); | ||||
561 | onEditingFinished: parent.updateRating(); | ||||
562 | } | ||||
563 | QtControls.Button { | ||||
564 | id: removeRatingButton; | ||||
565 | anchors { | ||||
566 | left: systemNameField.right; | ||||
567 | leftMargin: Kirigami.Units.smallSpacing; | ||||
568 | } | ||||
569 | contentItem: Kirigami.Icon { | ||||
570 | source: "list-remove"; | ||||
571 | } | ||||
572 | height: systemNameField.height; | ||||
573 | width: height; | ||||
574 | onClicked: { | ||||
575 | root.model.setDirty(); | ||||
576 | root.model.acbfData.metaData.bookInfo.removeContentRating(index); | ||||
577 | } | ||||
578 | } | ||||
579 | } | ||||
580 | } | ||||
581 | Item { | ||||
582 | width: parent.width; | ||||
583 | height: childrenRect.height; | ||||
584 | function addRating() { | ||||
585 | if(addRatingField.text !== "" && addSystemField.text !== "") { | ||||
586 | root.model.acbfData.metaData.bookInfo.addContentRating(addRatingField.text, addSystemField.text); | ||||
587 | root.model.setDirty(); | ||||
588 | addRatingField.text = ""; | ||||
589 | addSystemField.text = ""; | ||||
590 | } | ||||
591 | } | ||||
592 | QtControls.TextField { | ||||
593 | width : (parent.width-addRatingButton.width+Kirigami.Units.smallSpacing)/2; | ||||
594 | id: addRatingField; | ||||
595 | placeholderText: i18nc("placeholder text for the add content rating text entry", "Write to add rating label."); | ||||
596 | onEditingFinished: parent.addRating(); | ||||
597 | } | ||||
598 | QtControls.TextField { | ||||
599 | anchors { | ||||
600 | left: addRatingField.right; | ||||
601 | leftMargin: Kirigami.Units.smallSpacing; | ||||
602 | } | ||||
603 | width : ((parent.width-addRatingButton.width)/2)-(Kirigami.Units.smallSpacing*1.5); | ||||
604 | id: addSystemField; | ||||
605 | placeholderText: i18nc("placeholder text for the add content rating system text entry", "Write to add rating system."); | ||||
606 | onEditingFinished: parent.addRating(); | ||||
607 | } | ||||
608 | QtControls.Button { | ||||
609 | id: addRatingButton; | ||||
610 | anchors { | ||||
611 | left: addSystemField.right; | ||||
612 | leftMargin: Kirigami.Units.smallSpacing; | ||||
613 | } | ||||
614 | contentItem: Kirigami.Icon { | ||||
615 | source: "list-add"; | ||||
616 | } | ||||
617 | height: addSystemField.height; | ||||
618 | width: height; | ||||
619 | onClicked: parent.addRating(); | ||||
620 | } | ||||
621 | } | ||||
622 | Kirigami.Heading { | ||||
623 | width: parent.width; | ||||
624 | height: paintedHeight + Kirigami.Units.smallSpacing * 2; | ||||
625 | text: i18nc("label text for the form for reading direction.", "Reading Direction"); | ||||
626 | } | ||||
627 | QtControls.CheckBox { | ||||
628 | width: parent.width; | ||||
629 | text: i18nc("label text for right to left checkbox.", "Right to left."); | ||||
630 | checked: root.model.acbfData.metaData.bookInfo.rightToLeft; | ||||
631 | onCheckStateChanged: root.model.acbfData.metaData.bookInfo.rightToLeft = checked; | ||||
632 | } | ||||
633 | | ||||
634 | Kirigami.Heading { | ||||
635 | width: parent.width; | ||||
636 | height: paintedHeight + Kirigami.Units.smallSpacing * 2; | ||||
637 | text: i18nc("label text for the form for the publishing info list", "Publisher Info"); | ||||
638 | } | ||||
639 | QtControls.Label { | ||||
640 | text: i18nc("Label for publisher", "Publisher:"); | ||||
641 | } | ||||
642 | QtControls.TextField { | ||||
643 | width : parent.width; | ||||
644 | id: publisher; | ||||
645 | placeholderText: i18nc("placeholder text for the publisher entry", "Write to add publisher"); | ||||
646 | text: root.model.acbfData? root.model.acbfData.metaData.publishInfo.publisher: ""; | ||||
647 | onEditingFinished: { | ||||
648 | if (root.model.acbfData && text !=="") { | ||||
649 | root.model.acbfData.metaData.publishInfo.publisher = text | ||||
650 | root.model.setDirty(); | ||||
651 | } | ||||
652 | } | ||||
653 | } | ||||
654 | QtControls.Label { | ||||
655 | text: i18nc("Label for publishing date", "Publishing Date:"); | ||||
656 | } | ||||
657 | Item { | ||||
658 | width : parent.width; | ||||
659 | id: publishingDate; | ||||
660 | height: childrenRect.height; | ||||
661 | property date publishingDate: root.model.acbfData.metaData.publishInfo.publishDate; | ||||
662 | function changePublishDate() { | ||||
663 | root.model.acbfData.metaData.publishInfo.setPublishDateFromInts(pdYear.text, (pdMonth.currentIndex+1), pdDate.value); | ||||
664 | root.model.setDirty(); | ||||
665 | } | ||||
666 | QtControls.TextField { | ||||
667 | id: pdYear | ||||
668 | width: (parent.width-(Kirigami.Units.smallSpacing*2))/3; | ||||
669 | text: parent.publishingDate.getFullYear(); | ||||
670 | onEditingFinished: parent.changePublishDate(); | ||||
671 | inputMask: "9999" | ||||
672 | inputMethodHints: Qt.ImhFormattedNumbersOnly; | ||||
673 | } | ||||
674 | QtControls.ComboBox { | ||||
675 | id: pdMonth | ||||
676 | anchors { | ||||
677 | left: pdYear.right; | ||||
678 | margins: Kirigami.Units.smallSpacing; | ||||
679 | } | ||||
680 | model: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] | ||||
681 | width: (parent.width-(Kirigami.Units.smallSpacing*2))/3; | ||||
682 | currentIndex: parent.publishingDate.getMonth(); | ||||
683 | displayText: Qt.locale().monthName(currentText, Locale.LongFormat); | ||||
684 | onActivated: parent.changePublishDate(); | ||||
685 | delegate: QtControls.ItemDelegate { | ||||
686 | text:Qt.locale().monthName(modelData, Locale.LongFormat); | ||||
687 | } | ||||
688 | } | ||||
689 | QtControls.SpinBox { | ||||
690 | id: pdDate | ||||
691 | anchors { | ||||
692 | left: pdMonth.right; | ||||
693 | margins: Kirigami.Units.smallSpacing; | ||||
694 | } | ||||
695 | width: (parent.width-(Kirigami.Units.smallSpacing*2))/3; | ||||
696 | height: pdMonth.height; | ||||
697 | from: 1; | ||||
698 | to: 31; | ||||
699 | editable: true; | ||||
700 | value: parent.publishingDate.getDate(); | ||||
701 | onValueChanged: parent.changePublishDate(); | ||||
702 | } | ||||
703 | } | ||||
704 | QtControls.Label { | ||||
705 | text: i18nc("Label for city", "City:"); | ||||
706 | } | ||||
707 | QtControls.TextField { | ||||
708 | width : parent.width; | ||||
709 | id: city; | ||||
710 | placeholderText: i18nc("placeholder text for the publishing city entry", "Write to add city"); | ||||
711 | text: root.model.acbfData? root.model.acbfData.metaData.publishInfo.city: ""; | ||||
712 | onEditingFinished: { | ||||
713 | if (root.model.acbfData && text !=="") { | ||||
714 | root.model.acbfData.metaData.publishInfo.city = text ; | ||||
715 | root.model.setDirty(); | ||||
716 | } | ||||
717 | } | ||||
718 | } | ||||
719 | QtControls.Label { | ||||
720 | text: i18nc("Label for isbn", "ISBN:"); | ||||
721 | } | ||||
722 | | ||||
723 | QtControls.TextField { | ||||
724 | width : parent.width; | ||||
725 | id: isbn; | ||||
726 | placeholderText: i18nc("placeholder text for the publishing isbn entry", "Write to add isbn"); | ||||
727 | text: root.model.acbfData? root.model.acbfData.metaData.publishInfo.isbn: ""; | ||||
728 | onEditingFinished: { | ||||
729 | if (root.model.acbfData && text !=="") { | ||||
730 | root.model.acbfData.metaData.publishInfo.isbn = text | ||||
731 | root.model.setDirty(); | ||||
732 | } | ||||
733 | } | ||||
734 | } | ||||
735 | QtControls.Label { | ||||
736 | text: i18nc("Label for license", "License:"); | ||||
737 | } | ||||
738 | QtControls.TextField { | ||||
739 | width : parent.width; | ||||
740 | id: license; | ||||
741 | placeholderText: i18nc("placeholder text for the publishing license entry", "Write to add license"); | ||||
742 | text: root.model.acbfData? root.model.acbfData.metaData.publishInfo.license: ""; | ||||
743 | onEditingFinished: { | ||||
744 | if (root.model.acbfData && text !=="") { | ||||
745 | root.model.acbfData.metaData.publishInfo.license = text | ||||
746 | root.model.setDirty(); | ||||
747 | } | ||||
748 | } | ||||
749 | } | ||||
750 | Kirigami.Heading { | ||||
751 | width: parent.width; | ||||
752 | height: paintedHeight + Kirigami.Units.smallSpacing * 2; | ||||
753 | text: i18nc("label text for the form for the document info list", "Document Authors"); | ||||
754 | } | ||||
755 | | ||||
756 | Repeater { | ||||
757 | id: docAuthorRepeater; | ||||
758 | model: root.model.acbfData ? root.model.acbfData.metaData.documentInfo.authorNames : 0; | ||||
759 | delegate: QtControls.Label { | ||||
760 | width: parent.width - removeDocAuthorButton.width - Kirigami.Units.smallSpacing; | ||||
761 | text: modelData.length > 0 ? modelData : "(unnamed)"; | ||||
762 | QtControls.Button { | ||||
763 | id: editDocAuthorButton; | ||||
764 | anchors { | ||||
765 | right: removeDocAuthorButton.left; | ||||
766 | leftMargin: Kirigami.Units.smallSpacing; | ||||
767 | } | ||||
768 | contentItem: Kirigami.Icon { | ||||
769 | source: "document-edit"; | ||||
770 | } | ||||
771 | height: parent.height; | ||||
772 | width: height; | ||||
773 | onClicked: { | ||||
774 | docAuthorEditor.index = model.index; | ||||
775 | docAuthorEditor.open(); | ||||
776 | } | ||||
777 | } | ||||
778 | QtControls.Button { | ||||
779 | id: removeDocAuthorButton; | ||||
780 | anchors { | ||||
781 | left: parent.right; | ||||
782 | leftMargin: Kirigami.Units.smallSpacing; | ||||
783 | } | ||||
784 | contentItem: Kirigami.Icon { | ||||
785 | source: "list-remove"; | ||||
786 | } | ||||
787 | height: parent.height; | ||||
788 | width: height; | ||||
789 | onClicked: { | ||||
790 | // When removing, set the model dirty first, and then remove the entry to avoid reference errors. | ||||
791 | root.model.setDirty(); | ||||
792 | root.model.acbfData.metaData.documentInfo.removeAuthor(index); | ||||
793 | } | ||||
794 | } | ||||
795 | } | ||||
796 | } | ||||
797 | Item { width: parent.width; height: Kirigami.Units.smallSpacing; } | ||||
798 | QtControls.TextField { | ||||
799 | width: parent.width - addDocAuthorButton.width - Kirigami.Units.smallSpacing; | ||||
800 | placeholderText: i18nc("placeholder text for the add new author text entry", "Write to add new author (nickname)"); | ||||
801 | Keys.onReturnPressed: addAuthor(); | ||||
802 | function addAuthor() { | ||||
803 | if(text !== "") { | ||||
804 | // Just add an author where only the nickname is defined | ||||
805 | root.model.acbfData.metaData.documentInfo.addAuthor("", "", "", "", "", text, [""], [""]); | ||||
806 | root.model.setDirty(); | ||||
807 | text = ""; | ||||
808 | } | ||||
809 | } | ||||
810 | | ||||
811 | QtControls.Button { | ||||
812 | id: addDocAuthorButton; | ||||
813 | anchors { | ||||
814 | left: parent.right; | ||||
815 | leftMargin: Kirigami.Units.smallSpacing; | ||||
816 | } | ||||
817 | contentItem: Kirigami.Icon { | ||||
818 | source: "list-add"; | ||||
819 | } | ||||
820 | height: parent.height; | ||||
821 | width: height; | ||||
822 | onClicked: parent.addAuthor(); | ||||
823 | } | ||||
824 | } | ||||
825 | | ||||
826 | Kirigami.Heading { | ||||
827 | width: parent.width; | ||||
828 | height: paintedHeight + Kirigami.Units.smallSpacing * 2; | ||||
829 | text: i18nc("label text for the form for the sources list", "Document Sources"); | ||||
830 | } | ||||
831 | | ||||
832 | Repeater { | ||||
833 | model: root.model.acbfData ? root.model.acbfData.metaData.documentInfo.source : 0; | ||||
834 | delegate: Item { | ||||
835 | width: parent.width; | ||||
836 | height: childrenRect.height; | ||||
837 | QtControls.TextField { | ||||
838 | id: sourceText; | ||||
839 | width: parent.width - removeSourceButton.width - Kirigami.Units.smallSpacing; | ||||
840 | text: modelData; | ||||
841 | onEditingFinished: root.model.acbfData.metaData.documentInfo.sources[index] = text; | ||||
842 | QtControls.Button { | ||||
843 | id: removeSourceButton; | ||||
844 | anchors { | ||||
845 | left: parent.right; | ||||
846 | leftMargin: Kirigami.Units.smallSpacing; | ||||
847 | } | ||||
848 | contentItem: Kirigami.Icon { | ||||
849 | source: "list-remove"; | ||||
850 | } | ||||
851 | height: parent.height; | ||||
852 | width: height; | ||||
853 | onClicked: { | ||||
854 | root.model.setDirty(); | ||||
855 | root.model.acbfData.metaData.documentInfo.removeSource(index); | ||||
856 | } | ||||
857 | } | ||||
858 | } | ||||
859 | } | ||||
860 | } | ||||
861 | Item { width: parent.width; height: Kirigami.Units.smallSpacing; } | ||||
862 | QtControls.TextField { | ||||
863 | width: parent.width - addSourceButton.width - Kirigami.Units.smallSpacing; | ||||
864 | Keys.onReturnPressed: addEntry(); | ||||
865 | function addEntry() { | ||||
866 | if (text !== "") { | ||||
867 | root.model.acbfData.metaData.documentInfo.source.push(text); | ||||
868 | root.model.setDirty(); | ||||
869 | text = ""; | ||||
870 | } | ||||
871 | } | ||||
872 | | ||||
873 | QtControls.Button { | ||||
874 | id: addSourceButton; | ||||
875 | anchors { | ||||
876 | left: parent.right; | ||||
877 | leftMargin: Kirigami.Units.smallSpacing; | ||||
878 | } | ||||
879 | contentItem: Kirigami.Icon { | ||||
880 | source: "list-add"; | ||||
881 | } | ||||
882 | height: parent.height; | ||||
883 | width: height; | ||||
884 | onClicked: parent.addEntry(); | ||||
885 | } | ||||
886 | } | ||||
887 | | ||||
888 | Kirigami.Heading { | ||||
889 | width: parent.width; | ||||
890 | height: paintedHeight + Kirigami.Units.smallSpacing * 2; | ||||
891 | text: i18nc("label text for the form for the history list", "Document History"); | ||||
892 | } | ||||
893 | | ||||
894 | Repeater { | ||||
895 | model: root.model.acbfData ? root.model.acbfData.metaData.documentInfo.history : 0; | ||||
896 | delegate: Item { | ||||
897 | width: parent.width; | ||||
898 | height: childrenRect.height; | ||||
899 | QtControls.TextField { | ||||
900 | id: historyText; | ||||
901 | width: parent.width - removeHistoryButton.width - Kirigami.Units.smallSpacing; | ||||
902 | text: modelData; | ||||
903 | onEditingFinished: root.model.acbfData.metaData.documentInfo.history[index] = text; | ||||
904 | QtControls.Button { | ||||
905 | id: removeHistoryButton; | ||||
906 | anchors { | ||||
907 | left: parent.right; | ||||
908 | leftMargin: Kirigami.Units.smallSpacing; | ||||
909 | } | ||||
910 | contentItem: Kirigami.Icon { | ||||
911 | source: "list-remove"; | ||||
912 | } | ||||
913 | height: parent.height; | ||||
914 | width: height; | ||||
915 | onClicked: { | ||||
916 | root.model.setDirty(); | ||||
917 | root.model.acbfData.metaData.documentInfo.removeHistoryLine(index); | ||||
918 | } | ||||
919 | } | ||||
920 | } | ||||
921 | } | ||||
922 | } | ||||
923 | Item { width: parent.width; height: Kirigami.Units.smallSpacing; } | ||||
924 | QtControls.TextField { | ||||
925 | width: parent.width - addHistoryButton.width - Kirigami.Units.smallSpacing; | ||||
926 | Keys.onReturnPressed: addEntry(); | ||||
927 | function addEntry() { | ||||
928 | if (text !== "") { | ||||
929 | root.model.acbfData.metaData.documentInfo.history.push(text); | ||||
930 | root.model.setDirty(); | ||||
931 | text = ""; | ||||
932 | } | ||||
933 | } | ||||
934 | | ||||
935 | QtControls.Button { | ||||
936 | id: addHistoryButton; | ||||
937 | anchors { | ||||
938 | left: parent.right; | ||||
939 | leftMargin: Kirigami.Units.smallSpacing; | ||||
940 | } | ||||
941 | contentItem: Kirigami.Icon { | ||||
942 | source: "list-add"; | ||||
943 | } | ||||
944 | height: parent.height; | ||||
945 | width: height; | ||||
946 | onClicked: parent.addEntry(); | ||||
947 | } | ||||
948 | } | ||||
949 | Item { width: parent.width; height: Kirigami.Units.smallSpacing; } | ||||
950 | Item { | ||||
951 | width: parent.width; | ||||
952 | height: childrenRect.height; | ||||
953 | QtControls.Label { | ||||
954 | id: versionLabel; | ||||
955 | height: versionSpinBox.height; | ||||
956 | text: i18nc("Label for the document version spinbox","Document Version:"); | ||||
957 | } | ||||
958 | QtControls.SpinBox { | ||||
959 | id: versionSpinBox; | ||||
960 | anchors { | ||||
961 | top: versionLabel.top; | ||||
962 | left: versionLabel.right; | ||||
963 | leftMargin: Kirigami.Units.smallSpacing; | ||||
964 | } | ||||
965 | width: parent.width - (Kirigami.Units.smallSpacing*2) - versionLabel.width - addHistoryButton.width; | ||||
966 | from:0; | ||||
967 | to: 100 * 100; | ||||
968 | stepSize: 100; | ||||
969 | editable: true; | ||||
970 | | ||||
971 | property int decimals: 2; | ||||
972 | property real realValue: value / 100; | ||||
973 | | ||||
974 | validator: DoubleValidator { | ||||
975 | bottom: Math.min(spinbox.from, spinbox.to) | ||||
976 | top: Math.max(spinbox.from, spinbox.to) | ||||
977 | } | ||||
978 | | ||||
979 | textFromValue: function(value, locale) { | ||||
980 | return Number(value / 100).toLocaleString(locale, 'f', decimals) | ||||
981 | } | ||||
982 | | ||||
983 | valueFromText: function(text, locale) { | ||||
984 | return Number.fromLocaleString(locale, text) * 100 | ||||
985 | } | ||||
986 | value: root.model.acbfData.metaData.documentInfo.version * 100; | ||||
987 | | ||||
988 | onFocusChanged: { | ||||
989 | if (root.model.acbfData.metaData.documentInfo.version*100!==value) { | ||||
990 | root.model.acbfData.metaData.documentInfo.version = value/100; | ||||
991 | } | ||||
992 | } | ||||
993 | } | ||||
994 | } | ||||
995 | Kirigami.Heading { | ||||
996 | width: parent.width; | ||||
997 | height: paintedHeight + Kirigami.Units.smallSpacing * 2; | ||||
998 | text: i18nc("label text for the form for the body background color.", "General Page Background Color"); | ||||
999 | } | ||||
1000 | QtControls.TextField { | ||||
1001 | text: root.model.acbfData.body.bgcolor; | ||||
1002 | placeholderText: "#ffffff"; | ||||
1003 | onEditingFinished: root.model.acbfData.body.bgcolor = text; | ||||
1004 | } | ||||
1005 | | ||||
287 | 1006 | | |||
288 | AuthorEntryEditor { | 1007 | AuthorEntryEditor { | ||
289 | id: authorEditor; | 1008 | id: authorEditor; | ||
290 | bookinfo: root.model.acbfData.metaData.bookInfo; | 1009 | bookinfo: root.model.acbfData.metaData.bookInfo; | ||
291 | onSave: { | 1010 | onSave: { | ||
292 | root.model.acbfData.metaData.bookInfo.setAuthor(index, activity, language, firstName, middleName, lastName, nickName, [homePage], [email]); | 1011 | root.model.acbfData.metaData.bookInfo.setAuthor(index, activity, language, firstName, middleName, lastName, nickName, homePage, email); | ||
1012 | root.model.setDirty(); | ||||
1013 | } | ||||
1014 | } | ||||
1015 | AuthorEntryEditor { | ||||
1016 | id: docAuthorEditor; | ||||
1017 | bookinfo: root.model.acbfData.metaData.documentInfo; | ||||
1018 | onSave: { | ||||
1019 | root.model.acbfData.metaData.documentInfo.setAuthor(index, activity, language, firstName, middleName, lastName, nickName, homePage, email); | ||||
293 | root.model.setDirty(); | 1020 | root.model.setDirty(); | ||
294 | } | 1021 | } | ||
295 | } | 1022 | } | ||
Context not available. |