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

Andras Mantia amantia at kde.org
Wed Mar 10 12:36:31 GMT 2004


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wednesday 10 March 2004 14:25, David Faure wrote:
> > +  else
> > +    emit canceled("");
>
> This is IMHO very inconsistent. saveFile doesn't emit completed() either.

It does, although in a strange way:
bool ReadWritePart::save()
{
  d->m_saveOk = false;
  if( saveFile() )
    return saveToURL();
  return false;
}

So if saveFile() is successfull, saveToURL() is called, which has:
 if ( m_url.isLocalFile() )
  {
    setModified( false );
    emit completed();
    // if m_url is a local file there won't be a temp file -> nothing to 
remove
    assert( !m_bTemp );
    d->m_saveOk = true;
    return true; // Nothing to do
  }

So in case of a local file completed() is emitted if saveFile() returns true.

>
> > +   * 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.
The documentation says that the error message should be displayed by the part 
in the saveFile() (On failure the function should inform the user about the 
problem with an appropriate message box.), so I even wonder what is the use 
of the QString argument of canceled() if everyone follows the documentation.

> Hmm, so what's missing is a way to know if the saving (local or remote)
> worked or failed. 
Right, in an unified way.

> Well there is a way to know that (the bool for local 
> files, and the signals for remote files), just not a unified way.
Right, and the current solution breaks the idea of network transparency. The 
caller shouldn't need to make a difference between local or remote files. 
Call saveAs() and treat the success/failure in the same way without caring 
about the file type.

> 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);

I wanted a general solution. And as I pointed out, it would be more tricky, as 
the completed()/canceled() signal should be completely ignored in case of 
local files.

> For KDE 4 we can consider letting KParts emit canceled and completed
> itself.
OK, so I should go with the workaround solution in the app using the KPart.

Andras

- -- 
Quanta Plus developer - http://quanta.sourceforge.net
K Desktop Environment - http://www.kde.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQFATwvPTQdfac6L/08RAp9CAJ0SARnx6uY+vpW8qs6f4CS5rDQQ0wCbBNM2
lXAYcxSd7pokL6c9sYfqdY4=
=jTo9
-----END PGP SIGNATURE-----




More information about the kde-core-devel mailing list