Summary: | some file dialogs are save and not load dialogs | ||
---|---|---|---|
Product: | [Applications] Kleopatra Mobile | Reporter: | Marcus Brinkmann <marcus.brinkmann> |
Component: | general | Assignee: | Andre Heinecke <aheinecke> |
Status: | VERIFIED FIXED | ||
Severity: | normal | CC: | aheinecke |
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | Windows CE | ||
OS: | Microsoft Windows CE | ||
Latest Commit: | Version Fixed In: |
Description
Marcus Brinkmann
2011-01-19 02:19:20 UTC
Certificate export is the correct dialog, but the default filename is the fingerprint of the certificate and there is no file type filter preset. During a test i was able to save a file to /My Documents/mytestcert.der without problems after entering mytestcert.der as the filename. commit 650d05a1bdb5ea60f6bf1c9eb5ae5a601120b364 branch master Author: Andre Heinecke <aheinecke@intevation.de> Date: Wed Jan 19 18:28:10 2011 +0000 Convert filters to kde format for kfiledialog Instead of disabling filters when KFileDialog is used they are now converted to the correct format. The qt2KdeFilter is a copy out of KFileDialog. CCBUG: 263604 diff --git a/kleopatra/utils/filedialog.cpp b/kleopatra/utils/filedialog.cpp index de7b826..4c28158 100644 --- a/kleopatra/utils/filedialog.cpp +++ b/kleopatra/utils/filedialog.cpp @@ -38,6 +38,7 @@ #ifdef QT_NO_FILEDIALOG #include <KFileDialog> #include <KUrl> +#include <QTextStream> #endif #include <QMap> @@ -62,6 +63,35 @@ static void update( const QString & fname, const QString & id ) { (*dir_id_2_dir_map())[ id ] = QFileInfo( fname ).absolutePath(); } +#ifdef QT_NO_FILEDIALOG +static QString qt2KdeFilter(const QString &f) +{ + QString filter; + QTextStream str(&filter, QIODevice::WriteOnly); + QStringList list(f.split(";;").replaceInStrings("/", "\\/")); + QStringList::const_iterator it(list.begin()), + end(list.end()); + bool first=true; + + for(; it!=end; ++it) + { + int ob=(*it).lastIndexOf('('), + cb=(*it).lastIndexOf(')'); + + if(-1!=cb && ob<cb) + { + if(first) + first=false; + else + str << '\n'; + str << (*it).mid(ob+1, (cb-ob)-1) << '|' << (*it).mid(0, ob); + } + } + + return filter; +} +#endif + QString FileDialog::getExistingDirectory( QWidget * parent, const QString & caption, const QString & dirID ) { #ifndef QT_NO_FILEDIALOG const QString fname = QFileDialog::getExistingDirectory( parent, caption, dir( dirID ) ); @@ -76,8 +106,7 @@ QString FileDialog::getOpenFileName( QWidget * parent, const QString & caption, #ifndef QT_NO_FILEDIALOG const QString fname = QFileDialog::getOpenFileName( parent, caption, dir( dirID ), filter ); #else - Q_UNUSED( filter ); // incompatible syntax - const QString fname = KFileDialog::getOpenFileName( dir( dirID ), QString(), parent, caption ); + const QString fname = KFileDialog::getOpenFileName( dir( dirID ), qt2KdeFilter( filter ), parent, caption ); #endif update( fname, dirID ); return fname; @@ -87,8 +116,7 @@ QStringList FileDialog::getOpenFileNames( QWidget * parent, const QString & capt #ifndef QT_NO_FILEDIALOG const QStringList files = QFileDialog::getOpenFileNames( parent, caption, dir( dirID ), filter ); #else - Q_UNUSED( filter ); // incompatible syntax - const QStringList files = KFileDialog::getOpenFileNames( dir( dirID ), QString(), parent, caption ); + const QStringList files = KFileDialog::getOpenFileNames( dir( dirID ), qt2KdeFilter( filter ), parent, caption ); #endif if ( !files.empty() ) update( files.front(), dirID ); @@ -99,8 +127,7 @@ QString FileDialog::getSaveFileName( QWidget * parent, const QString & caption, #ifndef QT_NO_FILEDIALOG const QString fname = QFileDialog::getSaveFileName( parent, caption, dir( dirID ), filter ); #else - Q_UNUSED( filter ); // incompatible syntax - const QString fname = KFileDialog::getSaveFileName( dir( dirID ), QString(), parent, caption ); + const QString fname = KFileDialog::getSaveFileName( dir( dirID ), qt2KdeFilter( filter ), parent, caption ); #endif update( fname, dirID ); return fname; @@ -112,7 +139,7 @@ QString FileDialog::getSaveFileNameEx( QWidget * parent, const QString & caption #ifndef QT_NO_FILEDIALOG const QString fname = QFileDialog::getSaveFileName( parent, caption, QDir( dir( dirID ) ).filePath( proposedFileName ), filter ); #else - const QString fname = KFileDialog::getSaveFileName( QDir( dir( dirID ) ).filePath( proposedFileName ), QString(), parent, caption ); + const QString fname = KFileDialog::getSaveFileName( QDir( dir( dirID ) ).filePath( proposedFileName ), qt2KdeFilter( filter ), parent, caption ); #endif update( fname, dirID ); return fname; Andre, do you believe this is fixed, by your patch? The certificate export dialog was fixed, the save certificate request uses the same code but i was not able to test it since i did not get that far in the certifcate generation. Git commit 0a594ef9ee1ebc538cf7f8f5696e2ec606286cb2 by Andre Heinecke Pushed by aheinecke into branch master Do not set the KFileDialog save default to a dir This is more of a problem in KFileDialog when there are no Qt filedialogs available. The setting for the start FileName is not recognized as a folder and set to a directory. This only happens if there is no proposedFileName available. BUG: 263604 M +3 -2 kleopatra/utils/filedialog.cpp http://commits.kde.org/ee6cc38b/0a594ef9ee1ebc538cf7f8f5696e2ec606286cb2 |