|
MythTV
0.26-pre
|
00001 /* -*- myth -*- */ 00025 // Qt headers 00026 #include <QKeySequence> 00027 00028 // MythControls headers 00029 #include "action.h" 00030 00041 Action::Action(const QString &description, const QString &keys) 00042 : m_description(description), 00043 m_keys(QString(QKeySequence(keys)).split(", ")) 00044 { 00045 m_description.detach(); 00046 m_keys.detach(); 00047 } 00048 00055 bool Action::HasKey(const QString &key) const 00056 { 00057 return m_keys.contains(key); 00058 } 00059 00071 bool Action::AddKey(const QString &key) 00072 { 00073 if (key.isEmpty() || HasKey(key) || 00074 ((uint)m_keys.size() >= kMaximumNumberOfBindings)) 00075 { 00076 return false; 00077 } 00078 00079 QString tmp = key; 00080 tmp.detach(); 00081 m_keys.push_back(tmp); 00082 00083 return true; 00084 } 00085 00091 bool Action::ReplaceKey(const QString &newkey, const QString &oldkey) 00092 { 00093 // make sure that the key list doesn't already have the new key 00094 if (HasKey(newkey)) 00095 return false; 00096 00097 int idx = m_keys.indexOf(oldkey); 00098 if (idx < 0) 00099 return false; 00100 00101 QString tmp = newkey; 00102 tmp.detach(); 00103 m_keys[idx] = tmp; 00104 return true; 00105 }
1.7.6.1