| 4 | #include <QtCore/QHash> |
| 5 | |
| 6 | struct KeyCode { |
| 7 | KeyCode() : mCode(~0) {} |
| 8 | KeyCode(unsigned code) : mCode(code) {} |
| 9 | KeyCode(unsigned row, unsigned col) : mCode(((row & 7) << 3) | |
| 10 | ((col & 7) << 0)) {} |
| 11 | |
| 12 | bool valid() const { return mCode >> 6 == 0; } |
| 13 | unsigned char code() const { return mCode; } |
| 14 | unsigned char row() const { return (mCode >> 3) & 7; } |
| 15 | unsigned char col() const { return (mCode >> 0) & 7; } |
| 16 | |
| 17 | bool operator==(KeyCode other) const { return code() == other.code(); } |
| 18 | bool operator!=(KeyCode other) const { return !(*this == other); } |
| 19 | friend uint qHash(KeyCode code, uint seed = 0) { |
| 20 | return qHash(code.code(), seed); |
| 21 | } |
| 22 | |
| 23 | private: |
| 24 | unsigned char mCode; |
| 25 | }; |
| 26 | |
| 27 | #endif |
nothing calls this directly
no outgoing calls
no test coverage detected