00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #ifndef QKEYSEQUENCE_H
00043 #define QKEYSEQUENCE_H
00044
00045 #include <QtCore/qnamespace.h>
00046 #include <QtCore/qstring.h>
00047
00048 QT_BEGIN_HEADER
00049
00050 QT_BEGIN_NAMESPACE
00051
00052 QT_MODULE(Gui)
00053
00054 #ifndef QT_NO_SHORTCUT
00055
00056
00057
00058
00059 #ifndef QT_NO_DATASTREAM
00060 class QKeySequence;
00061 Q_GUI_EXPORT QDataStream &operator<<(QDataStream &in, const QKeySequence &ks);
00062 Q_GUI_EXPORT QDataStream &operator>>(QDataStream &out, QKeySequence &ks);
00063 #endif
00064
00065 #ifdef qdoc
00066 void qt_set_sequence_auto_mnemonic(bool b);
00067 #endif
00068
00069 class QVariant;
00070 class QKeySequencePrivate;
00071
00072 class Q_GUI_EXPORT QKeySequence
00073 {
00074 public:
00075 enum StandardKey {
00076 UnknownKey,
00077 HelpContents,
00078 WhatsThis,
00079 Open,
00080 Close,
00081 Save,
00082 New,
00083 Delete,
00084 Cut,
00085 Copy,
00086 Paste,
00087 Undo,
00088 Redo,
00089 Back,
00090 Forward,
00091 Refresh,
00092 ZoomIn,
00093 ZoomOut,
00094 Print,
00095 AddTab,
00096 NextChild,
00097 PreviousChild,
00098 Find,
00099 FindNext,
00100 FindPrevious,
00101 Replace,
00102 SelectAll,
00103 Bold,
00104 Italic,
00105 Underline,
00106 MoveToNextChar,
00107 MoveToPreviousChar,
00108 MoveToNextWord,
00109 MoveToPreviousWord,
00110 MoveToNextLine,
00111 MoveToPreviousLine,
00112 MoveToNextPage,
00113 MoveToPreviousPage,
00114 MoveToStartOfLine,
00115 MoveToEndOfLine,
00116 MoveToStartOfBlock,
00117 MoveToEndOfBlock,
00118 MoveToStartOfDocument,
00119 MoveToEndOfDocument,
00120 SelectNextChar,
00121 SelectPreviousChar,
00122 SelectNextWord,
00123 SelectPreviousWord,
00124 SelectNextLine,
00125 SelectPreviousLine,
00126 SelectNextPage,
00127 SelectPreviousPage,
00128 SelectStartOfLine,
00129 SelectEndOfLine,
00130 SelectStartOfBlock,
00131 SelectEndOfBlock,
00132 SelectStartOfDocument,
00133 SelectEndOfDocument,
00134 DeleteStartOfWord,
00135 DeleteEndOfWord,
00136 DeleteEndOfLine,
00137 InsertParagraphSeparator,
00138 InsertLineSeparator,
00139 SaveAs,
00140 Preferences,
00141 Quit
00142 };
00143
00144 enum SequenceFormat {
00145 NativeText,
00146 PortableText
00147 };
00148
00149 QKeySequence();
00150 QKeySequence(const QString &key);
00151 QKeySequence(const QString &key, SequenceFormat format);
00152 QKeySequence(int k1, int k2 = 0, int k3 = 0, int k4 = 0);
00153 QKeySequence(const QKeySequence &ks);
00154 QKeySequence(StandardKey key);
00155 ~QKeySequence();
00156
00157 uint count() const;
00158 bool isEmpty() const;
00159
00160 enum SequenceMatch {
00161 NoMatch,
00162 PartialMatch,
00163 ExactMatch
00164 #ifdef QT3_SUPPORT
00165 , Identical = ExactMatch
00166 #endif
00167 };
00168
00169 QString toString(SequenceFormat format = PortableText) const;
00170 static QKeySequence fromString(const QString &str, SequenceFormat format = PortableText);
00171
00172 SequenceMatch matches(const QKeySequence &seq) const;
00173 static QKeySequence mnemonic(const QString &text);
00174 static QList<QKeySequence> keyBindings(StandardKey key);
00175
00176
00177 operator QString() const;
00178 operator QVariant() const;
00179 operator int() const;
00180 int operator[](uint i) const;
00181 QKeySequence &operator=(const QKeySequence &other);
00182 bool operator==(const QKeySequence &other) const;
00183 inline bool operator!= (const QKeySequence &other) const
00184 { return !(*this == other); }
00185 bool operator< (const QKeySequence &ks) const;
00186 inline bool operator> (const QKeySequence &other) const
00187 { return other < *this; }
00188 inline bool operator<= (const QKeySequence &other) const
00189 { return !(other < *this); }
00190 inline bool operator>= (const QKeySequence &other) const
00191 { return !(*this < other); }
00192
00193 bool isDetached() const;
00194 private:
00195 static int decodeString(const QString &ks);
00196 static QString encodeString(int key);
00197 int assign(const QString &str);
00198 int assign(const QString &str, SequenceFormat format);
00199 void setKey(int key, int index);
00200
00201 QKeySequencePrivate *d;
00202
00203 friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &in, const QKeySequence &ks);
00204 friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &in, QKeySequence &ks);
00205 friend class Q3AccelManager;
00206 friend class QShortcutMap;
00207 friend class QShortcut;
00208
00209 public:
00210 typedef QKeySequencePrivate * DataPtr;
00211 inline DataPtr &data_ptr() { return d; }
00212 };
00213 Q_DECLARE_TYPEINFO(QKeySequence, Q_MOVABLE_TYPE);
00214 Q_DECLARE_SHARED(QKeySequence)
00215
00216 #ifndef QT_NO_DEBUG_STREAM
00217 Q_GUI_EXPORT QDebug operator<<(QDebug, const QKeySequence &);
00218 #endif
00219
00220 #else
00221
00222 class Q_GUI_EXPORT QKeySequence
00223 {
00224 public:
00225 QKeySequence() {}
00226 QKeySequence(int) {}
00227 };
00228
00229 #endif // QT_NO_SHORTCUT
00230
00231 QT_END_NAMESPACE
00232
00233 QT_END_HEADER
00234
00235 #endif // QKEYSEQUENCE_H