mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-02-06 04:00:08 +00:00
Added a couple of methods to PluginListComponent to allow deletion of selected plugins and access to the listbox.
This commit is contained in:
parent
611abe7812
commit
65da989cd0
2 changed files with 37 additions and 17 deletions
|
|
@ -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<int> 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 <PluginDescription> typesFound;
|
||||
OwnedArray<PluginDescription> typesFound;
|
||||
list.scanAndAddDragAndDroppedFiles (formatManager, files, typesFound);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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<TableModel>;
|
||||
ScopedPointer<TableModel> tableModel;
|
||||
ScopedPointer<TableListBoxModel> 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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue