mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
2743 Origin summary import dialog adjustments
This commit is contained in:
@@ -94,3 +94,28 @@ QString RiaFilePathTools::canonicalPath(const QString& path)
|
||||
{
|
||||
return QDir(path).absolutePath();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RiaFilePathTools::commonRootPath(const QStringList& paths)
|
||||
{
|
||||
QString root = paths.front();
|
||||
for (const auto& item : paths)
|
||||
{
|
||||
if (root.length() > item.length()) root.truncate(item.length());
|
||||
|
||||
int iDir = 0;
|
||||
for (int i = 0; i < root.length(); ++i)
|
||||
{
|
||||
if (i > 0 && (root[i-1] == '/' || root[i-1] == '\\')) iDir = i;
|
||||
|
||||
if (root[i] != item[i])
|
||||
{
|
||||
root.truncate(std::min(i, iDir));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return root;
|
||||
}
|
||||
|
||||
@@ -37,4 +37,5 @@ public:
|
||||
static QString relativePath(const QString& rootDir, const QString& dir);
|
||||
static bool equalPaths(const QString& path1, const QString& path2);
|
||||
static QString canonicalPath(const QString& path);
|
||||
static QString commonRootPath(const QStringList& paths);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user