Commit 98ab46e5 authored by JanKusanagi's avatar JanKusanagi

Optimize several string list creations with initializers

parent 3c64a473
......@@ -202,47 +202,46 @@ bool MiscHelpers::isImageAnimated(QString fileUri)
QStringList MiscHelpers::iconsForActivity(QString verb)
{
QVariantMap iconMap;
iconMap.insert("like", QStringList("emblem-favorite")
<< ":/images/button-like.png");
iconMap.insert("unlike", QStringList("emblem-favorite")
<< ":/images/button-like.png");
iconMap.insert("favorite", QStringList("emblem-favorite")
<< ":/images/button-like.png");
iconMap.insert("unfavorite", QStringList("emblem-favorite")
<< ":/images/button-like.png");
iconMap.insert("like", QStringList{ "emblem-favorite",
":/images/button-like.png" });
iconMap.insert("unlike", QStringList{ "emblem-favorite",
":/images/button-like.png" });
iconMap.insert("favorite", QStringList{ "emblem-favorite",
":/images/button-like.png" });
iconMap.insert("unfavorite", QStringList{ "emblem-favorite",
":/images/button-like.png" });
iconMap.insert("unshare", QStringList("dialog-cancel")
<< ":/images/button-cancel.png");
iconMap.insert("unshare", QStringList{ "dialog-cancel",
":/images/button-cancel.png" });
iconMap.insert("post", QStringList("mail-send")
<< ":/images/button-post.png");
iconMap.insert("post", QStringList{ "mail-send",
":/images/button-post.png" });
iconMap.insert("update", QStringList("view-refresh")
<< ":/images/menu-refresh.png");
iconMap.insert("update", QStringList{ "view-refresh",
":/images/menu-refresh.png" });
iconMap.insert("follow", QStringList("list-add-user")
<< ":/images/list-add.png");
iconMap.insert("stop-following", QStringList("list-remove-user")
<< ":/images/list-remove.png");
iconMap.insert("follow", QStringList{ "list-add-user",
":/images/list-add.png" });
iconMap.insert("stop-following", QStringList{ "list-remove-user",
":/images/list-remove.png" });
iconMap.insert("add", QStringList("list-add")
<< ":/images/list-add.png");
iconMap.insert("remove", QStringList("list-remove")
<< ":/images/list-remove.png");
iconMap.insert("add", QStringList{ "list-add",
":/images/list-add.png" });
iconMap.insert("remove", QStringList{ "list-remove",
":/images/list-remove.png" });
iconMap.insert("create", QStringList("document-new") // FIXME; also -edit?
<< ":/images/button-edit.png");
iconMap.insert("delete", QStringList("edit-delete")
<< ":/images/button-delete.png");
iconMap.insert("create", QStringList{ "document-new", // FIXME; also -edit?
":/images/button-edit.png" });
iconMap.insert("delete", QStringList{ "edit-delete",
":/images/button-delete.png" });
iconMap.insert("join", QStringList("user-group-new")
<< ":/images/button-online.png");
iconMap.insert("leave", QStringList("user-group-delete")
<< ":/images/button-close.png");
iconMap.insert("join", QStringList{ "user-group-new",
":/images/button-online.png" });
iconMap.insert("leave", QStringList{ "user-group-delete",
":/images/button-close.png" });
QStringList missingIconList;
missingIconList.append("dialog-information");
missingIconList.append(":/images/image-missing.png");
const QStringList missingIconList = QStringList{ "dialog-information",
":/images/image-missing.png" };
return iconMap.value(verb, missingIconList).toStringList();
......@@ -251,21 +250,21 @@ QStringList MiscHelpers::iconsForActivity(QString verb)
const QStringList MiscHelpers::imageExtensions()
{
return QStringList() << "png" << "jpg" << "jpeg" << "jpe" << "gif"
<< "mng" << "webp" << "svg";
return QStringList{ "png", "jpg", "jpeg", "jpe", "gif",
"mng", "webp", "svg" };
}
const QStringList MiscHelpers::audioExtensions()
{
return QStringList() << "ogg" << "oga" << "flac" << "opus" << "mka"
<< "mp3" << "mpga" << "wav" << "wma" << "asf" ;
return QStringList{ "ogg", "oga", "flac", "opus", "mka",
"mp3", "mpga", "wav", "wma", "asf" };
}
const QStringList MiscHelpers::videoExtensions()
{
return QStringList() << "mkv" << "mpg" << "mpeg" << "mpe" << "mpv"
<< "ogm" << "ogg" << "mp4" << "avi" << "webm"
<< "mov" << "flv" << "3gp" << "wmv" << "asf";
return QStringList{ "mkv", "mpg", "mpeg", "mpe", "mpv",
"ogm", "ogg", "mp4", "avi", "webm",
"mov", "flv", "3gp", "wmv", "asf" };
}
/*
......@@ -317,12 +316,12 @@ QString MiscHelpers::fileSizeString(QString fileURI)
if (fileSize > 1024) // if > 1024 bytes, transform to KiB
{
fileSize /= 1024.0;
sizeUnit = "KiB";
sizeUnit = QStringLiteral("KiB");
}
if (fileSize > 1024) // if > 1024 KiB, transform to MiB
{
fileSize /= 1024.0;
sizeUnit = "MiB";
sizeUnit = QStringLiteral("MiB");
}
......@@ -354,7 +353,7 @@ QString MiscHelpers::resolutionString(int width, int height)
QStringList MiscHelpers::htmlWithReplacedImages(QString originalHtml, int postWidth)
{
// if no <img tag is found, just return the original HTML
if (!originalHtml.contains("<img", Qt::CaseInsensitive))
if (!originalHtml.contains(QStringLiteral("<img"), Qt::CaseInsensitive))
{
//qDebug() << "MiscHelpers::htmlWithReplacedImages(); HTML does NOT contain <img> tags...";
return QStringList(originalHtml);
......
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