diff --git a/ApplicationLibCode/Commands/PlotTemplateCommands/RicSelectPlotTemplateUi.cpp b/ApplicationLibCode/Commands/PlotTemplateCommands/RicSelectPlotTemplateUi.cpp index c471fdf4dd..99ffaf400d 100644 --- a/ApplicationLibCode/Commands/PlotTemplateCommands/RicSelectPlotTemplateUi.cpp +++ b/ApplicationLibCode/Commands/PlotTemplateCommands/RicSelectPlotTemplateUi.cpp @@ -56,8 +56,23 @@ void RicSelectPlotTemplateUi::setMultiSelectMode( bool multiSelect ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicSelectPlotTemplateUi::setInitialSelection( std::vector selectedTemplates ) +void RicSelectPlotTemplateUi::setInitialSelection( const std::vector& selectedTemplates ) { + auto plotTemplateRoot = RimProject::current()->rootPlotTemplateItem(); + + std::vector fileItems; + RimPlotTemplateFolderItem::allPlotTemplates( fileItems, plotTemplateRoot ); + + for ( const auto& selectedTemplate : selectedTemplates ) + { + for ( const auto& fileItem : fileItems ) + { + if ( fileItem->absoluteFilePath() == selectedTemplate ) + { + m_selectedPlotTemplates.push_back( fileItem ); + } + } + } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/PlotTemplateCommands/RicSelectPlotTemplateUi.h b/ApplicationLibCode/Commands/PlotTemplateCommands/RicSelectPlotTemplateUi.h index 9b584027da..09869786f4 100644 --- a/ApplicationLibCode/Commands/PlotTemplateCommands/RicSelectPlotTemplateUi.h +++ b/ApplicationLibCode/Commands/PlotTemplateCommands/RicSelectPlotTemplateUi.h @@ -39,7 +39,7 @@ public: RicSelectPlotTemplateUi(); void setMultiSelectMode( bool multiSelect ); - void setInitialSelection( std::vector selectedTemplates ); + void setInitialSelection( const std::vector& selectedTemplates ); std::vector selectedPlotTemplates(); diff --git a/ApplicationLibCode/ProjectDataModel/PlotTemplates/RimPlotTemplateFolderItem.cpp b/ApplicationLibCode/ProjectDataModel/PlotTemplates/RimPlotTemplateFolderItem.cpp index 6dcd38add2..baba20195c 100644 --- a/ApplicationLibCode/ProjectDataModel/PlotTemplates/RimPlotTemplateFolderItem.cpp +++ b/ApplicationLibCode/ProjectDataModel/PlotTemplates/RimPlotTemplateFolderItem.cpp @@ -83,7 +83,7 @@ void RimPlotTemplateFolderItem::updateIconState() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimPlotTemplateFolderItem::fileNames() const +std::vector RimPlotTemplateFolderItem::fileItems() const { return m_fileNames.children(); } @@ -105,6 +105,24 @@ void RimPlotTemplateFolderItem::appendOptionItemsForPlotTemplates( QList& fileTemplates, + RimPlotTemplateFolderItem* templateFolderItem ) +{ + auto fileItems = templateFolderItem->fileItems(); + for ( auto fileItem : fileItems ) + { + fileTemplates.push_back( fileItem ); + } + + for ( auto folder : templateFolderItem->subFolders() ) + { + allPlotTemplates( fileTemplates, folder ); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -230,7 +248,7 @@ void RimPlotTemplateFolderItem::appendOptionItemsForPlotTemplatesRecursively( QL caf::IconProvider templateIcon( ":/SummaryTemplate16x16.png" ); caf::IconProvider ensTemplateIcon( ":/SummaryEnsembleTemplate16x16.png" ); - auto files = templateFolderItem->fileNames(); + auto files = templateFolderItem->fileItems(); for ( auto file : files ) { caf::IconProvider icon = templateIcon; diff --git a/ApplicationLibCode/ProjectDataModel/PlotTemplates/RimPlotTemplateFolderItem.h b/ApplicationLibCode/ProjectDataModel/PlotTemplates/RimPlotTemplateFolderItem.h index 35a61283ef..e0b5d2cac4 100644 --- a/ApplicationLibCode/ProjectDataModel/PlotTemplates/RimPlotTemplateFolderItem.h +++ b/ApplicationLibCode/ProjectDataModel/PlotTemplates/RimPlotTemplateFolderItem.h @@ -43,11 +43,14 @@ public: void createRootFolderItemsFromFolderPaths( const QStringList& folderPaths ); - std::vector fileNames() const; + std::vector fileItems() const; std::vector subFolders() const; static void appendOptionItemsForPlotTemplates( QList& options, RimPlotTemplateFolderItem* templateFolderItem ); + + static void allPlotTemplates( std::vector& fileItems, + RimPlotTemplateFolderItem* templateFolderItem ); void updateIconState() const; private: