diff --git a/src/main/java/mediathek/gui/tabs/tab_film/helpers/GuiFilmeModelHelper.java b/src/main/java/mediathek/gui/tabs/tab_film/helpers/GuiFilmeModelHelper.java index bc12df66c..5569ff8b4 100644 --- a/src/main/java/mediathek/gui/tabs/tab_film/helpers/GuiFilmeModelHelper.java +++ b/src/main/java/mediathek/gui/tabs/tab_film/helpers/GuiFilmeModelHelper.java @@ -9,7 +9,6 @@ import mediathek.gui.tabs.tab_film.searchfilters.FinalStageFilterNoPatternWithDescription; import mediathek.gui.tabs.tab_film.searchfilters.FinalStagePatternFilter; import mediathek.gui.tabs.tab_film.searchfilters.FinalStagePatternFilterWithDescription; -import mediathek.javafx.filterpanel.FilmLengthSlider; import mediathek.javafx.filterpanel.FilterActionPanel; import mediathek.tool.Filter; import mediathek.tool.models.TModelFilm; @@ -33,43 +32,11 @@ public GuiFilmeModelHelper(@NotNull FilterActionPanel filterActionPanel, this.searchFieldData = searchFieldData; } - private String getFilterThema() { - String filterThema = filterActionPanel.getViewSettingsPane().themaComboBox.getSelectionModel().getSelectedItem(); - if (filterThema == null) { - filterThema = ""; - } - - return filterThema; - } - - @Override - protected boolean noFiltersAreSet() { - var filmLengthSlider = filterActionPanel.getFilmLengthSlider(); - - return filterActionPanel.getViewSettingsPane().senderCheckList.getCheckModel().isEmpty() - && getFilterThema().isEmpty() - && searchFieldData.isEmpty() - && ((int) filmLengthSlider.getLowValue() == 0) - && ((int) filmLengthSlider.getHighValue() == FilmLengthSlider.UNLIMITED_VALUE) - && !filterActionPanel.isDontShowAbos() - && !filterActionPanel.isShowUnseenOnly() - && !filterActionPanel.isShowOnlyHighQuality() - && !filterActionPanel.isShowSubtitlesOnly() - && !filterActionPanel.isShowLivestreamsOnly() - && !filterActionPanel.isShowNewOnly() - && !filterActionPanel.isShowBookMarkedOnly() - && !filterActionPanel.isDontShowTrailers() - && !filterActionPanel.isDontShowSignLanguage() - && !filterActionPanel.isDontShowAudioVersions(); - } - - private void performTableFiltering() { arrIrgendwo = searchFieldData.evaluateThemaTitel(); calculateFilmLengthSliderValues(); - final String filterThema = getFilterThema(); final ObservableList selectedSenders = filterActionPanel.getViewSettingsPane().senderCheckList.getCheckModel().getCheckedItems(); if (filterActionPanel.isShowUnseenOnly()) @@ -101,15 +68,8 @@ private void performTableFiltering() { if (filterActionPanel.isShowSubtitlesOnly()) { stream = stream.filter(this::subtitleCheck); } - if (!filterThema.isEmpty()) { - stream = stream.filter(film -> film.getThema().equalsIgnoreCase(filterThema)); - } - if (maxLength < FilmLengthSlider.UNLIMITED_VALUE) { - stream = stream.filter(this::maxLengthCheck); - } - if (filterActionPanel.isShowUnseenOnly()) { - stream = stream.filter(this::seenCheck); - } + + stream = applyCommonFilters(stream); //perform min length filtering after all others may have reduced the available entries... stream = stream.filter(this::minLengthCheck); diff --git a/src/main/java/mediathek/gui/tabs/tab_film/helpers/GuiModelHelper.java b/src/main/java/mediathek/gui/tabs/tab_film/helpers/GuiModelHelper.java index a6eb4d0b0..17e5d490e 100644 --- a/src/main/java/mediathek/gui/tabs/tab_film/helpers/GuiModelHelper.java +++ b/src/main/java/mediathek/gui/tabs/tab_film/helpers/GuiModelHelper.java @@ -3,10 +3,12 @@ import mediathek.controller.history.SeenHistoryController; import mediathek.daten.DatenFilm; import mediathek.gui.tabs.tab_film.SearchFieldData; +import mediathek.javafx.filterpanel.FilmLengthSlider; import mediathek.javafx.filterpanel.FilterActionPanel; import javax.swing.table.TableModel; import java.util.concurrent.TimeUnit; +import java.util.stream.Stream; public abstract class GuiModelHelper { protected SliderRange sliderRange; @@ -34,7 +36,51 @@ protected boolean minLengthCheck(DatenFilm film) { return filmLength >= sliderRange.minLengthInSeconds(); } - protected abstract boolean noFiltersAreSet(); + protected String getFilterThema() { + String filterThema = filterActionPanel.getViewSettingsPane().themaComboBox.getSelectionModel().getSelectedItem(); + if (filterThema == null) { + filterThema = ""; + } + + return filterThema; + } + + protected Stream applyCommonFilters(Stream stream) { + final String filterThema = getFilterThema(); + if (!filterThema.isEmpty()) { + stream = stream.filter(film -> film.getThema().equalsIgnoreCase(filterThema)); + } + if (maxLength < FilmLengthSlider.UNLIMITED_VALUE) { + stream = stream.filter(this::maxLengthCheck); + } + if (filterActionPanel.isShowUnseenOnly()) { + stream = stream.filter(this::seenCheck); + } + //perform min length filtering after all others may have reduced the available entries... + stream = stream.filter(this::minLengthCheck); + + return stream; + } + + protected boolean noFiltersAreSet() { + var filmLengthSlider = filterActionPanel.getFilmLengthSlider(); + + return filterActionPanel.getViewSettingsPane().senderCheckList.getCheckModel().isEmpty() + && getFilterThema().isEmpty() + && searchFieldData.isEmpty() + && ((int) filmLengthSlider.getLowValue() == 0) + && ((int) filmLengthSlider.getHighValue() == FilmLengthSlider.UNLIMITED_VALUE) + && !filterActionPanel.isDontShowAbos() + && !filterActionPanel.isShowUnseenOnly() + && !filterActionPanel.isShowOnlyHighQuality() + && !filterActionPanel.isShowSubtitlesOnly() + && !filterActionPanel.isShowLivestreamsOnly() + && !filterActionPanel.isShowNewOnly() + && !filterActionPanel.isShowBookMarkedOnly() + && !filterActionPanel.isDontShowTrailers() + && !filterActionPanel.isDontShowSignLanguage() + && !filterActionPanel.isDontShowAudioVersions(); + } protected boolean seenCheck(DatenFilm film) { return !historyController.hasBeenSeenFromCache(film); diff --git a/src/main/java/mediathek/gui/tabs/tab_film/helpers/LuceneGuiFilmeModelHelper.java b/src/main/java/mediathek/gui/tabs/tab_film/helpers/LuceneGuiFilmeModelHelper.java index 0e9b4137e..c65adc860 100644 --- a/src/main/java/mediathek/gui/tabs/tab_film/helpers/LuceneGuiFilmeModelHelper.java +++ b/src/main/java/mediathek/gui/tabs/tab_film/helpers/LuceneGuiFilmeModelHelper.java @@ -8,7 +8,6 @@ import mediathek.daten.IndexedFilmList; import mediathek.gui.tabs.tab_film.SearchFieldData; import mediathek.gui.tasks.LuceneIndexKeys; -import mediathek.javafx.filterpanel.FilmLengthSlider; import mediathek.javafx.filterpanel.FilterActionPanel; import mediathek.javafx.filterpanel.ZeitraumSpinner; import mediathek.mainwindow.MediathekGui; @@ -54,34 +53,9 @@ public LuceneGuiFilmeModelHelper(@NotNull FilterActionPanel filterActionPanel, this.searchFieldData = searchFieldData; } - private String getFilterThema() { - String filterThema = filterActionPanel.getViewSettingsPane().themaComboBox.getSelectionModel().getSelectedItem(); - if (filterThema == null) { - filterThema = ""; - } - - return filterThema; - } - @Override protected boolean noFiltersAreSet() { - var filmLengthSlider = filterActionPanel.getFilmLengthSlider(); - - return filterActionPanel.getViewSettingsPane().senderCheckList.getCheckModel().isEmpty() - && getFilterThema().isEmpty() - && searchFieldData.isEmpty() - && ((int) filmLengthSlider.getLowValue() == 0) - && ((int) filmLengthSlider.getHighValue() == FilmLengthSlider.UNLIMITED_VALUE) - && !filterActionPanel.isDontShowAbos() - && !filterActionPanel.isShowUnseenOnly() - && !filterActionPanel.isShowOnlyHighQuality() - && !filterActionPanel.isShowSubtitlesOnly() - && !filterActionPanel.isShowLivestreamsOnly() - && !filterActionPanel.isShowNewOnly() - && !filterActionPanel.isShowBookMarkedOnly() - && !filterActionPanel.isDontShowTrailers() - && !filterActionPanel.isDontShowSignLanguage() - && !filterActionPanel.isDontShowAudioVersions() + return super.noFiltersAreSet() && filterActionPanel.zeitraumProperty().get().equalsIgnoreCase(ZeitraumSpinner.UNLIMITED_VALUE); } @@ -177,18 +151,7 @@ private TModelFilm performTableFiltering() { if (filterActionPanel.isDontShowAbos()) stream = stream.filter(film -> film.getAbo() == null); - final String filterThema = getFilterThema(); - if (!filterThema.isEmpty()) { - stream = stream.filter(film -> film.getThema().equalsIgnoreCase(filterThema)); - } - if (maxLength < FilmLengthSlider.UNLIMITED_VALUE) { - stream = stream.filter(this::maxLengthCheck); - } - if (filterActionPanel.isShowUnseenOnly()) { - stream = stream.filter(this::seenCheck); - } - //perform min length filtering after all others may have reduced the available entries... - stream = stream.filter(this::minLengthCheck); + stream = applyCommonFilters(stream); resultList = stream.collect(Collectors.toList()); //logger.trace("Resulting filmlist size after all filters applied: {}", resultList.size());