Commit 22b03c57 authored by Thomas Eschenbacher's avatar Thomas Eschenbacher
Browse files

QString::sprintf has been deprecated

parent 609d088f
......@@ -719,7 +719,6 @@ void Kwave::MainWidget::fixZoomAndOffset(double zoom, sample_index_t offset)
m_zoom = zoom;
m_offset = offset;
Q_ASSERT(m_zoom >= 0.0);
Kwave::SignalManager *signal_manager = m_context.signalManager();
Q_ASSERT(signal_manager);
......
......@@ -1158,8 +1158,8 @@ void Kwave::TopWidget::metaDataChanged(Kwave::MetaDataList meta_data)
// sample rate and resolution
if (bits) {
QString khz = _("%0.3f");
khz = khz.sprintf("%0.3f", static_cast<double>(rate) * 1E-3);
QString khz;
khz.setNum(static_cast<double>(rate) * 1E-3, 'f', 3);
txt = _(" ") + i18n("Mode: %1 kHz @ %2 Bit", khz, bits) + _(" ");
} else txt = _("");
m_lbl_status_mode->setText(txt);
......
......@@ -252,19 +252,7 @@ void Kwave::ZoomToolBar::setZoomInfo(Kwave::FileContext *context, double zoom)
if ((signal_manager) && (signal_manager->tracks())) {
if (rate > 0) {
// time display mode
int s = Kwave::toInt(ms) / 1000;
int m = s / 60;
if (ms >= 60*1000) {
strZoom = strZoom.sprintf("%02d:%02d min", m, s % 60);
} else if (ms >= 1000) {
strZoom = strZoom.sprintf("%d sec", s);
} else if (ms >= 1) {
strZoom = strZoom.sprintf("%d ms",
Kwave::toInt(round(ms)));
} else if (ms >= 0.01) {
strZoom = strZoom.sprintf("%0.3g ms", ms);
}
strZoom = Kwave::ms2string(ms, 3);
} else {
// percent mode
double percent = 100.0 / zoom;
......
......@@ -272,7 +272,7 @@ void Kwave::FileProgress::updateStatistics(double rate, double rest,
if (!m_stat_bytes) return;
// left: transfer rate and estimated time
num = num.sprintf("%1.1f", rate / 1024.0);
num.setNum(rate / 1024.0, 'f', 1);
quint64 ms = qMin(quint64(rest * 1000.0), 24ULL * 60ULL * 60ULL * 1000ULL);
text = i18nc("file progress dialog, "
......@@ -287,8 +287,9 @@ void Kwave::FileProgress::updateStatistics(double rate, double rest,
"%1=number of loaded/saved megabytes, "
"%2=number of total megabytes to load or save",
"%1 MB of %2 MB done",
num1.sprintf("%1.1f", pos / (1024.0 * 1024.0)),
num2.sprintf("%1.1f", m_size / (1024.0 * 1024.0)));
num1.setNum(static_cast<double>(pos / (1024.0 * 1024.0)), 'f', 1),
num2.setNum(static_cast<double>(m_size / (1024.0 * 1024.0)), 'f', 1)
);
m_stat_bytes->setText(text);
// process events for some short time, otherwise we would
......
......@@ -102,7 +102,7 @@ bool Kwave::Logger::open(const QString& filename)
//***************************************************************************
void Kwave::Logger::log(const QObject *sender,
Kwave::Logger::LogLevel level,
const QString& msg)
const QString &msg)
{
static const char *str_level[] = {
"DBG", "INF", "WAR", "ERR", "FAT"
......@@ -122,22 +122,22 @@ void Kwave::Logger::log(const QObject *sender,
// get the time stamp
QDateTime now = QDateTime::currentDateTime();
QString date_time = now.toString(_("yyyy-MM-dd hh:mm:ss.zzz"));
// get the PID of the application
long int x_pid = qApp ? static_cast<long int>(qApp->applicationPid()) : -1;
// format the log log message
// x-status date time x-pid x-message
QString line;
line.sprintf("<%s> %s %ld %s\n",
x_status,
UTF8(date_time),
x_pid,
UTF8(msg)
);
m_logfile->write(line.toUtf8().constData());
{
QTextStream out(m_logfile);
out << "<" << x_status << "> " <<
now.toString(_("yyyy-MM-dd hh:mm:ss.zzz")) << " " <<
x_pid << " " <<
msg <<
endl;
}
m_logfile->flush();
}
......
......@@ -97,7 +97,7 @@ Kwave::PluginManager::~PluginManager()
for (QMap<QString, PluginModule>::iterator it(m_plugin_modules.begin());
it != m_plugin_modules.end(); )
{
const QString &name = it.key();
// const QString &name = it.key();
PluginModule &p = it.value();
p.m_use_count--;
......
......@@ -402,10 +402,7 @@ int Kwave::SignalManager::save(const QUrl &url, bool selection)
encoder->supportedProperties().contains(Kwave::INF_CREATION_DATE))
{
// add a date tag
QDate now(QDate::currentDate());
QString date;
date = date.sprintf("%04d-%02d-%02d",
now.year(), now.month(), now.day());
QString date(QDate::currentDate().toString(_("yyyy-MM-dd")));
qDebug("adding date tag: '%s'", DBG(date));
file_info.set(Kwave::INF_CREATION_DATE, date);
}
......
......@@ -46,17 +46,20 @@ QString Kwave::zoom2string(double percent)
{
QString result;
if (percent < 1.0) {
int digits = Kwave::toInt(ceil(1.0 - log10(percent)));
QString format = _("%0.") + QString::number(digits) + _("f %%");
result = format.sprintf(UTF8(format), percent);
} else if (percent < 10.0) {
result = result.sprintf("%0.1f %%", percent);
} else if (percent < 1000.0) {
result = result.sprintf("%0.0f %%", percent);
if (percent < 1000.0) {
int digits;
if (percent < 1.0)
digits = Kwave::toInt(ceil(1.0 - log10(percent)));
else if (percent < 10.0)
digits = 1;
else
digits = 0;
result.setNum(percent, 'f', digits);
result += _(" %");
} else {
result = result.sprintf("x %d",
Kwave::toInt(rint(percent / 100.0)));
result.setNum(Kwave::toInt(rint(percent / 100.0)));
result.prepend(_("x "));
}
return result;
}
......@@ -112,13 +115,13 @@ QString Kwave::ms2hms(double ms)
t /= 60;
h = t;
QString hms_format = i18nc(
return i18nc(
"time of label tooltip, %1=hour, %2=minute, %3=second, %4=milliseconds",
"%02u:%02u:%02u.%04u");
QString hms;
hms.sprintf(UTF8(hms_format), h, m, s, tms);
return hms;
"%1:%2:%3.%4").
arg( h, 2, 10, QLatin1Char('0')).
arg( m, 2, 10, QLatin1Char('0')).
arg( s, 2, 10, QLatin1Char('0')).
arg(tms, 4, 10, QLatin1Char('0'));
}
//***************************************************************************
......
......@@ -252,8 +252,10 @@ void Kwave::DebugPlugin::run(QStringList params)
unsigned int index = 0;
foreach (const Kwave::Stripe &stripe, stripes) {
QString text;
text = text.sprintf("stripe #%d [%llu .. %llu]",
index++, stripe.start(), stripe.end());
text = _("stripe #%1 [%2 .. %3]").
arg(index++).
arg(stripe.start()).
arg(stripe.end());
sig.addLabel(stripe.start(), text);
}
return;
......@@ -460,7 +462,7 @@ void Kwave::DebugPlugin::screenshot(const QByteArray &class_name,
);
QString str;
str = str.sprintf("screenshot of %s - [%p] %d/%d %dx%d",
str = str.asprintf("screenshot of %s - [%p] %d/%d %dx%d",
DBG(filename), static_cast<void*>(widget),
rect.x(), rect.y(), rect.width(), rect.height()
);
......
......@@ -323,12 +323,7 @@ void Kwave::NewSignalDialog::updateFileSize()
mbytes /= 1024.0; // to megabytes
QString str_bytes;
if (mbytes >= 10.0) {
str_bytes.sprintf("%0.1f", mbytes);
} else {
str_bytes.sprintf("%0.3f", mbytes);
}
str_bytes.setNum(mbytes, 'f', (mbytes >= 10.0) ? 1 : 3);
lblFileSize->setText(i18n("(Resulting file size: %1 MB)", str_bytes));
}
......
......@@ -127,7 +127,7 @@ void Kwave::NormalizePlugin::run(QStringList params)
QString db;
emit setProgressText(i18n("Normalizing (%1 dB) ...",
db.sprintf("%+0.1f", 20 * log10(gain))));
db.asprintf("%+0.1f", 20 * log10(gain))));
normalizer.setAttribute(SLOT(setGain(QVariant)), QVariant(gain));
while (!shouldStop() && !source.eof()) {
......
......@@ -1072,10 +1072,7 @@ void Kwave::RecordPlugin::startRecording()
fileInfo.set(Kwave::INF_SOFTWARE, software);
// add a date tag, ISO format
QDate now(QDate::currentDate());
QString date;
date = date.sprintf("%04d-%02d-%02d",
now.year(), now.month(), now.day());
QString date(QDate::currentDate().toString(_("yyyy-MM-dd")));
fileInfo.set(Kwave::INF_CREATION_DATE, date);
signalManager().setFileInfo(fileInfo, false);
}
......
......@@ -510,7 +510,7 @@ QString Kwave::SaveBlocksPlugin::createFileName(const QString &base,
QString ex = _("(\\\\\\[") + format + _("nr\\\\\\])");
QRegExp rx(ex, Qt::CaseInsensitive);
format += _("u");
p.replace(rx, nr.sprintf(format.toLatin1(), index));
p.replace(rx, nr.asprintf(format.toLatin1(), index));
}
// format the "count" parameter
......@@ -522,7 +522,7 @@ QString Kwave::SaveBlocksPlugin::createFileName(const QString &base,
QString ex = _("(\\\\\\[") + format + _("count\\\\\\])");
QRegExp rx(ex, Qt::CaseInsensitive);
format += _("u");
p.replace(rx, nr.sprintf(format.toLatin1(), count));
p.replace(rx, nr.asprintf(format.toLatin1(), count));
} else {
p.replace(rx_count, _("(\\d+)"));
}
......@@ -537,7 +537,7 @@ QString Kwave::SaveBlocksPlugin::createFileName(const QString &base,
QString ex = _("(\\\\\\[") + format + _("total\\\\\\])");
QRegExp rx(ex, Qt::CaseInsensitive);
format += _("u");
p.replace(rx, nr.sprintf(format.toLatin1(), total));
p.replace(rx, nr.asprintf(format.toLatin1(), total));
} else {
p.replace(rx_total, _("(\\d+)"));
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment