mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4687 Summary Template : Add UI to select template
#4705 Summary Template : Add icon and use from features and dialogs
This commit is contained in:
@@ -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 );
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user