Summary: | Cannot save a png attachment | ||
---|---|---|---|
Product: | [Unmaintained] KOrganizer Mobile | Reporter: | Ludwig Reiter <ludwig.reiter> |
Component: | general | Assignee: | kdepim bugs <kdepim-bugs> |
Status: | CLOSED FIXED | ||
Severity: | normal | CC: | aheinecke |
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | Maemo 5 | ||
OS: | Microsoft Windows CE | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: |
Description
Ludwig Reiter
2010-11-24 15:08:42 UTC
SVN commit 1200997 by vkrause: Actually attempt to save image attachments. BUG: 256760 BUG: 257790 M +3 -0 AttachmentList.qml WebSVN link: http://websvn.kde.org/?view=rev&revision=1200997 version: 20101201.1202511 A file dialog opens. ok But it has preconfigured "Document" as file name. (failure) Save. The saved file has the size 0. (failure) Works fine on desktop, so it must be a plain Maemo/WinCE problem... Wince: Looking at the attachment shows a fine preview of the png, Test 1: -> Actions -> save all attachments - Save attachment dialog comes up - Filter ist set for all files - Filename is the filename for all attachments -> Added .png suffig to the filename -> Hit save - MessageBox: "Prozess kann nicht gestartet werden: Keine Verbindung zu klauncher: The name org.kde.klauncher was not provided by any .service files" - File is not saved Test 2: -> Hit save icon in the attachment flap - File Dialog comes up, filename is not the filename of the attachment but korganizer-mobile301570 -> save - file is created but without .png suffix can not be opened Test 3 -> Hit save icon in the attachment flap - File Dialog comes up, filename is not the filename of the attachment but korganizer-mobile301570 -> Change name to korganizer-mobile301570.png - save - file is there correctly The Test in Comment #4 was with version -gitfc6a857 from 2011-01-01 commit 523864bd8dc0d928b549a59fe6cf6ccde66953b1 branch master Author: Andre Heinecke <aheinecke@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(); commit 1c3bb63a51b8e6a06f21d7decbd63efcbc862bb0 branch master Author: Andre Heinecke <aheinecke@intevation.de> Date: Wed Jan 5 14:21:13 2011 +0000 Fix saveAllAttachments for WinCE. On Windows CE CalendarSupport::saveAttachments does not work. So we now do the AttachmentLookup directly and then use the KDeclarativeMainView saveAttachment function to do the actual saving. CCBUG: 257790 diff --git a/mobile/calendar/mainview.cpp b/mobile/calendar/mainview.cpp index edbdb60..43ba8e4 100644 --- a/mobile/calendar/mainview.cpp +++ b/mobile/calendar/mainview.cpp @@ -714,8 +714,37 @@ void MainView::fetchForSaveAllAttachmentsDone( KJob *job ) } const Akonadi::Item item = static_cast<Akonadi::ItemFetchJob*>( job )->items().first(); - +#ifndef Q_OS_WINCE CalendarSupport::saveAttachments( item, this ); +#else + // CalendarSupport is not completly ported for Windows CE so we use the + // attachment handling code from KDeclarativeMainView + KCalCore::Incidence::Ptr incidence = CalendarSupport::incidence( item ); + + if ( !incidence ) { + KMessageBox::sorry( + this, + i18n( "No item selected." ), + "SaveAttachments" ); + return; + } + + KCalCore::Attachment::List attachments = incidence->attachments(); + + if ( attachments.empty() ) + return; + + Q_FOREACH( KCalCore::Attachment::Ptr attachment, attachments ) { + QString fileName = attachment->label(); + QString sourceUrl; + if ( attachment->isUri() ) { + sourceUrl = attachment->uri(); + } else { + sourceUrl = incidence->writeAttachmentToTempFile( attachment ); + } + saveAttachment( sourceUrl, fileName ); + } +#endif //Q_OS_WINCE } void MainView::archiveOldEntries() Issue that remains is that when saving a single file from the attachment menu the filename is something like korganizer-mobile301570. Because the filename is there directly taken from the url which is a temporary file and not from the label as it should be. To reproduce Comment #8 -> Attach a file to an incidence -> Pull out the attachment flap when looking at that incidence -> hit the save icon in the bottom right corner commit 48068ac956521cac309005b36ad2638c1a727b57 branch master Author: Tobias Koenig <tokoe@kde.org> Date: Thu Jan 13 13:24:25 2011 +0100 Use display name as filename suggestion for saving BUG: 257790 diff --git a/mobile/calendar/korganizer-mobile.qml b/mobile/calendar/korganizer-mobile.qml index c47b47e..2eb0a41 100644 --- a/mobile/calendar/korganizer-mobile.qml +++ b/mobile/calendar/korganizer-mobile.qml @@ -507,7 +507,7 @@ KPIM.MainView { } onSaveAttachment: { - application.saveAttachment(url); + application.saveAttachment(url, fileName); } } ] diff --git a/mobile/lib/AttachmentList.qml b/mobile/lib/AttachmentList.qml index 343f718..3f3be4a 100644 --- a/mobile/lib/AttachmentList.qml +++ b/mobile/lib/AttachmentList.qml @@ -34,7 +34,7 @@ Item { /** Emittted when an attachment has been selected. */ signal openAttachment(string url, string mimeType) - signal saveAttachment(string url) + signal saveAttachment(string url, string fileName) Component { id: attachmentDelegate @@ -63,6 +63,7 @@ Item { wrapper.ListView.view.currentIndex = model.index wrapper.ListView.view.currentMimeType = model.mimeType; wrapper.ListView.view.currentAttachmentUrl = model.attachmentUrl; + wrapper.ListView.view.currentFileName = model.display; } } } @@ -71,6 +72,7 @@ Item { KPIM.DecoratedListView { property string currentMimeType property string currentAttachmentUrl + property string currentFileName id: attachmentListView anchors.top: parent.top @@ -87,6 +89,7 @@ Item { attachmentListView.currentIndex = -1 attachmentListView.currentMimeType = ""; attachmentListView.currentAttachmentUrl = ""; + attachmentListView.currentFileName = ""; } } } @@ -119,7 +122,7 @@ Item { height: parent.height / 6 buttonText: KDE.i18n( "Save" ) onClicked: { - saveAttachment(attachmentListView.currentAttachmentUrl); + saveAttachment(attachmentListView.currentAttachmentUrl, attachmentListView.currentFileName); } } } @@ -154,7 +157,7 @@ Item { height: 48 icon: KDE.iconPath( "document-save", width ); onClicked: { - saveAttachment(attachmentListView.currentAttachmentUrl); + saveAttachment(attachmentListView.currentAttachmentUrl, attachmentListView.currentFileName); } states: [ State { diff --git a/mobile/lib/kdeclarativemainview.cpp b/mobile/lib/kdeclarativemainview.cpp index dbff324..fafe342 100644 --- a/mobile/lib/kdeclarativemainview.cpp +++ b/mobile/lib/kdeclarativemainview.cpp @@ -748,7 +748,7 @@ void KDeclarativeMainView::openAttachment( const QString &url, const QString &mi #endif } -void KDeclarativeMainView::saveAttachment( const QString &url , const QString &defaultFileName) +void KDeclarativeMainView::saveAttachment( const QString &url, const QString &defaultFileName ) { QString fileName = defaultFileName; if ( defaultFileName.isEmpty() ) { diff --git a/mobile/mail/kmail-mobile.qml b/mobile/mail/kmail-mobile.qml index 66fb2fd..fae1896 100644 --- a/mobile/mail/kmail-mobile.qml +++ b/mobile/mail/kmail-mobile.qml @@ -489,7 +489,7 @@ KPIM.MainView { } onSaveAttachment: { - application.saveAttachment(url); + application.saveAttachment(url, fileName); } } ] diff --git a/mobile/tasks/tasks.qml b/mobile/tasks/tasks.qml index ee0448e..10ec061 100644 --- a/mobile/tasks/tasks.qml +++ b/mobile/tasks/tasks.qml @@ -341,7 +341,7 @@ KPIM.MainView { } onSaveAttachment: { - application.saveAttachment(url); + application.saveAttachment(url, fileName); } } ] Calendar Touch (Windows CE) 2011-01-16 Test of the description: passed Closed. |