当前位置: 首页>>代码示例>>C++>>正文


C++ QMetaEnum::valueToKey方法代码示例

本文整理汇总了C++中QMetaEnum::valueToKey方法的典型用法代码示例。如果您正苦于以下问题:C++ QMetaEnum::valueToKey方法的具体用法?C++ QMetaEnum::valueToKey怎么用?C++ QMetaEnum::valueToKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QMetaEnum的用法示例。


在下文中一共展示了QMetaEnum::valueToKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

QDebug operator <<(QDebug debug, const Snore::SnorePlugin::PluginTypes &flags)
{
    QMetaEnum e = SnorePlugin::staticMetaObject.enumerator(SnorePlugin::staticMetaObject.indexOfEnumerator("PluginType"));
    debug.nospace() << "PluginTypes(";
    bool needSeparator = false;
    int key;
    for (int i = 0; i < e.keyCount(); ++i)
    {
        key = e.value(i);
        if (flags.testFlag((SnorePlugin::PluginType)key))
        {
            if (needSeparator)
            {
                debug.nospace() << '|';
            }
            else
            {
                needSeparator = true;
            }

            debug.nospace() << e.valueToKey(key);

        }
    }
    debug << ')';
    return debug.space();

}
开发者ID:muesli,项目名称:Snorenotify,代码行数:28,代码来源:plugins.cpp

示例2: getValue

QString GestureDirectionEnum::getValue(GestureDirection gdEnum)
{
    GestureDirectionEnum GestureDirectionEnum;
    int index = GestureDirectionEnum.metaObject()->indexOfEnumerator("GestureDirection");
    QMetaEnum metaEnum = GestureDirectionEnum.metaObject()->enumerator(index);
    return metaEnum.valueToKey(gdEnum);
}
开发者ID:WilliamDCLT,项目名称:linux_config,代码行数:7,代码来源:GestureDirectionEnum.cpp

示例3: save

void DownloadManager::save() const
{
    QSettings settings;
    settings.beginGroup(QLatin1String("downloadmanager"));
    QMetaEnum removePolicyEnum = staticMetaObject.enumerator(staticMetaObject.indexOfEnumerator("RemovePolicy"));
    settings.setValue(QLatin1String("removeDownloadsPolicy"), QLatin1String(removePolicyEnum.valueToKey(m_removePolicy)));
    settings.setValue(QLatin1String("size"), size());
    if (m_removePolicy == Exit)
        return;

    for (int i = 0; i < m_downloads.count(); ++i) {
        QString key = QString(QLatin1String("download_%1_")).arg(i);
        settings.setValue(key + QLatin1String("url"), m_downloads[i]->m_url);
        settings.setValue(key + QLatin1String("location"), QFileInfo(m_downloads[i]->m_output).filePath());
        settings.setValue(key + QLatin1String("done"), m_downloads[i]->downloadedSuccessfully());
    }
    int i = m_downloads.count();
    QString key = QString(QLatin1String("download_%1_")).arg(i);
    while (settings.contains(key + QLatin1String("url"))) {
        settings.remove(key + QLatin1String("url"));
        settings.remove(key + QLatin1String("location"));
        settings.remove(key + QLatin1String("done"));
        key = QString(QLatin1String("download_%1_")).arg(++i);
    }
}
开发者ID:dfizban,项目名称:remixos-usb-tool,代码行数:25,代码来源:downloadmanager.cpp

示例4: networkState

MediaPlayer::NetworkState MediaPlayerPrivate::networkState() const
{
    const QMetaObject* metaObj = this->metaObject();
    QMetaEnum networkStates = metaObj->enumerator(metaObj->indexOfEnumerator("NetworkState"));
    LOG(Media, "MediaPlayerPrivatePhonon::networkState() --> %s", networkStates.valueToKey(m_networkState));
    return m_networkState;
}
开发者ID:boyliang,项目名称:ComponentSuperAccessor,代码行数:7,代码来源:MediaPlayerPrivatePhonon.cpp

