mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00

1. Add external_recycle_bin_folder config; 2. By default, each external file will use _v_recycle_bin in the same directory as its recycle bin folder to hold deleted images;
85 lines
1.8 KiB
C++
85 lines
1.8 KiB
C++
#include "vorphanfile.h"
|
|
#include <QDebug>
|
|
#include <QTextEdit>
|
|
#include <QFileInfo>
|
|
#include <QDir>
|
|
#include "utils/vutils.h"
|
|
#include "vconfigmanager.h"
|
|
|
|
extern VConfigManager *g_config;
|
|
|
|
VOrphanFile::VOrphanFile(QObject *p_parent,
|
|
const QString &p_path,
|
|
bool p_modifiable,
|
|
bool p_systemFile)
|
|
: VFile(p_parent,
|
|
VUtils::fileNameFromPath(p_path),
|
|
FileType::Orphan,
|
|
p_modifiable,
|
|
QDateTime(),
|
|
QDateTime()),
|
|
m_path(p_path),
|
|
m_systemFile(p_systemFile)
|
|
{
|
|
}
|
|
|
|
QString VOrphanFile::fetchPath() const
|
|
{
|
|
return m_path;
|
|
}
|
|
|
|
QString VOrphanFile::fetchBasePath() const
|
|
{
|
|
return VUtils::basePathFromPath(m_path);
|
|
}
|
|
|
|
QString VOrphanFile::fetchImageFolderPath() const
|
|
{
|
|
QString folder = m_imageFolder;
|
|
if (m_imageFolder.isEmpty()) {
|
|
folder = g_config->getImageFolderExt();
|
|
}
|
|
|
|
QFileInfo fi(folder);
|
|
if (fi.isAbsolute()) {
|
|
return folder;
|
|
} else {
|
|
return QDir(fetchBasePath()).filePath(folder);
|
|
}
|
|
}
|
|
|
|
bool VOrphanFile::useRelativeImageFolder() const
|
|
{
|
|
QString folder = m_imageFolder;
|
|
if (m_imageFolder.isEmpty()) {
|
|
folder = g_config->getImageFolderExt();
|
|
}
|
|
|
|
return !QFileInfo(folder).isAbsolute();
|
|
}
|
|
|
|
QString VOrphanFile::getImageFolderInLink() const
|
|
{
|
|
QString folder = m_imageFolder;
|
|
if (m_imageFolder.isEmpty()) {
|
|
folder = g_config->getImageFolderExt();
|
|
}
|
|
|
|
return folder;
|
|
}
|
|
|
|
QString VOrphanFile::fetchRecycleBinFolderPath() const
|
|
{
|
|
QString folder = m_recycleBinFolder;
|
|
if (m_recycleBinFolder.isEmpty()) {
|
|
folder = g_config->getRecycleBinFolderExt();
|
|
}
|
|
|
|
QFileInfo fi(folder);
|
|
if (fi.isAbsolute()) {
|
|
return folder;
|
|
} else {
|
|
return QDir(fetchBasePath()).filePath(folder);
|
|
}
|
|
}
|