summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@theqtcompany.com>2016-02-10 08:24:50 +0100
committerAndy Shaw <andy.shaw@theqtcompany.com>2016-03-02 14:24:45 +0000
commit82b8158022064851ef9151d441241aa4019605c2 (patch)
treec1299bd7330595eefe1791136a374eaad0667f5f /src
parent0db793fe4117c243361d4b8eff4fb5ab87f66020 (diff)
Windows: Extract the suffix from the simple file filter case
Since the filter can either be something like "*.txt" or "Text Files (*.txt)" then it should have the suffix default to "txt" in both cases. Change-Id: I36a72f5bf0fb12c84db103f91c4fca94d0d933ae Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/platforms/windows/qwindowsdialoghelpers.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
index 2d75e1720a..ca5b90b429 100644
--- a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
+++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
@@ -1466,18 +1466,21 @@ public:
};
// Return the first suffix from the name filter "Foo files (*.foo;*.bar)" -> "foo".
+// Also handles the simple name filter case "*.txt" -> "txt"
static inline QString suffixFromFilter(const QString &filter)
{
- int suffixPos = filter.indexOf(QLatin1String("(*."));
+ int suffixPos = filter.indexOf(QLatin1String("*."));
if (suffixPos < 0)
return QString();
- suffixPos += 3;
+ suffixPos += 2;
int endPos = filter.indexOf(QLatin1Char(' '), suffixPos + 1);
if (endPos < 0)
endPos = filter.indexOf(QLatin1Char(';'), suffixPos + 1);
if (endPos < 0)
endPos = filter.indexOf(QLatin1Char(')'), suffixPos + 1);
- return endPos >= 0 ? filter.mid(suffixPos, endPos - suffixPos) : QString();
+ if (endPos < 0)
+ endPos = filter.size();
+ return filter.mid(suffixPos, endPos - suffixPos);
}
void QWindowsNativeSaveFileDialog::setNameFilters(const QStringList &f)