diff options
| author | iamgoofball <iamgoofball@gmail.com> | 2019-01-23 01:07:20 -0800 |
|---|---|---|
| committer | iamgoofball <iamgoofball@gmail.com> | 2019-01-23 01:07:20 -0800 |
| commit | f75032840450263bfe27d3b5a68ea1458a0ce8a5 (patch) | |
| tree | 27525521826fd01038970fa7347cacaad31404e3 /src | |
| parent | 906c9016bb4660eb0445a3345a55ede959c3cb96 (diff) | |
Multithreaded filtering of the character list
Diffstat (limited to 'src')
| -rw-r--r-- | src/charselect.cpp | 52 |
1 files changed, 32 insertions, 20 deletions
diff --git a/src/charselect.cpp b/src/charselect.cpp index e6d9c9f4..c5a10bde 100644 --- a/src/charselect.cpp +++ b/src/charselect.cpp @@ -29,6 +29,35 @@ public: } }; +class AOCharSelectFilterThreading : public QRunnable +{ +public: + Courtroom *mycourt_fuck; + int char_num; + AOCharSelectFilterThreading(Courtroom *my_courtroom, int character_number){ + mycourt_fuck = my_courtroom; + char_num = character_number; + } + void run() + { + AOCharButton* current_char = mycourt_fuck->ui_char_button_list.at(char_num); + + if (!mycourt_fuck->ui_char_taken->isChecked() && mycourt_fuck->char_list.at(char_num).taken) + return; + + if (!mycourt_fuck->char_list.at(char_num).name.contains(mycourt_fuck->ui_char_search->text(), Qt::CaseInsensitive)) + return; + + // We only really need to update the fact that a character is taken + // for the buttons that actually appear. + // You'd also update the passwordedness and etc. here later. + current_char->reset(); + current_char->set_taken(mycourt_fuck->char_list.at(char_num).taken); + + mycourt_fuck->ui_char_button_list_filtered.append(current_char); + } +}; + void Courtroom::construct_char_select() { ui_char_select_background = new AOImage(this, ao_app); @@ -234,27 +263,10 @@ void Courtroom::filter_character_list() ui_char_button_list_filtered.clear(); for (int i = 0; i < char_list.size(); i++) { - AOCharButton* current_char = ui_char_button_list.at(i); - - // It seems passwording characters is unimplemented yet? - // Until then, this will stay here, I suppose. - //if (ui_char_passworded->isChecked() && character_is_passworded??) - // continue; - - if (!ui_char_taken->isChecked() && char_list.at(i).taken) - continue; - - if (!char_list.at(i).name.contains(ui_char_search->text(), Qt::CaseInsensitive)) - continue; - - // We only really need to update the fact that a character is taken - // for the buttons that actually appear. - // You'd also update the passwordedness and etc. here later. - current_char->reset(); - current_char->set_taken(char_list.at(i).taken); - - ui_char_button_list_filtered.append(current_char); + AOCharSelectFilterThreading *char_filter = new AOCharSelectFilterThreading(this, i); + QThreadPool::globalInstance()->start(char_filter); } + QThreadPool::globalInstance()->waitForDone(); current_char_page = 0; set_char_select_page(); |