示例5: fixError

void QgsGeometryGapCheck::fixError( const QMap<QString, QgsFeaturePool *> &featurePools, QgsGeometryCheckError *error, int method, const QMap<QString, int> & /*mergeAttributeIndices*/, Changes &changes ) const
{
  QMetaEnum metaEnum = QMetaEnum::fromType<QgsGeometryGapCheck::ResolutionMethod>();
  if ( !metaEnum.isValid() || !metaEnum.valueToKey( method ) )
  {
    error->setFixFailed( tr( "Unknown method" ) );
  }
  else
  {
    ResolutionMethod methodValue = static_cast<ResolutionMethod>( method );
    switch ( methodValue )
    {
      case NoChange:
        error->setFixed( method );
        break;
      case MergeLongestEdge:
        QString errMsg;
        if ( mergeWithNeighbor( featurePools, static_cast<QgsGeometryGapCheckError *>( error ), changes, errMsg ) )
        {
          error->setFixed( method );
        }
        else
        {
          error->setFixFailed( tr( "Failed to merge with neighbor: %1" ).arg( errMsg ) );
        }
        break;
    }
  }
}
开发者ID:phborba,项目名称:QGIS,代码行数:29,代码来源:qgsgeometrygapcheck.cpp

示例6: eventName

QString RPGEngine::eventName(QEvent * event)
{
  QMetaObject dataObject = event->staticMetaObject;
  int index = dataObject.indexOfEnumerator("Type");
  QMetaEnum enumData = dataObject.enumerator(index);
  return QString(enumData.valueToKey(event->type()));
}
开发者ID:SaLanc,项目名称:Orange-Engine,代码行数:7,代码来源:rpgengine.cpp

示例7: readyState

MediaPlayer::ReadyState MediaPlayerPrivate::readyState() const
{
    const QMetaObject* metaObj = this->metaObject();
    QMetaEnum readyStates = metaObj->enumerator(metaObj->indexOfEnumerator("ReadyState"));
    LOG(Media, "MediaPlayerPrivatePhonon::readyState() --> %s", readyStates.valueToKey(m_readyState));
    return m_readyState;
}
开发者ID:boyliang,项目名称:ComponentSuperAccessor,代码行数:7,代码来源:MediaPlayerPrivatePhonon.cpp

示例8: onSocketError

void CardReader::onSocketError(QAbstractSocket::SocketError error)
{
	// See http://stackoverflow.com/a/16390227
	const QMetaObject & metaObject = QAbstractSocket::staticMetaObject;
	QMetaEnum metaEnum = metaObject.enumerator(metaObject.indexOfEnumerator("SocketError"));
	frontend_error(QStringLiteral("Socket error: ") + metaEnum.valueToKey(error), false);
}
开发者ID:SVArago,项目名称:Arago-Card-Reader,代码行数:7,代码来源:cardreader.cpp

示例9: toString

/*!
    Returns the numeric \a code as a string or \a 0 if the code is unknown.

    \sa Irc::Code and IrcNumericMessage::code()
 */
const char* Irc::toString(int code)
{
    int index = staticMetaObject.indexOfEnumerator("Code");
    Q_ASSERT(index != -1);
    QMetaEnum enumerator = staticMetaObject.enumerator(index);
    return enumerator.valueToKey(code);
}
开发者ID:jbache,项目名称:communi,代码行数:12,代码来源:irc.cpp

示例10: block

