[PATCH] KParts::ReadWritePart::saveAs - again ;-)

David Faure faure at kde.org
Wed Mar 10 12:25:27 GMT 2004


On Tuesday 09 March 2004 18:39, Andras Mantia wrote:
> Hi,
> 
>  The save() and saveAs() methods are supposed to return a boolean value, an
> although it's not clearly documented, it should be true on success and false
> on failure. This works fine in case of local files, but as soon as you save a
> non-local file, it will always return true, as the saving is asynchronous.
> This wouldn't be a big problem itself (although makes the function to behave
> differently in case of non-local files), as there is a completed () and
> canceled (const QString &errMsg) signal that one can use to check the result
> of the save. The real problem comes here: it's not usable, as in case of
> local files on failure there is no such signal emitted,  unless the KPart
> emits it in the reimplemented saveFile() method. But why should it emit, if
> in all other cases it's emitted in the KParts::ReadWritePart.

The idea was the app would use progress/completed/canceled to show progress
(which is only needed for remote files), and possible errors in canceled().

> +  else
> +    emit canceled("");

This is IMHO very inconsistent. saveFile doesn't emit completed() either.

> +   * problem with an appropriate message box and should emit the
> +   * canceled() signal with the error message as argument.
> +   * Standard error  messages can be constructed using KIO::buildErrorString()

canceled("") means canceled by the user. That's different from "error while saving".
In KOffice we added a "lastErrorString" to be able to show the error when e.g. saveFile()
fails (e.g. error in export filter etc.) ... maybe this should be moved up to KParts.

Hmm, so what's missing is a way to know if the saving (local or remote) worked or failed.
Well there is a way to know that (the bool for local files, and the signals for remote files),
just not a unified way.
You didn't talk about the 3rd solution: leaving KParts and the parts unchanged,
but simply calling the error-handling-code (e.g. slotSavingCanceled()) in case of
local files, when saveFile returns false?
if (!saveFile()) slotSavingCanceled(QString::null);

For KDE 4 we can consider letting KParts emit canceled and completed itself.

-- 
David Faure, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).




More information about the kde-core-devel mailing list