dtkio
dtk library for dtkio.
载入中...
搜索中...
未找到
ddiskjob.h
浏览该文件的文档.
1// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
5#ifndef DDISKJOB_H
6#define DDISKJOB_H
7
8#include <DtkMountGlobal>
9
10#include <QObject>
11
12#include <DExpected>
13
14DMOUNT_BEGIN_NAMESPACE
15
16class DDiskJob;
17namespace DDeviceManager {
18DCORE_NAMESPACE::DExpected<DDiskJob *> createDiskJob(const QString &, QObject *);
19} // namespace DDeviceManager
20
21class DDiskJobPrivate;
22class DDiskJob : public QObject
23{
24 Q_OBJECT
25 Q_DECLARE_PRIVATE(DDiskJob)
26 friend DCORE_NAMESPACE::DExpected<DDiskJob *> DDeviceManager::createDiskJob(const QString &, QObject *);
27
28 Q_PROPERTY(QString path READ path CONSTANT FINAL)
29 Q_PROPERTY(QStringList objects READ objects CONSTANT FINAL)
30 Q_PROPERTY(bool cancelable READ cancelable CONSTANT FINAL)
31 Q_PROPERTY(bool progressValid READ progressValid CONSTANT FINAL)
32 Q_PROPERTY(double progress READ progress NOTIFY progressChanged FINAL)
33 Q_PROPERTY(QString operation READ operation CONSTANT FINAL)
34 Q_PROPERTY(quint32 startedByUid READ startedByUid CONSTANT FINAL)
35 Q_PROPERTY(quint64 bytes READ bytes CONSTANT FINAL)
36 Q_PROPERTY(quint64 expectedEndTime READ expectedEndTime NOTIFY expectedEndTimeChanged FINAL)
37 Q_PROPERTY(quint64 rate READ rate NOTIFY rateChanged FINAL)
38 Q_PROPERTY(quint64 startTime READ startTime CONSTANT FINAL)
39
40public:
41 ~DDiskJob() override;
42
43 QString path() const;
44 QStringList objects() const;
45 bool cancelable() const;
46 bool progressValid() const;
47 double progress() const;
48 QString operation() const;
49 quint32 startedByUid() const;
50 quint64 bytes() const;
51 quint64 expectedEndTime() const;
52 quint64 rate() const;
53 quint64 startTime() const;
54
55public Q_SLOTS:
56 void cancel(const QVariantMap &options);
57
58Q_SIGNALS:
59 void completed(bool success, const QString &message);
60 void progressChanged(double progress);
61 void rateChanged(quint64 rate);
62 void expectedEndTimeChanged(quint64 expectedEndTime);
63
64protected:
65 explicit DDiskJob(const QString &path, QObject *parent = nullptr);
66
67private:
68 QScopedPointer<DDiskJobPrivate> d_ptr;
69};
70
71DMOUNT_END_NAMESPACE
72
73#endif // DDISKJOB_H
提供对设备任务接口的操作
Definition ddiskjob.h:23
quint64 rate() const
获取当前任务处理速率
quint32 startedByUid() const
获取启动当前任务的用户 uid
QStringList objects() const
获取当前任务关联的对象列表
bool progressValid() const
获取当前进度数值是否有效
bool cancelable() const
获取当前任务是否可取消
quint64 expectedEndTime() const
获取当前任务预测的结束 unix 时间(毫秒)
void cancel(const QVariantMap &options)
槽函数,取消任务操作
double progress() const
获取当前任务进度
void progressChanged(double progress)
信号,告知任务处理进度
quint64 startTime() const
获取当前任务开始时间(毫秒)
DDiskJob(const QString &path, QObject *parent=nullptr)
构造函数
~DDiskJob() override
析构函数
quint64 bytes() const
获取当前任务需要处理的字节数
void rateChanged(quint64 rate)
信号,告知任务处理速率改变
void completed(bool success, const QString &message)
信号,告知任务结束
QString path() const
获取当前任务对应的任务接口路径
QString operation() const
获取当前操作类型
void expectedEndTimeChanged(quint64 expectedEndTime)
信号,告知任务预测结束时间改变
DExpected< DDiskJob * > createDiskJob(const QString &path, QObject *parent=nullptr)
通过任务路径,创建任务类型对象