~mateo-salta/nitroshare/nitroshare

« back to all changes in this revision

Viewing changes to src/file/CFileSender.cpp

  • Committer: Nathan Osman
  • Date: 2012-06-28 21:00:27 UTC
  • Revision ID: admin@quickmediasolutions.com-20120628210027-agxop1i2cj8ym985
Corrected a couple of issues with the progress bar on the share box sticking at 100%.

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
 
53
53
void CFileSender::OnBytesWritten(qint64 amount)
54
54
{
55
 
    m_current_file_bytes_so_far += amount;
56
 
 
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);
59
 
 
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);
62
 
 
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);
65
 
 
66
 
    emit Progress((progress + percent_transferred * percent_of_total) * 100.0);
67
 
 
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)
 
59
    {
 
60
        m_current_file_bytes_so_far += amount;
 
61
 
 
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);
 
64
 
 
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);
 
67
 
 
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);
 
70
 
 
71
        emit Progress((progress + percent_transferred * percent_of_total) * 100.0);
 
72
 
 
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;
 
77
    }
72
78
}
73
79
 
74
80
void CFileSender::OnConnected()