summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederik Gladhorn <gladhorn@kde.org>2014-09-17 22:30:39 (GMT)
committerFrederik Gladhorn <gladhorn@kde.org>2014-09-17 22:30:39 (GMT)
commit3581fb624593bd7bbdd9a6b173050a7cf9413394 (patch)
tree0c86c1c2e2a66387dd51b3b1bb936c8eb1e91950
parent4e15c70d91ebdf216dd4c5b520fdba98a119d800 (diff)
Port to QTemporaryFile
-rw-r--r--aboutdata.h2
-rw-r--r--core/document.cpp18
-rw-r--r--core/document_p.h6
-rw-r--r--generators/djvu/generator_djvu.cpp5
-rw-r--r--generators/dvi/dviexport.cpp2
-rw-r--r--generators/dvi/generator_dvi.cpp6
-rw-r--r--generators/dvi/psgs.cpp3
-rw-r--r--generators/poppler/generator_pdf.cpp8
-rw-r--r--generators/spectre/generator_ghostview.cpp5
-rw-r--r--part.cpp18
-rw-r--r--part.h4
-rw-r--r--ui/latexrenderer.cpp6
12 files changed, 39 insertions, 44 deletions
diff --git a/aboutdata.h b/aboutdata.h
index 8e1999a..97d9746 100644
--- a/aboutdata.h
+++ b/aboutdata.h
@@ -14,6 +14,8 @@
#include "core/version.h"
+#include <klocalizedstring.h>
+
inline KAboutData okularAboutData()
{
KAboutData about(
diff --git a/core/document.cpp b/core/document.cpp
index fa31279..a07e6de 100644
--- a/core/document.cpp
+++ b/core/document.cpp
@@ -28,6 +28,7 @@
#include <QtCore/QFile>
#include <QtCore/QFileInfo>
#include <QtCore/QMap>
+#include <QtCore/qtemporaryfile.h>
#include <QtCore/QTextStream>
#include <QtCore/QTimer>
#include <QtWidgets/QApplication>
@@ -50,7 +51,6 @@
#include <krun.h>
#include <kshell.h>
#include <kstandarddirs.h>
-#include <ktemporaryfile.h>
#include <ktoolinvocation.h>
#include <kzip.h>
@@ -108,8 +108,8 @@ struct ArchiveData
{
}
- KTemporaryFile document;
- KTemporaryFile metadataFile;
+ QTemporaryFile document;
+ QTemporaryFile metadataFile;
};
struct RunningSearch
@@ -962,7 +962,7 @@ Document::OpenResult DocumentPrivate::openDocumentInternal( const KService::Ptr&
}
else
{
- m_tempFile = new KTemporaryFile();
+ m_tempFile = new QTemporaryFile();
if ( !m_tempFile->open() )
{
delete m_tempFile;
@@ -1002,7 +1002,7 @@ Document::OpenResult DocumentPrivate::openDocumentInternal( const KService::Ptr&
return openResult;
}
-bool DocumentPrivate::savePageDocumentInfo( KTemporaryFile *infoFile, int what ) const
+bool DocumentPrivate::savePageDocumentInfo( QTemporaryFile *infoFile, int what ) const
{
if ( infoFile->open() )
{
@@ -4190,7 +4190,7 @@ Document::OpenResult Document::openDocumentArchive( const QString & docFile, con
std::auto_ptr< ArchiveData > archiveData( new ArchiveData() );
const int dotPos = documentFileName.indexOf( '.' );
if ( dotPos != -1 )
- archiveData->document.setSuffix( documentFileName.mid( dotPos ) );
+ archiveData->document.setFileTemplate(QDir::tempPath() + QLatin1String("/okular_XXXXXX") + documentFileName.mid(dotPos));
if ( !archiveData->document.open() )
return OpenError;
@@ -4205,7 +4205,7 @@ Document::OpenResult Document::openDocumentArchive( const QString & docFile, con
if ( metadataEntry && metadataEntry->isFile() )
{
std::auto_ptr< QIODevice > metadataEntryDevice( static_cast< const KZipFileEntry * >( metadataEntry )->createDevice() );
- archiveData->metadataFile.setSuffix( ".xml" );
+ archiveData->metadataFile.setFileTemplate(QDir::tempPath() + QLatin1String("/okular_XXXXXX.xml"));
if ( archiveData->metadataFile.open() )
{
copyQIODevice( metadataEntryDevice.get(), &archiveData->metadataFile );
@@ -4276,7 +4276,7 @@ bool Document::saveDocumentArchive( const QString &fileName )
metadataFileNameNode.appendChild( contentDoc.createTextNode( "metadata.xml" ) );
// If the generator can save annotations natively, do it
- KTemporaryFile modifiedFile;
+ QTemporaryFile modifiedFile;
bool annotationsSavedNatively = false;
if ( d->canAddAnnotationsNatively() )
{
@@ -4298,7 +4298,7 @@ bool Document::saveDocumentArchive( const QString &fileName )
}
}
- KTemporaryFile metadataFile;
+ QTemporaryFile metadataFile;
PageItems saveWhat = annotationsSavedNatively ? None : AnnotationPageItems;
if ( !d->savePageDocumentInfo( &metadataFile, saveWhat ) )
return false;
diff --git a/core/document_p.h b/core/document_p.h
index 51632ec..0ed4e3f 100644
--- a/core/document_p.h
+++ b/core/document_p.h
@@ -32,7 +32,7 @@ class QUndoStack;
class QEventLoop;
class QFile;
class QTimer;
-class KTemporaryFile;
+class QTemporaryFile;
struct AllocatedPixmap;
struct ArchiveData;
@@ -129,7 +129,7 @@ class DocumentPrivate
ConfigInterface* generatorConfig( GeneratorInfo& info );
SaveInterface* generatorSave( GeneratorInfo& info );
Document::OpenResult openDocumentInternal( const KService::Ptr& offer, bool isstdin, const QString& docFile, const QByteArray& filedata, const QString& password );
- bool savePageDocumentInfo( KTemporaryFile *infoFile, int what ) const;
+ bool savePageDocumentInfo( QTemporaryFile *infoFile, int what ) const;
DocumentViewport nextDocumentViewport() const;
void notifyAnnotationChanges( int page );
bool canAddAnnotationsNatively() const;
@@ -198,7 +198,7 @@ class DocumentPrivate
// cached stuff
QString m_docFileName;
QString m_xmlFileName;
- KTemporaryFile *m_tempFile;
+ QTemporaryFile *m_tempFile;
qint64 m_docSize;
// viewport stuff
diff --git a/generators/djvu/generator_djvu.cpp b/generators/djvu/generator_djvu.cpp
index 9338cf5..5190965 100644
--- a/generators/djvu/generator_djvu.cpp
+++ b/generators/djvu/generator_djvu.cpp
@@ -28,7 +28,7 @@
#include <kaboutdata.h>
#include <QtCore/QDebug>
#include <klocale.h>
-#include <ktemporaryfile.h>
+#include <qtemporaryfile.h>
static void recurseCreateTOC( QDomDocument &maindoc, const QDomNode &parent, QDomNode &parentDestination, KDjVu *djvu )
{
@@ -186,8 +186,7 @@ bool DjVuGenerator::print( QPrinter& printer )
bool result = false;
// Create tempfile to write to
- KTemporaryFile tf;
- tf.setSuffix( ".ps" );
+ QTemporaryFile tf(QDir::tempPath() + QLatin1String("/okular_XXXXXX.ps"));
if ( !tf.open() )
return false;
diff --git a/generators/dvi/dviexport.cpp b/generators/dvi/dviexport.cpp
index 32f0794..c8db452 100644
--- a/generators/dvi/dviexport.cpp
+++ b/generators/dvi/dviexport.cpp
@@ -220,7 +220,7 @@ DVIExportToPS::DVIExportToPS(dviRenderer& parent,
if (!options.isEmpty() || dvi.suggestedPageSize != 0) {
// Get a name for a temporary file.
// Must open the QTemporaryFile to access the name.
- KTemporaryFile tmpfile;
+ QTemporaryFile tmpfile;
tmpfile.setAutoRemove(false);
tmpfile.open();
tmpfile_name_ = tmpfile.fileName();
diff --git a/generators/dvi/generator_dvi.cpp b/generators/dvi/generator_dvi.cpp
index 1690e90..0d555d4 100644
--- a/generators/dvi/generator_dvi.cpp
+++ b/generators/dvi/generator_dvi.cpp
@@ -25,16 +25,17 @@
#include "TeXFont.h"
#include <qapplication.h>
+#include <qdir.h>
#include <qstring.h>
#include <qurl.h>
#include <qvector.h>
#include <qstack.h>
+#include <qtemporaryfile.h>
#include <qmutex.h>
#include <kaboutdata.h>
#include <QtCore/QDebug>
#include <klocale.h>
-#include <ktemporaryfile.h>
#ifdef DVI_OPEN_BUSYLOOP
#ifdef Q_OS_UNIX
@@ -548,8 +549,7 @@ void DviGenerator::loadPages( QVector< Okular::Page * > &pagesVector )
bool DviGenerator::print( QPrinter& printer )
{
// Create tempfile to write to
- KTemporaryFile tf;
- tf.setSuffix( ".ps" );
+ QTemporaryFile tf(QDir::tempPath() + QLatin1String("/okular_XXXXXX.ps" ));
if ( !tf.open() )
return false;
diff --git a/generators/dvi/psgs.cpp b/generators/dvi/psgs.cpp
index 3b0b9a2..13117c4 100644
--- a/generators/dvi/psgs.cpp
+++ b/generators/dvi/psgs.cpp
@@ -160,9 +160,8 @@ void ghostscript_interface::gs_generate_graphics_file(const PageNumber& page, co
// Generate a PNG-file
// Step 1: Write the PostScriptString to a File
- KTemporaryFile PSfile;
+ QTemporaryFile PSfile(QDir::tempPath() + QLatin1String("/okular_XXXXXX.ps"));
PSfile.setAutoRemove(false);
- PSfile.setSuffix(".ps");
PSfile.open();
const QString PSfileName = PSfile.fileName();
diff --git a/generators/poppler/generator_pdf.cpp b/generators/poppler/generator_pdf.cpp
index 2b8a9e5..4140a55 100644
--- a/generators/poppler/generator_pdf.cpp
+++ b/generators/poppler/generator_pdf.cpp
@@ -14,22 +14,23 @@
// qt/kde includes
#include <qcheckbox.h>
#include <qcolor.h>
+#include <qdir.h>
#include <qfile.h>
#include <qimage.h>
#include <qlayout.h>
#include <qmutex.h>
#include <qregexp.h>
#include <qstack.h>
+#include <qtemporaryfile.h>
#include <qtextstream.h>
#include <QPrinter>
#include <QPainter>
+#include <QtCore/QDebug>
#include <k4aboutdata.h>
#include <kconfigdialog.h>
#include <klocale.h>
#include <kmessagebox.h>
-#include <ktemporaryfile.h>
-#include <QtCore/QDebug>
#include <kglobal.h>
#include <core/action.h>
@@ -1018,8 +1019,7 @@ bool PDFGenerator::print( QPrinter& printer )
}
// Create the tempfile to send to FilePrinter, which will manage the deletion
- KTemporaryFile tf;
- tf.setSuffix( ".ps" );
+ QTemporaryFile tf(QDir::tempPath() + QLatin1String("/okular_XXXXXX.ps"));
if ( !tf.open() )
{
lastPrintError = TemporaryFileOpenPrintError;
diff --git a/generators/spectre/generator_ghostview.cpp b/generators/spectre/generator_ghostview.cpp
index 493f12c..e951e44 100644
--- a/generators/spectre/generator_ghostview.cpp
+++ b/generators/spectre/generator_ghostview.cpp
@@ -105,8 +105,7 @@ bool GSGenerator::print( QPrinter& printer )
bool result = false;
// Create tempfile to write to
- KTemporaryFile tf;
- tf.setSuffix( ".ps" );
+ QTemporaryFile tf(QDir::tempPath() + QLatin1String("/okular_XXXXXX.ps"));
// Get list of pages to print
QList<int> pageList = Okular::FilePrinter::pageList( printer,
@@ -119,7 +118,7 @@ bool GSGenerator::print( QPrinter& printer )
if ( printer.outputFileName().right(3) == "pdf" )
{
exportFormat = SPECTRE_EXPORTER_FORMAT_PDF;
- tf.setSuffix(".pdf");
+ tf.setFileTemplate(QDir::tempPath() + QLatin1String("/okular_XXXXXX.pdf"));
}
if ( !tf.open() )
diff --git a/part.cpp b/part.cpp
index c987fba..a65c7f6 100644
--- a/part.cpp
+++ b/part.cpp
@@ -29,6 +29,7 @@
#include <qlayout.h>
#include <qlabel.h>
#include <qtimer.h>
+#include <qtemporaryfile.h>
#include <QtPrintSupport/QPrinter>
#include <QtPrintSupport/QPrintDialog>
#include <QScrollBar>
@@ -52,7 +53,6 @@
#include <kservicetypetrader.h>
#include <kstandarddirs.h>
#include <kstandardshortcut.h>
-#include <ktemporaryfile.h>
#include <ktoggleaction.h>
#include <ktogglefullscreenaction.h>
#include <kio/job.h>
@@ -128,12 +128,12 @@ class FileKeeper
}
}
- KTemporaryFile* copyToTemporary() const
+ QTemporaryFile* copyToTemporary() const
{
if ( !m_handle )
return 0;
- KTemporaryFile * retFile = new KTemporaryFile;
+ QTemporaryFile * retFile = new QTemporaryFile;
retFile->open();
std::rewind( m_handle );
@@ -1165,8 +1165,7 @@ bool Part::slotImportPSFile()
KUrl url = KFileDialog::getOpenUrl( KUrl(), "application/postscript", this->widget() );
if ( url.isLocalFile() )
{
- KTemporaryFile tf;
- tf.setSuffix( ".pdf" );
+ QTemporaryFile tf(QDir::tempPath() + QLatin1String("/okular_XXXXXX.pdf"));
tf.setAutoRemove( false );
if ( !tf.open() )
return false;
@@ -2204,7 +2203,7 @@ void Part::slotSaveFileAs()
bool Part::saveAs( const QUrl & saveUrl )
{
- KTemporaryFile tf;
+ QTemporaryFile tf;
QString fileName;
if ( !tf.open() )
{
@@ -2260,7 +2259,7 @@ void Part::slotSaveCopyAs()
// make use of the already downloaded (in case of remote URLs) file,
// no point in downloading that again
KUrl srcUrl = KUrl::fromPath( localFilePath() );
- KTemporaryFile * tempFile = 0;
+ QTemporaryFile * tempFile = 0;
// duh, our local file disappeared...
if ( !QFile::exists( localFilePath() ) )
{
@@ -2375,9 +2374,8 @@ void Part::slotPrintPreview()
else
{
// Generate a temp filename for Print to File, then release the file so generator can write to it
- KTemporaryFile tf;
+ QTemporaryFile tf(QDir::tempPath() + QLatin1String("/okular_XXXXXX.ps"));
tf.setAutoRemove( true );
- tf.setSuffix( ".ps" );
tf.open();
printer.setOutputFileName( tf.fileName() );
tf.close();
@@ -2845,7 +2843,7 @@ bool Part::handleCompressed( QString &destpath, const QString &path, const QStri
// we are working with a compressed file, decompressing
// temporary file for decompressing
- KTemporaryFile *newtempfile = new KTemporaryFile();
+ QTemporaryFile *newtempfile = new QTemporaryFile();
newtempfile->setAutoRemove(true);
if ( !newtempfile->open() )
diff --git a/part.h b/part.h
index c8cfa19..30aa654 100644
--- a/part.h
+++ b/part.h
@@ -47,7 +47,7 @@ class KToggleAction;
class KToggleFullScreenAction;
class KSelectAction;
class KAboutData;
-class KTemporaryFile;
+class QTemporaryFile;
class QAction;
namespace KParts { class GUIActivateEvent; }
@@ -252,7 +252,7 @@ class OKULAR_PART_EXPORT Part : public KParts::ReadWritePart, public Okular::Doc
static int numberOfParts;
- KTemporaryFile *m_tempfile;
+ QTemporaryFile *m_tempfile;
// the document
Okular::Document * m_document;
diff --git a/ui/latexrenderer.cpp b/ui/latexrenderer.cpp
index ded4100..32c03fb 100644
--- a/ui/latexrenderer.cpp
+++ b/ui/latexrenderer.cpp
@@ -15,12 +15,12 @@
#include <QtCore/QDebug>
#include <kstandarddirs.h>
#include <kprocess.h>
-#include <ktemporaryfile.h>
#include <QColor>
#include <QDir>
#include <QFileInfo>
#include <QImage>
+#include <qtemporaryfile.h>
#include <QTextDocument>
#include <QTextStream>
@@ -118,9 +118,7 @@ LatexRenderer::Error LatexRenderer::handleLatex( QString& fileName, const QStrin
KProcess latexProc;
KProcess dvipngProc;
- KTemporaryFile *tempFile = new KTemporaryFile();
- tempFile->setPrefix("kdelatex-");
- tempFile->setSuffix(".tex");
+ QTemporaryFile *tempFile = new QTemporaryFile(QDir::tempPath() + QLatin1String("/okular_kdelatex-XXXXXX.tex"));
tempFile->open();
QString tempFileName = tempFile->fileName();
QFileInfo *tempFileInfo = new QFileInfo(tempFileName);