KDE/kdelibs/kio/kfile

Christian Ehrlicher Ch.Ehrlicher at gmx.de
Thu Sep 18 19:27:07 CEST 2008


SVN commit 862361 by chehrlic:

Fix set mime type filter via KFileDialog ctor on windows

BUG: 167771
CCMAIL: kde-windows at kde.org

 M  +16 -8     kfiledialog.cpp  


--- trunk/KDE/kdelibs/kio/kfile/kfiledialog.cpp #862360:862361
@@ -222,7 +222,12 @@
     d->w = ::qobject_cast<KAbstractFileWidget *>(fileQWidget);
 
     if (d->native) {
-        d->native->filter = filter;
+        // check if it's a mimefilter
+        int pos = filter.indexOf('/');
+        if (pos > 0 && filter[pos - 1] != '\\')
+          setMimeFilter(filter.split(QLatin1Char(' '), QString::SkipEmptyParts));
+        else
+          setFilter(filter);
         return;
     }
 
@@ -272,7 +277,7 @@
 void KFileDialog::setFilter(const QString& filter)
 {
     if (d->native) {
-        d->native->filter = filter;
+        d->native->filter = qtFilter(filter);
         return;
     }
     d->w->setFilter(filter);
@@ -291,13 +296,16 @@
     d->w->setMimeFilter(mimeTypes, defaultType);
 
     if (d->native) {
-        QString kdeFilter;
+        const KUrl emptyUrl;
+        QStringList kdeFilter;
         foreach( const QString& mimeType, mimeTypes ) {
             KMimeType::Ptr mime( KMimeType::mimeType(mimeType) );
             if (mime)
-               kdeFilter += (mime->patterns().join(" ") + QLatin1Char('|') + mime->comment());
+               kdeFilter.append(mime->patterns().join(QLatin1String(" ")) +
+                                QLatin1Char('|') +
+                                mime->comment(emptyUrl));
         }
-        d->native->filter = kdeFilter;
+        d->native->filter = qtFilter(kdeFilter);
     }
 }
 
@@ -390,7 +398,7 @@
             parent,
             caption.isEmpty() ? i18n("Open") : caption,
             KFileDialogPrivate::Native::staticStartDir( startDir ).path(),
-            qtFilter(filter) );
+            filter );
 // TODO use extra args?     QString * selectedFilter = 0, Options options = 0
     }
     KFileDialog dlg(startDir, filter, parent);
@@ -437,7 +445,7 @@
             parent,
             caption.isEmpty() ? i18n("Open") : caption,
             KFileDialogPrivate::Native::staticStartDir( startDir ).path(),
-            qtFilter(filter) );
+            filter );
 // TODO use extra args?  QString * selectedFilter = 0, Options options = 0
     }
     KFileDialog dlg(startDir, filter, parent);
@@ -605,7 +613,7 @@
             parent,
             caption.isEmpty() ? i18n("Save As") : caption,
             KFileDialogPrivate::Native::staticStartDir( startDir ).path(),
-            qtFilter(filter) );
+            filter );
 // TODO use extra args?     QString * selectedFilter = 0, Options options = 0
         if (!result.isEmpty()) {
             if (!recentDirClass.isEmpty())


More information about the Kde-windows mailing list