mirror of https://github.com/zlatinb/muwire
filter library by keywords more similar to network search. Github issue #61
parent
72c23b0417
commit
0bada3b66c
|
@ -587,12 +587,13 @@ class MainFrameController {
|
|||
void filterLibrary() {
|
||||
JTextField field = builder.getVariable("library-filter-textfield")
|
||||
String filter = field.getText()
|
||||
if (filter != null)
|
||||
filter = filter.strip()
|
||||
if (filter == null || filter.length() == 0)
|
||||
model.filter = null
|
||||
else
|
||||
model.filter = filter.toLowerCase()
|
||||
if (filter == null)
|
||||
return
|
||||
filter = filter.strip().replaceAll(SplitPattern.SPLIT_PATTERN," ").toLowerCase()
|
||||
String [] split = filter.split(" ")
|
||||
def hs = new HashSet()
|
||||
split.each {if (it.length() > 0) hs << it}
|
||||
model.filter = hs.toArray(new String[0])
|
||||
model.filterLibrary()
|
||||
}
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ class MainFrameModel {
|
|||
|
||||
// Library model
|
||||
@Observable boolean filteringEnabled
|
||||
volatile String filter
|
||||
volatile String[] filter
|
||||
volatile Filterer filterer
|
||||
boolean treeVisible = true
|
||||
private final Set<SharedFile> allSharedFiles = Collections.synchronizedSet(new LinkedHashSet<>())
|
||||
|
@ -470,7 +470,12 @@ class MainFrameModel {
|
|||
private boolean filter(SharedFile sharedFile) {
|
||||
if (filter == null)
|
||||
return true
|
||||
sharedFile.getCachedPath().containsIgnoreCase(filter)
|
||||
String path = sharedFile.getCachedPath()
|
||||
boolean contains = true
|
||||
for (String keyword : filter) {
|
||||
contains &= path.contains(keyword)
|
||||
}
|
||||
contains
|
||||
}
|
||||
|
||||
void filterLibrary() {
|
||||
|
|
Loading…
Reference in New Issue