mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
explorer: bug-fix about clicking items when no root entries
This commit is contained in:
parent
a5ada5310a
commit
a2670903cf
@ -194,6 +194,12 @@ void VExplorer::setupUI()
|
|||||||
if (!model->isDir(p_index)) {
|
if (!model->isDir(p_index)) {
|
||||||
QStringList files;
|
QStringList files;
|
||||||
files << model->filePath(p_index);
|
files << model->filePath(p_index);
|
||||||
|
|
||||||
|
// If there is no directory entry currently, new one using the parent dir.
|
||||||
|
if (m_index == -1 || m_entries.isEmpty()) {
|
||||||
|
setAsRootDirectory(VUtils::basePathFromPath(files[0]));
|
||||||
|
}
|
||||||
|
|
||||||
openFiles(files, g_config->getNoteOpenMode());
|
openFiles(files, g_config->getNoteOpenMode());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -454,11 +460,7 @@ void VExplorer::handleContextMenuRequested(QPoint p_pos)
|
|||||||
setRootAct->setToolTip(tr("Set current folder as the root directory to explore"));
|
setRootAct->setToolTip(tr("Set current folder as the root directory to explore"));
|
||||||
connect(setRootAct, &QAction::triggered,
|
connect(setRootAct, &QAction::triggered,
|
||||||
this, [this, filePath]() {
|
this, [this, filePath]() {
|
||||||
int idx = addEntry(filePath);
|
setAsRootDirectory(filePath);
|
||||||
updateDirectoryComboBox();
|
|
||||||
if (idx != -1) {
|
|
||||||
setCurrentEntry(idx);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
menu.addAction(setRootAct);
|
menu.addAction(setRootAct);
|
||||||
|
|
||||||
@ -754,3 +756,18 @@ void VExplorer::renameFile(const QString &p_filePath)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VExplorer::setAsRootDirectory(const QString &p_path)
|
||||||
|
{
|
||||||
|
if (p_path.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
qDebug() << "set new root directory" << p_path;
|
||||||
|
|
||||||
|
int idx = addEntry(p_path);
|
||||||
|
updateDirectoryComboBox();
|
||||||
|
if (idx != -1) {
|
||||||
|
setCurrentEntry(idx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -67,6 +67,8 @@ private:
|
|||||||
|
|
||||||
void renameFile(const QString &p_filePath);
|
void renameFile(const QString &p_filePath);
|
||||||
|
|
||||||
|
void setAsRootDirectory(const QString &p_path);
|
||||||
|
|
||||||
bool m_initialized;
|
bool m_initialized;
|
||||||
|
|
||||||
bool m_uiInitialized;
|
bool m_uiInitialized;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user