From 31046164628d4e890cd39b19ee5255509eb5431f Mon Sep 17 00:00:00 2001 From: jules Date: Mon, 19 Dec 2016 12:09:00 +0000 Subject: [PATCH] Added some copy/paste options for module paths to the Projucer's module listbox --- .../Source/Project/jucer_ModulesPanel.h | 38 ++++++++++++++++--- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/extras/Projucer/Source/Project/jucer_ModulesPanel.h b/extras/Projucer/Source/Project/jucer_ModulesPanel.h index 42036cfd36..c6197e7195 100644 --- a/extras/Projucer/Source/Project/jucer_ModulesPanel.h +++ b/extras/Projucer/Source/Project/jucer_ModulesPanel.h @@ -44,6 +44,7 @@ public: addAndMakeVisible (table); table.updateContent(); table.setRowHeight (20); + table.setMultipleSelectionEnabled (true); addAndMakeVisible (setCopyModeButton); addAndMakeVisible (copyPathButton); @@ -154,6 +155,7 @@ private: ValueTree modulesValueTree; TableListBox table; TextButton setCopyModeButton, copyPathButton; + std::map modulePathClipboard; void valueTreePropertyChanged (ValueTree&, const Identifier&) override { itemChanged(); } void valueTreeChildAdded (ValueTree&, ValueTree&) override { itemChanged(); } @@ -182,30 +184,56 @@ private: void showSetPathsMenu() { - EnabledModuleList& moduleList = project.getModules(); + enum + { + copyPathsToAllModulesID = 1, + copyPathsID, + pastePathsID + }; - const String moduleToCopy (moduleList.getModuleID (table.getSelectedRow())); + auto& moduleList = project.getModules(); + auto moduleToCopy = moduleList.getModuleID (table.getSelectedRow()); if (moduleToCopy.isNotEmpty()) { PopupMenu m; - m.addItem (1, "Copy the paths from the module '" + moduleToCopy + "' to all other modules"); + m.addItem (copyPathsToAllModulesID, "Copy the paths from the module '" + moduleToCopy + "' to all other modules"); + m.addItem (copyPathsID, "Copy paths from selected module", table.getNumSelectedRows() == 1); + m.addItem (pastePathsID, "Paste paths to selected modules", ! modulePathClipboard.empty()); int res = m.showAt (©PathButton); - if (res != 0) + if (res == copyPathsToAllModulesID) { for (Project::ExporterIterator exporter (project); exporter.next();) { for (int i = 0; i < moduleList.getNumModules(); ++i) { - String modID = moduleList.getModuleID (i); + auto modID = moduleList.getModuleID (i); if (modID != moduleToCopy) exporter->getPathForModuleValue (modID) = exporter->getPathForModuleValue (moduleToCopy).getValue(); } } } + else if (res == copyPathsID) + { + modulePathClipboard.clear(); + + for (Project::ExporterIterator exporter (project); exporter.next();) + modulePathClipboard[exporter->getName()] = exporter->getPathForModuleValue (moduleToCopy).getValue(); + } + else if (res == pastePathsID) + { + for (int selectionId = 0; selectionId < table.getNumSelectedRows(); ++selectionId) + { + auto rowNumber = table.getSelectedRow (selectionId); + auto modID = moduleList.getModuleID (rowNumber); + + for (Project::ExporterIterator exporter (project); exporter.next();) + exporter->getPathForModuleValue (modID) = modulePathClipboard[exporter->getName()]; + } + } table.repaint(); }