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