diff --git a/modules/juce_audio_processors/scanning/juce_PluginListComponent.cpp b/modules/juce_audio_processors/scanning/juce_PluginListComponent.cpp index a0c2388cfa..adff877481 100644 --- a/modules/juce_audio_processors/scanning/juce_PluginListComponent.cpp +++ b/modules/juce_audio_processors/scanning/juce_PluginListComponent.cpp @@ -85,7 +85,7 @@ public: void deleteKeyPressed (int) override { - owner.removeSelected(); + owner.removeSelectedPlugins(); } void sortOrderChanged (int newSortColumnId, bool isForwards) override @@ -102,14 +102,6 @@ public: } } - static void removePluginItem (KnownPluginList& list, int index) - { - if (index < list.getNumTypes()) - list.removeType (index); - else - list.removeFromBlacklist (list.getBlacklistedFiles() [index - list.getNumTypes()]); - } - static String getPluginDescription (const PluginDescription& desc) { StringArray items; @@ -207,13 +199,24 @@ void PluginListComponent::updateList() table.repaint(); } -void PluginListComponent::removeSelected() +void PluginListComponent::removeSelectedPlugins() { const SparseSet selected (table.getSelectedRows()); for (int i = table.getNumRows(); --i >= 0;) if (selected.contains (i)) - TableModel::removePluginItem (list, i); + removePluginItem (i); +} + +void PluginListComponent::setTableModel (TableListBoxModel* model) +{ + table.setModel (nullptr); + tableModel = model; + table.setModel (tableModel); + + table.getHeader().reSortTable(); + table.updateContent(); + table.repaint(); } bool PluginListComponent::canShowSelectedFolder() const @@ -238,6 +241,14 @@ void PluginListComponent::removeMissingPlugins() list.removeType (i); } +void PluginListComponent::removePluginItem (int index) +{ + if (index < list.getNumTypes()) + list.removeType (index); + else + list.removeFromBlacklist (list.getBlacklistedFiles() [index - list.getNumTypes()]); +} + void PluginListComponent::optionsMenuStaticCallback (int result, PluginListComponent* pluginList) { if (pluginList != nullptr) @@ -250,7 +261,7 @@ void PluginListComponent::optionsMenuCallback (int result) { case 0: break; case 1: list.clear(); break; - case 2: removeSelected(); break; + case 2: removeSelectedPlugins(); break; case 3: showSelectedFolder(); break; case 4: removeMissingPlugins(); break; @@ -293,7 +304,7 @@ bool PluginListComponent::isInterestedInFileDrag (const StringArray& /*files*/) void PluginListComponent::filesDropped (const StringArray& files, int, int) { - OwnedArray typesFound; + OwnedArray typesFound; list.scanAndAddDragAndDroppedFiles (formatManager, files, typesFound); } diff --git a/modules/juce_audio_processors/scanning/juce_PluginListComponent.h b/modules/juce_audio_processors/scanning/juce_PluginListComponent.h index 97751a8022..2c21c3f756 100644 --- a/modules/juce_audio_processors/scanning/juce_PluginListComponent.h +++ b/modules/juce_audio_processors/scanning/juce_PluginListComponent.h @@ -72,6 +72,17 @@ public: /** Returns true if there's currently a scan in progress. */ bool isScanning() const noexcept; + /** Removes the plugins currently selected in the table. */ + void removeSelectedPlugins(); + + /** Sets a custom table model to be used. + This will take ownership of the model and delete it when no longer needed. + */ + void setTableModel (TableListBoxModel* model); + + /** Returns the table used to display the plugin list. */ + TableListBox& getTableListBox() noexcept { return table; } + private: //============================================================================== AudioPluginFormatManager& formatManager; @@ -83,9 +94,7 @@ private: int numThreads; class TableModel; - friend class TableModel; - friend struct ContainerDeletePolicy; - ScopedPointer tableModel; + ScopedPointer tableModel; class Scanner; friend class Scanner; @@ -98,8 +107,8 @@ private: void updateList(); void showSelectedFolder(); bool canShowSelectedFolder() const; - void removeSelected(); void removeMissingPlugins(); + void removePluginItem (int index); void resized() override; bool isInterestedInFileDrag (const StringArray&) override;