[SCM] Kaboom - Debian KDE 3->4 migration tool branch, master, updated. b290cd2d980482d617b371539e4ca9fc2e7bd630
George Kiagiadakis
gkiagia-guest at alioth.debian.org
Sat Mar 7 10:58:24 UTC 2009
The following commit has been merged in the master branch:
commit 8595edd921f159060fc51e029efb02fc9b04ba97
Author: George Kiagiadakis <gkiagia at users.sourceforge.net>
Date: Sat Mar 7 12:24:48 2009 +0200
Prettify the strings used in the operations and add a bytesToString() method
that converts a number of bytes to a human-friendly string (ex. 1024 -> "1 KiB").
diff --git a/choicepage.cpp b/choicepage.cpp
index f973cc7..9977681 100644
--- a/choicepage.cpp
+++ b/choicepage.cpp
@@ -80,7 +80,7 @@ ChoicePage::ChoicePage(QWidget *parent) : QWizardPage(parent)
lay->addWidget(d->onceDoneLabel);
lay->addSpacing(10);
lay->addWidget(d->scenariosLabel);
-
+
d->backupinformation = new QWidget(this);
d->backupinformation->hide();
lay->addWidget(d->backupinformation);
@@ -206,7 +206,8 @@ void ChoicePage::checkSpaceForBackup()
{
quint64 partsize = DirOperations::totalPartitionSize(QDir::homePath());
d->spacebar->setValue(round(static_cast<double>(partsize-freespace)/static_cast<double>(partsize)*100));
- d->freeinfo->setText(tr("The current KDE settings and data directory takes up %1 bytes").arg(dirsize));
+ d->freeinfo->setText( tr("The current KDE settings and data directory takes up %1")
+ .arg(DirOperations::bytesToString(dirsize)) );
d->backupinformation->setVisible(true);
d->backup->hide();
}
diff --git a/diroperations/diroperations.cpp b/diroperations/diroperations.cpp
index 92abbaf..306f98e 100644
--- a/diroperations/diroperations.cpp
+++ b/diroperations/diroperations.cpp
@@ -20,6 +20,7 @@
#include <QtCore/QFile>
#include <QtCore/QEventLoop>
#include <QtCore/QVariant>
+#include <QtCore/QCoreApplication>
#include <QtCore/QDebug>
#include <climits> //for PATH_MAX
#define _FILE_OFFSET_BITS 64
@@ -41,6 +42,21 @@ QString Exception::what() const
}
}
+QString bytesToString(quint64 bytes)
+{
+ if ( bytes > (1<<30) )
+ return QCoreApplication::translate("DirOperations", "%L1 GiB")
+ .arg(double(bytes) / (1<<30), 0, 'f', 2);
+ else if ( bytes > (1<<20) )
+ return QCoreApplication::translate("DirOperations", "%L1 MiB")
+ .arg(double(bytes) / (1<<20), 0, 'f', 2);
+ else if ( bytes > (1<<10) )
+ return QCoreApplication::translate("DirOperations", "%L1 KiB")
+ .arg(double(bytes) / (1<<10), 0, 'f', 2);
+ else
+ return QCoreApplication::translate("DirOperations", "%L1 bytes")
+ .arg(bytes);
+}
QString relativeSymLinkTarget(const QString & fileName)
{
diff --git a/diroperations/diroperations.h b/diroperations/diroperations.h
index 28231aa..6526970 100644
--- a/diroperations/diroperations.h
+++ b/diroperations/diroperations.h
@@ -54,6 +54,11 @@ namespace DirOperations {
enum CopyOption { NoOptions = 0x0, RemoveDestination = 0x1, OverWrite = 0x2 };
Q_DECLARE_FLAGS(CopyOptions, CopyOption);
+ /*! Returns a string that describes the number of bytes given in a human-friendly way.
+ * (i.e. suffixed with KiB, MiB, GiB etc...)
+ */
+ QString bytesToString(quint64 bytes);
+
/*! Returns the target path of the symbolic link \a fileName .
* The path returned is relative to the symlink. For example if
* we have the following link:
diff --git a/diroperations/recursivedirjob.cpp b/diroperations/recursivedirjob.cpp
index e6493f6..c096136 100644
--- a/diroperations/recursivedirjob.cpp
+++ b/diroperations/recursivedirjob.cpp
@@ -143,7 +143,8 @@ quint64 RecursiveDirJobHelper::calculateDirSize(const QString & dir)
}
if ( m_reportProgress && (++refreshCounter % 100 == 0) )
- emit setLabelText(tr("Calculating... %1 bytes").arg(totalSize));
+ emit setLabelText( tr("Calculating the size of \"%1\"... %2")
+ .arg(dir).arg(bytesToString(totalSize)) );
} else { // list is empty
if ( !stack.isEmpty() ){
@@ -182,7 +183,7 @@ void RecursiveDirJobHelper::recursiveCpDir(const QString & sourcePath, const QSt
if ( m_reportProgress ) {
quint64 dirSize = calculateDirSize(sourcePath);
- emit setLabelText(tr("Copying files..."));
+ emit setLabelText(tr("Copying files from \"%1\" to \"%2\"...").arg(sourcePath).arg(destPath));
if (dirSize > 0) {
emit setMaximum(dirSize);
//the directory special file is already (almost) copied in dest.mkdir() above
@@ -282,7 +283,7 @@ void RecursiveDirJobHelper::recursiveRmDir(const QString & dir)
if (m_reportProgress) {
quint64 dirSize = calculateDirSize(dir);
- emit setLabelText(tr("Removing files..."));
+ emit setLabelText(tr("Removing directory \"%1\"...").arg(dir));
if (dirSize > 0) {
emit setMaximum(dirSize);
//start with the size of the directory to be removed.
--
Kaboom - Debian KDE 3->4 migration tool
More information about the pkg-kde-commits
mailing list