- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- File List
- File Members

# qkeysequence.h

Go to the documentation of this file.

    00001 /****************************************************************************
    00002 **
    00003 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    00004 ** All rights reserved.
    00005 ** Contact: Nokia Corporation (qt-info@nokia.com)
    00006 **
    00007 ** This file is part of the QtGui module of the Qt Toolkit.
    00008 **
    00009 ** $QT_BEGIN_LICENSE:LGPL$
    00010 ** Commercial Usage
    00011 ** Licensees holding valid Qt Commercial licenses may use this file in
    00012 ** accordance with the Qt Commercial License Agreement provided with the
    00013 ** Software or, alternatively, in accordance with the terms contained in
    00014 ** a written agreement between you and Nokia.
    00015 **
    00016 ** GNU Lesser General Public License Usage
    00017 ** Alternatively, this file may be used under the terms of the GNU Lesser
    00018 ** General Public License version 2.1 as published by the Free Software
    00019 ** Foundation and appearing in the file LICENSE.LGPL included in the
    00020 ** packaging of this file.  Please review the following information to
    00021 ** ensure the GNU Lesser General Public License version 2.1 requirements
    00022 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    00023 **
    00024 ** In addition, as a special exception, Nokia gives you certain additional
    00025 ** rights.  These rights are described in the Nokia Qt LGPL Exception
    00026 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this module.
    00027 **
    00028 ** GNU General Public License Usage
    00029 ** Alternatively, this file may be used under the terms of the GNU
    00030 ** General Public License version 3.0 as published by the Free Software
    00031 ** Foundation and appearing in the file LICENSE.GPL included in the
    00032 ** packaging of this file.  Please review the following information to
    00033 ** ensure the GNU General Public License version 3.0 requirements will be
    00034 ** met: http://www.gnu.org/copyleft/gpl.html.
    00035 **
    00036 ** If you have questions regarding the use of this file, please contact
    00037 ** Nokia at qt-info@nokia.com.
    00038 ** $QT_END_LICENSE$
    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   QKeySequence stream functions
    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; // ### Qt 5: return 'int'
    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     // ### Qt 5: kill 'operator QString' - it's evil
    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