mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Add preferences setting for maximum search depth in script folders. Clean up context menu a bit. (#9012)
This commit is contained in:
@@ -38,14 +38,13 @@ RimScriptCollection::RimScriptCollection()
|
||||
CAF_PDM_InitObject( "ScriptLocation", ":/Folder.png" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &directory, "ScriptDirectory", "Folder" );
|
||||
directory.uiCapability()->setUiReadOnly( true );
|
||||
directory.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &calcScripts, "CalcScripts", "" );
|
||||
calcScripts.uiCapability()->setUiTreeHidden( true );
|
||||
CAF_PDM_InitFieldNoDefault( &subDirectories, "SubDirectories", "" );
|
||||
subDirectories.uiCapability()->setUiTreeHidden( true );
|
||||
|
||||
CAF_PDM_InitField( &m_searchSubFolders, "SearchSubFolders", false, "Add Subfolders" );
|
||||
|
||||
directory.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -60,15 +59,19 @@ RimScriptCollection::~RimScriptCollection()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimScriptCollection::readContentFromDisc()
|
||||
void RimScriptCollection::readContentFromDisc( int folderLevelsLeft )
|
||||
{
|
||||
calcScripts.deleteChildren();
|
||||
subDirectories.deleteChildren();
|
||||
|
||||
folderLevelsLeft--;
|
||||
if ( folderLevelsLeft < 0 ) return;
|
||||
|
||||
if ( directory().isEmpty() )
|
||||
{
|
||||
for ( size_t i = 0; i < subDirectories.size(); ++i )
|
||||
{
|
||||
if ( subDirectories[i] ) subDirectories[i]->readContentFromDisc();
|
||||
if ( subDirectories[i] ) subDirectories[i]->readContentFromDisc( folderLevelsLeft );
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -104,9 +107,7 @@ void RimScriptCollection::readContentFromDisc()
|
||||
}
|
||||
}
|
||||
|
||||
subDirectories.deleteChildren();
|
||||
|
||||
if ( m_searchSubFolders() )
|
||||
if ( folderLevelsLeft > 0 )
|
||||
{
|
||||
QDir dir( directory );
|
||||
QFileInfoList fileInfoList = dir.entryInfoList( QDir::AllDirs | QDir::NoDotAndDotDot | QDir::Readable );
|
||||
@@ -120,7 +121,7 @@ void RimScriptCollection::readContentFromDisc()
|
||||
RimScriptCollection* scriptLocation = new RimScriptCollection;
|
||||
scriptLocation->directory = fi.absoluteFilePath();
|
||||
scriptLocation->setUiName( fi.baseName() );
|
||||
scriptLocation->readContentFromDisc();
|
||||
scriptLocation->readContentFromDisc( folderLevelsLeft );
|
||||
|
||||
subDirectories.push_back( scriptLocation );
|
||||
}
|
||||
@@ -128,25 +129,6 @@ void RimScriptCollection::readContentFromDisc()
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimScriptCollection::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
||||
const QVariant& oldValue,
|
||||
const QVariant& newValue )
|
||||
{
|
||||
if ( &directory == changedField )
|
||||
{
|
||||
QFileInfo fi( directory );
|
||||
this->setUiName( fi.baseName() );
|
||||
this->readContentFromDisc();
|
||||
}
|
||||
else if ( &m_searchSubFolders == changedField )
|
||||
{
|
||||
this->readContentFromDisc();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user