You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-08-13 22:12:50 +02:00
abstract folder list to reuse bits for notelist
This commit is contained in:
@@ -10,6 +10,28 @@ Item {
|
||||
|
||||
function onShown() {}
|
||||
|
||||
function handleItemListEditingAccepted(list, index, text) {
|
||||
if (list.model.virtualItemShown()) {
|
||||
list.model.hideVirtualItem();
|
||||
list.model.addData(text)
|
||||
list.selectItemById(list.model.lastInsertId());
|
||||
} else {
|
||||
list.model.setData(index, text)
|
||||
}
|
||||
}
|
||||
|
||||
function handleItemListStoppedEditing(list) {
|
||||
if (folderList.model.virtualItemShown()) {
|
||||
folderList.model.hideVirtualItem();
|
||||
}
|
||||
}
|
||||
|
||||
function handleItemListAction(list, action) {
|
||||
if (action === "delete") {
|
||||
list.model.deleteData(list.index)
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
id: layout
|
||||
anchors.fill: parent
|
||||
@@ -30,23 +52,15 @@ Item {
|
||||
}
|
||||
|
||||
onEditingAccepted: function(index, text) {
|
||||
if (folderList.model.virtualItemShown()) {
|
||||
folderList.model.hideVirtualItem();
|
||||
folderList.model.addData(text)
|
||||
folderList.selectItemById(folderList.model.lastInsertId());
|
||||
} else {
|
||||
folderList.model.setData(index, text)
|
||||
}
|
||||
handleItemListEditingAccepted(folderList, index, text);
|
||||
}
|
||||
|
||||
onStoppedEditing: {
|
||||
if (folderList.model.virtualItemShown()) {
|
||||
folderList.model.hideVirtualItem();
|
||||
}
|
||||
handleItemListStoppedEditing(folderList);
|
||||
}
|
||||
|
||||
onDeleteButtonClicked: {
|
||||
folderList.model.deleteData(index)
|
||||
handleItemListAction(folderList, "delete");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,6 +77,18 @@ Item {
|
||||
onCurrentItemChanged: {
|
||||
appRoot.currentNoteChanged()
|
||||
}
|
||||
|
||||
onEditingAccepted: function(index, text) {
|
||||
handleItemListEditingAccepted(noteList, index, text);
|
||||
}
|
||||
|
||||
onStoppedEditing: {
|
||||
handleItemListStoppedEditing(noteList);
|
||||
}
|
||||
|
||||
onDeleteButtonClicked: {
|
||||
handleItemListAction(noteList, "delete");
|
||||
}
|
||||
}
|
||||
|
||||
NoteEditor {
|
||||
|
@@ -157,6 +157,10 @@ void Application::synchronizerTimer_timeout() {
|
||||
|
||||
QString Application::selectedFolderId() const {
|
||||
QObject* rootObject = (QObject*)view_.rootObject();
|
||||
if (!rootObject) {
|
||||
qCritical() << "Calling selectedFolderId() when root is null";
|
||||
return "";
|
||||
}
|
||||
|
||||
int index = rootObject->property("currentFolderIndex").toInt();
|
||||
QModelIndex modelIndex = folderModel_.index(index);
|
||||
|
Reference in New Issue
Block a user