From aced51baffac6e436ce7384d46ab7641ca7bf03a Mon Sep 17 00:00:00 2001 From: Le Tan Date: Sun, 6 Dec 2020 10:28:09 +0800 Subject: [PATCH] NotebookExplorer: use root node if it is recycle bin node on new file --- README.md | 4 ++-- src/widgets/notebookexplorer.cpp | 20 ++++++++++++-------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 2a31ffc4..51c04603 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # vnote A pleasant note-taking platform. +![CI-Windows](https://github.com/vnotex/vnote/workflows/CI-Windows/badge.svg) ![CI-Linux](https://github.com/vnotex/vnote/workflows/CI-Linux/badge.svg) + > At early 2019, I decided to refactor VNote as VNoteX. Now a fresh VNote is ready! > VNoteX is closed source and is intended to keep several premium features compared to VNote. Most of VNoteX's code base will be open source as VNote 3.0, so VNote will share most of the code base with VNoteX and continue to be open source from 3.0. > **Welcome to VNoteX and VNote 3.0!** @@ -14,8 +16,6 @@ The obsolete code base of VNote 2.0 is available at the [vnote2.0](https://githu For more information, please visit [**VNote's Homepage**](https://vnotex.github.io/vnote). -![CI-Win](https://github.com/vnotex/vnote/workflows/CI-Win/badge.svg) ![CI-Linux](https://github.com/vnotex/vnote/workflows/CI-Linux/badge.svg) - ![VNote](pics/vnote.png) ## Description diff --git a/src/widgets/notebookexplorer.cpp b/src/widgets/notebookexplorer.cpp index cf505fde..1a496d0e 100644 --- a/src/widgets/notebookexplorer.cpp +++ b/src/widgets/notebookexplorer.cpp @@ -200,8 +200,9 @@ void NotebookExplorer::newFolder() return; } - if (m_currentNotebook->isRecycleBinNode(node) - || m_currentNotebook->isNodeInRecycleBin(node)) { + if (m_currentNotebook->isRecycleBinNode(node)) { + node = m_currentNotebook->getRootNode().data(); + } else if (m_currentNotebook->isNodeInRecycleBin(node)) { MessageBoxHelper::notify(MessageBoxHelper::Information, tr("Could not create folder within Recycle Bin."), VNoteX::getInst().getMainWindow()); @@ -221,8 +222,9 @@ void NotebookExplorer::newNote() return; } - if (m_currentNotebook->isRecycleBinNode(node) - || m_currentNotebook->isNodeInRecycleBin(node)) { + if (m_currentNotebook->isRecycleBinNode(node)) { + node = m_currentNotebook->getRootNode().data(); + } else if (m_currentNotebook->isNodeInRecycleBin(node)) { MessageBoxHelper::notify(MessageBoxHelper::Information, tr("Could not create note within Recycle Bin."), VNoteX::getInst().getMainWindow()); @@ -285,8 +287,9 @@ void NotebookExplorer::importFile() return; } - if (m_currentNotebook->isRecycleBinNode(node) - || m_currentNotebook->isNodeInRecycleBin(node)) { + if (m_currentNotebook->isRecycleBinNode(node)) { + node = m_currentNotebook->getRootNode().data(); + } else if (m_currentNotebook->isNodeInRecycleBin(node)) { MessageBoxHelper::notify(MessageBoxHelper::Information, tr("Could not create file within Recycle Bin."), VNoteX::getInst().getMainWindow()); @@ -325,8 +328,9 @@ void NotebookExplorer::importFolder() return; } - if (m_currentNotebook->isRecycleBinNode(node) - || m_currentNotebook->isNodeInRecycleBin(node)) { + if (m_currentNotebook->isRecycleBinNode(node)) { + node = m_currentNotebook->getRootNode().data(); + } else if (m_currentNotebook->isNodeInRecycleBin(node)) { MessageBoxHelper::notify(MessageBoxHelper::Information, tr("Could not create folder within Recycle Bin."), VNoteX::getInst().getMainWindow());