| 167 | } |
| 168 | |
| 169 | void PluginSearchWindow::updateTree(const String& filter) { |
| 170 | traceScope(); |
| 171 | |
| 172 | auto addFn = [this](const ServerPlugin& p, const String& l) { |
| 173 | traceScope(); |
| 174 | if (m_onClick) { |
| 175 | m_onClick(p, l); |
| 176 | } |
| 177 | hide(); |
| 178 | }; |
| 179 | |
| 180 | auto* root = m_tree.getRootItem(); |
| 181 | root->clearSubItems(); |
| 182 | |
| 183 | m_tree.setDefaultOpenness(filter.isNotEmpty()); |
| 184 | |
| 185 | if (filter.isEmpty() && !m_recents.isEmpty()) { |
| 186 | int countAdded = 0; |
| 187 | for (const auto& p : m_recents) { |
| 188 | if (auto* plug = getPlugin(p.getType() + p.getName())) { |
| 189 | auto* plugEntry = new TreePlugin( |
| 190 | *plug, [this] { updateHeight(); }, false, true); |
| 191 | root->addSubItem(plugEntry); |
| 192 | if (plug->getLayouts().isEmpty()) { |
| 193 | plugEntry->addSubItem(new TreeLayout(*plug, "Default", addFn)); |
| 194 | } else { |
| 195 | for (auto& l : plug->getLayouts()) { |
| 196 | plugEntry->addSubItem(new TreeLayout(*plug, l, addFn)); |
| 197 | } |
| 198 | } |
| 199 | plugEntry->setOpenness(TreeViewItem::Openness::opennessClosed); |
| 200 | countAdded++; |
| 201 | } |
| 202 | } |
| 203 | if (countAdded > 0) { |
| 204 | root->addSubItem(new TreeSeparator()); |
| 205 | } |
| 206 | } |
| 207 | |
| 208 | auto filterParts = StringArray::fromTokens(filter, " ", ""); |
| 209 | |
| 210 | // ceate menu structure: [type] -> [category] -> [company] -> plugin |
| 211 | MenuLevel menuRoot; |
| 212 | for (const auto& type : m_processor.getPluginTypes()) { |
| 213 | for (const auto& plug : m_processor.getPlugins(type)) { |
| 214 | if (filterParts.size() > 0) { |
| 215 | bool match = true; |
| 216 | for (auto& f : filterParts) { |
| 217 | if (f.isNotEmpty() && !plug.getName().containsIgnoreCase(f) && |
| 218 | !plug.getCompany().containsIgnoreCase(f) && !plug.getCategory().containsIgnoreCase(f)) { |
| 219 | match = false; |
| 220 | } |
| 221 | } |
| 222 | if (!match) { |
| 223 | continue; |
| 224 | } |
| 225 | } |
| 226 |
nothing calls this directly
no test coverage detected