|
|
@ -6,6 +6,7 @@ import os |
|
|
from ui.workers.gather_home_storage_status_worker import GatherHomeStorageStatus |
|
|
from ui.workers.gather_home_storage_status_worker import GatherHomeStorageStatus |
|
|
from ui.workers.gather_pokemon_forms_worker import GatherPokemonFormsWorker |
|
|
from ui.workers.gather_pokemon_forms_worker import GatherPokemonFormsWorker |
|
|
|
|
|
|
|
|
|
|
|
from utility.functions import get_display_name |
|
|
from db import db |
|
|
from db import db |
|
|
|
|
|
|
|
|
class MainWindowController: |
|
|
class MainWindowController: |
|
|
@ -21,6 +22,7 @@ class MainWindowController: |
|
|
def initialize_pokemon_list(self, data): |
|
|
def initialize_pokemon_list(self, data): |
|
|
self.pokemon_data_cache = data |
|
|
self.pokemon_data_cache = data |
|
|
self.view.update_pokemon_forms(data) |
|
|
self.view.update_pokemon_forms(data) |
|
|
|
|
|
self.apply_filters() |
|
|
|
|
|
|
|
|
def filter_pokemon_list(self): |
|
|
def filter_pokemon_list(self): |
|
|
self.filter_timer.start() |
|
|
self.filter_timer.start() |
|
|
@ -29,9 +31,12 @@ class MainWindowController: |
|
|
search_text = self.view.search_bar.text().lower() |
|
|
search_text = self.view.search_bar.text().lower() |
|
|
show_only_home_storable = self.view.filter_home_storable.isChecked() |
|
|
show_only_home_storable = self.view.filter_home_storable.isChecked() |
|
|
show_only_missing_encounters = self.view.highlight_no_encounters.isChecked() |
|
|
show_only_missing_encounters = self.view.highlight_no_encounters.isChecked() |
|
|
|
|
|
gender_relevant = False |
|
|
|
|
|
|
|
|
filtered_data = [] |
|
|
filtered_data = [] |
|
|
for pfic, display_name in self.pokemon_data_cache: |
|
|
for pokemon in self.pokemon_data_cache: |
|
|
|
|
|
display_name = get_display_name(pokemon) |
|
|
|
|
|
pfic = pokemon["pfic"] |
|
|
# Check if the item matches the search text |
|
|
# Check if the item matches the search text |
|
|
text_match = search_text in display_name.lower() |
|
|
text_match = search_text in display_name.lower() |
|
|
|
|
|
|
|
|
@ -47,9 +52,13 @@ class MainWindowController: |
|
|
# TODO: reimplement this check. |
|
|
# TODO: reimplement this check. |
|
|
has_encounters = True |
|
|
has_encounters = True |
|
|
|
|
|
|
|
|
|
|
|
include_gender = True |
|
|
|
|
|
if gender_relevant == False and pokemon["gender_relevant"] == False: |
|
|
|
|
|
include_gender = not any(item["pfic"][:-2] == pfic[:-2] for item in filtered_data) |
|
|
|
|
|
|
|
|
# If both conditions are met, add to filtered data |
|
|
# If both conditions are met, add to filtered data |
|
|
if text_match and home_storable: |
|
|
if text_match and home_storable and include_gender: |
|
|
filtered_data.append((pfic, display_name)) |
|
|
filtered_data.append(pokemon) |
|
|
|
|
|
|
|
|
# Update the view with the filtered data |
|
|
# Update the view with the filtered data |
|
|
self.view.update_pokemon_forms(filtered_data) |
|
|
self.view.update_pokemon_forms(filtered_data) |
|
|
@ -91,7 +100,7 @@ class MainWindowController: |
|
|
# This method will be called in the main thread when the worker finishes |
|
|
# This method will be called in the main thread when the worker finishes |
|
|
# Update the UI with the gathered forms |
|
|
# Update the UI with the gathered forms |
|
|
for pokemon in data: |
|
|
for pokemon in data: |
|
|
db.add_pokemon_form(pokemon["pfic"], pokemon["name"], pokemon["form_name"], pokemon["national_dex"], pokemon["generation"], pokemon["sprite_url"]) |
|
|
db.add_pokemon_form(pokemon["pfic"], pokemon["name"], pokemon["form_name"], pokemon["national_dex"], pokemon["generation"], pokemon["sprite_url"], pokemon["gender_relevant"]) |
|
|
self.pokemon_data_cache = data |
|
|
self.pokemon_data_cache = data |
|
|
self.view.update_pokemon_forms(data) |
|
|
self.view.update_pokemon_forms(data) |
|
|
|
|
|
|
|
|
|