KDEUI
kshortcut.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00027 #ifndef KSHORTCUT_H
00028 #define KSHORTCUT_H
00029
00030 #include <kdeui_export.h>
00031
00032 #include <QtCore/QList>
00033 #include <QtCore/QMetaType>
00034 #include <QtGui/QKeySequence>
00035
00036 class KShortcutPrivate;
00037
00057 class KDEUI_EXPORT KShortcut
00058 {
00059 public:
00063 enum EmptyHandling {
00065 KeepEmpty = 0,
00067 RemoveEmpty
00068 };
00069
00075 KShortcut();
00076
00082 explicit KShortcut(const QKeySequence &primary);
00083
00091 KShortcut(const QKeySequence &primary, const QKeySequence &alternate);
00092
00101 explicit KShortcut(int keyQtPri, int keyQtAlt = 0);
00102
00106 KShortcut(const KShortcut &other);
00107
00117 explicit KShortcut(const QString &description);
00118
00125 explicit KShortcut(const QList<QKeySequence> &seqs);
00126
00130 ~KShortcut();
00131
00139 QKeySequence primary() const;
00140
00145 QKeySequence alternate() const;
00146
00151 bool isEmpty() const;
00152
00157 bool contains(const QKeySequence &needle) const;
00158
00166 QString toString() const;
00167
00168 bool operator==(const KShortcut &other) const;
00169
00170 bool operator!=(const KShortcut &other) const;
00171
00180 operator QList<QKeySequence>() const;
00181
00189 QList<QKeySequence> toList(enum EmptyHandling handleEmpty = RemoveEmpty) const;
00190
00194 operator QVariant() const;
00195
00204 void setPrimary(const QKeySequence &keySeq);
00205
00210 void setAlternate(const QKeySequence &keySeq);
00211
00218 void remove(const QKeySequence &keySeq, enum EmptyHandling handleEmpty = RemoveEmpty);
00219
00223 KShortcut &operator=(const KShortcut &other);
00224
00225 private:
00226 class KShortcutPrivate *const d;
00227 };
00228
00229 uint qHash(int);
00230 inline uint qHash(const KShortcut &key)
00231 {
00232 return qHash(key.primary()[0]) + qHash(key.primary()[1]);
00233 }
00234
00235 inline uint qHash(const QKeySequence &key)
00236 {
00237 uint hash = 0;
00238 for(uint i = 0; i < key.count(); i++)
00239 hash += qHash(key[i]);
00240 return hash;
00241 }
00242
00243 Q_DECLARE_METATYPE(KShortcut)
00244
00245 #endif // KSHORTCUT_H