/*! Writes the data of the given \a coapOption to \a dbg.

    \sa CoapOption
*/
QDebug operator<<(QDebug debug, const CoapOption &coapOption)
{
    const QMetaObject &metaObject = CoapOption::staticMetaObject;
    QMetaEnum optionEnum = metaObject.enumerator(metaObject.indexOfEnumerator("Option"));

    switch (coapOption.option()) {
    case CoapOption::ETag:
        debug.nospace() << "CoapOption(" << optionEnum.valueToKey(coapOption.option()) << "): " << "0x" + coapOption.data().toHex() << endl;
        break;
    case CoapOption::UriHost:
        debug.nospace() << "CoapOption(" << optionEnum.valueToKey(coapOption.option()) << "): " << coapOption.data() << endl;
        break;
    case CoapOption::UriPath:
        debug.nospace() << "CoapOption(" << optionEnum.valueToKey(coapOption.option()) << "): " << coapOption.data() << endl;
        break;
    case CoapOption::UriQuery:
        debug.nospace() << "CoapOption(" << optionEnum.valueToKey(coapOption.option()) << "): " << coapOption.data() << endl;
        break;
    case CoapOption::ContentFormat: {
        const QMetaObject &pduMetaObject = CoapPdu::staticMetaObject;
        QMetaEnum contentEnum = pduMetaObject.enumerator(pduMetaObject.indexOfEnumerator("ContentType"));
        debug.nospace() << "CoapOption(" << optionEnum.valueToKey(coapOption.option()) << "): " << contentEnum.valueToKey(static_cast<CoapPdu::ContentType>(coapOption.data().toHex().toInt(0, 16))) << endl;
        break;
    }
    case CoapOption::Block1: {
        // SZX = size exponent
        CoapPduBlock block(coapOption.data());
        debug.nospace() << "CoapOption(" << optionEnum.valueToKey(coapOption.option()) << "): " << coapOption.data().toHex() << " Block #" << block.blockNumber() << ", More flag = " << block.moreFlag() << ", SZX:" << block.blockSize() << endl;
        break;
    }
    case CoapOption::Block2: {
        // SZX = size exponent
        CoapPduBlock block(coapOption.data());
        debug.nospace() << "CoapOption(" << optionEnum.valueToKey(coapOption.option()) << "): " << coapOption.data().toHex() << " Block #" << block.blockNumber() << ", More flag = " << block.moreFlag() << ", SZX:" << block.blockSize() << endl;
        break;
    }
    case CoapOption::Observe: {
        debug.nospace() << "CoapOption(" << optionEnum.valueToKey(coapOption.option()) << "): " << coapOption.data().toHex().toInt(0, 16) << endl;
        break;
    }
    default:
        QString optionName = optionEnum.valueToKey(coapOption.option());
        if (optionName.isNull()) {
            debug.nospace() << "CoapOption(" << "Unknown" << "): " << "value = " << coapOption.option() << " -> " << coapOption.data() << " = " << "0x" + coapOption.data().toHex() << endl;
        } else {
            debug.nospace() << "CoapOption(" << optionName << "): " << coapOption.data() << " = " << "0x" + coapOption.data().toHex() << endl;
        }
        break;
    }

    return debug.space();
}
开发者ID:Boernsman,项目名称:guh,代码行数:56,代码来源:coapoption.cpp

示例11: updateStates

