GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/gui/models/sortlistmodelinv.h Lines: 4 9 44.4 %
Date: 2017-11-29 Branches: 0 4 0.0 %

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2009-2010  The Mana Developers
4
 *  Copyright (C) 2011-2017  The ManaPlus Developers
5
 *
6
 *  This file is part of The ManaPlus Client.
7
 *
8
 *  This program is free software; you can redistribute it and/or modify
9
 *  it under the terms of the GNU General Public License as published by
10
 *  the Free Software Foundation; either version 2 of the License, or
11
 *  any later version.
12
 *
13
 *  This program is distributed in the hope that it will be useful,
14
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 *  GNU General Public License for more details.
17
 *
18
 *  You should have received a copy of the GNU General Public License
19
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
 */
21
22
#ifndef GUI_MODELS_SORTLISTMODELINV_H
23
#define GUI_MODELS_SORTLISTMODELINV_H
24
25
#include "gui/models/listmodel.h"
26
27
#include "utils/gettext.h"
28
29
static const char *const SORT_NAME_INVENTORY[6] =
30
{
31
    // TRANSLATORS: inventory sort mode
32
    N_("default"),
33
    // TRANSLATORS: inventory sort mode
34
    N_("by name"),
35
    // TRANSLATORS: inventory sort mode
36
    N_("by id"),
37
    // TRANSLATORS: inventory sort mode
38
    N_("by weight"),
39
    // TRANSLATORS: inventory sort mode
40
    N_("by amount"),
41
    // TRANSLATORS: inventory sort mode
42
    N_("by type")
43
};
44
45
class SortListModelInv final : public ListModel
46
{
47
    public:
48
        SortListModelInv() :
49
4
            ListModel()
50
        { }
51
52
        A_DELETE_COPY(SortListModelInv)
53
54
        ~SortListModelInv()
55
2
        { }
56
57
14
        int getNumberOfElements() override final
58
14
        { return 6; }
59
60
        std::string getElementAt(int i) override final
61
        {
62
            if (i >= getNumberOfElements() || i < 0)
63
                return "???";
64
65
            return gettext(SORT_NAME_INVENTORY[i]);
66
        }
67
};
68
69
#endif  // GUI_MODELS_SORTLISTMODELINV_H