mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
Merge pull request #6169 from electron/map-roles-by-command-id
Map roles by command id instead of index
This commit is contained in:
@@ -17,12 +17,14 @@ AtomMenuModel::~AtomMenuModel() {
|
||||
}
|
||||
|
||||
void AtomMenuModel::SetRole(int index, const base::string16& role) {
|
||||
roles_[index] = role;
|
||||
int command_id = GetCommandIdAt(index);
|
||||
roles_[command_id] = role;
|
||||
}
|
||||
|
||||
base::string16 AtomMenuModel::GetRoleAt(int index) {
|
||||
if (ContainsKey(roles_, index))
|
||||
return roles_[index];
|
||||
int command_id = GetCommandIdAt(index);
|
||||
if (ContainsKey(roles_, command_id))
|
||||
return roles_[command_id];
|
||||
else
|
||||
return base::string16();
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ class AtomMenuModel : public ui::SimpleMenuModel {
|
||||
private:
|
||||
Delegate* delegate_; // weak ref.
|
||||
|
||||
std::map<int, base::string16> roles_;
|
||||
std::map<int, base::string16> roles_; // command id -> role
|
||||
base::ObserverList<Observer> observers_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomMenuModel);
|
||||
|
||||
Reference in New Issue
Block a user