53
53
void CFileSender::OnBytesWritten(qint64 amount)
55
m_current_file_bytes_so_far += amount;
57
/* Determine what percentage of the file has been transferred so far. */
58
double percent_transferred = CalculateProgress(m_current_file_bytes_so_far, m_current_file_transfer_bytes);
60
/* Next, determine what percentage of the total transfer this file represents. */
61
double percent_of_total = CalculateProgress(m_current_file_uncompressed_bytes, m_total_uncompressed_bytes);
63
/* Lastly add that amount to what has been transferred so far for the final number. */
64
double progress = CalculateProgress(m_total_uncompressed_bytes_so_far, m_total_uncompressed_bytes);
66
emit Progress((progress + percent_transferred * percent_of_total) * 100.0);
68
/* If we've reached the end of the current file, then add the _uncompressed_
69
size of this file to the total. */
70
if(m_current_file_bytes_so_far >= m_current_file_transfer_bytes)
71
m_total_uncompressed_bytes_so_far += m_current_file_uncompressed_bytes;
55
/* This signal is emitted for not only file data being
56
written but also our headers, etc. So only do anything
57
if we are in the process of transferring files. */
58
if(m_state == TransferringFiles)
60
m_current_file_bytes_so_far += amount;
62
/* Determine what percentage of the file has been transferred so far. */
63
double percent_transferred = CalculateProgress(m_current_file_bytes_so_far, m_current_file_transfer_bytes);
65
/* Next, determine what percentage of the total transfer this file represents. */
66
double percent_of_total = CalculateProgress(m_current_file_uncompressed_bytes, m_total_uncompressed_bytes);
68
/* Lastly add that amount to what has been transferred so far for the final number. */
69
double progress = CalculateProgress(m_total_uncompressed_bytes_so_far, m_total_uncompressed_bytes);
71
emit Progress((progress + percent_transferred * percent_of_total) * 100.0);
73
/* If we've reached the end of the current file, then add the _uncompressed_
74
size of this file to the total. */
75
if(m_current_file_bytes_so_far >= m_current_file_transfer_bytes)
76
m_total_uncompressed_bytes_so_far += m_current_file_uncompressed_bytes;
74
80
void CFileSender::OnConnected()