2009-04-11 18:25:12 +00:00
|
|
|
/*
|
2015-06-10 21:27:11 +00:00
|
|
|
* This file Copyright (C) 2010-2015 Mnemosyne LLC
|
2009-04-11 18:25:12 +00:00
|
|
|
*
|
2014-01-21 03:10:30 +00:00
|
|
|
* It may be used under the GNU GPL versions 2 or 3
|
2014-01-19 01:09:44 +00:00
|
|
|
* or any future license endorsed by Mnemosyne LLC.
|
2009-04-11 18:25:12 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2016-03-29 16:37:21 +00:00
|
|
|
#pragma once
|
2009-04-11 18:25:12 +00:00
|
|
|
|
2020-06-05 19:02:11 +00:00
|
|
|
#include <array>
|
|
|
|
|
2009-04-11 18:25:12 +00:00
|
|
|
#include <QMetaType>
|
|
|
|
#include <QString>
|
|
|
|
#include <QVariant>
|
|
|
|
|
|
|
|
class FilterMode
|
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
public:
|
2015-06-12 22:12:12 +00:00
|
|
|
enum
|
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
SHOW_ALL,
|
|
|
|
SHOW_ACTIVE,
|
|
|
|
SHOW_DOWNLOADING,
|
|
|
|
SHOW_SEEDING,
|
|
|
|
SHOW_PAUSED,
|
|
|
|
SHOW_FINISHED,
|
|
|
|
SHOW_VERIFYING,
|
|
|
|
SHOW_ERROR,
|
|
|
|
NUM_MODES
|
2015-06-12 22:12:12 +00:00
|
|
|
};
|
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
public:
|
|
|
|
FilterMode(int mode = SHOW_ALL) :
|
2020-05-27 21:53:12 +00:00
|
|
|
mode_(mode)
|
2017-04-19 12:04:45 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
FilterMode(QString const& name) :
|
2020-05-27 21:53:12 +00:00
|
|
|
mode_(modeFromName(name))
|
2017-04-19 12:04:45 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
int mode() const
|
|
|
|
{
|
2020-05-27 21:53:12 +00:00
|
|
|
return mode_;
|
2017-04-19 12:04:45 +00:00
|
|
|
}
|
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
QString const& name() const
|
2017-04-19 12:04:45 +00:00
|
|
|
{
|
2020-05-27 21:53:12 +00:00
|
|
|
return nameFromMode(mode_);
|
2017-04-19 12:04:45 +00:00
|
|
|
}
|
2015-06-12 22:12:12 +00:00
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
static int modeFromName(QString const& name);
|
2015-06-12 22:12:12 +00:00
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
static QString const& nameFromMode(int mode)
|
2017-04-19 12:04:45 +00:00
|
|
|
{
|
2020-06-05 19:02:11 +00:00
|
|
|
return Names[mode];
|
2017-04-19 12:04:45 +00:00
|
|
|
}
|
2015-06-12 22:12:12 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
private:
|
2020-05-27 21:53:12 +00:00
|
|
|
int mode_;
|
2013-09-14 22:45:04 +00:00
|
|
|
|
2020-06-05 19:02:11 +00:00
|
|
|
static std::array<QString, NUM_MODES> const Names;
|
2009-04-11 18:25:12 +00:00
|
|
|
};
|
|
|
|
|
2015-06-12 22:12:12 +00:00
|
|
|
Q_DECLARE_METATYPE(FilterMode)
|
|
|
|
|
2009-04-11 18:25:12 +00:00
|
|
|
class SortMode
|
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
public:
|
2015-06-12 22:12:12 +00:00
|
|
|
enum
|
|
|
|
{
|
2017-04-19 12:04:45 +00:00
|
|
|
SORT_BY_ACTIVITY,
|
|
|
|
SORT_BY_AGE,
|
|
|
|
SORT_BY_ETA,
|
|
|
|
SORT_BY_NAME,
|
|
|
|
SORT_BY_PROGRESS,
|
|
|
|
SORT_BY_QUEUE,
|
|
|
|
SORT_BY_RATIO,
|
|
|
|
SORT_BY_SIZE,
|
|
|
|
SORT_BY_STATE,
|
|
|
|
SORT_BY_ID,
|
|
|
|
NUM_MODES
|
2015-06-12 22:12:12 +00:00
|
|
|
};
|
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
public:
|
|
|
|
SortMode(int mode = SORT_BY_ID) :
|
2020-05-27 21:53:12 +00:00
|
|
|
mode_(mode)
|
2017-04-19 12:04:45 +00:00
|
|
|
{
|
|
|
|
}
|
2015-06-12 22:12:12 +00:00
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
SortMode(QString const& name) :
|
2020-05-27 21:53:12 +00:00
|
|
|
mode_(modeFromName(name))
|
2017-04-19 12:04:45 +00:00
|
|
|
{
|
|
|
|
}
|
2015-06-12 22:12:12 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
int mode() const
|
|
|
|
{
|
2020-05-27 21:53:12 +00:00
|
|
|
return mode_;
|
2017-04-19 12:04:45 +00:00
|
|
|
}
|
2015-06-12 22:12:12 +00:00
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
QString const& name() const
|
2017-04-19 12:04:45 +00:00
|
|
|
{
|
2020-06-05 19:02:11 +00:00
|
|
|
return Names[mode_];
|
2017-04-19 12:04:45 +00:00
|
|
|
}
|
|
|
|
|
2017-04-20 16:02:19 +00:00
|
|
|
static int modeFromName(QString const& name);
|
|
|
|
static QString const& nameFromMode(int mode);
|
2017-04-19 12:04:45 +00:00
|
|
|
|
|
|
|
private:
|
2020-05-27 21:53:12 +00:00
|
|
|
int mode_ = SORT_BY_ID;
|
2013-09-14 22:45:04 +00:00
|
|
|
|
2020-06-05 19:02:11 +00:00
|
|
|
static std::array<QString, NUM_MODES> const Names;
|
2009-04-11 18:25:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Q_DECLARE_METATYPE(SortMode)
|