Getting the document from the cache

David Faure faure at kde.org
Mon Jan 31 12:35:20 GMT 2005


On Monday 31 January 2005 10:01, Andras Mantia wrote:
>      KTempFile sourceFile(QString::null, QString::fromLatin1(".html"));
>      if (sourceFile.status() == 0)
>      {
>        KHTMLPageCache::self()->saveData(d->m_cacheId,
> sourceFile.dataStream());
>        sourceFile.close();
>        QFile f( sourceFile.name() );
>        if ( f.open( IO_ReadOnly ) )
>        {
>          QTextStream stream( &f );
>          stream.setCodec(QTextCodec::codecForName(encoding().latin1()));
>          sourceStr = stream.read();
>          f.close();
>        }
>      }
>      sourceFile.unlink();

OK for the encoding part, but you can use a QBuffer or a QByteArray to get 
a QTextStream in memory, instead of using a tempfile; it should be faster
(and less code).

-- 
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 kfm-devel mailing list