mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
System: Created a general basename cleanup function, and applied that when creating filenames from userdescription etc. Related to #1054 preparations
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
#include "RimWellLogCurve.h"
|
||||
#include "RimWellLogExtractionCurve.h"
|
||||
|
||||
#include "cafUtils.h"
|
||||
#include "cvfAssert.h"
|
||||
|
||||
#include "laswell.hpp"
|
||||
@@ -146,41 +147,34 @@ public:
|
||||
|
||||
std::string generateFilename() const
|
||||
{
|
||||
QString f;
|
||||
QString fileBasenameCandidate;
|
||||
QString separator("-");
|
||||
|
||||
if (!m_wellName.isEmpty())
|
||||
{
|
||||
f += m_wellName;
|
||||
fileBasenameCandidate += m_wellName;
|
||||
}
|
||||
|
||||
if (!m_caseName.isEmpty())
|
||||
{
|
||||
if (!f.isEmpty()) f += separator;
|
||||
f += m_caseName;
|
||||
if (!fileBasenameCandidate.isEmpty()) fileBasenameCandidate += separator;
|
||||
fileBasenameCandidate += m_caseName;
|
||||
}
|
||||
|
||||
// Add property name if only one curve is exported
|
||||
if (m_logCurveData.size() == 1)
|
||||
{
|
||||
if (!f.isEmpty()) f += separator;
|
||||
f += QString::fromStdString(m_logCurveData[0].channelName());
|
||||
if (!fileBasenameCandidate.isEmpty()) fileBasenameCandidate += separator;
|
||||
fileBasenameCandidate += QString::fromStdString(m_logCurveData[0].channelName());
|
||||
}
|
||||
|
||||
if (!m_date.isEmpty())
|
||||
{
|
||||
if (!f.isEmpty()) f += separator;
|
||||
f += m_date;
|
||||
if (!fileBasenameCandidate.isEmpty()) fileBasenameCandidate += separator;
|
||||
fileBasenameCandidate += m_date;
|
||||
}
|
||||
|
||||
QString cleanFileName = f.trimmed();
|
||||
cleanFileName.replace(".", "_");
|
||||
cleanFileName.replace(",", "_");
|
||||
cleanFileName.replace(":", "_");
|
||||
cleanFileName.replace(";", "_");
|
||||
cleanFileName.replace(" ", "_");
|
||||
cleanFileName.replace("/", "_");
|
||||
cleanFileName.replace(QRegExp("_+"), "_");
|
||||
QString cleanFileName = caf::Utils::makeValidFileBasename( fileBasenameCandidate);
|
||||
|
||||
cleanFileName += ".las";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user