MythTV  master
actionset.h
Go to the documentation of this file.
1 /* -*- myth -*- */
23 #ifndef ACTIONSET_H
24 #define ACTIONSET_H
25 
26 // Qt headers
27 #include <QStringList>
28 #include <QHash>
29 #include <QMap>
30 
36 class ActionSet
37 {
38  public:
40  ActionSet() = default;
41  ~ActionSet();
42 
43  // Commands
44  bool AddAction(const ActionID &id,
45  const QString &description,
46  const QString &keys);
47  bool Add(const ActionID &id, const QString &key);
48  bool Remove(const ActionID &id, const QString &key);
49  bool Replace(const ActionID &id,
50  const QString &newkey,
51  const QString &oldkey);
52 
53  // Sets
54  bool SetModifiedFlag(const ActionID &id, bool modified);
55 
56  // Gets
57  QStringList GetContextStrings(void) const;
58  QStringList GetActionStrings(const QString &context_name) const;
59  QString GetKeyString(const ActionID &id) const;
60  QStringList GetKeys(const ActionID &id) const;
61  QStringList GetContextKeys(const QString &context_name) const;
62  QStringList GetAllKeys(void) const;
63  QString GetDescription(const ActionID &id) const;
65  ActionList GetActions(const QString &key) const
66  { return m_keyToActionMap[key]; }
68  ActionList GetModified(void) const { return m_modified; }
70  bool HasModified(void) const { return !m_modified.isEmpty(); }
72  bool IsModified(const ActionID &id) const
73  { return m_modified.contains(id); }
74 
75  protected:
76  Action *GetAction(const ActionID &id);
77 
78  public:
80  static const QString kJumpContext;
82  static const QString kGlobalContext;
83 
84  private:
85  QMap<QString, ActionList> m_keyToActionMap;
86  using ContextMap = QHash<QString, Context>;
89 };
90 
91 #endif /* ACTIONSET_H */
ActionSet::m_modified
ActionList m_modified
Definition: actionset.h:88
ActionSet::GetKeys
QStringList GetKeys(const ActionID &id) const
Get the keys bound to an action by its identifier.
Definition: actionset.cpp:238
ActionSet::~ActionSet
~ActionSet()
Definition: actionset.cpp:33
ActionSet::GetActionStrings
QStringList GetActionStrings(const QString &context_name) const
Returns a list of all action in the action set.
Definition: actionset.cpp:173
ActionSet
Maintains consistancy between actions and keybindings.
Definition: actionset.h:37
ActionList
QList< ActionID > ActionList
Definition: action.h:115
ActionSet::GetContextKeys
QStringList GetContextKeys(const QString &context_name) const
Definition: actionset.cpp:252
ActionSet::Replace
bool Replace(const ActionID &id, const QString &newkey, const QString &oldkey)
Replace a specific key in a specific action.
Definition: actionset.cpp:120
ActionSet::m_keyToActionMap
QMap< QString, ActionList > m_keyToActionMap
Definition: actionset.h:85
ActionSet::GetModified
ActionList GetModified(void) const
Returns the appropriate container of modified actions.
Definition: actionset.h:68
ActionSet::GetActions
ActionList GetActions(const QString &key) const
Returns the actions bound to the specified key.
Definition: actionset.h:65
Action
An action (for this plugin) consists of a description, and a set of key sequences.
Definition: action.h:41
ActionSet::Remove
bool Remove(const ActionID &id, const QString &key)
Remove a key from an action identifier.
Definition: actionset.cpp:89
ActionSet::ActionSet
ActionSet()=default
Create a new, empty set of action bindings.
ActionSet::GetContextStrings
QStringList GetContextStrings(void) const
Returns a list of all contexts in the action set.
Definition: actionset.cpp:160
ActionSet::ContextMap
QHash< QString, Context > ContextMap
Definition: actionset.h:86
ActionSet::GetAction
Action * GetAction(const ActionID &id)
Returns a pointer to an action by its identifier. (note: result not thread-safe)
Definition: actionset.cpp:299
ActionSet::HasModified
bool HasModified(void) const
Returns true iff changes have been made.
Definition: actionset.h:70
ActionSet::m_contexts
ContextMap m_contexts
Definition: actionset.h:87
ActionSet::AddAction
bool AddAction(const ActionID &id, const QString &description, const QString &keys)
Add an action.
Definition: actionset.cpp:198
ActionSet::kJumpContext
static const QString kJumpContext
The statically assigned context for jump point actions.
Definition: actionset.h:80
ActionSet::GetAllKeys
QStringList GetAllKeys(void) const
Get all keys (from every context) to which an action is bound.
Definition: actionset.cpp:267
ActionSet::IsModified
bool IsModified(const ActionID &id) const
Returns true iff the action is modified.
Definition: actionset.h:72
ActionSet::SetModifiedFlag
bool SetModifiedFlag(const ActionID &id, bool modified)
Mark an action as modified or unmodified by its identifier.
Definition: actionset.cpp:143
ActionSet::kGlobalContext
static const QString kGlobalContext
The name of global actions.
Definition: actionset.h:82
ActionID
A class that uniquely identifies an action.
Definition: action.h:85
ActionSet::GetDescription
QString GetDescription(const ActionID &id) const
Returns the description of an action by its identifier.
Definition: actionset.cpp:282
modified
static bool modified(uint64_t sig)
Definition: eitcache.cpp:87
ActionSet::Add
bool Add(const ActionID &id, const QString &key)
Add a binding.
Definition: actionset.cpp:57
ActionSet::GetKeyString
QString GetKeyString(const ActionID &id) const
Returns a string containing all the keys in bound to an action by its identifier.
Definition: actionset.cpp:222