mirror of
https://github.com/iDescriptor/iDescriptor.git
synced 2026-06-22 03:45:51 +08:00
d2717aaa4c
- Added PhotoExportManager class to handle exporting files from a device to a specified output directory, including cancellation support and progress tracking. - Introduced asynchronous file export using a worker thread, ensuring UI responsiveness during export operations. - Implemented filtering and sorting capabilities in PhotoModel, allowing users to view images and videos based on selected criteria. - Enhanced MediaPreviewDialog by commenting out the image loading logic for future implementation. - Updated VirtualLocation to manage device removal and improved image mounting logic. - Refactored code for better organization and maintainability, including the addition of helper methods for file handling and metadata extraction.
68 lines
1.8 KiB
C++
68 lines
1.8 KiB
C++
#ifndef PHOTOEXPORTMANAGER_H
|
|
#define PHOTOEXPORTMANAGER_H
|
|
|
|
#include "iDescriptor.h"
|
|
#include <QFileInfo>
|
|
#include <QMutex>
|
|
#include <QObject>
|
|
#include <QString>
|
|
#include <QStringList>
|
|
#include <QThread>
|
|
|
|
class PhotoExportManager : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit PhotoExportManager(QObject *parent = nullptr);
|
|
|
|
struct ExportResult {
|
|
QString filePath;
|
|
QString outputPath;
|
|
bool success;
|
|
QString errorMessage;
|
|
};
|
|
|
|
// Start export operation
|
|
void exportFiles(iDescriptorDevice *device, const QStringList &filePaths,
|
|
const QString &outputDirectory);
|
|
|
|
// Check if export is currently running
|
|
bool isExporting() const { return m_isExporting; }
|
|
|
|
// Cancel current export operation
|
|
void cancelExport();
|
|
|
|
signals:
|
|
void exportStarted(int totalFiles);
|
|
void fileExported(const PhotoExportManager::ExportResult &result);
|
|
void exportProgress(int completed, int total,
|
|
const QString ¤tFileName);
|
|
void exportFinished(int successful, int failed);
|
|
void exportCancelled();
|
|
|
|
private slots:
|
|
void performExport();
|
|
|
|
private:
|
|
// Export single file using AFC
|
|
ExportResult exportSingleFile(afc_client_t afc, const QString &devicePath,
|
|
const QString &outputPath);
|
|
|
|
// Extract filename from device path
|
|
QString extractFileName(const QString &devicePath) const;
|
|
|
|
// Generate unique output path if file exists
|
|
QString generateUniqueOutputPath(const QString &basePath) const;
|
|
|
|
// Member variables
|
|
iDescriptorDevice *m_device;
|
|
QStringList m_filePaths;
|
|
QString m_outputDirectory;
|
|
bool m_isExporting;
|
|
bool m_cancelRequested;
|
|
QMutex m_mutex;
|
|
QThread *m_workerThread;
|
|
};
|
|
|
|
#endif // PHOTOEXPORTMANAGER_H
|