[Bug 257790] Cannot save a png attachment
Andre Heinecke
aheinecke at intevation.de
Wed Jan 5 14:26:33 GMT 2011
https://bugs.kde.org/show_bug.cgi?id=257790
--- Comment #6 from Andre Heinecke <aheinecke intevation de> 2011-01-05 15:26:31 ---
commit 523864bd8dc0d928b549a59fe6cf6ccde66953b1
branch master
Author: Andre Heinecke <aheinecke at intevation.de>
Date: Wed Jan 5 13:46:18 2011 +0000
Modifiy attachment save function.
Allow to supply a defaultFileName for saveAttachment that is
independend ot the Url and will be preselected in the FileDialog.
Also check if the MimeType of the attachment can be determined and
if so use the patterns of this mimetype as a filter so that the
file Suffix is correctly set.
CCBUG: 257790
diff --git a/mobile/lib/kdeclarativemainview.cpp
b/mobile/lib/kdeclarativemainview.cpp
index e713b16..094b1f6 100644
--- a/mobile/lib/kdeclarativemainview.cpp
+++ b/mobile/lib/kdeclarativemainview.cpp
@@ -738,15 +738,23 @@ void KDeclarativeMainView::openAttachment( const QString
&url, const QString &mi
#endif
}
-void KDeclarativeMainView::saveAttachment( const QString &url )
+void KDeclarativeMainView::saveAttachment( const QString &url , const QString
&defaultFileName)
{
- QString fileName = KUrl( url ).fileName();
- if ( fileName.isEmpty() ) {
- fileName = i18nc( "filename for an unnamed attachment", "attachment.1" );
+ QString fileName = defaultFileName;
+ if ( defaultFileName.isEmpty() ) {
+ fileName = KUrl( url ).fileName();
+ if ( fileName.isEmpty() ) {
+ fileName = i18nc( "filename for an unnamed attachment", "attachment.1"
);
+ }
+ }
+ QStringList patterns = KMimeType::findByUrl( url, 0, true, true, 0
)->patterns();
+ QString filter = QString();
+ if ( !patterns.isEmpty() ) {
+ filter += patterns.join( QLatin1String( "\n" ) );
+ filter += i18n( "\n*|all files" );
}
-
const QString targetFile = KFileDialog::getSaveFileName( KUrl(
"kfiledialog:///saveAttachment/" + fileName ),
- QString(),
+ filter,
this,
i18n( "Save
Attachment" ) );
if ( targetFile.isEmpty() ) {
diff --git a/mobile/lib/kdeclarativemainview.h
b/mobile/lib/kdeclarativemainview.h
index dad6f03..672f177 100644
--- a/mobile/lib/kdeclarativemainview.h
+++ b/mobile/lib/kdeclarativemainview.h
@@ -172,7 +172,7 @@ class MOBILEUI_EXPORT KDeclarativeMainView : public
KDeclarativeFullScreenView
void openManual();
void openAttachment( const QString &url, const QString &mimeType );
- void saveAttachment( const QString &url );
+ void saveAttachment( const QString &url, const QString &defaultFileName =
QString() );
void reportBug();
--
Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
More information about the Kdepim-bugs
mailing list