mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-06 06:19:52 +08:00
restore the expansion state of the directory tree after creating or pasting
Signed-off-by: Le Tan <tamlokveer@gmail.com>
This commit is contained in:
parent
5a097421e1
commit
3feec565f6
@ -222,6 +222,7 @@ void VDirectoryTree::updateItemChildren(QTreeWidgetItem *p_item)
|
|||||||
fillTreeItem(*item, dir->getName(), dir, QIcon(":/resources/icons/dir_item.svg"));
|
fillTreeItem(*item, dir->getName(), dir, QIcon(":/resources/icons/dir_item.svg"));
|
||||||
updateDirectoryTreeOne(item, 1);
|
updateDirectoryTreeOne(item, 1);
|
||||||
}
|
}
|
||||||
|
expandItemTree(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete items without corresponding VDirectory
|
// Delete items without corresponding VDirectory
|
||||||
@ -644,3 +645,19 @@ QTreeWidgetItem *VDirectoryTree::expandToVDirectory(const VDirectory *p_director
|
|||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VDirectoryTree::expandItemTree(QTreeWidgetItem *p_item)
|
||||||
|
{
|
||||||
|
if (!p_item) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
VDirectory *dir = getVDirectory(p_item);
|
||||||
|
int nrChild = p_item->childCount();
|
||||||
|
for (int i = 0; i < nrChild; ++i) {
|
||||||
|
expandItemTree(p_item->child(i));
|
||||||
|
}
|
||||||
|
if (dir->isExpanded()) {
|
||||||
|
Q_ASSERT(nrChild > 0);
|
||||||
|
expandItem(p_item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -63,6 +63,8 @@ private:
|
|||||||
void updateChildren(QTreeWidgetItem *p_item);
|
void updateChildren(QTreeWidgetItem *p_item);
|
||||||
// Expand/create the directory tree nodes to @p_directory.
|
// Expand/create the directory tree nodes to @p_directory.
|
||||||
QTreeWidgetItem *expandToVDirectory(const VDirectory *p_directory);
|
QTreeWidgetItem *expandToVDirectory(const VDirectory *p_directory);
|
||||||
|
// Expand the tree under @p_item according to VDirectory.isOpened().
|
||||||
|
void expandItemTree(QTreeWidgetItem *p_item);
|
||||||
|
|
||||||
VNote *vnote;
|
VNote *vnote;
|
||||||
QPointer<VNotebook> m_notebook;
|
QPointer<VNotebook> m_notebook;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user