Brought common part to a separate method.

--HG--
branch : develop
This commit is contained in:
dismine 2014-02-18 22:20:58 +02:00
parent 2b7570e886
commit 1264c1df58
2 changed files with 48 additions and 59 deletions

View File

@ -480,57 +480,41 @@ void TableWindow::PdfFile(const QString &name) const
void TableWindow::EpsFile(const QString &name) const
{
QTemporaryFile tmp;
if (tmp.open()) {
QProcess proc;
QString program;
QStringList params;
if (tmp.open())
{
PdfFile(tmp.fileName());
#ifdef Q_OS_WIN32
program = "pdftops.exe";
#else
program = "pdftops";
#endif
QStringList params;
params << "-eps" << tmp.fileName() << name;
#ifndef QT_NO_CURSOR
QApplication::setOverrideCursor(Qt::WaitCursor);
#endif
proc.start(program, params);
proc.waitForFinished(15000);
#ifndef QT_NO_CURSOR
QApplication::restoreOverrideCursor();
#endif
qDebug() << proc.errorString();
QFile F(name);
if(!F.exists())
{
QMessageBox msgBox(QMessageBox::Critical, "Critical error!",
"Creating file '"+name+"' failed!",
QMessageBox::Ok | QMessageBox::Default);
msgBox.exec();
}
PdfToPs(name, params);
}
}
void TableWindow::PsFile(const QString &name) const
{
QTemporaryFile tmp;
if (tmp.open()) {
if (tmp.open())
{
PdfFile(tmp.fileName());
QStringList params;
params << tmp.fileName() << name;
PdfToPs(name, params);
}
}
void TableWindow::PdfToPs(const QString &name, const QStringList &params) const
{
QProcess proc;
QString program;
QStringList params;
PdfFile(tmp.fileName());
#ifdef Q_OS_WIN32
program = "pdftops.exe";
#else
program = "pdftops";
#endif
params << tmp.fileName() << name;
#ifndef QT_NO_CURSOR
QApplication::setOverrideCursor(Qt::WaitCursor);
@ -542,13 +526,11 @@ void TableWindow::PsFile(const QString &name) const
#endif
qDebug() << proc.errorString();
QFile F(name);
if(!F.exists())
QFile f(name);
if (!f.exists())
{
QMessageBox msgBox(QMessageBox::Critical, "Critical error!",
"Creating file '"+name+"' failed!",
QMessageBox msgBox(QMessageBox::Critical, "Critical error!", "Creating file '"+name+"' failed!",
QMessageBox::Ok | QMessageBox::Default);
msgBox.exec();
}
}
}

View File

@ -218,6 +218,13 @@ private:
* @param name name layout file.
*/
void PsFile(const QString &name)const;
/**
* @brief PdfToPs use external tool "pdftops" for converting pdf too eps or ps format.
* @param name name output file.
* @param params string with parameter for tool. Parameters have format: "-eps input_file out_file". Use -eps when
* need create eps file.
*/
void PdfToPs(const QString &name, const QStringList &params)const;
};
#endif // TABLEWINDOW_H