summaryrefslogtreecommitdiffstats
path: root/src/libs/installer/fileutils.cpp
diff options
context:
space:
mode:
authorkh1 <karsten.heimrich@digia.com>2014-06-23 13:33:07 +0200
committerKarsten Heimrich <karsten.heimrich@digia.com>2014-06-24 10:31:17 +0200
commit2ff4f0a8534f820131cc30392cb96b9c55fe7ab3 (patch)
tree891e49214d189b0619a53c96196d361067a68e74 /src/libs/installer/fileutils.cpp
parent924ebcdbc9b9e590a5f0905941e2d05ac34d4be2 (diff)
Don't use QObject::tr().
Change-Id: Icefbff9851a4e096a4b800adea7d17db756abe99 Reviewed-by: Kai Koehne <kai.koehne@digia.com>
Diffstat (limited to 'src/libs/installer/fileutils.cpp')
-rw-r--r--src/libs/installer/fileutils.cpp61
1 files changed, 36 insertions, 25 deletions
diff --git a/src/libs/installer/fileutils.cpp b/src/libs/installer/fileutils.cpp
index 76fae9d08..309c52180 100644
--- a/src/libs/installer/fileutils.cpp
+++ b/src/libs/installer/fileutils.cpp
@@ -188,11 +188,11 @@ void QInstaller::removeFiles(const QString &path, bool ignoreErrors)
if (fi.isSymLink() || fi.isFile()) {
QFile f(fi.filePath());
if (!f.remove()) {
- QString errorMessage = QObject::tr("Could not remove file %1: %2").arg(f.fileName(), f.errorString());
- if (ignoreErrors)
- qWarning() << errorMessage;
- else
+ const QString errorMessage = QCoreApplication::translate("QInstaller",
+ "Could not remove file %1: %2").arg(f.fileName(), f.errorString());
+ if (!ignoreErrors)
throw Error(errorMessage);
+ qWarning() << errorMessage;
}
}
}
@@ -229,12 +229,11 @@ void QInstaller::removeDirectory(const QString &path, bool ignoreErrors)
foreach (const QString &dir, dirs) {
errno = 0;
if (d.exists(path) && !d.rmdir(dir)) {
- QString errorMessage = QObject::tr("Could not remove folder %1: %2").arg(dir,
- errnoToQString(errno));
- if (ignoreErrors)
- qWarning() << errorMessage;
- else
+ const QString errorMessage = QCoreApplication::translate("QInstaller",
+ "Could not remove folder %1: %2").arg(dir, errnoToQString(errno));
+ if (!ignoreErrors)
throw Error(errorMessage);
+ qWarning() << errorMessage;
}
}
}
@@ -302,9 +301,10 @@ void QInstaller::copyDirectoryContents(const QString &sourceDir, const QString &
{
Q_ASSERT(QFileInfo(sourceDir).isDir());
Q_ASSERT(!QFileInfo(targetDir).exists() || QFileInfo(targetDir).isDir());
- if (!QDir().mkpath(targetDir))
- throw Error(QObject::tr("Could not create folder %1").arg(targetDir));
-
+ if (!QDir().mkpath(targetDir)) {
+ throw Error(QCoreApplication::translate("QInstaller", "Could not create folder %1")
+ .arg(targetDir));
+ }
QDirIterator it(sourceDir, QDir::NoDotAndDotDot | QDir::AllEntries);
while (it.hasNext()) {
const QFileInfo i(it.next());
@@ -315,7 +315,8 @@ void QInstaller::copyDirectoryContents(const QString &sourceDir, const QString &
QFile f(i.filePath());
const QString target = QDir(targetDir).absoluteFilePath(i.fileName());
if (!f.copy(target)) {
- throw Error(QObject::tr("Could not copy file from %1 to %2: %3").arg(f.fileName(), target,
+ throw Error(QCoreApplication::translate("QInstaller",
+ "Could not copy file from %1 to %2: %3").arg(f.fileName(), target,
f.errorString()));
}
}
@@ -326,9 +327,10 @@ void QInstaller::moveDirectoryContents(const QString &sourceDir, const QString &
{
Q_ASSERT(QFileInfo(sourceDir).isDir());
Q_ASSERT(!QFileInfo(targetDir).exists() || QFileInfo(targetDir).isDir());
- if (!QDir().mkpath(targetDir))
- throw Error(QObject::tr("Could not create folder %1").arg(targetDir));
-
+ if (!QDir().mkpath(targetDir)) {
+ throw Error(QCoreApplication::translate("QInstaller", "Could not create folder %1")
+ .arg(targetDir));
+ }
QDirIterator it(sourceDir, QDir::NoDotAndDotDot | QDir::AllEntries);
while (it.hasNext()) {
const QFileInfo i(it.next());
@@ -342,7 +344,8 @@ void QInstaller::moveDirectoryContents(const QString &sourceDir, const QString &
QFile f(i.filePath());
const QString target = QDir(targetDir).absoluteFilePath(i.fileName());
if (!f.rename(target)) {
- throw Error(QObject::tr("Could not move file from %1 to %2: %3").arg(f.fileName(), target,
+ throw Error(QCoreApplication::translate("QInstaller",
+ "Could not move file from %1 to %2: %3").arg(f.fileName(), target,
f.errorString()));
}
}
@@ -352,23 +355,29 @@ void QInstaller::moveDirectoryContents(const QString &sourceDir, const QString &
void QInstaller::mkdir(const QString &path)
{
errno = 0;
- if (!QDir().mkdir(QFileInfo(path).absoluteFilePath()))
- throw Error(QObject::tr("Could not create folder %1: %2").arg(path, errnoToQString(errno)));
+ if (!QDir().mkdir(QFileInfo(path).absoluteFilePath())) {
+ throw Error(QCoreApplication::translate("QInstaller", "Could not create folder %1: %2")
+ .arg(path, errnoToQString(errno)));
+ }
}
void QInstaller::mkpath(const QString &path)
{
errno = 0;
- if (!QDir().mkpath(QFileInfo(path).absoluteFilePath()))
- throw Error(QObject::tr("Could not create folder %1: %2").arg(path, errnoToQString(errno)));
+ if (!QDir().mkpath(QFileInfo(path).absoluteFilePath())) {
+ throw Error(QCoreApplication::translate("QInstaller", "Could not create folder %1: %2")
+ .arg(path, errnoToQString(errno)));
+ }
}
QString QInstaller::generateTemporaryFileName(const QString &templ)
{
if (templ.isEmpty()) {
QTemporaryFile f;
- if (!f.open())
- throw Error(QObject::tr("Could not open temporary file: %1").arg(f.errorString()));
+ if (!f.open()) {
+ throw Error(QCoreApplication::translate("QInstaller",
+ "Could not open temporary file: %1").arg(f.errorString()));
+ }
return f.fileName();
}
@@ -384,8 +393,10 @@ QString QInstaller::generateTemporaryFileName(const QString &templ)
++count;
QFile f(tmp.arg(templ, suffix).arg(count));
- if (!f.open(QIODevice::WriteOnly))
- throw Error(QObject::tr("Could not open temporary file for template %1: %2").arg(templ, f.errorString()));
+ if (!f.open(QIODevice::WriteOnly)) {
+ throw Error(QCoreApplication::translate("QInstaller",
+ "Could not open temporary file for template %1: %2").arg(templ, f.errorString()));
+ }
f.remove();
return f.fileName();
}