Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2578189
kazv-io.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
kazv-io.cpp
View Options
/*
* This file is part of kazv.
* SPDX-FileCopyrightText: 2021 Tusooa Zhu <tusooa@kazv.moe>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
#include
"kazv-io.hpp"
#include
"kazv-io-manager.hpp"
#include
<QUrl>
#include
<QObject>
struct
KazvIOPrivate
{
QPointer
<
KazvIOManager
>
manager
;
float
progress
;
QUrl
url
;
};
KazvIO
::
KazvIO
(
QObject
*
parent
)
:
QObject
(
parent
)
,
m_d
(
new
KazvIOPrivate
)
{
}
KazvIO
::~
KazvIO
()
=
default
;
/*
* This function is only applicable to a single thread,
* if the manager is located in other threads, please modify this function appropriately
*/
void
KazvIO::download
(
QUrl
localFileUrl
)
{
auto
job
=
m_d
->
manager
->
startNewDownloadJob
(
m_d
->
url
,
localFileUrl
);
connect
(
job
,
&
KJob
::
percentChanged
,
this
,
&
KazvIO
::
updatePercent
);
connect
(
job
,
&
KJob
::
result
,
this
,
&
KazvIO
::
result
);
}
/*
* This function is only applicable to a single thread,
* if the manager is located in other threads, please modify this function appropriately
*/
void
KazvIO::suspend
()
{
m_d
->
manager
->
suspendJob
(
m_d
->
url
);
}
/*
* This function is only applicable to a single thread,
* if the manager is located in other threads, please modify this function appropriately
*/
void
KazvIO::resume
()
{
m_d
->
manager
->
resumeJob
(
m_d
->
url
);
}
/*
* This function is only applicable to a single thread,
* if the manager is located in other threads, please modify this function appropriately
*/
void
KazvIO::cancel
()
{
m_d
->
manager
->
cancelJob
(
m_d
->
url
);
Q_EMIT
result
();
}
float
KazvIO::progress
()
{
return
m_d
->
progress
;
}
QUrl
KazvIO::url
()
{
return
m_d
->
url
;
}
void
KazvIO::setUrl
(
QUrl
url
)
{
m_d
->
url
=
url
;
Q_EMIT
urlChanged
();
}
KazvIOManager
*
KazvIO::manager
()
{
return
m_d
->
manager
;
}
void
KazvIO::setManager
(
KazvIOManager
*
manager
)
{
m_d
->
manager
=
manager
;
Q_EMIT
managerChanged
();
}
void
KazvIO::updatePercent
(
KJob
*
job
,
unsigned
long
percent
)
{
m_d
->
progress
=
1.0
*
percent
/
100
;
Q_EMIT
progressChanged
();
}
File Metadata
Details
Attached
Mime Type
text/x-c
Expires
Tue, Jun 24, 10:32 PM (1 d, 1 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
235043
Default Alt Text
kazv-io.cpp (1 KB)
Attached To
Mode
rK kazv
Attached
Detach File
Event Timeline
Log In to Comment