Add search hit and download count to shared file table in both UIs

This commit is contained in:
Zlatin Balevsky
2019-10-26 15:02:46 +01:00
parent 5e329dfa2c
commit c6fb76610d
8 changed files with 55 additions and 7 deletions

View File

@@ -35,6 +35,7 @@ import com.muwire.core.files.FileLoadedEvent
import com.muwire.core.files.FileSharedEvent
import com.muwire.core.files.FileUnsharedEvent
import com.muwire.core.search.QueryEvent
import com.muwire.core.search.SearchEvent
import com.muwire.core.search.UIResultBatchEvent
import com.muwire.core.search.UIResultEvent
import com.muwire.core.trust.TrustEvent
@@ -199,6 +200,7 @@ class MainFrameModel {
core.eventBus.register(AllFilesLoadedEvent.class, this)
core.eventBus.register(UpdateDownloadedEvent.class, this)
core.eventBus.register(TrustSubscriptionUpdatedEvent.class, this)
core.eventBus.register(SearchEvent.class, this)
core.muOptions.watchedKeywords.each {
core.eventBus.publish(new ContentControlEvent(term : it, regex: false, add: true))
@@ -379,6 +381,7 @@ class MainFrameModel {
uploads << e.uploader
JTable table = builder.getVariable("uploads-table")
table.model.fireTableDataChanged()
view.refreshSharedFiles()
}
}
@@ -416,6 +419,12 @@ class MainFrameModel {
updateTablePreservingSelection("subscription-table")
}
}
void onSearchEvent(SearchEvent e) {
runInsideUIAsync {
view.refreshSharedFiles()
}
}
void onQueryEvent(QueryEvent e) {
if (e.replyTo == core.me.destination)

View File

@@ -226,8 +226,10 @@ class MainFrameView {
table(id : "shared-files-table", autoCreateRowSorter: true) {
tableModel(list : model.shared) {
closureColumn(header : "Name", preferredWidth : 500, type : String, read : {row -> row.getCachedPath()})
closureColumn(header : "Size", preferredWidth : 100, type : Long, read : {row -> row.getCachedLength() })
closureColumn(header : "Comments", preferredWidth : 100, type : Boolean, read : {it.getComment() != null})
closureColumn(header : "Size", preferredWidth : 50, type : Long, read : {row -> row.getCachedLength() })
closureColumn(header : "Comments", preferredWidth : 50, type : Boolean, read : {it.getComment() != null})
closureColumn(header : "Search Hits", preferredWidth: 50, type : Integer, read : {it.getHits()})
closureColumn(header : "Downloaders", preferredWidth: 50, type : Integer, read : {it.getDownloaders().size()})
}
}
}