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

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2007  Joshua Langley <[email protected]>
4
 *  Copyright (C) 2009  The Mana World Development Team
5
 *  Copyright (C) 2009-2010  The Mana Developers
6
 *  Copyright (C) 2011-2017  The ManaPlus Developers
7
 *
8
 *  This file is part of The ManaPlus Client.
9
 *
10
 *  This program is free software; you can redistribute it and/or modify
11
 *  it under the terms of the GNU General Public License as published by
12
 *  the Free Software Foundation; either version 2 of the License, or
13
 *  any later version.
14
 *
15
 *  This program is distributed in the hope that it will be useful,
16
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 *  GNU General Public License for more details.
19
 *
20
 *  You should have received a copy of the GNU General Public License
21
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
 */
23
24
#ifndef GUI_MODELS_KEYLISTMODEL_H
25
#define GUI_MODELS_KEYLISTMODEL_H
26
27
#include "gui/setupactiondata.h"
28
29
#include "gui/models/listmodel.h"
30
31
#include "localconsts.h"
32
33
extern SetupActionData *const setupActionData[];
34
35
/**
36
 * The list model for key function list.
37
 *
38
 * \ingroup Interface
39
 */
40
4
class KeyListModel final : public ListModel
41
{
42
    public:
43
4
        KeyListModel() :
44
            mDataNum(0),
45
            mSelectedData(0),
46
8
            mSize(0)
47
        {
48
        }
49
50
        A_DELETE_COPY(KeyListModel)
51
52
        /**
53
         * Returns the number of elements in container.
54
         */
55
4
        int getNumberOfElements() override final
56
4
        { return mSize; }
57
58
        /**
59
         * Returns element from container.
60
         */
61
        std::string getElementAt(int i) override final
62
        { return setupActionData[mSelectedData][i].text; }
63
64
        /**
65
         * Sets element from container.
66
         */
67
        void setElementAt(const int i, const std::string &caption)
68
312
        { setupActionData[mSelectedData][i].text = caption; }
69
70
        void setSize(const int size) noexcept2
71
4
        { mSize = size; }
72
73
        void setDataNum(const int num) noexcept2
74
        { mDataNum = num; }
75
76
        void setSelectedData(const int i) noexcept2
77
4
        { mSelectedData = i; }
78
79
        int getSelectedData() const noexcept2 A_WARN_UNUSED
80
160
        { return mSelectedData; }
81
82
    private:
83
        int mDataNum;
84
        int mSelectedData;
85
        int mSize;
86
};
87
88
#endif  // GUI_MODELS_KEYLISTMODEL_H