1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-02-23 22:50:41 +00:00
transmission/qt/filters.cc
Mike Gelfand d96ef13a89 Define QT_NO_CAST_FROM_ASCII (Qt client)
Use latin1 encoding most of the time where default encoding was used
before. Qt 4 assumes latin1 by default while Qt 5 uses utf-8 which is
not what we want.

Use utf-8 encoding in some places where default encoding was used before.
This includes strings coming from RPC.

Fix an issue with SortMode::names[] (filters.cc) where missing comma
between "sort-by-queue" and "sort-by-ratio" resulted in two array entries
being merged into solid "sort-by-queuesort-by-ratio" string and all the
following items being shifted compared to their enum counterparts.
2015-01-29 21:53:05 +00:00

56 lines
1.3 KiB
C++

/*
* This file Copyright (C) 2009-2014 Mnemosyne LLC
*
* It may be used under the GNU GPL versions 2 or 3
* or any future license endorsed by Mnemosyne LLC.
*
* $Id$
*/
#include "filters.h"
const QString FilterMode::names[NUM_MODES] =
{
QLatin1String ("show-all"),
QLatin1String ("show-active"),
QLatin1String ("show-downloading"),
QLatin1String ("show-seeding"),
QLatin1String ("show-paused"),
QLatin1String ("show-finished"),
QLatin1String ("show-verifying"),
QLatin1String ("show-error")
};
int
FilterMode::modeFromName (const QString& name)
{
for (int i=0; i<NUM_MODES; ++i)
if( names[i] == name )
return i;
return FilterMode().mode(); // use the default value
}
const QString SortMode::names[NUM_MODES] =
{
QLatin1String ("sort-by-activity"),
QLatin1String ("sort-by-age"),
QLatin1String ("sort-by-eta"),
QLatin1String ("sort-by-name"),
QLatin1String ("sort-by-progress"),
QLatin1String ("sort-by-queue"),
QLatin1String ("sort-by-ratio"),
QLatin1String ("sort-by-size"),
QLatin1String ("sort-by-state"),
QLatin1String ("sort-by-id")
};
int
SortMode::modeFromName (const QString& name)
{
for (int i=0; i<NUM_MODES; ++i)
if (names[i] == name)
return i;
return SortMode().mode(); // use the default value
}