[prev in list] [next in list] [prev in thread] [next in thread]
List: koffice-devel
Subject: Re: Bug 93853: JJ: KWord/KPresenter: no network transparency when
From: Giovanni Venturi <gventuri73 () tiscali ! it>
Date: 2004-12-02 0:23:02
Message-ID: 200412020123.14014.gventuri73 () tiscali ! it
[Download RAW message or body]
[Attachment #2 (multipart/signed)]
[Attachment #4 (multipart/mixed)]
Alle 22:33, mercoledì 1 dicembre 2004, Giovanni Venturi ha scritto:
> Alle 01:24, mercoledì 1 dicembre 2004, Giovanni Venturi ha scritto:
> > I attach the first patch (just for KWord now).
> > If you like it I commit. I tryed it and it works.
> > Gianni
>
> And that's KPresenter patch. Can I commit both?
> Gianni
Here two better patches that specialize error messages.
Can I commit? Is it necessary to backport to KOffice 1.3.x branch?
Gianni
--
A KDE Italian translator
Slackware GNU/Linux current version - kernel 2.6.9
["kpresenter.patch" (text/x-diff)]
Index: kpresenter_view.cc
===================================================================
RCS file: /home/kde/koffice/kpresenter/kpresenter_view.cc,v
retrieving revision 1.1084
diff -u -p -p -u -r1.1084 kpresenter_view.cc
--- kpresenter_view.cc 29 Nov 2004 19:12:21 -0000 1.1084
+++ kpresenter_view.cc 2 Dec 2004 00:11:58 -0000
@@ -730,24 +730,56 @@ void KPresenterView::savePicture( const
KFileDialog fd( oldFile, QString::null, this, 0, TRUE );
fd.setMimeFilter( mimetypes );
fd.setCaption(i18n("Save Picture"));
+ fd.setOperationMode(KFileDialog::Saving);
if ( fd.exec() == QDialog::Accepted )
{
url = fd.selectedURL();
- if( url.isEmpty() )
- {
- KMessageBox::sorry( this, i18n("File name is empty."),
- i18n("Save Picture"));
- return;
- }
- // ### TODO: (JJ:) network transparency, use KIO::NetAccess::upload
- QFile file( url.path() );
- if ( file.open( IO_ReadWrite ) ) {
- picture.save( &file );
- file.close();
- }
- else
- KMessageBox::error(this, i18n("Error during saving."),
- i18n("Save Picture"));
+ if ( url.isValid() )
+ {
+ if ( url.isLocalFile() )
+ {
+ QFile file( url.path() );
+ if ( file.open( IO_ReadWrite ) )
+ {
+ picture.save( &file );
+ file.close();
+ }
+ else
+ {
+ KMessageBox::error(this,
+ i18n("Error during saving. Couldn't open '%1' for \
writing").arg ( url.path() ), + i18n("Save \
Picture")); + }
+ }
+ else
+ {
+ KTempFile tempFile;
+ tempFile.setAutoDelete( true );
+ if ( tempFile.status() == 0 )
+ {
+ QFile file( tempFile.name() );
+ if ( file.open( IO_ReadWrite ) )
+ {
+ picture.save( &file );
+ file.close();
+ if ( !KIO::NetAccess::upload( tempFile.name(), url, this ) )
+ {
+ KMessageBox::sorry( this, i18n(
+ "Unable to save the file to '%1'. %2.").arg( url.prettyURL() ).arg( \
KIO::NetAccess::lastErrorString() ), + i18n("Save Failed") );
+ }
+ }
+ else
+ KMessageBox::error(this,
+ i18n("Error during saving. Couldn't open '%1' \
temporary file for writing").arg ( file.name() ), + \
i18n("Save Picture")); + }
+ else
+ KMessageBox::sorry( this, i18n(
+ "Error during saving. Couldn't create temporary file: %1.").arg( strerror( \
tempFile.status() ) ), + i18n("Save Picture") );
+ }
+ }
}
}
["kword.patch" (text/x-diff)]
Index: kwview.cc
===================================================================
RCS file: /home/kde/koffice/kword/kwview.cc,v
retrieving revision 1.1056
diff -u -p -p -u -r1.1056 kwview.cc
--- kwview.cc 14 Nov 2004 09:44:51 -0000 1.1056
+++ kwview.cc 2 Dec 2004 00:12:11 -0000
@@ -125,6 +125,7 @@
using namespace KSpell2;
#endif
+#include <kio/netaccess.h>
KWView::KWView( KWViewMode* viewMode, QWidget *_parent, const char *_name, \
KWDocument* _doc ) : KoView( _doc, _parent, _name )
@@ -5890,40 +5891,72 @@ void KWView::savePicture()
if ( frame )//test for dcop call
{
KWPictureFrameSet *frameset = static_cast<KWPictureFrameSet \
*>(frame->frameSet());
- QString oldFile=frameset->picture().getKey().filename();
+ QString oldFile = frameset->picture().getKey().filename();
KURL url;
url.setPath( oldFile );
- if (!QDir(url.directory()).exists())
+ if ( !QDir(url.directory()).exists() )
oldFile = url.fileName();
- KoPicture picture(frameset->picture());
- QString mimetype=picture.getMimeType();
+ KoPicture picture( frameset->picture() );
+ QString mimetype = picture.getMimeType();
kdDebug() << "Picture has mime type: " << mimetype << endl;
QStringList mimetypes;
mimetypes << mimetype;
KFileDialog fd( oldFile, QString::null, this, 0, TRUE );
fd.setMimeFilter( mimetypes );
fd.setCaption(i18n("Save Picture"));
+ fd.setOperationMode(KFileDialog::Saving);
if ( fd.exec() == QDialog::Accepted )
- {
- url = fd.selectedURL();
- if( url.isEmpty() )
+ {
+ url = fd.selectedURL();
+ if ( url.isValid() )
{
- KMessageBox::sorry( this,
- i18n("File name is empty."),
- i18n("Save Picture"));
- return;
- }
- // ### TODO: (JJ:) network transparency, use KIO::NetAccess::upload
- QFile file( url.path() );
- if ( file.open( IO_ReadWrite ) ) {
- picture.save( &file );
- file.close();
- } else {
- KMessageBox::error(this,
- i18n("Error during saving."),
+ if ( url.isLocalFile() )
+ {
+ QFile file( url.path() );
+ if ( file.open( IO_ReadWrite ) )
+ {
+ picture.save( &file );
+ file.close();
+ }
+ else
+ {
+ KMessageBox::error(this,
+ i18n("Error during saving. Couldn't open '%1' for \
writing").arg ( url.path() ), i18n("Save Picture"));
- }
+ }
+ }
+ else
+ {
+ KTempFile tempFile;
+ tempFile.setAutoDelete( true );
+ if ( tempFile.status() == 0 )
+ {
+ QFile file( tempFile.name() );
+ if ( file.open( IO_ReadWrite ) )
+ {
+ picture.save( &file );
+ file.close();
+ if ( !KIO::NetAccess::upload( tempFile.name(), url, this ) )
+ {
+ KMessageBox::sorry( this, i18n(
+ "Unable to save the file to '%1'. %2.").arg( url.prettyURL() ).arg( \
KIO::NetAccess::lastErrorString() ), + i18n("Save Failed") );
+ }
+ }
+ else
+ KMessageBox::error(this,
+ i18n("Error during saving. Couldn't open '%1' \
temporary file for writing").arg ( file.name() ), + \
i18n("Save Picture")); + }
+ else
+ KMessageBox::sorry( this, i18n(
+ "Error during saving. Couldn't create temporary file: %1.").arg( strerror( \
tempFile.status() ) ), + i18n("Save Picture") );
+ }
+ }
+ else
+ KMessageBox::sorry( this, i18n("URL %1 is invalid.").arg( url.prettyURL() \
), i18n("Save Picture") ); }
}
}
[Attachment #9 (application/pgp-signature)]
_______________________________________________
koffice-devel mailing list
koffice-devel@kde.org
https://mail.kde.org/mailman/listinfo/koffice-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic