wip on grouping by file

This commit is contained in:
Zlatin Balevsky
2019-11-08 18:15:54 +00:00
parent db84d8e5bf
commit 76d8d847bd
7 changed files with 51 additions and 7 deletions

View File

@@ -90,6 +90,7 @@ class MainFrameController {
params["search-terms"] = search
params["uuid"] = uuid.toString()
params["core"] = core
params["settings"] = view.settings
def group = mvcGroup.createMVCGroup("SearchTab", uuid.toString(), params)
model.results[uuid.toString()] = group

View File

@@ -155,6 +155,8 @@ class OptionsController {
uiSettings.autoFontSize = model.automaticFontSize
uiSettings.fontSize = Integer.parseInt(view.fontSizeField.text)
uiSettings.groupByFile = model.groupByFile
boolean clearCancelledDownloads = view.clearCancelledDownloadsCheckbox.model.isSelected()
model.clearCancelledDownloads = clearCancelledDownloads
uiSettings.clearCancelledDownloads = clearCancelledDownloads
@@ -242,6 +244,16 @@ class OptionsController {
model.closeDecisionMade = true
}
@ControllerAction
void groupByFile() {
model.groupByFile = true
}
@ControllerAction
void groupBySender() {
model.groupByFile = false
}
@ControllerAction
void clearHistory() {
uiSettings.searchHistory.clear()

View File

@@ -42,6 +42,7 @@ class OptionsModel {
@Observable boolean excludeLocalResult
@Observable boolean showSearchHashes
@Observable boolean clearUploads
@Observable boolean groupByFile
@Observable boolean exitOnClose
@Observable boolean closeDecisionMade
@@ -92,6 +93,7 @@ class OptionsModel {
clearUploads = uiSettings.clearUploads
exitOnClose = uiSettings.exitOnClose
storeSearchHistory = uiSettings.storeSearchHistory
groupByFile = uiSettings.groupByFile
if (core.router != null) {
inBw = String.valueOf(settings.inBw)

View File

@@ -76,9 +76,14 @@ class SearchTabModel {
sourcesBucket.put(e.infohash, sourceBucket)
}
sourceBucket.addAll(e.sources)
results2.clear()
results2.addAll(hashBucket.keySet())
JTable table = builder.getVariable("senders-table")
table.model.fireTableDataChanged()
table = builder.getVariable("results-table2")
table.model.fireTableDataChanged()
}
}

View File

@@ -200,10 +200,16 @@ class OptionsView {
panel (border : titledBorder(title : "Search Settings", border : etchedBorder(), titlePosition : TitledBorder.TOP),
constraints : gbc(gridx : 0, gridy : 1, fill : GridBagConstraints.HORIZONTAL, weightx : 100)) {
gridBagLayout()
label(text : "Remember search history", constraints: gbc(gridx: 0, gridy:0, anchor : GridBagConstraints.LINE_START, weightx: 100))
label(text : "By default, group search results by", constraints : gbc(gridx :0, gridy: 0, anchor : GridBagConstraints.LINE_START, weightx : 100))
panel(constraints : gbc(gridx : 1, gridy : 0, anchor : GridBagConstraints.LINE_END)) {
buttonGroup(id : "groupBy")
radioButton(text : "Sender", selected : bind {!model.groupByFile}, buttonGroup : groupBy, groupBySenderAction)
radioButton(text : "File", selected : bind {model.groupByFile}, buttonGroup : groupBy, groupByFileAction)
}
label(text : "Remember search history", constraints: gbc(gridx: 0, gridy:1, anchor : GridBagConstraints.LINE_START, weightx: 100))
storeSearchHistoryCheckbox = checkBox(selected : bind {model.storeSearchHistory},
constraints : gbc(gridx : 1, gridy:0, anchor : GridBagConstraints.LINE_END))
button(text : "Clear history", constraints : gbc(gridx : 1, gridy : 1, anchor : GridBagConstraints.LINE_END), clearHistoryAction)
constraints : gbc(gridx : 1, gridy:1, anchor : GridBagConstraints.LINE_END))
button(text : "Clear history", constraints : gbc(gridx : 1, gridy : 2, anchor : GridBagConstraints.LINE_END), clearHistoryAction)
}
panel (border : titledBorder(title : "Other Settings", border : etchedBorder(), titlePosition : TitledBorder.TOP),

View File

@@ -39,6 +39,8 @@ class SearchTabView {
FactoryBuilderSupport builder
@MVCMember @Nonnull
SearchTabModel model
UISettings settings
def pane
def parent
@@ -175,6 +177,7 @@ class SearchTabView {
tableModel(list : model.senders2) {
closureColumn(header : "Sender", preferredWidth : 350, type : String, read : {it.sender.getHumanReadableName()})
closureColumn(header : "Browse", preferredWidth : 20, type : Boolean, read : {it.browse})
closureColumn(header : "Comment", preferredWidth : 20, type : Boolean, read : {it.comment != null})
closureColumn(header : "Certificates", preferredWidth : 20, type: Integer, read : {it.certificates})
closureColumn(header : "Trust", preferredWidth : 50, type : String, read : {
model.core.trustService.getLevel(it.sender.destination).toString()
@@ -202,8 +205,8 @@ class SearchTabView {
panel (constraints : BorderLayout.SOUTH) {
label(text : "Group by")
buttonGroup(id : "groupBy")
radioButton(text : "Sender", selected : true, buttonGroup : groupBy, actionPerformed: showSenderGrouping)
radioButton(text : "File", selected : false, buttonGroup : groupBy, actionPerformed: showFileGrouping)
radioButton(text : "Sender", selected : bind {!model.groupedByFile}, buttonGroup : groupBy, actionPerformed: showSenderGrouping)
radioButton(text : "File", selected : bind {model.groupedByFile}, buttonGroup : groupBy, actionPerformed: showFileGrouping)
}
}
@@ -344,6 +347,14 @@ class SearchTabView {
sendersTable2.model.fireTableDataChanged()
})
resultsTable2.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() > 1 && e.button == MouseEvent.BUTTON1)
mvcGroup.controller.download()
}
})
// TODO: add download right-click action
// senders table 2
@@ -358,15 +369,19 @@ class SearchTabView {
model.browseActionEnabled = false
model.viewCertificatesActionEnabled = false
model.trustButtonsEnabled = false
model.viewCommentActionEnabled = false
return
}
model.browseActionEnabled = model.senders2[row].browse
model.trustButtonsEnabled = true
model.viewCommentActionEnabled = model.senders2[row].comment != null
model.viewCertificatesActionEnabled = model.senders2[row].certificates > 0
})
showSenderGrouping.call()
if (settings.groupByFile)
showFileGrouping.call()
else
showSenderGrouping.call()
}
def closeTab = {