Percentage available on progress count struct
This commit is contained in:
@ -344,7 +344,7 @@ func (f *FrontendQt) setProgressManager(progress *transfer.Progress) {
|
|||||||
f.Qml.SetProgressFails(int(counts.Failed))
|
f.Qml.SetProgressFails(int(counts.Failed))
|
||||||
f.Qml.SetProgressDescription(progress.PauseReason())
|
f.Qml.SetProgressDescription(progress.PauseReason())
|
||||||
if counts.Total > 0 {
|
if counts.Total > 0 {
|
||||||
newProgress := float32(counts.Imported+counts.Skipped+counts.Failed) / float32(counts.Total)
|
newProgress := counts.Progress()
|
||||||
if newProgress >= 0 && newProgress != f.Qml.Progress() {
|
if newProgress >= 0 && newProgress != f.Qml.Progress() {
|
||||||
f.Qml.SetProgress(newProgress)
|
f.Qml.SetProgress(newProgress)
|
||||||
f.Qml.ProgressChanged(newProgress)
|
f.Qml.ProgressChanged(newProgress)
|
||||||
|
|||||||
@ -26,3 +26,10 @@ type ProgressCounts struct {
|
|||||||
Added,
|
Added,
|
||||||
Total uint
|
Total uint
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Progress returns ratio between processed messages (fully imported, skipped
|
||||||
|
// and failed ones) and total number of messages as percentage (0 - 1).
|
||||||
|
func (c *ProgressCounts) Progress() float32 {
|
||||||
|
progressed := c.Imported + c.Skipped + c.Failed
|
||||||
|
return float32(progressed) / float32(c.Total)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user