mirror of https://github.com/zlatinb/muwire
add an ETA column
parent
62811861a4
commit
12b51ceb02
|
@ -14,7 +14,7 @@ class DownloadsModel {
|
||||||
private final TextGUIThread guiThread
|
private final TextGUIThread guiThread
|
||||||
private final Core core
|
private final Core core
|
||||||
private final List<Downloader> downloaders = new ArrayList<>()
|
private final List<Downloader> downloaders = new ArrayList<>()
|
||||||
private final TableModel model = new TableModel("Name", "Status", "Progress", "Speed")
|
private final TableModel model = new TableModel("Name", "Status", "Progress", "Speed", "ETA")
|
||||||
|
|
||||||
DownloadsModel(TextGUIThread guiThread, Core core) {
|
DownloadsModel(TextGUIThread guiThread, Core core) {
|
||||||
this.guiThread = guiThread
|
this.guiThread = guiThread
|
||||||
|
@ -40,7 +40,8 @@ class DownloadsModel {
|
||||||
rowCount.times { model.removeRow(0) }
|
rowCount.times { model.removeRow(0) }
|
||||||
downloaders.each {
|
downloaders.each {
|
||||||
String status = it.getCurrentState().toString()
|
String status = it.getCurrentState().toString()
|
||||||
String speed = DataHelper.formatSize2Decimal(it.speed(), false) + "B/sec"
|
int speedInt = it.speed()
|
||||||
|
String speed = DataHelper.formatSize2Decimal(speedInt, false) + "B/sec"
|
||||||
|
|
||||||
int pieces = it.nPieces
|
int pieces = it.nPieces
|
||||||
int done = it.donePieces()
|
int done = it.donePieces()
|
||||||
|
@ -50,7 +51,15 @@ class DownloadsModel {
|
||||||
String totalSize = DataHelper.formatSize2Decimal(it.length, false) + "B"
|
String totalSize = DataHelper.formatSize2Decimal(it.length, false) + "B"
|
||||||
String progress = (String.format("%2d", percent) + "% of ${totalSize}".toString())
|
String progress = (String.format("%2d", percent) + "% of ${totalSize}".toString())
|
||||||
|
|
||||||
model.addRow([new DownloaderWrapper(it), status, progress, speed])
|
String ETA
|
||||||
|
if (speedInt == 0)
|
||||||
|
ETA = "Unknown"
|
||||||
|
else {
|
||||||
|
long remaining = (pieces - done) * it.pieceSize / speedInt
|
||||||
|
ETA = DataHelper.formatDuration(remaining * 1000)
|
||||||
|
}
|
||||||
|
|
||||||
|
model.addRow([new DownloaderWrapper(it), status, progress, speed, ETA])
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ class DownloadsView extends BasicWindow {
|
||||||
|
|
||||||
Panel contentPanel = new Panel()
|
Panel contentPanel = new Panel()
|
||||||
contentPanel.setLayoutManager(new GridLayout(1))
|
contentPanel.setLayoutManager(new GridLayout(1))
|
||||||
table = new Table("Name","Status","Progress","Speed")
|
table = new Table("Name","Status","Progress","Speed","ETA")
|
||||||
table.setCellSelection(false)
|
table.setCellSelection(false)
|
||||||
table.setSelectAction({rowSelected()})
|
table.setSelectAction({rowSelected()})
|
||||||
table.setTableModel(model.model)
|
table.setTableModel(model.model)
|
||||||
|
|
Loading…
Reference in New Issue