diff options
| author | Crystalwarrior <Varsash@Gmail.com> | 2022-07-16 16:51:05 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-16 15:51:05 +0200 |
| commit | fef33dfc4fd5644c0db97fe33ff789fb55d6d081 (patch) | |
| tree | fc3dd30359200c15bf853f1ebed46cc7137284c4 | |
| parent | e587c76eb0f858bf969216fed7b85603f6080906 (diff) | |
Optimize area list slightly by recycling QTreeWidgetItems instead of clearing and creating them every time (#754)
Remove index that only shows up during ARUP cuz it confuses the hell out of area indexes defined by server
Co-authored-by: stonedDiscord <Tukz@gmx.de>
| -rw-r--r-- | src/courtroom.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 030cc134..300b34b6 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -1690,9 +1690,6 @@ void Courtroom::list_music() // Todo: multithread this due to some servers having large as hell area list void Courtroom::list_areas() { - ui_area_list->clear(); - // ui_music_search->setText(""); - int n_listed_areas = 0; for (int n_area = 0; n_area < area_list.size(); ++n_area) { @@ -1700,8 +1697,6 @@ void Courtroom::list_areas() i_area.append(area_list.at(n_area)); if (ao_app->arup_enabled) { - i_area.prepend("[" + QString::number(n_area) + "] "); // Give it the index - i_area.append("\n "); i_area.append(arup_statuses.at(n_area)); @@ -1722,7 +1717,10 @@ void Courtroom::list_areas() } - QTreeWidgetItem *treeItem = new QTreeWidgetItem(ui_area_list); + QTreeWidgetItem *treeItem = ui_area_list->topLevelItem(n_area); + if (treeItem == nullptr) { + treeItem = new QTreeWidgetItem(ui_area_list); + } treeItem->setText(0, area_list.at(n_area)); treeItem->setText(1, i_area); @@ -1752,6 +1750,10 @@ void Courtroom::list_areas() ++n_listed_areas; } + while (ui_area_list->topLevelItemCount() > n_listed_areas) { + ui_area_list->takeTopLevelItem(ui_area_list->topLevelItemCount()-1); + } + if (ui_music_search->text() != "") { on_music_search_edited(ui_music_search->text()); } |
