KDEUI
kshortcut.h
Go to the documentation of this file.
00001 /* This file is part of the KDE libraries 00002 Copyright (C) 2001,2002 Ellis Whitehead <ellis@kde.org> 00003 Copyright (C) 2006 Hamish Rodda <rodda@kde.org> 00004 Copyright (C) 2006 Andreas Hartmetz <ahartmetz@gmail.com> 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License as published by the Free Software Foundation; either 00009 version 2 of the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Library General Public License for more details. 00015 00016 You should have received a copy of the GNU Library General Public License 00017 along with this library; see the file COPYING.LIB. If not, write to 00018 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 Boston, MA 02110-1301, USA. 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
KDE 4.6 API Reference