⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qkeysequence.cpp

📁 qt-x11-opensource-src-4.1.4.tar.gz源码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
                           : QString(QLatin1String("F%1")).arg(key - Qt::Key_F1 + 1);    } else if (key) {        int i=0;        while (keyname[i].name) {            if (key == keyname[i].key) {                p = nativeText ? QShortcut::tr(keyname[i].name)                               : QString(QLatin1String(keyname[i].name));                break;            }            ++i;        }        // If we can't find the actual translatable keyname,        // fall back on the unicode representation of it...        // Or else characters like Qt::Key_aring may not get displayed        // (Really depends on you locale)        if (!keyname[i].name) {            if (key < 0x10000) {                p = QChar(key & 0xffff).toUpper();            } else {                p = QChar((key-0x10000)/0x400+0xd800);                p += QChar((key-0x10000)%400+0xdc00);            }        }    }#ifdef Q_WS_MAC    if (nativeText)        s += p;    else#endif    addKey(s, p, format);    return s;}/*!    Matches the sequence with \a seq. Returns ExactMatch if    successful, PartialMatch if \a seq matches incompletely,    and NoMatch if the sequences have nothing in common.    Returns NoMatch if \a seq is shorter.*/QKeySequence::SequenceMatch QKeySequence::matches(const QKeySequence &seq) const{    uint userN = count(),          seqN = seq.count();    if (userN > seqN)        return NoMatch;    // If equal in length, we have a potential ExactMatch sequence,    // else we already know it can only be partial.    SequenceMatch match = (userN == seqN ? ExactMatch : PartialMatch);    for (uint i = 0; i < userN; ++i) {        int userKey = (*this)[i],            sequenceKey = seq[i];        if (userKey != sequenceKey)            return NoMatch;    }    return match;}/*!    Creates a shortcut string for the key sequence.    For example, the value Qt::CTRL+Qt::Key_O results in "Ctrl+O".    If the key sequence has multiple key codes, each is separated    by commas in the string returned, such as "Alt+X, Ctrl+Y, Z".    The strings, "Ctrl", "Shift", etc. are translated using    QObject::tr() in the "QShortcut" scope.    If the key sequence has no keys, an empty string is returned.    On Mac OS X, the string returned resembles the sequence that is    shown in the menubar.    \sa toString()*/QKeySequence::operator QString() const{    return QKeySequence::toString(QKeySequence::NativeText);}/*!   Returns the key sequence as a QVariant*/QKeySequence::operator QVariant() const{    return QVariant(QVariant::KeySequence, this);}/*!    \obsolete    For backward compatibility: returns the first keycode    as integer. If the key sequence is empty, 0 is returned. */QKeySequence::operator int () const{    if (1 <= count())        return d->key[0];    return 0;}/*!    Returns a reference to the element at position \a index in the key    sequence. This can only be used to read an element. */int QKeySequence::operator[](uint index) const{    Q_ASSERT_X(index < 4, "QKeySequence::operator[]", "index out of range");    return d->key[index];}/*!    Assignment operator. Assigns the \a other key sequence to this    object. */QKeySequence &QKeySequence::operator=(const QKeySequence &other){    qAtomicAssign(d, other.d);    return *this;}/*!    \fn bool QKeySequence::operator!=(const QKeySequence &other) const    Returns true if this key sequence is not equal to the \a other    key sequence; otherwise returns false.*//*!    Returns true if this key sequence is equal to the \a other    key sequence; otherwise returns false. */bool QKeySequence::operator==(const QKeySequence &other) const{    return (d->key[0] == other.d->key[0] &&            d->key[1] == other.d->key[1] &&            d->key[2] == other.d->key[2] &&            d->key[3] == other.d->key[3]);}/*!    Provides an arbitrary comparison of this key sequence and    \a other key sequence. All that is guaranteed is that the    operator returns false if both key sequences are equal and    that (ks1 \< ks2) == !( ks2 \< ks1) if the key sequences    are not equal.    This function is useful in some circumstances, for example    if you want to use QKeySequence objects as keys in a QMap.    \sa operator==() operator!=() operator>() operator<=() operator>=()*/bool QKeySequence::operator< (const QKeySequence &other) const{    for (int i = 0; i < 4; ++i)        if (d->key[i] != other.d->key[i])            return d->key[i] < other.d->key[i];    return false;}/*!    \fn bool QKeySequence::operator> (const QKeySequence &other) const    Returns true if this key sequence is larger than the \a other key    sequence; otherwise returns false.    \sa operator==() operator!=() operator<() operator<=() operator>=()*//*!    \fn bool QKeySequence::operator<= (const QKeySequence &other) const    Returns true if this key sequence is smaller or equal to the    \a other key sequence; otherwise returns false.    \sa operator==() operator!=() operator<() operator>() operator>=()*//*!    \fn bool QKeySequence::operator>= (const QKeySequence &other) const    Returns true if this key sequence is larger or equal to the    \a other key sequence; otherwise returns false.    \sa operator==() operator!=() operator<() operator>() operator<=()*//*!    \internal*/bool QKeySequence::isDetached() const{    return d->ref == 1;}/*!    \since 4.1    Return a string representation of the key sequence based on \a format.    \sa fromString()*/QString QKeySequence::toString(SequenceFormat format) const{    QString finalString;    // A standard string, with no translation or anything like that. In some ways it will    // look like our latin case on Windows and X11    int end = count();    for (int i = 0; i < end; ++i) {        finalString += d->encodeString(d->key[i], format);        finalString += QLatin1String(", ");    }    finalString.truncate(finalString.length() - 2);    return finalString;}/*!    \since 4.1    Return a QKeySequence from the string \a str based on \a format.    \sa toString()*/QKeySequence QKeySequence::fromString(const QString &str, SequenceFormat format){    QStringList sl = str.split(QLatin1String(", "));    int keys[4] = {0, 0, 0, 0};    int total = qMin(sl.count(), 4);    for (int i = 0; i < total; ++i)        keys[i] = QKeySequencePrivate::decodeString(sl[i], format);    return QKeySequence(keys[0], keys[1], keys[2], keys[3]);}/*****************************************************************************  QKeySequence stream functions *****************************************************************************/#if !defined(QT_NO_DATASTREAM)/*!    \fn QDataStream &operator<<(QDataStream &stream, const QKeySequence &sequence)    \relates QKeySequence    Writes the key \a sequence to the \a stream.    \sa \link datastreamformat.html Format of the QDataStream operators \endlink*/QDataStream &operator<<(QDataStream &s, const QKeySequence &keysequence){    QList<quint32> list;    list << keysequence.d->key[0];    if (s.version() >= 5 && keysequence.count() > 1) {        list << keysequence.d->key[1];        list << keysequence.d->key[2];        list << keysequence.d->key[3];    }    s << list;    return s;}/*!    \fn QDataStream &operator>>(QDataStream &stream, QKeySequence &sequence)    \relates QKeySequence    Reads a key sequence from the \a stream into the key \a sequence.    \sa \link datastreamformat.html Format of the QDataStream operators \endlink*/QDataStream &operator>>(QDataStream &s, QKeySequence &keysequence){	qAtomicDetach(keysequence.d);    QList<quint32> list;    s >> list;    for (int i = 0; i < 4; ++i)        keysequence.d->key[i] = list.value(i);    return s;}#endif //QT_NO_DATASTREAM#ifndef QT_NO_DEBUG_STREAMQDebug operator<<(QDebug dbg, const QKeySequence &p){#ifndef Q_BROKEN_DEBUG_STREAM    dbg.nospace() << "QKeySequence(" << QString(p) << ')';    return dbg.space();#else    qWarning("This compiler doesn't support streaming QKeySequence to QDebug");    return dbg;    Q_UNUSED(p);#endif}#endif#endif // QT_NO_SHORTCUT

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -