mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-06 06:19:52 +08:00
DirectoryTree: support adding sibling folder
This commit is contained in:
parent
f1b5c5428d
commit
476ce365d7
@ -325,7 +325,7 @@ void VDirectoryTree::contextMenuRequested(QPoint pos)
|
|||||||
this, &VDirectoryTree::newRootDirectory);
|
this, &VDirectoryTree::newRootDirectory);
|
||||||
|
|
||||||
QAction *sortAct = new QAction(VIconUtils::menuIcon(":/resources/icons/sort.svg"),
|
QAction *sortAct = new QAction(VIconUtils::menuIcon(":/resources/icons/sort.svg"),
|
||||||
tr("&Sort"),
|
tr("S&ort"),
|
||||||
&menu);
|
&menu);
|
||||||
sortAct->setToolTip(tr("Sort folders in this folder/notebook manually"));
|
sortAct->setToolTip(tr("Sort folders in this folder/notebook manually"));
|
||||||
connect(sortAct, SIGNAL(triggered(bool)),
|
connect(sortAct, SIGNAL(triggered(bool)),
|
||||||
@ -352,6 +352,16 @@ void VDirectoryTree::contextMenuRequested(QPoint pos)
|
|||||||
|
|
||||||
menu.addAction(newNoteAct);
|
menu.addAction(newNoteAct);
|
||||||
|
|
||||||
|
QAction *newSiblingFolder = new QAction(tr("New Si&bling Folder"), &menu);
|
||||||
|
newSiblingFolder->setToolTip(tr("Create a folder in the same parent folder"));
|
||||||
|
connect(newSiblingFolder, &QAction::triggered,
|
||||||
|
this, [this]() {
|
||||||
|
auto item = currentItem();
|
||||||
|
if (item) {
|
||||||
|
newDirectory(item->parent());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
QAction *newSubDirAct = new QAction(VIconUtils::menuIcon(":/resources/icons/create_subdir.svg"),
|
QAction *newSubDirAct = new QAction(VIconUtils::menuIcon(":/resources/icons/create_subdir.svg"),
|
||||||
tr("New &Subfolder"),
|
tr("New &Subfolder"),
|
||||||
&menu);
|
&menu);
|
||||||
@ -359,8 +369,10 @@ void VDirectoryTree::contextMenuRequested(QPoint pos)
|
|||||||
VUtils::fixTextWithShortcut(newSubDirAct, "NewSubfolder");
|
VUtils::fixTextWithShortcut(newSubDirAct, "NewSubfolder");
|
||||||
connect(newSubDirAct, &QAction::triggered,
|
connect(newSubDirAct, &QAction::triggered,
|
||||||
this, &VDirectoryTree::newSubDirectory);
|
this, &VDirectoryTree::newSubDirectory);
|
||||||
|
|
||||||
if (item->parent()) {
|
if (item->parent()) {
|
||||||
// Low-level item
|
// Low-level item
|
||||||
|
menu.addAction(newSiblingFolder);
|
||||||
menu.addAction(newSubDirAct);
|
menu.addAction(newSubDirAct);
|
||||||
|
|
||||||
if (item->parent()->childCount() > 1) {
|
if (item->parent()->childCount() > 1) {
|
||||||
@ -427,7 +439,7 @@ void VDirectoryTree::contextMenuRequested(QPoint pos)
|
|||||||
|
|
||||||
if (item) {
|
if (item) {
|
||||||
QAction *openLocationAct = new QAction(VIconUtils::menuIcon(":/resources/icons/open_location.svg"),
|
QAction *openLocationAct = new QAction(VIconUtils::menuIcon(":/resources/icons/open_location.svg"),
|
||||||
tr("&Open Folder Location"),
|
tr("Open Folder &Location"),
|
||||||
&menu);
|
&menu);
|
||||||
openLocationAct->setToolTip(tr("Explore this folder in operating system"));
|
openLocationAct->setToolTip(tr("Explore this folder in operating system"));
|
||||||
connect(openLocationAct, &QAction::triggered,
|
connect(openLocationAct, &QAction::triggered,
|
||||||
@ -460,12 +472,16 @@ void VDirectoryTree::newSubDirectory()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QTreeWidgetItem *curItem = currentItem();
|
newDirectory(currentItem());
|
||||||
if (!curItem) {
|
}
|
||||||
|
|
||||||
|
void VDirectoryTree::newDirectory(QTreeWidgetItem *p_parentItem)
|
||||||
|
{
|
||||||
|
if (!p_parentItem) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
VDirectory *curDir = getVDirectory(curItem);
|
VDirectory *curDir = getVDirectory(p_parentItem);
|
||||||
|
|
||||||
QString info = tr("Create a subfolder in <span style=\"%1\">%2</span>.")
|
QString info = tr("Create a subfolder in <span style=\"%1\">%2</span>.")
|
||||||
.arg(g_config->c_dataTextStyle)
|
.arg(g_config->c_dataTextStyle)
|
||||||
@ -490,7 +506,7 @@ void VDirectoryTree::newSubDirectory()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateItemDirectChildren(curItem);
|
updateItemDirectChildren(p_parentItem);
|
||||||
|
|
||||||
locateDirectory(subDir);
|
locateDirectory(subDir);
|
||||||
}
|
}
|
||||||
|
@ -71,6 +71,8 @@ private slots:
|
|||||||
// Create sub-directory of current item's directory.
|
// Create sub-directory of current item's directory.
|
||||||
void newSubDirectory();
|
void newSubDirectory();
|
||||||
|
|
||||||
|
void newDirectory(QTreeWidgetItem *p_parentItem);
|
||||||
|
|
||||||
// Current tree item changed.
|
// Current tree item changed.
|
||||||
void currentDirectoryItemChanged(QTreeWidgetItem *currentItem);
|
void currentDirectoryItemChanged(QTreeWidgetItem *currentItem);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user