Clean up FileTransferJob description
* Set magic `destUrl` property to let it know the job destination in case of multiple files being transferred * Set a normal "Receiving File(s)" title like we do with "Copying" title * Set device name and destination path as details
This commit is contained in:
parent
ae6ab69676
commit
daa6f7fc14
3 changed files with 7 additions and 23 deletions
|
@ -41,7 +41,12 @@ void CompositeFileTransferJob::startNextSubJob()
|
||||||
{
|
{
|
||||||
m_currentJob = qobject_cast<FileTransferJob*>(subjobs().at(0));
|
m_currentJob = qobject_cast<FileTransferJob*>(subjobs().at(0));
|
||||||
m_currentJobSendPayloadSize = 0;
|
m_currentJobSendPayloadSize = 0;
|
||||||
emitDescription(m_currentJob->destination().toString());
|
|
||||||
|
Q_EMIT description(this, i18ncp("@title job", "Receiving file", "Receiving files", m_totalJobs),
|
||||||
|
{i18nc("The source of a file operation", "Source"), Daemon::instance()->getDevice(this->m_deviceId)->name()},
|
||||||
|
{i18nc("The destination of a file operation", "Destination"), m_currentJob->destination().toDisplayString(QUrl::PreferLocalFile)}
|
||||||
|
);
|
||||||
|
|
||||||
m_currentJob->start();
|
m_currentJob->start();
|
||||||
#ifdef SAILFISHOS
|
#ifdef SAILFISHOS
|
||||||
connect(m_currentJob, SIGNAL(processedAmount(KJob*,KJob::Unit,qulonglong)), this, SLOT(slotProcessedAmount(KJob*,KJob::Unit,qulonglong)));
|
connect(m_currentJob, SIGNAL(processedAmount(KJob*,KJob::Unit,qulonglong)), this, SLOT(slotProcessedAmount(KJob*,KJob::Unit,qulonglong)));
|
||||||
|
@ -66,9 +71,6 @@ bool CompositeFileTransferJob::addSubjob(KJob* job)
|
||||||
setTotalAmount(Files, m_totalJobs);
|
setTotalAmount(Files, m_totalJobs);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString filename = np->get<QString>(QStringLiteral("filename"));
|
|
||||||
emitDescription(filename);
|
|
||||||
|
|
||||||
if (!hasSubjobs()) {
|
if (!hasSubjobs()) {
|
||||||
QMetaObject::invokeMethod(this, "startNextSubJob", Qt::QueuedConnection);
|
QMetaObject::invokeMethod(this, "startNextSubJob", Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
|
@ -130,20 +132,3 @@ void CompositeFileTransferJob::slotResult(KJob *job)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompositeFileTransferJob::emitDescription(const QString& currentFileName)
|
|
||||||
{
|
|
||||||
QPair<QString, QString> field2;
|
|
||||||
|
|
||||||
const QUrl fileUrl(currentFileName);
|
|
||||||
const QString fileName = fileUrl.toDisplayString(QUrl::PreferLocalFile);
|
|
||||||
|
|
||||||
if (m_totalJobs > 1) {
|
|
||||||
field2.first = i18n("Progress");
|
|
||||||
field2.second = i18n("Receiving file %1 of %2", m_currentJobNum, m_totalJobs);
|
|
||||||
}
|
|
||||||
|
|
||||||
Q_EMIT description(this, i18np("Receiving file from %2", "Receiving %1 files from %2", m_totalJobs, Daemon::instance()->getDevice(this->m_deviceId)->name()),
|
|
||||||
{ i18n("File"), fileName }, field2
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -34,8 +34,6 @@ private Q_SLOTS:
|
||||||
void startNextSubJob();
|
void startNextSubJob();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void emitDescription(const QString& currentFileName);
|
|
||||||
|
|
||||||
QString m_deviceId;
|
QString m_deviceId;
|
||||||
bool m_running;
|
bool m_running;
|
||||||
int m_currentJobNum;
|
int m_currentJobNum;
|
||||||
|
|
|
@ -112,6 +112,7 @@ bool SharePlugin::receivePacket(const NetworkPacket& np)
|
||||||
|
|
||||||
if (!m_compositeJob) {
|
if (!m_compositeJob) {
|
||||||
m_compositeJob = new CompositeFileTransferJob(device()->id());
|
m_compositeJob = new CompositeFileTransferJob(device()->id());
|
||||||
|
m_compositeJob->setProperty("destUrl", destinationDir().toString());
|
||||||
KIO::getJobTracker()->registerJob(m_compositeJob);
|
KIO::getJobTracker()->registerJob(m_compositeJob);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue