AttachmentView: no duplicate signals, disable downloadbuttons on download
commit1be92fec6afc0ce251a0d670c8f5601109259203
authorCaspar Schutijser <caspar@schutijser.com>
Fri, 28 Jun 2013 11:34:45 +0000 (28 13:34 +0200)
committerCaspar Schutijser <caspar@schutijser.com>
Fri, 28 Jun 2013 12:00:22 +0000 (28 14:00 +0200)
tree85c4493976244374554bf964db40a1ce0fe92566
parent395c5db7ebfa14b08c4c80eafa83f4172887b484
AttachmentView: no duplicate signals, disable downloadbuttons on download

The signals for the m_openingsManager are now connected in the
constructor, not in AttachmentView::slotOpenAttachment(). This prevents
duplicate connections being created.

While here, also disable the downloadbutton when downloading an
attachment. To implement this, I added a started() signal to
FileDownloadManager, used to indicate when the transfer starts.
Just disabling the downloadbutton in
AttachmentView::slotDownloadAttachment() causes problems when the user
clicks "Download" and then closes the File Dialog without selecting a
file. manager->downloadPart() then returns without downloading the file,
so it doesn't emit a succeeded() or transferError() signal. By creating
a started() signal, we know for sure that the downloadbutton only is
disabled when a transfer really happens. The downloadbutton will be
enabled upon success or failure.

For consistency, FileDownloadManager::downloadMessage() also emits
a started() signal when it starts downloading, although that signal is
not used anywhere.

This commit also renames slotTransferSucceeded() to
slotDeleteTemporaryFile(). I did this because slotTransferSucceeded()
seems to be a general name that can be used for both "Open directly"
and "Download", but it wasn't in the old situation. The "new"
slotTransferSucceeded() only enables the downloadbutton.

AttachmentView::slotOpenAttachment() will only download the attachment
if the temporary file does not exist yet.
src/Gui/AttachmentView.cpp
src/Gui/AttachmentView.h
src/Imap/Network/FileDownloadManager.cpp
src/Imap/Network/FileDownloadManager.h