Use const & with foreach loops where possible [krazy 46/46] by Mikko Rapeli

parent 89b6a842
......@@ -2055,7 +2055,7 @@ void ClipItem::updateGeometryKeyframes(QDomElement effect, int paramIndex, int w
if (offset > 0) {
QStringList kfrs = data.split(';');
data.clear();
foreach (QString keyframe, kfrs) {
foreach (const QString &keyframe, kfrs) {
if (keyframe.contains('=')) {
int pos = keyframe.section('=', 0, 0).toInt();
pos += offset;
......
......@@ -176,7 +176,7 @@ bool DocumentChecker::hasErrorInClips()
filesToCheck.append(luma);
}
// Check existence of luma files
foreach (const QString lumafile, filesToCheck) {
foreach (const QString &lumafile, filesToCheck) {
filePath = lumafile;
if (!filePath.startsWith('/')) filePath.prepend(root);
if (!QFile::exists(filePath)) {
......@@ -193,7 +193,7 @@ bool DocumentChecker::hasErrorInClips()
m_dialog->setFont(KGlobalSettings::toolBarFont());
m_ui.setupUi(m_dialog);
foreach(const QString l, missingLumas) {
foreach(const QString &l, missingLumas) {
QTreeWidgetItem *item = new QTreeWidgetItem(m_ui.treeWidget, QStringList() << i18n("Luma file") << l);
item->setIcon(0, KIcon("dialog-close"));
item->setData(0, idRole, l);
......@@ -856,7 +856,7 @@ void DocumentChecker::slotDeleteSelected()
if (!deletedLumas.isEmpty()) {
QDomElement e;
QDomNodeList transitions = m_doc.elementsByTagName("transition");
foreach (QString lumaPath, deletedLumas) {
foreach (const QString &lumaPath, deletedLumas) {
for (int i = 0; i < transitions.count(); i++) {
e = transitions.item(i).toElement();
QString resource = EffectsList::property(e, "luma");
......
......@@ -278,7 +278,7 @@ QString GeometryWidget::getExtraValue(const QString &name) const
QStringList list = val.split(';', QString::SkipEmptyParts);
val.clear();
val.append(list.takeFirst().section('/', 0, 0));
foreach (const QString value, list) {
foreach (const QString &value, list) {
val.append(';' + value.section('/', 0, 0));
}
}
......
......@@ -463,7 +463,7 @@ void KeyframeEdit::checkVisibleParam()
if (m_params.count() == 0)
return;
foreach(QDomElement elem, m_params) {
foreach(const QDomElement &elem, m_params) {
if (elem.attribute("intimeline") == "1")
return;
}
......
......@@ -589,7 +589,7 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, const QString &
if (!clipsToLoad.isEmpty() && m_activeDocument) {
QStringList list = clipsToLoad.split(',');
QList <QUrl> urls;
foreach(QString path, list) {
foreach(const QString &path, list) {
kDebug() << QDir::current().absoluteFilePath(path);
urls << QUrl::fromLocalFile(QDir::current().absoluteFilePath(path));
}
......
......@@ -248,7 +248,7 @@ void ParameterPlotter::mousePressEvent(QMouseEvent * event)
newpoints.append(QPointF(pt->x(), pt->y()));
}
p->clearPoints();
foreach(const QPointF qf, newpoints) {
foreach(const QPointF &qf, newpoints) {
p->addPoint(qf);
}
replacePlotObject(m_activeIndexPlot, p);
......
......@@ -96,7 +96,7 @@ void MeltJob::startJob()
else
prod = m_producer->cut(in, out);
QStringList list = producerParams.split(' ', QString::SkipEmptyParts);
foreach(QString data, list) {
foreach(const QString &data, list) {
if (data.contains('=')) {
prod->set(data.section('=', 0, 0).toUtf8().constData(), data.section('=', 1, 1).toUtf8().constData());
}
......@@ -119,7 +119,7 @@ void MeltJob::startJob()
m_consumer->set("real_time", -KdenliveSettings::mltthreads() );
list = consumerParams.split(' ', QString::SkipEmptyParts);
foreach(QString data, list) {
foreach(const QString &data, list) {
if (data.contains('=')) {
kDebug()<<"// filter con: "<<data;
m_consumer->set(data.section('=', 0, 0).toUtf8().constData(), data.section('=', 1, 1).toUtf8().constData());
......@@ -128,7 +128,7 @@ void MeltJob::startJob()
Mlt::Filter mltFilter(*m_profile, filter.toUtf8().data());
list = filterParams.split(' ', QString::SkipEmptyParts);
foreach(QString data, list) {
foreach(const QString &data, list) {
if (data.contains('=')) {
kDebug()<<"// filter p: "<<data;
mltFilter.set(data.section('=', 0, 0).toUtf8().constData(), data.section('=', 1, 1).toUtf8().constData());
......@@ -150,7 +150,7 @@ void MeltJob::startJob()
m_consumer->stop();
QStringList wanted = properties.split(',', QString::SkipEmptyParts);
stringMap jobResults;
foreach(const QString key, wanted) {
foreach(const QString &key, wanted) {
QString value = mltFilter.get(key.toUtf8().constData());
jobResults.insert(key, value);
}
......
......@@ -52,13 +52,13 @@ void ProxyJob::startJob()
mltParameters << "-consumer" << "avformat:" + m_dest;
QStringList params = m_proxyParams.split('-', QString::SkipEmptyParts);
foreach(QString s, params) {
s = s.simplified();
if (s.count(' ') == 0) {
s.append("=1");
foreach(const QString &s, params) {
QString t = s.simplified();
if (t.count(' ') == 0) {
t.append("=1");
}
else s.replace(' ', '=');
mltParameters << s;
else t.replace(' ', '=');
mltParameters << t;
}
mltParameters.append(QString("real_time=-%1").arg(KdenliveSettings::mltthreads()));
......
......@@ -1426,7 +1426,7 @@ void RenderWidget::refreshParams()
m_view.bitrateLabel->setEnabled(true);
if ( item->data(BitratesRole).canConvert(QVariant::StringList) && item->data(BitratesRole).toStringList().count()) {
QStringList bitrates = item->data(BitratesRole).toStringList();
foreach (QString bitrate, bitrates)
foreach (const QString &bitrate, bitrates)
m_view.comboBitrates->addItem(bitrate);
if (item->data(DefaultBitrateRole).canConvert(QVariant::String))
m_view.comboBitrates->setCurrentIndex(bitrates.indexOf(item->data(DefaultBitrateRole).toString()));
......@@ -1443,7 +1443,7 @@ void RenderWidget::refreshParams()
m_view.audiobitrateLabel->setEnabled(true);
if ( item->data(AudioBitratesRole).canConvert(QVariant::StringList) && item->data(AudioBitratesRole).toStringList().count()) {
QStringList audiobitrates = item->data(AudioBitratesRole).toStringList();
foreach (QString bitrate, audiobitrates)
foreach (const QString &bitrate, audiobitrates)
m_view.comboAudioBitrates->addItem(bitrate);
if (item->data(DefaultAudioBitrateRole).canConvert(QVariant::String))
m_view.comboAudioBitrates->setCurrentIndex(audiobitrates.indexOf(item->data(DefaultAudioBitrateRole).toString()));
......
......@@ -438,7 +438,7 @@ void StopmotionWidget::parseExistingSequences()
//dir.setNameFilters(filters);
QStringList sequences = dir.entryList(filters, QDir::Files, QDir::Name);
//kDebug()<<"PF: "<<<<", sm: "<<sequences;
foreach(QString sequencename, sequences) {
foreach(const QString &sequencename, sequences) {
sequence_name->addItem(sequencename.section('_', 0, -2));
}
}
......
......@@ -512,7 +512,7 @@ TitleWidget::TitleWidget(KUrl url, Timecode tc, QString projectTitlePath, Render
//templateBox->setIconSize(QSize(60,60));
templateBox->clear();
templateBox->addItem("");
foreach(TitleTemplate t, titletemplates) {
foreach(const TitleTemplate &t, titletemplates) {
templateBox->addItem(t.icon, t.name, t.file);
}
lastDocumentHash = QCryptographicHash::hash(xml().toString().toAscii(), QCryptographicHash::Md5).toHex();
......
......@@ -52,7 +52,7 @@ int main(int argc, char *argv[])
bool useFFT = false;
// Load arguments
foreach (QString str, args) {
foreach (const QString &str, args) {
if (str.startsWith("--profile=")) {
QString s = str;
......
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