[prev in list] [next in list] [prev in thread] [next in thread] 

List:       koffice-devel
Subject:    Re: New Junior Jobs (kofficecore and KWord/KPresenter)
From:       Sven Langkamp <longamp () reallygood ! de>
Date:       2004-11-03 20:19:16
Message-ID: 200411032119.16731.longamp () reallygood ! de
[Download RAW message or body]

On Monday 01 November 2004 19:10, Nicolas Goutte wrote:
> I have a list of new junior jobs to do. (Putting them in KDE Bugs would
> take more time.)
>
> 1. Replacing ::unlink by QFile::remove
> In koffice/lib/kofficecore/koDocument.cc line 1301, there is a call
> to ::unlink this should be replaced to QFile::remove (of course then
> calling QFile::encodeName is not needed anymore)
> (See also if one of the #includes can be removed. I am not sure abou that.)
>
> 2. Use KoStoreDevice in KoDocument::savePreview
> In koffice/lib/kofficecore/koDocument.cc line 1200, the thumbnail is saved
> used QBuffer. It should use KoStoreDevice instead, like in SaveOasisPreview
> (line 1181)
Attached a patch.

["patch.diff" (text/x-diff)]

Index: lib/kofficecore/koDocument.cc
===================================================================
RCS file: /home/kde/koffice/lib/kofficecore/koDocument.cc,v
retrieving revision 1.332
diff -u -r1.332 koDocument.cc
--- lib/kofficecore/koDocument.cc	1 Nov 2004 18:51:07 -0000	1.332
+++ lib/kofficecore/koDocument.cc	3 Nov 2004 20:09:13 -0000
@@ -22,7 +22,6 @@
 
 #include <config.h>
 #include <assert.h>
-#include <unistd.h>
 
 #include <qbuffer.h>
 
@@ -1191,20 +1190,14 @@
 {
     QPixmap pix = generatePreview(QSize(256, 256));
     // Reducing to 8bpp reduces file sizes quite a lot.
-    QImageIO imageIO;
-    imageIO.setImage( pix.convertToImage().convertDepth(8, Qt::AvoidDither | Qt::DiffuseDither) );
-
-    // NOTE: we cannot use QDataStream, as it is not 1:1
-    QByteArray imageData;
-    // ### TODO: perhaps use a KoStoreDevice instead
-    QBuffer buffer(imageData);
-    buffer.open(IO_WriteOnly);
-    imageIO.setIODevice(&buffer);
-    imageIO.setFormat("PNG");
-    imageIO.write();
-    buffer.close();
-
-    return store->write( imageData ) == (Q_LONG)imageData.size();
+    const QImage preview ( pix.convertToImage().convertDepth( 8, Qt::AvoidDither | Qt::DiffuseDither) );
+    KoStoreDevice io ( store );
+    if ( !io.open( IO_WriteOnly ) )
+        return false;
+    if ( ! preview.save( &io, "PNG" ) ) // ### TODO What is -9 in quality terms?
+        return false;
+    io.close();
+    return true;
 }
 
 QPixmap KoDocument::generatePreview( const QSize& size )
@@ -1298,7 +1291,7 @@
             return ret;
         }
         case KMessageBox::No :
-            unlink( QFile::encodeName( asf ) );
+            QFile::remove( asf );
             return false;
         default: // Cancel
             return false;
@@ -1362,8 +1355,7 @@
                     autosaveOpened = true;
                     break;
                 case KMessageBox::No :
-                    // ### TODO (JJ:) use QFile::remove instead of ::unlink
-                    unlink( QFile::encodeName( asf ) );
+                    QFile::remove( asf );
                     break;
                 default: // Cancel
                     return false;
@@ -1516,7 +1508,7 @@
 
         // remove temp file - uncomment this to debug import filters
         if(!importedFile.isEmpty())
-            unlink( QFile::encodeName(importedFile) );
+            QFile::remove( importedFile );
     }
 
     if ( ok && d->m_bSingleViewMode )
@@ -2214,10 +2206,10 @@
         // Eliminate any auto-save file
         QString asf = autoSaveFile( m_file ); // the one in the current dir
         if ( QFile::exists( asf ) )
-            unlink( QFile::encodeName( asf ) );
+            QFile::remove( asf );
         asf = autoSaveFile( QString::null ); // and the one in $HOME
         if ( QFile::exists( asf ) )
-            unlink( QFile::encodeName( asf ) );
+            QFile::remove( asf );
 }
 
 void KoDocument::setBackupFile( bool _b )


_______________________________________________
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