mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
import: do not copy files when import if they locate in current folder
This commit is contained in:
parent
5cd114e549
commit
eb734f591e
@ -744,15 +744,27 @@ bool VFileList::importFiles(const QStringList &p_files, QString *p_errMsg)
|
||||
|
||||
QString name = VUtils::fileNameFromPath(file);
|
||||
Q_ASSERT(!name.isEmpty());
|
||||
name = VUtils::getFileNameWithSequence(dirPath, name, true);
|
||||
QString targetFilePath = dir.filePath(name);
|
||||
bool ret = VUtils::copyFile(file, targetFilePath, false);
|
||||
if (!ret) {
|
||||
VUtils::addErrMsg(p_errMsg, tr("Fail to copy file %1 as %2.")
|
||||
.arg(file)
|
||||
.arg(targetFilePath));
|
||||
ret = false;
|
||||
continue;
|
||||
|
||||
bool copyNeeded = true;
|
||||
if (VUtils::equalPath(dirPath, fi.absolutePath())) {
|
||||
qDebug() << "skip cpoy file" << file << "locates in" << dirPath;
|
||||
copyNeeded = false;
|
||||
}
|
||||
|
||||
QString targetFilePath;
|
||||
if (copyNeeded) {
|
||||
name = VUtils::getFileNameWithSequence(dirPath, name, true);
|
||||
targetFilePath = dir.filePath(name);
|
||||
bool ret = VUtils::copyFile(file, targetFilePath, false);
|
||||
if (!ret) {
|
||||
VUtils::addErrMsg(p_errMsg, tr("Fail to copy file %1 as %2.")
|
||||
.arg(file)
|
||||
.arg(targetFilePath));
|
||||
ret = false;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
targetFilePath = file;
|
||||
}
|
||||
|
||||
VNoteFile *destFile = m_directory->addFile(name, -1);
|
||||
|
@ -987,7 +987,8 @@ void VMainWindow::initFileMenu()
|
||||
// Import notes from files.
|
||||
m_importNoteAct = newAction(VIconUtils::menuIcon(":/resources/icons/import_note.svg"),
|
||||
tr("&New Notes From Files"), this);
|
||||
m_importNoteAct->setToolTip(tr("Create notes from external files in current folder by copy"));
|
||||
m_importNoteAct->setToolTip(tr("Create notes from external files in current folder "
|
||||
"(will copy files if they do not locate in current folder)"));
|
||||
connect(m_importNoteAct, &QAction::triggered,
|
||||
this, &VMainWindow::importNoteFromFile);
|
||||
m_importNoteAct->setEnabled(false);
|
||||
|
Loading…
x
Reference in New Issue
Block a user