mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 22:09: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);
|
QString name = VUtils::fileNameFromPath(file);
|
||||||
Q_ASSERT(!name.isEmpty());
|
Q_ASSERT(!name.isEmpty());
|
||||||
name = VUtils::getFileNameWithSequence(dirPath, name, true);
|
|
||||||
QString targetFilePath = dir.filePath(name);
|
bool copyNeeded = true;
|
||||||
bool ret = VUtils::copyFile(file, targetFilePath, false);
|
if (VUtils::equalPath(dirPath, fi.absolutePath())) {
|
||||||
if (!ret) {
|
qDebug() << "skip cpoy file" << file << "locates in" << dirPath;
|
||||||
VUtils::addErrMsg(p_errMsg, tr("Fail to copy file %1 as %2.")
|
copyNeeded = false;
|
||||||
.arg(file)
|
}
|
||||||
.arg(targetFilePath));
|
|
||||||
ret = false;
|
QString targetFilePath;
|
||||||
continue;
|
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);
|
VNoteFile *destFile = m_directory->addFile(name, -1);
|
||||||
|
@ -987,7 +987,8 @@ void VMainWindow::initFileMenu()
|
|||||||
// Import notes from files.
|
// Import notes from files.
|
||||||
m_importNoteAct = newAction(VIconUtils::menuIcon(":/resources/icons/import_note.svg"),
|
m_importNoteAct = newAction(VIconUtils::menuIcon(":/resources/icons/import_note.svg"),
|
||||||
tr("&New Notes From Files"), this);
|
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,
|
connect(m_importNoteAct, &QAction::triggered,
|
||||||
this, &VMainWindow::importNoteFromFile);
|
this, &VMainWindow::importNoteFromFile);
|
||||||
m_importNoteAct->setEnabled(false);
|
m_importNoteAct->setEnabled(false);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user