mirror of
https://github.com/transmission/transmission.git
synced 2025-12-24 12:28:52 +00:00
Further reading: * https://forum.qt.io/topic/78540/qstringliteral-vs-qlatin1string/2 * https://woboq.com/blog/qstringliteral.html * https://www.qt.io/blog/2014/06/13/qt-weekly-13-qstringliteral tl;dr: QLatin1Literal uses less memory than QStringLiteral; however, since most Qt APIs require a QString argument, there's extra runtime cost of converting QLatin1Strings to QStrings. QStringLiteral uses a little more memory but constructs its QStrings at compile time. ok, the `prefer-qstringliteral` branch is getting out of control: the secondary goal of fixing a .clang-tidy issue is causing more diffs than the primary goal. So, I'm breaking it into two separate PRs.
62 lines
1.4 KiB
C++
62 lines
1.4 KiB
C++
/*
|
|
* This file Copyright (C) 2009-2015 Mnemosyne LLC
|
|
*
|
|
* It may be used under the GNU GPL versions 2 or 3
|
|
* or any future license endorsed by Mnemosyne LLC.
|
|
*
|
|
*/
|
|
|
|
#include "Filters.h"
|
|
|
|
QString const FilterMode::names_[NUM_MODES] =
|
|
{
|
|
QStringLiteral("show-all"),
|
|
QStringLiteral("show-active"),
|
|
QStringLiteral("show-downloading"),
|
|
QStringLiteral("show-seeding"),
|
|
QStringLiteral("show-paused"),
|
|
QStringLiteral("show-finished"),
|
|
QStringLiteral("show-verifying"),
|
|
QStringLiteral("show-error")
|
|
};
|
|
|
|
int FilterMode::modeFromName(QString const& name)
|
|
{
|
|
for (int i = 0; i < NUM_MODES; ++i)
|
|
{
|
|
if (names_[i] == name)
|
|
{
|
|
return i;
|
|
}
|
|
}
|
|
|
|
return FilterMode().mode(); // use the default value
|
|
}
|
|
|
|
QString const SortMode::names_[NUM_MODES] =
|
|
{
|
|
QStringLiteral("sort-by-activity"),
|
|
QStringLiteral("sort-by-age"),
|
|
QStringLiteral("sort-by-eta"),
|
|
QStringLiteral("sort-by-name"),
|
|
QStringLiteral("sort-by-progress"),
|
|
QStringLiteral("sort-by-queue"),
|
|
QStringLiteral("sort-by-ratio"),
|
|
QStringLiteral("sort-by-size"),
|
|
QStringLiteral("sort-by-state"),
|
|
QStringLiteral("sort-by-id")
|
|
};
|
|
|
|
int SortMode::modeFromName(QString const& name)
|
|
{
|
|
for (int i = 0; i < NUM_MODES; ++i)
|
|
{
|
|
if (names_[i] == name)
|
|
{
|
|
return i;
|
|
}
|
|
}
|
|
|
|
return SortMode().mode(); // use the default value
|
|
}
|