blob: 36a32d2c73601ca1c17edbbcf7fe1cb1fc7ea940 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
#ifndef MYKEY_H
#define MYKEY_H
#include <qstring.h>
class MyKey
{
public:
MyKey(short key, short modFlags){modFlags_ = modFlags; key_ = key;}
MyKey(){modFlags_ = 0; key_ = 0;}
MyKey(QString & string)
{
QString tmpString = string.left(string.findRev('+'));
modFlags_ = 0;
if (tmpString.contains("256")) // QString.setNum(Qt::ShiftButton)
modFlags_ |= Qt::ShiftButton;
if (tmpString.contains("512")) // QString.setNum(Qt::ControlButton)
modFlags_ |= Qt::ControlButton;
if (tmpString.contains("1024")) // QString.setNum(Qt::AltButton)
modFlags_ |= Qt::AltButton;
tmpString = string.right(string.length() - string.findRev('+') - 1);
key_ = tmpString.toShort();
}
short modFlags() const {return modFlags_;}
short key()const {return key_;}
bool operator==( const MyKey& myKey ) const
{
return (modFlags_ == myKey.modFlags() && key_ == myKey.key());
}
bool operator!=( const MyKey& myKey ) const
{
return (modFlags_ != myKey.modFlags() || key_ != myKey.key());
}
bool operator<( const MyKey& myKey ) const
{
return (!(modFlags_ < myKey.modFlags()) || key_ < myKey.key());
}
bool operator>( const MyKey& myKey ) const
{
return (!(modFlags_ > myKey.modFlags()) && key_ > myKey.key());
}
QString toString() const
{
QString string;
QString numString;
if (modFlags_ & Qt::ShiftButton)
{
numString.setNum(Qt::ShiftButton);
string += numString;
string += '+';
}
if (modFlags_ & Qt::ControlButton)
{
numString.setNum(Qt::ControlButton);
string += numString;
string += '+';
}
if (modFlags_ & Qt::AltButton)
{
numString.setNum(Qt::AltButton);
string += numString;
string += '+';
}
numString.setNum(key_);
string += numString;
return string;
}
private:
short modFlags_;
short key_;
};
#endif
|