Commit a9b53833 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Minor optimization

parent 4a5cbe22
......@@ -75,7 +75,7 @@ int main(int argc, char **argv)
QString srcString = args.takeFirst();
QUrl srcurl;
if (srcString.startsWith(QLatin1String("consumer:"))) {
srcurl = QUrl::fromEncoded(srcString.section(QStringLiteral(":"), 1).toUtf8().constData());
srcurl = QUrl::fromEncoded(srcString.section(QLatin1Char(':'), 1).toUtf8().constData());
} else {
srcurl = QUrl::fromEncoded(srcString.toUtf8().constData());
}
......
......@@ -2924,9 +2924,9 @@ void Bin::slotExpandUrl(const ItemInfo &info, const QString &url, QUndoCommand *
|| mltService == QLatin1String("kdenlivetitle")
|| mltService == QLatin1String("color")
|| mltService == QLatin1String("colour")) {
hash = mltService + QStringLiteral(":")
+ EffectsList::property(prod, QStringLiteral("kdenlive:clipname")) + QStringLiteral(":")
+ EffectsList::property(prod, QStringLiteral("kdenlive:folderid")) + QStringLiteral(":");
hash = mltService + QLatin1Char(':')
+ EffectsList::property(prod, QStringLiteral("kdenlive:clipname")) + QLatin1Char(':')
+ EffectsList::property(prod, QStringLiteral("kdenlive:folderid")) + QLatin1Char(':');
if (mltService == QLatin1String("kdenlivetitle")) {
// Calculate hash based on title contents.
hash.append(QString(QCryptographicHash::hash(EffectsList::property(prod, QStringLiteral("xmldata")).toUtf8(),
......
......@@ -80,7 +80,7 @@ QStringList ClipCreationDialog::getExtensions()
allExtensions << ext;
} else if (ext.startsWith(QLatin1String("."))) {
allExtensions << QStringLiteral("*") + ext;
} else if (!ext.contains(QStringLiteral("."))) {
} else if (!ext.contains(QLatin1Char('.'))) {
allExtensions << QStringLiteral("*.") + ext;
} else {
//Unrecognized format
......
......@@ -120,7 +120,7 @@ KdenliveSettingsDialog::KdenliveSettingsDialog(const QMap<QString, QString> &map
// Mime types
QStringList mimes = ClipCreationDialog::getExtensions();
qSort(mimes);
m_configEnv.supportedmimes->setPlainText(mimes.join(QStringLiteral(" ")));
m_configEnv.supportedmimes->setPlainText(mimes.join(QLatin1Char(' ')));
m_page2 = addPage(p2, i18n("Environment"));
m_page2->setIcon(KoIconUtils::themedIcon(QStringLiteral("application-x-executable-script")));
......@@ -902,7 +902,7 @@ void KdenliveSettingsDialog::updateSettings()
KdenliveSettings::setAddedExtensions(m_configEnv.kcfg_addedExtensions->text());
QStringList mimes = ClipCreationDialog::getExtensions();
qSort(mimes);
m_configEnv.supportedmimes->setPlainText(mimes.join(QStringLiteral(" ")));
m_configEnv.supportedmimes->setPlainText(mimes.join(QLatin1Char(' ')));
}
KConfigDialog::settingsChangedSlot();
......
......@@ -192,7 +192,7 @@ bool DocumentChecker::hasErrorInClips()
original.prepend(root);
}
// Check for slideshows
bool slideshow = original.contains(QStringLiteral("/.all.")) || original.contains(QStringLiteral("?")) || original.contains(QStringLiteral("%"));
bool slideshow = original.contains(QStringLiteral("/.all.")) || original.contains(QLatin1Char('?')) || original.contains(QLatin1Char('%'));
if (slideshow && !EffectsList::property(e, QStringLiteral("ttl")).isEmpty()) {
original = QFileInfo(original).absolutePath();
}
......@@ -204,7 +204,7 @@ bool DocumentChecker::hasErrorInClips()
continue;
}
// Check for slideshows
bool slideshow = resource.contains(QStringLiteral("/.all.")) || resource.contains(QStringLiteral("?")) || resource.contains(QStringLiteral("%"));
bool slideshow = resource.contains(QStringLiteral("/.all.")) || resource.contains(QLatin1Char('?')) || resource.contains(QLatin1Char('%'));
if ((service == QLatin1String("qimage") || service == QLatin1String("pixbuf")) && slideshow) {
resource = QFileInfo(resource).absolutePath();
}
......@@ -307,7 +307,7 @@ bool DocumentChecker::hasErrorInClips()
int status = CLIPMISSING;
const QString service = EffectsList::property(e, QStringLiteral("mlt_service"));
QString resource = service == QLatin1String("timewarp") ? EffectsList::property(e, QStringLiteral("warp_resource")) : EffectsList::property(e, QStringLiteral("resource"));
bool slideshow = resource.contains(QStringLiteral("/.all.")) || resource.contains(QStringLiteral("?")) || resource.contains(QStringLiteral("%"));
bool slideshow = resource.contains(QStringLiteral("/.all.")) || resource.contains(QLatin1Char('?')) || resource.contains(QLatin1Char('%'));
if (service == QLatin1String("avformat") || service == QLatin1String("avformat-novalidate") || service == QLatin1String("framebuffer") || service == QLatin1String("timewarp")) {
clipType = i18n("Video clip");
type = AV;
......@@ -647,7 +647,7 @@ QString DocumentChecker::searchPathRecursively(const QDir &dir, const QString &f
QStringList filters;
if (type == SlideShow) {
if (fileName.contains(QLatin1Char('%'))) {
filters << fileName.section(QLatin1Char('%'), 0, -2) + QStringLiteral("*");
filters << fileName.section(QLatin1Char('%'), 0, -2) + QLatin1Char('*');
} else {
return QString();
}
......
......@@ -1328,7 +1328,7 @@ void KdenliveDoc::slotProxyCurrentItem(bool doProxy, QList<ProjectClip *> clipLi
if (!ok) {
// Error
}
QString extension = QStringLiteral(".") + getDocumentProperty(QStringLiteral("proxyextension"));
QString extension = QLatin1Char('.') + getDocumentProperty(QStringLiteral("proxyextension"));
QString params = getDocumentProperty(QStringLiteral("proxyparams"));
if (params.contains(QStringLiteral("-s "))) {
QString proxySize = params.section(QStringLiteral("-s "), 1).section(QStringLiteral("x"), 0, 0);
......@@ -1444,7 +1444,7 @@ QMap<QString, QString> KdenliveDoc::documentProperties()
m_documentProperties.insert(QStringLiteral("version"), QString::number(DOCUMENTVERSION));
m_documentProperties.insert(QStringLiteral("kdenliveversion"), QStringLiteral(KDENLIVE_VERSION));
if (!m_projectFolder.isEmpty()) {
m_documentProperties.insert(QStringLiteral("storagefolder"), m_projectFolder + QStringLiteral("/") +
m_documentProperties.insert(QStringLiteral("storagefolder"), m_projectFolder + QLatin1Char('/') +
m_documentProperties.value(QStringLiteral("documentid")));
}
m_documentProperties.insert(QStringLiteral("profile"), profilePath());
......@@ -1787,7 +1787,7 @@ QDir KdenliveDoc::getCacheDir(CacheType type, bool *ok) const
// Use specified folder to store all files
kdenliveCacheDir = m_projectFolder;
}
basePath = kdenliveCacheDir + QStringLiteral("/") + documentId;
basePath = kdenliveCacheDir + QLatin1Char('/') + documentId;
switch (type) {
case SystemCacheRoot:
return QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
......
......@@ -235,7 +235,7 @@ ParameterContainer::ParameterContainer(const QDomElement &effect, const ItemInfo
lswid->addItem(i18n("None (Dissolve)"));
for (int j = 0; j < listitems.count(); ++j) {
QString entry = listitems.at(j);
lswid->addItem(listitems.at(j).section(QStringLiteral("/"), -1), entry);
lswid->addItem(listitems.at(j).section(QLatin1Char('/'), -1), entry);
if (!entry.isEmpty() && (entry.endsWith(QLatin1String(".png")) || entry.endsWith(QLatin1String(".pgm")))) {
if (!MainWindow::m_lumacache.contains(entry)) {
QImage pix(entry);
......@@ -689,7 +689,7 @@ void ParameterContainer::makeDrag(const QString &name)
if (value.isEmpty()) {
return;
}
value.prepend(name + QStringLiteral("="));
value.prepend(name + QLatin1Char('='));
QDrag *dr = new QDrag(qApp);
// The data to be transferred by the drag and drop operation is contained in a QMimeData object
QMimeData *mimeData = new QMimeData;
......
......@@ -1498,7 +1498,7 @@ void AnimationWidget::slotCopyKeyframes()
QMapIterator<QString, QString> i(anims);
while (i.hasNext()) {
i.next();
result.append(i.key() + QStringLiteral("=") + i.value() + QLatin1Char('\n'));
result.append(i.key() + QLatin1Char('=') + i.value() + QLatin1Char('\n'));
}
QClipboard *clipboard = QApplication::clipboard();
clipboard->setText(result);
......
......@@ -41,7 +41,7 @@ static QColor stringToColor(QString strColor)
(intval) & 0xff); // a
} else {
// 0xRRGGBB, 0xRGB
color.setNamedColor(strColor.replace(0, 2, QStringLiteral("#")));
color.setNamedColor(strColor.replace(0, 2, QLatin1Char('#')));
}
} else {
if (strColor.length() == 9) {
......
......@@ -219,7 +219,7 @@ void MainWindow::init(const QString &MltPath, const QUrl &Url, const QString &cl
KdenliveSettings::setCurrent_profile(defaultProfile.isEmpty() ? ProjectManager::getDefaultProjectFormat() : defaultProfile);
// If using a custom profile, make sure the file exists or fallback to default
if (KdenliveSettings::current_profile().startsWith(QStringLiteral("/")) && !QFile::exists(KdenliveSettings::current_profile())) {
if (KdenliveSettings::current_profile().startsWith(QLatin1Char('/')) && !QFile::exists(KdenliveSettings::current_profile())) {
KMessageBox::sorry(this, i18n("Cannot find your default profile, switching to ATSC 1080p 25"));
KdenliveSettings::setCurrent_profile(QStringLiteral("atsc_1080p_25"));
KdenliveSettings::setDefault_profile(QStringLiteral("atsc_1080p_25"));
......@@ -3503,7 +3503,7 @@ void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QS
if (project->useProxy() && !m_renderWidget->proxyRendering()) {
QString root = doc.documentElement().attribute(QStringLiteral("root"));
if (!root.isEmpty() && !root.endsWith(QLatin1Char('/'))) {
root.append(QStringLiteral("/"));
root.append(QLatin1Char('/'));
}
// replace proxy clips with originals
......
......@@ -62,7 +62,7 @@ void BinController::setDocumentRoot(const QString &root)
} else {
m_documentRoot = root;
if (!m_documentRoot.endsWith(QLatin1Char('/'))) {
m_documentRoot.append(QStringLiteral("/"));
m_documentRoot.append(QLatin1Char('/'));
}
}
}
......
......@@ -157,7 +157,7 @@ void ClipController::getInfoForProducer()
m_clipType = AV;
}
} else if (m_service == QLatin1String("qimage") || m_service == QLatin1String("pixbuf")) {
if (m_path.contains(QStringLiteral("%")) || m_path.contains(QStringLiteral("/.all."))) {
if (m_path.contains(QLatin1Char('%')) || m_path.contains(QStringLiteral("/.all."))) {
m_clipType = SlideShow;
} else {
m_clipType = Image;
......
......@@ -858,7 +858,7 @@ void ClipPropertiesController::fillProperties()
QLocale locale(QLocale::system()); // use the user's locale for getting proper separators!
propertyMap.append(QStringList()
<< i18n("File size")
<< KIO::convertSize(filesize) + QStringLiteral(" (") + locale.toString(filesize) + QStringLiteral(")"));
<< KIO::convertSize(filesize) + QStringLiteral(" (") + locale.toString(filesize) + QLatin1Char(')'));
}
for (int i = 0; i < propertyMap.count(); i++) {
......
......@@ -720,7 +720,7 @@ bool ArchiveWidget::processProjectFile()
QDomElement mlt = m_doc.documentElement();
QString root = mlt.attribute(QStringLiteral("root"));
if (!root.isEmpty() && !root.endsWith(QLatin1Char('/'))) {
root.append(QStringLiteral("/"));
root.append(QLatin1Char('/'));
}
// Adjust global settings
......
......@@ -144,7 +144,7 @@ void ProjectManager::newFile(bool showProjectSettings, bool force)
if (KdenliveSettings::customprojectfolder()) {
projectFolder = KdenliveSettings::defaultprojectfolder();
if (!projectFolder.endsWith(QLatin1Char('/'))) {
projectFolder.append(QStringLiteral("/"));
projectFolder.append(QLatin1Char('/'));
}
documentProperties.insert(QStringLiteral("storagefolder"), projectFolder + documentId);
}
......@@ -182,7 +182,7 @@ void ProjectManager::newFile(bool showProjectSettings, bool force)
documentProperties.insert(QStringLiteral("proxyimageminsize"), QString::number(w->proxyImageMinSize()));
if (!projectFolder.isEmpty()) {
if (!projectFolder.endsWith(QLatin1Char('/'))) {
projectFolder.append(QStringLiteral("/"));
projectFolder.append(QLatin1Char('/'));
}
documentProperties.insert(QStringLiteral("storagefolder"), projectFolder +documentId);
}
......
......@@ -1827,7 +1827,7 @@ void ClipItem::setState(PlaylistState::ClipState state)
} else {
if (m_clipType == Color) {
QString colour = m_binClip->getProducerProperty(QStringLiteral("colour"));
colour = colour.replace(0, 2, QStringLiteral("#"));
colour = colour.replace(0, 2, QLatin1Char('#'));
m_baseColor = QColor(colour.left(7));
} else if (m_clipType == Audio) {
m_baseColor = QColor(141, 215, 166);
......
......@@ -77,7 +77,7 @@ MarkerDialog::MarkerDialog(ClipController *clip, const CommentedTime &t, const T
//p = m_clip->pixmap(m_in->getValue(), width, height);
break;
case Color:
colour = colour.replace(0, 2, QStringLiteral("#"));
colour = colour.replace(0, 2, QLatin1Char('#'));
p.fill(QColor(colour.left(7)));
break;
//UNKNOWN, AUDIO, VIRTUAL:
......
......@@ -392,7 +392,7 @@ QList<ItemInfo> Track::replaceAll(const QString &id, Mlt::Producer *original, Ml
// No duplication required
cut = original->cut(p->get_in(), p->get_out());
}
else if (!idForTrack.contains(QStringLiteral("_")) && idForTrack == current.section(QStringLiteral("_"), 0, 0)) {
else if (!idForTrack.contains(QLatin1Char('_')) && idForTrack == current.section(QLatin1Char('_'), 0, 0)) {
// Unproxying a slideshow
cut = original->cut(p->get_in(), p->get_out());
} else {
......@@ -403,10 +403,10 @@ QList<ItemInfo> Track::replaceAll(const QString &id, Mlt::Producer *original, Ml
// No audio - no duplication required
cut = original->cut(p->get_in(), p->get_out());
}
else if (!cut && ((current == idForTrack) || (!current.contains(QStringLiteral("_")) && current == idForTrack.section(QStringLiteral("_"), 0, 0)))) {
else if (!cut && ((current == idForTrack) || (!current.contains(QLatin1Char('_')) && current == idForTrack.section(QLatin1Char('_'), 0, 0)))) {
// Use duplicate
if (trackProducer == nullptr) {
if (idForTrack.contains(QStringLiteral("_"))) {
if (idForTrack.contains(QLatin1Char('_'))) {
trackProducer = Clip(*original).clone();
trackProducer->set("id", idForTrack.toUtf8().constData());
}
......
......@@ -62,16 +62,16 @@ public:
{
QStringList str;
str << locale.toString(speed) << QString::number(strobe) << QString::number((int) state);
return str.join(QStringLiteral(":"));
return str.join(QLatin1Char(':'));
}
void readFromString(const QString &str, const QLocale &locale)
{
speed = locale.toDouble(str.section(QStringLiteral(":"), 0, 0));
strobe = str.section(QStringLiteral(":"), 1, 1).toInt();
speed = locale.toDouble(str.section(QLatin1Char(':'), 0, 0));
strobe = str.section(QLatin1Char(':'), 1, 1).toInt();
if (str.count(QLatin1Char(':')) == 1) {
state = PlaylistState::Original;
} else {
state = (PlaylistState::ClipState) str.section(QStringLiteral(":"), 2, 2).toInt();
state = (PlaylistState::ClipState) str.section(QLatin1Char(':'), 2, 2).toInt();
}
}
};
......
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