swift
actionhotkeylist.cpp
1 // SPDX-FileCopyrightText: Copyright (C) 2013 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
5 
7 
8 SWIFT_DEFINE_SEQUENCE_MIXINS(swift::misc::input, CActionHotkey, CActionHotkeyList)
9 
10 namespace swift::misc::input
11 {
13  : CSequence<CActionHotkey>(baseClass)
14  {}
15 
17  {
18  CActionHotkeyList subsets;
19  for (const auto &actionHotkey : *this)
20  {
21  if (actionHotkey.getCombination().isSubsetOf(other.getCombination())) { subsets.push_back(actionHotkey); }
22  }
23  return subsets;
24  }
25 
27  {
28  CActionHotkeyList supersets;
29  for (const CActionHotkey &actionHotkey : *this)
30  {
31  if (other.getCombination().isSubsetOf(actionHotkey.getCombination())) { supersets.push_back(actionHotkey); }
32  }
33  return supersets;
34  }
35 
37  {
38  CActionHotkeyList sameMachineKeys;
39  for (const CActionHotkey &actionHotkey : *this)
40  {
41  if (!actionHotkey.isForSameMachineId(key)) { continue; }
42  sameMachineKeys.push_back(actionHotkey);
43  }
44  return sameMachineKeys;
45  }
46 
47  bool CActionHotkeyList::containsAction(const QString &action) const
48  {
49  return this->contains(&CActionHotkey::getAction, action);
50  }
51 
53  {
54  const CIdentifier comparison("comparison for local machine");
55  for (CActionHotkey &actionHotkey : *this)
56  {
57  // to avoid issue we always update
58  actionHotkey.updateToCurrentMachine();
59 
60  // const bool sameMachine = actionHotkey.getIdentifier().hasSameMachineNameOrId(comparison);
61  // if (sameMachine) { actionHotkey.updateToCurrentMachine(); }
62  }
63  }
64 } // namespace swift::misc::input
Value object encapsulating information identifying a component of a modular distributed swift process...
Definition: identifier.h:29
bool contains(const T &object) const
Return true if there is an element equal to given object. Uses the most efficient implementation avai...
Definition: range.h:109
void push_back(const T &value)
Appends an element at the end of the sequence.
Definition: sequence.h:305
Value object encapsulating a action hotkey.
Definition: actionhotkey.h:25
const QString & getAction() const
Action.
Definition: actionhotkey.h:55
void updateToCurrentMachine()
Local machine.
bool isForSameMachineId(const CActionHotkey &key) const
Key for the same machine id?
const CHotkeyCombination & getCombination() const
Get hotkey combination.
Definition: actionhotkey.h:49
Value object encapsulating a list of hotkeys.
CActionHotkeyList findBySameMachine(const CActionHotkey &key) const
Find hotkeys for the same machine.
void updateToCurrentMachine()
Update for my machine.
bool containsAction(const QString &action) const
Contains action?
CActionHotkeyList findSupersetsOf(const CActionHotkey &other) const
Returns true if this list has a hotkey with a combination for which other is a superset of other Exam...
CActionHotkeyList()=default
Default constructor.
CActionHotkeyList findSubsetsOf(const CActionHotkey &other) const
Returns true if this list has a action hotkey with a combination which is a subset of other Example: ...
bool isSubsetOf(const CHotkeyCombination &other) const
Is sequence a subset of other? E.g. CTRL would be a subset of CTRL+D.
#define SWIFT_DEFINE_SEQUENCE_MIXINS(Namespace, T, List)
Explicit template definition of mixins for a CSequence subclass.
Definition: sequence.h:63