diff --git a/filetransfer/ftpclient/ftpmanager.cpp b/filetransfer/ftpclient/ftpmanager.cpp index 8013c6b..fe630f8 100644 --- a/filetransfer/ftpclient/ftpmanager.cpp +++ b/filetransfer/ftpclient/ftpmanager.cpp @@ -270,6 +270,10 @@ void FtpManager::ftpCommandFinished(int commandId, bool error) delete file; file = nullptr; m_downFiles.remove(commandId); + if (m_downFiles.isEmpty() && !m_isFree) { + m_isFree = true; + Q_EMIT sigUpdateTransferProgress(0, 0); + } return; } @@ -319,8 +323,8 @@ void FtpManager::ftpCommandFinished(int commandId, bool error) Q_EMIT sigCurrentDirectoryList(m_currentAllFiles); } else { QString downloadPath = m_taskDownload.value(0); - qInfo() << "CommandFinished: Successfully obtained the list under " - + m_taskDownloadMap.value(downloadPath).currentPath + " directory!"; + qInfo() << "CommandFinished: Successfully obtained the list under " + + m_taskDownloadMap.value(downloadPath).currentPath + " directory!"; QList currentDownloadFiles; QStringList dirPathList; if (m_taskDownloadMap.value(downloadPath).fileList.isEmpty()) { @@ -458,33 +462,33 @@ void FtpManager::ftpCommandStarted(int commandId) void FtpManager::ftpStateChanged(int state) { switch (state) { - case QFtp::Unconnected: { - qInfo() << "StateChanged: Unconnected."; - connectFtp(); - break; - } - case QFtp::HostLookup: { - qInfo() << "StateChanged: Host name lookup in progress."; - break; - } - case QFtp::Connecting: { - qInfo() << "StateChanged: Attempting to connect to host."; - break; - } - case QFtp::Connected: { - qInfo() << "StateChanged: The connection with the host has been realized."; - break; - } - case QFtp::LoggedIn: { - qInfo() << "StateChanged: Connection and user login have been realized."; - break; - } - case QFtp::Closing: { - qInfo() << "StateChanged: Connection closing."; - break; - } - default: - break; + case QFtp::Unconnected: { + qInfo() << "StateChanged: Unconnected."; + connectFtp(); + break; + } + case QFtp::HostLookup: { + qInfo() << "StateChanged: Host name lookup in progress."; + break; + } + case QFtp::Connecting: { + qInfo() << "StateChanged: Attempting to connect to host."; + break; + } + case QFtp::Connected: { + qInfo() << "StateChanged: The connection with the host has been realized."; + break; + } + case QFtp::LoggedIn: { + qInfo() << "StateChanged: Connection and user login have been realized."; + break; + } + case QFtp::Closing: { + qInfo() << "StateChanged: Connection closing."; + break; + } + default: + break; } } @@ -564,7 +568,7 @@ void FtpManager::initFtp() void FtpManager::handleUploadDir(QString dirPath, QString uploadPath) { - QDir dir(dirPath); // QDir的路径一定要是全路径,相对路径会有错误 + QDir dir(dirPath); // QDir的路径一定要是全路径,相对路径会有错误 if (!dir.exists()) { qCritical() << dirPath << "Folder does not exist!"; @@ -791,7 +795,6 @@ void FtpManager::clearErrorFiles() } } - void FtpManager::connectFtp() { if (m_reconnectNum >= RECONNECT_MAX_NUM) { @@ -830,12 +833,12 @@ void FtpManager::connectFtp() void FtpManager::setTransferMode(int mode) { switch (mode) { - case QFtp::Active: - m_ftp->setTransferMode(QFtp::Active); - break; - case QFtp::Passive: - m_ftp->setTransferMode(QFtp::Passive); - break; + case QFtp::Active: + m_ftp->setTransferMode(QFtp::Active); + break; + case QFtp::Passive: + m_ftp->setTransferMode(QFtp::Passive); + break; } }