diff --git a/src/core/configmgr.cpp b/src/core/configmgr.cpp index 6f4b3a14..2cf10fa3 100644 --- a/src/core/configmgr.cpp +++ b/src/core/configmgr.cpp @@ -24,7 +24,7 @@ using namespace vnotex; #ifndef QT_NO_DEBUG -#define VX_DEBUG_WEB +// #define VX_DEBUG_WEB #endif const QString ConfigMgr::c_orgName = "VNote"; diff --git a/src/widgets/notebooknodeexplorer.cpp b/src/widgets/notebooknodeexplorer.cpp index 1d1caeb9..87c8c3ea 100644 --- a/src/widgets/notebooknodeexplorer.cpp +++ b/src/widgets/notebooknodeexplorer.cpp @@ -793,6 +793,11 @@ void NotebookNodeExplorer::createContextMenuOnNode(QMenu *p_menu, const Node *p_ act = createAction(Action::Open, p_menu); p_menu->addAction(act); + if (selectedSize == 1 && p_node->isContainer()) { + act = createAction(Action::ExpandAll, p_menu); + p_menu->addAction(act); + } + p_menu->addSeparator(); act = createAction(Action::Cut, p_menu); @@ -822,6 +827,11 @@ void NotebookNodeExplorer::createContextMenuOnNode(QMenu *p_menu, const Node *p_ act = createAction(Action::Open, p_menu); p_menu->addAction(act); + if (selectedSize == 1 && p_node->isContainer()) { + act = createAction(Action::ExpandAll, p_menu); + p_menu->addAction(act); + } + p_menu->addSeparator(); act = createAction(Action::NewNote, p_menu); @@ -1139,6 +1149,12 @@ QAction *NotebookNodeExplorer::createAction(Action p_act, QObject *p_parent) connect(act, &QAction::triggered, this, &NotebookNodeExplorer::openSelectedNodes); break; + + case Action::ExpandAll: + act = new QAction(tr("&Expand All\t*"), p_parent); + connect(act, &QAction::triggered, + this, &NotebookNodeExplorer::expandCurrentNodeAll); + break; } return act; @@ -1831,3 +1847,34 @@ bool NotebookNodeExplorer::checkInvalidNode(const Node *p_node) const return false; } + +void NotebookNodeExplorer::expandCurrentNodeAll() +{ + auto item = m_masterExplorer->currentItem(); + if (!item || item->childCount() == 0) { + return; + } + auto data = getItemNodeData(item); + if (!data.isNode()) { + return; + } + + expandItemRecursively(item); +} + +void NotebookNodeExplorer::expandItemRecursively(QTreeWidgetItem *p_item) +{ + if (!p_item) { + return; + } + + p_item->setExpanded(true); + const int cnt = p_item->childCount(); + if (cnt == 0) { + return; + } + + for (int i = 0; i < cnt; ++i) { + expandItemRecursively(p_item->child(i)); + } +} diff --git a/src/widgets/notebooknodeexplorer.h b/src/widgets/notebooknodeexplorer.h index 58e823ed..4402e989 100644 --- a/src/widgets/notebooknodeexplorer.h +++ b/src/widgets/notebooknodeexplorer.h @@ -148,7 +148,8 @@ namespace vnotex Reload, ReloadIndex, ImportToConfig, - Open + Open, + ExpandAll }; void setupUI(); @@ -257,6 +258,10 @@ namespace vnotex // Return true if it is invalid. bool checkInvalidNode(const Node *p_node) const; + void expandCurrentNodeAll(); + + void expandItemRecursively(QTreeWidgetItem *p_item); + static NotebookNodeExplorer::NodeData getItemNodeData(const QTreeWidgetItem *p_item); static void setItemNodeData(QTreeWidgetItem *p_item, const NodeData &p_data);