void MediaPlayerPrivate::updateStates()
{
    MediaPlayer::NetworkState oldNetworkState = m_networkState;
    MediaPlayer::ReadyState oldReadyState = m_readyState;

    Phonon::State phononState = m_mediaObject->state();

    if (phononState == Phonon::StoppedState) {
        if (m_readyState < MediaPlayer::HaveMetadata) {
            m_networkState = MediaPlayer::Loading; // FIXME: should this be MediaPlayer::Idle?
            m_readyState = MediaPlayer::HaveMetadata;
            m_mediaObject->pause();
        }
    } else if (phononState == Phonon::PausedState) {
        m_networkState = MediaPlayer::Loaded;
        m_readyState = MediaPlayer::HaveEnoughData;
    } else if (phononState == Phonon::ErrorState) {
         if (!m_mediaObject || m_mediaObject->errorType() == Phonon::FatalError) {
             // FIXME: is it possile to differentiate between different types of errors
             m_networkState = MediaPlayer::NetworkError;
             m_readyState = MediaPlayer::HaveNothing;
             cancelLoad();
         } else
             m_mediaObject->pause();
    }

    if (seeking())
        m_readyState = MediaPlayer::HaveNothing;

    if (m_networkState != oldNetworkState) {
        const QMetaObject* metaObj = this->metaObject();
        QMetaEnum networkStates = metaObj->enumerator(metaObj->indexOfEnumerator("NetworkState"));
        LOG(Media, "Network state changed from '%s' to '%s'",
                networkStates.valueToKey(oldNetworkState),
                networkStates.valueToKey(m_networkState));
        m_player->networkStateChanged();
    }

    if (m_readyState != oldReadyState) {
        const QMetaObject* metaObj = this->metaObject();
        QMetaEnum readyStates = metaObj->enumerator(metaObj->indexOfEnumerator("ReadyState"));
        LOG(Media, "Ready state changed from '%s' to '%s'",
                readyStates.valueToKey(oldReadyState),
                readyStates.valueToKey(m_readyState));
        m_player->readyStateChanged();
    }
}
开发者ID:325116067,项目名称:semc-qsd8x50,代码行数:47,代码来源:MediaPlayerPrivatePhonon.cpp

示例12: qtscript_QAbstractSocket_SocketType_toStringHelper

static QString qtscript_QAbstractSocket_SocketType_toStringHelper(QAbstractSocket::SocketType value)
{
    const QMetaObject *meta = qtscript_QAbstractSocket_metaObject();
    int idx = meta->indexOfEnumerator("SocketType");
    Q_ASSERT(idx != -1);
    QMetaEnum menum = meta->enumerator(idx);
    return QString::fromLatin1(menum.valueToKey(value));
}
开发者ID:Alpha-Kand,项目名称:qcad,代码行数:8,代码来源:qtscript_QAbstractSocket.cpp

示例13: qtscript_QAbstractSocket_NetworkLayerProtocol_toStringHelper

static QString qtscript_QAbstractSocket_NetworkLayerProtocol_toStringHelper(QAbstractSocket::NetworkLayerProtocol value)
{
    const QMetaObject *meta = qtscript_QAbstractSocket_metaObject();
    int idx = meta->indexOfEnumerator("NetworkLayerProtocol");
    Q_ASSERT(idx != -1);
    QMetaEnum menum = meta->enumerator(idx);
    return QString::fromLatin1(menum.valueToKey(value));
}
开发者ID:Alpha-Kand,项目名称:qcad,代码行数:8,代码来源:qtscript_QAbstractSocket.cpp

示例14: qtscript_QNetworkReply_NetworkError_toStringHelper

static QString qtscript_QNetworkReply_NetworkError_toStringHelper(QNetworkReply::NetworkError value)
{
    const QMetaObject *meta = qtscript_QNetworkReply_metaObject();
    int idx = meta->indexOfEnumerator("NetworkError");
    Q_ASSERT(idx != -1);
    QMetaEnum menum = meta->enumerator(idx);
    return QString::fromLatin1(menum.valueToKey(value));
}
开发者ID:SSMN,项目名称:MuseScore,代码行数:8,代码来源:qtscript_QNetworkReply.cpp

示例15: qtscript_QStackedLayout_StackingMode_toStringHelper

static QString qtscript_QStackedLayout_StackingMode_toStringHelper(QStackedLayout::StackingMode value)
{
    const QMetaObject *meta = qtscript_QStackedLayout_metaObject();
    int idx = meta->indexOfEnumerator("StackingMode");
    Q_ASSERT(idx != -1);
    QMetaEnum menum = meta->enumerator(idx);
    return QString::fromLatin1(menum.valueToKey(value));
}
开发者ID:Alpha-Kand,项目名称:qcad,代码行数:8,代码来源:qtscript_QStackedLayout.cpp


注:本文中的QMetaEnum::valueToKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。