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
00163 bool conflictsWith(const QKeySequence &needle) const;
00164
00172 QString toString() const;
00173
00182 QString toString(QKeySequence::SequenceFormat format) const;
00183
00184 bool operator==(const KShortcut &other) const;
00185
00186 bool operator!=(const KShortcut &other) const;
00187
00196 operator QList<QKeySequence>() const;
00197
00205 QList<QKeySequence> toList(enum EmptyHandling handleEmpty = RemoveEmpty) const;
00206
00210 operator QVariant() const;
00211
00220 void setPrimary(const QKeySequence &keySeq);
00221
00226 void setAlternate(const QKeySequence &keySeq);
00227
00234 void remove(const QKeySequence &keySeq, enum EmptyHandling handleEmpty = RemoveEmpty);
00235
00239 KShortcut &operator=(const KShortcut &other);
00240
00241 private:
00242 class KShortcutPrivate *const d;
00243 };
00244
00245 uint qHash(int);
00246 inline uint qHash(const KShortcut &key)
00247 {
00248 return qHash(key.primary()[0]) + qHash(key.primary()[1]);
00249 }
00250
00251 inline uint qHash(const QKeySequence &key)
00252 {
00253 uint hash = 0;
00254 for(uint i = 0; i < key.count(); i++)
00255 hash += qHash(key[i]);
00256 return hash;
00257 }
00258
00259 Q_DECLARE_METATYPE(KShortcut)
00260
00261 #endif // KSHORTCUT_H