refs #912, utility function for hotkey list

This commit is contained in:
Klaus Basan
2017-03-18 22:48:43 +01:00
committed by Mathew Sutcliffe
parent 08f6f3f81c
commit 9921cc3497
2 changed files with 16 additions and 9 deletions

View File

@@ -20,7 +20,7 @@ namespace BlackMisc
CSequence<CActionHotkey>(baseClass)
{ }
CActionHotkeyList CActionHotkeyList::findSubsetsOf(const CActionHotkey &other)
CActionHotkeyList CActionHotkeyList::findSubsetsOf(const CActionHotkey &other) const
{
CActionHotkeyList subsets;
for (const auto &actionHotkey : *this)
@@ -33,7 +33,7 @@ namespace BlackMisc
return subsets;
}
CActionHotkeyList CActionHotkeyList::findSupersetsOf(const CActionHotkey &other)
CActionHotkeyList CActionHotkeyList::findSupersetsOf(const CActionHotkey &other) const
{
CActionHotkeyList supersets;
for (const auto &actionHotkey : *this)
@@ -45,5 +45,10 @@ namespace BlackMisc
}
return supersets;
}
}
}
bool CActionHotkeyList::containsAction(const QString &action) const
{
return this->contains(&CActionHotkey::getAction, action);
}
} // ns
} // ns

View File

@@ -47,16 +47,18 @@ namespace BlackMisc
//! Returns true if this list has a action hotkey with a combination which is a subset of other
//! Example:
//! List contains CTRL and other has combination CTRL-F
CActionHotkeyList findSubsetsOf(const CActionHotkey &other);
CActionHotkeyList findSubsetsOf(const CActionHotkey &other) const;
//! Returns true if this list has a hotkey with a combination for which other is a subset
//! Example:
//! List contains CTRL-F and other has combination CTRL
CActionHotkeyList findSupersetsOf(const CActionHotkey &other);
};
CActionHotkeyList findSupersetsOf(const CActionHotkey &other) const;
}
} // namespace
//! Contains action
bool containsAction(const QString &action) const;
};
} // ns
} // ns
Q_DECLARE_METATYPE(BlackMisc::Input::CActionHotkeyList)
Q_DECLARE_METATYPE(BlackMisc::CCollection<BlackMisc::Input::CActionHotkey>)