2016-12-10 22:39:53 +00:00
|
|
|
import QtQuick 2.7
|
|
|
|
import QtQuick.Controls 2.0
|
|
|
|
import QtQuick.Layouts 1.0
|
|
|
|
|
|
|
|
Item {
|
2017-01-10 20:32:10 +01:00
|
|
|
|
|
|
|
property Item appRoot
|
2016-12-11 16:09:39 +00:00
|
|
|
property alias currentFolderIndex: folderList.currentIndex
|
2016-12-14 21:50:26 +00:00
|
|
|
property alias currentNoteIndex: noteList.currentIndex
|
2016-12-10 22:39:53 +00:00
|
|
|
|
2017-01-12 18:16:39 +01:00
|
|
|
function onShown() {}
|
2017-01-11 11:14:57 +01:00
|
|
|
|
2017-01-12 19:22:05 +01:00
|
|
|
function handleItemListEditingAccepted(list, index, text) {
|
|
|
|
if (list.model.virtualItemShown()) {
|
|
|
|
list.model.hideVirtualItem();
|
|
|
|
list.model.addData(text)
|
|
|
|
list.selectItemById(list.model.lastInsertId());
|
|
|
|
} else {
|
2017-01-13 10:36:27 +01:00
|
|
|
list.model.setTitle(index, text)
|
2017-01-12 19:22:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function handleItemListStoppedEditing(list) {
|
|
|
|
if (folderList.model.virtualItemShown()) {
|
|
|
|
folderList.model.hideVirtualItem();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function handleItemListAction(list, action) {
|
|
|
|
if (action === "delete") {
|
|
|
|
list.model.deleteData(list.index)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-10 22:39:53 +00:00
|
|
|
RowLayout {
|
|
|
|
id: layout
|
|
|
|
anchors.fill: parent
|
|
|
|
spacing: 0
|
|
|
|
|
2017-01-12 18:18:59 +01:00
|
|
|
ItemList {
|
2016-12-11 16:09:39 +00:00
|
|
|
id: folderList
|
|
|
|
model: folderListModel
|
2016-12-10 22:39:53 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.minimumWidth: 50
|
|
|
|
Layout.preferredWidth: 100
|
2016-12-14 21:50:26 +00:00
|
|
|
Layout.maximumWidth: 200
|
2016-12-10 22:39:53 +00:00
|
|
|
Layout.minimumHeight: 150
|
|
|
|
|
|
|
|
onCurrentItemChanged: {
|
2017-01-10 20:32:10 +01:00
|
|
|
appRoot.currentFolderChanged()
|
2016-12-10 22:39:53 +00:00
|
|
|
}
|
2016-12-31 10:48:18 +01:00
|
|
|
|
|
|
|
onEditingAccepted: function(index, text) {
|
2017-01-12 19:22:05 +01:00
|
|
|
handleItemListEditingAccepted(folderList, index, text);
|
2016-12-31 10:48:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
onStoppedEditing: {
|
2017-01-12 19:22:05 +01:00
|
|
|
handleItemListStoppedEditing(folderList);
|
2016-12-31 10:48:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
onDeleteButtonClicked: {
|
2017-01-12 19:22:05 +01:00
|
|
|
handleItemListAction(folderList, "delete");
|
2016-12-31 10:48:18 +01:00
|
|
|
}
|
2016-12-10 22:39:53 +00:00
|
|
|
}
|
|
|
|
|
2017-01-12 18:20:46 +01:00
|
|
|
ItemList {
|
2016-12-11 16:09:39 +00:00
|
|
|
id: noteList
|
2016-12-12 22:33:33 +00:00
|
|
|
model: noteListModel
|
2016-12-10 22:39:53 +00:00
|
|
|
Layout.fillWidth: true
|
2016-12-11 16:09:39 +00:00
|
|
|
Layout.fillHeight: true
|
2016-12-10 22:39:53 +00:00
|
|
|
Layout.minimumWidth: 100
|
2016-12-14 21:50:26 +00:00
|
|
|
Layout.maximumWidth: 200
|
2016-12-10 22:39:53 +00:00
|
|
|
Layout.preferredWidth: 200
|
|
|
|
Layout.preferredHeight: 100
|
2016-12-14 21:50:26 +00:00
|
|
|
|
|
|
|
onCurrentItemChanged: {
|
2017-01-10 20:32:10 +01:00
|
|
|
appRoot.currentNoteChanged()
|
2016-12-14 21:50:26 +00:00
|
|
|
}
|
2017-01-12 19:22:05 +01:00
|
|
|
|
|
|
|
onEditingAccepted: function(index, text) {
|
|
|
|
handleItemListEditingAccepted(noteList, index, text);
|
|
|
|
}
|
|
|
|
|
|
|
|
onStoppedEditing: {
|
|
|
|
handleItemListStoppedEditing(noteList);
|
|
|
|
}
|
|
|
|
|
|
|
|
onDeleteButtonClicked: {
|
|
|
|
handleItemListAction(noteList, "delete");
|
|
|
|
}
|
2016-12-14 21:50:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NoteEditor {
|
|
|
|
id: noteEditor
|
|
|
|
model: noteModel
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.minimumWidth: 100
|
|
|
|
Layout.preferredHeight: 100
|
2016-12-10 22:39:53 +00:00
|
|
|
}
|
|
|
|
|
2016-12-11 16:09:39 +00:00
|
|
|
}
|
2016-12-10 22:39:53 +00:00
|
|
|
|
2016-12-29 20:19:00 +01:00
|
|
|
AddButton {
|
|
|
|
id: addButton
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.bottom: parent.bottom
|
2016-12-31 10:48:18 +01:00
|
|
|
onAddFolderButtonClicked: {
|
|
|
|
folderList.model.showVirtualItem();
|
|
|
|
folderList.startEditing(folderList.model.rowCount() - 1);
|
|
|
|
}
|
2017-01-10 20:32:10 +01:00
|
|
|
onAddNoteButtonClicked: appRoot.addNoteButtonClicked()
|
2016-12-29 20:19:00 +01:00
|
|
|
}
|
|
|
|
|
2017-01-10 19:59:12 +01:00
|
|
|
Button {
|
|
|
|
id: syncButton
|
|
|
|
text: "Sync"
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.top: parent.top
|
2017-01-10 20:32:10 +01:00
|
|
|
onClicked: appRoot.syncButtonClicked()
|
2017-01-10 19:59:12 +01:00
|
|
|
}
|
|
|
|
|
2017-01-11 11:14:57 +01:00
|
|
|
Button {
|
|
|
|
id: logoutButton
|
|
|
|
text: "Logout"
|
|
|
|
anchors.right: syncButton.left
|
|
|
|
anchors.top: parent.top
|
2017-01-12 17:59:19 +01:00
|
|
|
onClicked: appRoot.logoutClicked()
|
2017-01-11 11:14:57 +01:00
|
|
|
}
|
|
|
|
|
2016-12-10 22:39:53 +00:00
|
|
|
}
|