#4687 Summary Template : Add UI to select template

#4705 Summary Template : Add icon and use from features and dialogs
This commit is contained in:
Magne Sjaastad
2019-09-12 08:43:09 +02:00
parent d045c0aade
commit 7fc0a47443
11 changed files with 256 additions and 57 deletions

View File

@@ -34,7 +34,7 @@ CAF_PDM_SOURCE_INIT( RimPlotTemplateFileItem, "PlotTemplateFileItem" );
//--------------------------------------------------------------------------------------------------
RimPlotTemplateFileItem::RimPlotTemplateFileItem()
{
CAF_PDM_InitObject( "PlotTemplateFileItem", ":/OctaveScriptFile16x16.png", "Calc Script", "" );
CAF_PDM_InitObject( "PlotTemplateFileItem", ":/SummaryTemplate16x16.png", "Plot Template", "" );
CAF_PDM_InitField( &m_absoluteFileName, "AbsolutePath", QString(), "Location", "", "", "" );
m_absoluteFileName.uiCapability()->setUiReadOnly( true );

View File

@@ -74,6 +74,15 @@ std::vector<RimPlotTemplateFolderItem*> RimPlotTemplateFolderItem::subFolders()
return m_subFolders.childObjects();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotTemplateFolderItem::appendOptionItemsForPlotTemplates( QList<caf::PdmOptionItemInfo>& options,
RimPlotTemplateFolderItem* templateFolderItem )
{
appendOptionItemsForPlotTemplatesRecursively( options, templateFolderItem, 0 );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -176,6 +185,37 @@ void RimPlotTemplateFolderItem::defineEditorAttribute( const caf::PdmFieldHandle
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotTemplateFolderItem::appendOptionItemsForPlotTemplatesRecursively(
QList<caf::PdmOptionItemInfo>& options, RimPlotTemplateFolderItem* templateFolderItem, int menuLevel )
{
{
auto subFolders = templateFolderItem->subFolders();
for ( auto sub : subFolders )
{
caf::PdmOptionItemInfo optionInfo = caf::PdmOptionItemInfo::createHeader( sub->uiName(), true );
optionInfo.setLevel( menuLevel );
options.push_back( optionInfo );
appendOptionItemsForPlotTemplatesRecursively( options, sub, menuLevel + 1 );
}
}
caf::QIconProvider templateIcon( ":/SummaryTemplate16x16.png" );
auto files = templateFolderItem->fileNames();
for ( auto file : files )
{
caf::PdmOptionItemInfo optionInfo( file->uiName(), file, false, templateIcon );
optionInfo.setLevel( menuLevel );
options.push_back( optionInfo );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -46,6 +46,9 @@ public:
std::vector<RimPlotTemplateFileItem*> fileNames() const;
std::vector<RimPlotTemplateFolderItem*> subFolders() const;
static void appendOptionItemsForPlotTemplates( QList<caf::PdmOptionItemInfo>& options,
RimPlotTemplateFolderItem* templateFolderItem );
private:
void searchForFileAndFolderNames();
void setFolderPath( const QString& path );
@@ -60,6 +63,10 @@ private:
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute ) override;
static void appendOptionItemsForPlotTemplatesRecursively( QList<caf::PdmOptionItemInfo>& options,
RimPlotTemplateFolderItem* templateFolderItem,
int menuLevel );
private:
caf::PdmField<caf::FilePath> m_folderName;
caf::PdmChildArrayField<RimPlotTemplateFileItem*> m_fileNames;