[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdegraphics/kviewshell/plugins/ps
From: Wilfried Huss <Wilfried.Huss () gmx ! at>
Date: 2006-07-31 16:51:04
Message-ID: 1154364664.263014.23688.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 568268 by whuss:
port of commit 568262:
use KIO::convertSize() to format the filesize
M +26 -21 psRenderer.cpp
--- trunk/KDE/kdegraphics/kviewshell/plugins/ps/psRenderer.cpp #568267:568268
@@ -21,11 +21,15 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
+#include <config.h>
+
+#include <kapplication.h>
#include <kmessagebox.h>
#include <kdebug.h>
#include <kicontheme.h>
#include <klocale.h>
#include <kmimetype.h>
+#include <kio/job.h>
#include <kprocio.h>
#include <ktempfile.h>
@@ -260,7 +264,7 @@
infoWdg.m_mime->setText( mimetype->comment() );
QFileInfo fi(filename);
infoWdg.m_filename->setText( "<qt><strong>"+fi.fileName()+"</strong></qt>" );
-
+
infoWdg.m_title->setText( internalDoc->title() );
infoWdg.m_title->setCursorPosition(0);
infoWdg.m_for->setText( internalDoc->author() );
@@ -273,11 +277,11 @@
infoWdg.m_copyright->setText( internalDoc->copyright() );
infoWdg.m_path->setText( fi.dirPath(true) );
- infoWdg.m_size->setText(QString("%1 Bytes").arg(fi.size()) );
+ infoWdg.m_size->setText( KIO::convertSize(fi.size()) );
infoWdg.m_modified->setText( \
KGlobal::locale()->formatDateTime(fi.lastModified()) ); infoWdg.m_pages->setText( \
QString("%1").arg(numPages) ); }
-
+
// Show the dialog
dialog.setMainWidget(&infoWdg);
dialog.exec();
@@ -289,19 +293,19 @@
QFile psFile(workingCopyFileName);
if (!psFile.open(IO_ReadOnly))
return false;
-
+
// Open the output file
KTempFile new_wcopy(QString::null,".pdf");
new_wcopy.close();
QFile outFile(new_wcopy.name());
if (!outFile.open(IO_WriteOnly))
return false;
-
+
//
// Read, modify and write the PreProlog
//
- // First read the PreProlog into a QByteArray.
+ // First read the PreProlog into a QByteArray.
Position prolog = internalDoc->prolog();
unsigned long length = prolog.first;
QByteArray data(length);
@@ -311,14 +315,14 @@
return false;
}
psFile.readBlock(data.data(), length);
-
+
// Read the QByteArray into QStrings, replace the text, if
// necessary, and write them out
QTextIStream i_stream(&data);
QTextStream o_stream(&outFile);
i_stream.setEncoding(QTextStream::Latin1);
o_stream.setEncoding(QTextStream::Latin1);
-
+
QStringList DSCComments;
while(!i_stream.atEnd()) {
QString line = i_stream.readLine();
@@ -333,10 +337,10 @@
DSCComments += "%% KViewShell could not find any DSC comments at the beginning \
of the document. Expect problems."; DSCComments += "%%";
}
-
+
DSCComments.insert(1, "%%For: " + infoWdg.m_for->text());
DSCComments.insert(1, "%%Title: " + infoWdg.m_title->text());
-
+
for (int i = 0; i < DSCComments.size(); ++i)
o_stream << DSCComments.at(i) << endl;
@@ -355,7 +359,7 @@
#warning DUPLICATED CODE. OPTIMIZE THIS
clear();
workingCopyFileName = new_wcopy.name();
-
+
internalDoc = new GSInternalDocument(workingCopyFileName, GSInternalDocument::PS);
// Set the number of pages page sizes
@@ -510,6 +514,7 @@
pageSize = internalDoc->computePageSize(internalDoc->pageMedia(i));
kDebug() << "size of Page " << i << ": (" << pageSize.width() << ", " << \
pageSize.height() << ")" << endl; +
Length w,h;
w.setLength_in_bigPoints(pageSize.width());
h.setLength_in_bigPoints(pageSize.height());
@@ -543,16 +548,16 @@
void PsRenderer::clear(void)
{
DocumentRenderer::clear();
-
+
// Wait for all access to this documentRenderer to finish
QMutexLocker locker(&mutex);
-
+
// Delete temporary files, if any
QFileInfo wc(workingCopyFileName);
QFileInfo oc(filename);
if (wc.absFilePath() != oc.absFilePath())
QFile::remove(workingCopyFileName);
-
+
delete internalDoc;
internalDoc = 0;
}
@@ -562,26 +567,26 @@
{
if (internalDoc == 0)
return;
-
+
KTempFile new_wcopy(QString::null,".ps");
new_wcopy.close();
-
+
QList<int> pages;
for(int i=1; i<from; i++)
pages << i;
for(int i=to+1; i<numPages; i++)
pages << i;
-
+
if (generatePSFileForPage(new_wcopy.name(), pages) == false)
return;
-
+
_isModified = true;
-
+
#warning DUPLICATED CODE
clear();
workingCopyFileName = new_wcopy.name();
-
+
internalDoc = new GSInternalDocument(workingCopyFileName, GSInternalDocument::PS);
// Set the number of pages page sizes
@@ -645,7 +650,7 @@
// Store path to current file
QFileInfo fi(workingCopyFileName);
path = fi.dirPath();
-
+
// the return value 'true' indicates that this operation was not successful.
return;
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic