summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJens Bache-Wiig <jbache@trolltech.com>2009-08-04 14:54:07 (GMT)
committerJens Bache-Wiig <jbache@trolltech.com>2009-08-04 14:57:54 (GMT)
commitc9a449af8d17e493950a63ca3f8a22232968c47e (patch)
tree9debe4f19aefec457c1aca4ffb5ef80a791c43ea /src
parented375675d4a4f6fd63edeb242e23c87b3de4be6f (diff)
downloadQt-c9a449af8d17e493950a63ca3f8a22232968c47e.zip
Qt-c9a449af8d17e493950a63ca3f8a22232968c47e.tar.gz
Qt-c9a449af8d17e493950a63ca3f8a22232968c47e.tar.bz2
Make file extension case insensitive with the Gtk+ file dialog
The Qt dialog treats extension filters as case insensitive where the default behavior of the Gtk+ file dialog is to be case sensitive. The GtkFileFilter allows only simple glob syntax to be used so we basically rewrite the extension string from .xyz to .[xX][yY][zZ]. Task-number: 259155 Reviewed-by: joao
Diffstat (limited to 'src')
-rw-r--r--src/gui/styles/gtksymbols.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/gui/styles/gtksymbols.cpp b/src/gui/styles/gtksymbols.cpp
index be9b10a..b2c53f3 100644
--- a/src/gui/styles/gtksymbols.cpp
+++ b/src/gui/styles/gtksymbols.cpp
@@ -733,7 +733,24 @@ static void setupGtkFileChooser(GtkWidget* gtkFileChooser, QWidget *parent,
QGtk::gtk_file_filter_set_name(gtkFilter, qPrintable(name.isEmpty() ? extensions.join(QLS(", ")) : name));
foreach (const QString &fileExtension, extensions) {
- QGtk::gtk_file_filter_add_pattern (gtkFilter, qPrintable(fileExtension));
+ // Note Gtk file dialogs are by default case sensitive
+ // and only supports basic glob syntax so we
+ // rewrite .xyz to .[xX][yY][zZ]
+ QString caseInsensitive;
+ for (int i = 0 ; i < fileExtension.length() ; ++i) {
+ QChar ch = fileExtension.at(i);
+ if (ch.isLetter()) {
+ caseInsensitive.append(
+ QLatin1Char('[') +
+ ch.toLower() +
+ ch.toUpper() +
+ QLatin1Char(']'));
+ } else {
+ caseInsensitive.append(ch);
+ }
+ }
+ QGtk::gtk_file_filter_add_pattern (gtkFilter, qPrintable(caseInsensitive));
+
}
QGtk::gtk_file_chooser_add_filter((GtkFileChooser*)gtkFileChooser, gtkFilter);
if (selectedFilter && (rawfilter == *selectedFilter))