1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
|
/*
SPDX-FileCopyrightText: 2003 Shie Erlich <erlich@users.sourceforge.net>
SPDX-FileCopyrightText: 2003 Rafi Yanai <yanai@users.sourceforge.net>
SPDX-FileCopyrightText: 2004-2022 Krusader Krew <https://krusader.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef FILESYSTEMPROVIDER_H
#define FILESYSTEMPROVIDER_H
// QtCore
#include <QObject>
#include <QUrl>
#include <KIO/Job>
#include "filesystem.h"
/**
* @brief Provider for virtual file systems.
*
* This is a singleton.
*/
class FileSystemProvider : public QObject
{
Q_OBJECT
public:
/**
* Get a filesystem implementation for the filesystem target specified by URL. oldFilesystem is returned if
* the filesystem did not change.
*
* The filesystem instances returned by this method are already connected with this handler and will
* notify each other about filesystem changes.
*/
FileSystem *getFilesystem(const QUrl &url, FileSystem *oldFilesystem = nullptr);
/**
* Start a copy job for copying, moving or linking files to a destination directory.
* Operation may be implemented async depending on destination filesystem.
*/
void startCopyFiles(const QList<QUrl> &urls,
const QUrl &destination,
KIO::CopyJob::CopyMode mode = KIO::CopyJob::Copy,
bool showProgressInfo = true,
JobMan::StartMode startMode = JobMan::Default);
/**
* Handle file dropping. Starts a copy job for copying, moving or linking files to a destination
* directory after user choose the action in a context menu.
*
* Operation may implemented async depending on destination filesystem.
*/
void startDropFiles(QDropEvent *event, const QUrl &destination, QWidget *targetWidget);
/**
* Start a delete job for trashing or deleting files.
*
* Operation implemented async.
*/
void startDeleteFiles(const QList<QUrl> &urls, bool moveToTrash = true);
static FileSystemProvider &instance();
static FileSystem::FS_TYPE getFilesystemType(const QUrl &url);
/** Get ACL permissions for a file */
static void getACL(FileItem *file, QString &acl, QString &defAcl);
public slots:
/**
* Notify filesystems if they are affected by changes made by another filesystem.
*
* Only works if filesystem is connected to this provider.
*
* @param directory the directory that was changed (deleted, moved, content changed,...)
* @param removed whether the directory was removed
*/
void refreshFilesystems(const QUrl &directory, bool removed);
private:
FileSystem *getFilesystemInstance(const QUrl &directory);
FileSystem *createFilesystem(const FileSystem::FS_TYPE type);
FileSystemProvider();
// filesystem instances for directory independent file operations, lazy initialized
FileSystem *_defaultFileSystem;
FileSystem *_virtFileSystem;
QList<QPointer<FileSystem>> _fileSystems;
static QString getACL(const QString &path, int type);
};
#endif
|