mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-10 23:46:00 -06:00
Allow relative paths in replace case
This commit is contained in:
parent
bbc8750d8f
commit
7a2b9926a0
@ -26,6 +26,9 @@
|
||||
|
||||
#include "RimProject.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RicfSingleCaseReplace, "replaceCase");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -69,13 +72,21 @@ RicfCommandResponse RicfSingleCaseReplace::execute()
|
||||
|
||||
cvf::ref<RiaProjectModifier> projectModifier = new RiaProjectModifier;
|
||||
|
||||
QString filePath = m_newGridFile();
|
||||
QFileInfo casePathInfo(filePath);
|
||||
if (!casePathInfo.exists())
|
||||
{
|
||||
QDir startDir(RiaApplication::instance()->startDir());
|
||||
filePath = startDir.absoluteFilePath(m_newGridFile());
|
||||
}
|
||||
|
||||
if (m_caseId() < 0)
|
||||
{
|
||||
projectModifier->setReplaceCaseFirstOccurrence(m_newGridFile());
|
||||
}
|
||||
else
|
||||
{
|
||||
projectModifier->setReplaceCase(m_caseId(), m_newGridFile());
|
||||
projectModifier->setReplaceCase(m_caseId(), );
|
||||
}
|
||||
|
||||
if (!RiaApplication::instance()->loadProject(lastProjectPath, RiaApplication::PLA_NONE, projectModifier.p()))
|
||||
@ -128,8 +139,15 @@ RicfCommandResponse RicfMultiCaseReplace::execute()
|
||||
cvf::ref<RiaProjectModifier> projectModifier = new RiaProjectModifier;
|
||||
for (const auto& a : m_caseIdToGridFileNameMap)
|
||||
{
|
||||
const auto caseId = a.first;
|
||||
const auto filePath = a.second;
|
||||
const int caseId = a.first;
|
||||
QString filePath = a.second;
|
||||
QFileInfo casePathInfo(filePath);
|
||||
if (!casePathInfo.exists())
|
||||
{
|
||||
QDir startDir(RiaApplication::instance()->startDir());
|
||||
filePath = startDir.absoluteFilePath(filePath);
|
||||
}
|
||||
|
||||
if (caseId < 0)
|
||||
{
|
||||
projectModifier->setReplaceCaseFirstOccurrence(filePath);
|
||||
|
@ -56,7 +56,6 @@ def test_PdmObject(rips_instance, initializeTest):
|
||||
assert(case.id == 0)
|
||||
assert(case.address() is not 0)
|
||||
assert(case.classKeyword() == "EclipseCase")
|
||||
assert(case.getValue('CaseFileName') == casePath)
|
||||
caseId = case.getValue('CaseId')
|
||||
assert(caseId == case.id)
|
||||
|
||||
@ -84,7 +83,7 @@ def test_replaceCase(rips_instance, initializeTest):
|
||||
cases = rips_instance.project.cases()
|
||||
assert(len(cases) is 1)
|
||||
|
||||
rips_instance.commands.replaceCase(newGridFile=os.path.abspath(casePath), caseId=case.id)
|
||||
rips_instance.commands.replaceCase(newGridFile=casePath, caseId=case.id)
|
||||
cases = rips_instance.project.cases()
|
||||
assert(len(cases) is 1)
|
||||
case = project.case(id=0)
|
||||
|
Loading…
Reference in New Issue
Block a user