KEYMAPPER: Change the keymap action list to be an Array

This commit is contained in:
Bastien Bouclet 2017-08-14 12:59:37 +02:00
parent 3b5016a62d
commit 729cd24c0b
3 changed files with 10 additions and 9 deletions

View File

@ -42,7 +42,7 @@ Keymap::Keymap(KeymapType type, const String &name) :
}
Keymap::~Keymap() {
for (ActionList::iterator it = _actions.begin(); it != _actions.end(); ++it)
for (ActionArray::iterator it = _actions.begin(); it != _actions.end(); ++it)
delete *it;
}
@ -78,7 +78,7 @@ const HardwareInput *Keymap::getActionMapping(Action *action) const {
}
const Action *Keymap::findAction(const char *id) const {
for (ActionList::const_iterator it = _actions.begin(); it != _actions.end(); ++it) {
for (ActionArray::const_iterator it = _actions.begin(); it != _actions.end(); ++it) {
if (strcmp((*it)->id, id) == 0)
return *it;
}
@ -103,7 +103,7 @@ void Keymap::loadMappings(const HardwareInputSet *hwKeys) {
String prefix = KEYMAP_KEY_PREFIX + _name + "_";
for (ActionList::iterator it = _actions.begin(); it != _actions.end(); ++it) {
for (ActionArray::const_iterator it = _actions.begin(); it != _actions.end(); ++it) {
Action* ua = *it;
String actionId(ua->id);
String confKey = prefix + actionId;
@ -132,7 +132,7 @@ void Keymap::saveMappings() {
String prefix = KEYMAP_KEY_PREFIX + _name + "_";
for (HardwareActionMap::iterator it = _hwActionMap.begin(); it != _hwActionMap.end(); it++) {
for (HardwareActionMap::const_iterator it = _hwActionMap.begin(); it != _hwActionMap.end(); it++) {
const Action *action = it->_value;
const HardwareInput *input = it->_key;

View File

@ -47,6 +47,8 @@ public:
kKeymapTypeGame
};
typedef Array<Action *> ActionArray;
Keymap(KeymapType type, const String &name);
~Keymap();
@ -80,7 +82,7 @@ public:
/**
* Get the list of all the Actions contained in this Keymap
*/
List<Action *> &getActions() { return _actions; }
const ActionArray &getActions() const { return _actions; }
void setConfigDomain(ConfigManager::Domain *dom);
@ -97,7 +99,7 @@ public:
*/
void saveMappings();
const String &getName() { return _name; }
const String &getName() const { return _name; }
KeymapType getType() const { return _type; }
/**
@ -118,7 +120,6 @@ private:
const Action *findAction(const char *id) const;
typedef List<Action *> ActionList;
typedef HashMap<const HardwareInput *, Action *> HardwareActionMap;
KeymapType _type;
@ -126,7 +127,7 @@ private:
bool _enabled;
ActionList _actions;
ActionArray _actions;
HardwareActionMap _hwActionMap;
ConfigManager::Domain *_configDomain;

View File

@ -216,7 +216,7 @@ void RemapDialog::loadKeymap() {
assert(_kmPopUp->getSelected() != -1);
Keymap *km = _keymapTable[_kmPopUp->getSelectedTag()];
for (List<Action *>::iterator it = km->getActions().begin(); it != km->getActions().end(); ++it) {
for (Keymap::ActionArray::const_iterator it = km->getActions().begin(); it != km->getActions().end(); ++it) {
ActionRow row;
row.action = *it;