示例#1
0
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();

}
示例#2
0
static QByteArray debugMediaObject(WebCore::MediaPlayerPrivate* mediaPlayer, const MediaObject& mediaObject)
{
    QByteArray byteArray;
    QTextStream stream(&byteArray);

    const QMetaObject* metaObj = mediaPlayer->metaObject();
    QMetaEnum phononStates = metaObj->enumerator(metaObj->indexOfEnumerator("PhononState"));

    stream << "debugMediaObject -> Phonon::MediaObject(";
    stream << "State: " << phononStates.valueToKey(mediaObject.state());
    stream << " | Current time: " << mediaObject.currentTime();
    stream << " | Remaining time: " << mediaObject.remainingTime();
    stream << " | Total time: " << mediaObject.totalTime();
    stream << " | Meta-data: ";
    QMultiMap<QString, QString> map = mediaObject.metaData();
    for (QMap<QString, QString>::const_iterator it = map.constBegin();
        it != map.constEnd(); ++it) {
        stream << "(" << it.key() << ", " << it.value() << ")";
    }
    stream << " | Has video: " << mediaObject.hasVideo();
    stream << " | Is seekable: " << mediaObject.isSeekable();
    stream << ")";

    stream.flush();

    return byteArray;
}
QString GestureDirectionEnum::getValue(GestureDirection gdEnum)
{
    GestureDirectionEnum GestureDirectionEnum;
    int index = GestureDirectionEnum.metaObject()->indexOfEnumerator("GestureDirection");
    QMetaEnum metaEnum = GestureDirectionEnum.metaObject()->enumerator(index);
    return metaEnum.valueToKey(gdEnum);
}
示例#4
0
// Convert complex variant types to DOM properties with the help of  QAbstractFormBuilder
// Does not perform a check using  QAbstractFormBuilder::checkProperty().
DomProperty *variantToDomProperty(QAbstractFormBuilder *afb, const QMetaObject *meta,
                                  const QString &pname, const QVariant &v)
{
    const QFormBuilderStrings &strings = QFormBuilderStrings::instance();

    DomProperty *dom_prop = new DomProperty();
    dom_prop->setAttributeName(pname);

    const int pindex = meta->indexOfProperty(pname.toLatin1());
    if (pindex != -1) {
        QMetaProperty meta_property = meta->property(pindex);
        if ((v.type() == QVariant::Int || v.type() == QVariant::UInt) && meta_property.isEnumType()) {
            const QMetaEnum e = meta_property.enumerator();
            if (e.isFlag())
                dom_prop->setElementSet(QString::fromAscii(e.valueToKeys(v.toInt())));
            else
                dom_prop->setElementEnum(QString::fromAscii(e.valueToKey(v.toInt())));
            return dom_prop;
        }
        if (!meta_property.hasStdCppSet() || (isOfType(meta, &QAbstractScrollArea::staticMetaObject) && pname == strings.cursorProperty))
            dom_prop->setAttributeStdset(0);
    }

    // Try simple properties
    if (applySimpleProperty(v, isTranslatable(pname, v, meta), dom_prop))
        return dom_prop;

    // Complex properties
    switch (v.type()) {
    case QVariant::Palette: {
        DomPalette *dom = new DomPalette();
        QPalette palette = qvariant_cast<QPalette>(v);

        palette.setCurrentColorGroup(QPalette::Active);
        dom->setElementActive(afb->saveColorGroup(palette));

        palette.setCurrentColorGroup(QPalette::Inactive);
        dom->setElementInactive(afb->saveColorGroup(palette));

        palette.setCurrentColorGroup(QPalette::Disabled);
        dom->setElementDisabled(afb->saveColorGroup(palette));

        dom_prop->setElementPalette(dom);
    } break;
    case QVariant::Brush:
        dom_prop->setElementBrush(afb->saveBrush(qvariant_cast<QBrush>(v)));
        break;
    default:
        delete dom_prop;
        if (afb->resourceBuilder()->isResourceType(v)) {
            dom_prop = afb->resourceBuilder()->saveResource(afb->workingDirectory(), v);
            if (dom_prop)
                dom_prop->setAttributeName(pname);
            break;
        }
        uiLibWarning(msgCannotWriteProperty(pname, v));
        return 0;
    }
    return dom_prop;
}
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);
    }
}
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;
}
示例#7
0
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;
    }
  }
}
示例#8
0
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()));
}
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;
}
示例#10
0
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);
}
示例#11
0
文件: irc.cpp 项目: jbache/communi
/*!
    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);
}
示例#12
0
/*! 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();
}
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();
    }
}
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));
}
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));
}
示例#16
0
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));
}
示例#17
0
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));
}
示例#18
0
static QString qtscript_QLayout_SizeConstraint_toStringHelper(QLayout::SizeConstraint value)
{
    const QMetaObject *meta = qtscript_QLayout_metaObject();
    int idx = meta->indexOfEnumerator("SizeConstraint");
    Q_ASSERT(idx != -1);
    QMetaEnum menum = meta->enumerator(idx);
    return QString::fromLatin1(menum.valueToKey(value));
}
示例#19
0
QString Screen::densityString() const
{
    DisplayDensity dd = displayDensity();
    int index = metaObject()->indexOfEnumerator("DisplayDensity");
    Q_ASSERT(index != -1);
    QMetaEnum enumerator = metaObject()->enumerator(index);
    return QLatin1String(enumerator.valueToKey(dd));
}
示例#20
0
static QString qtscript_QComboBox_SizeAdjustPolicy_toStringHelper(QComboBox::SizeAdjustPolicy value)
{
    const QMetaObject *meta = qtscript_QComboBox_metaObject();
    int idx = meta->indexOfEnumerator("SizeAdjustPolicy");
    Q_ASSERT(idx != -1);
    QMetaEnum menum = meta->enumerator(idx);
    return QString::fromLatin1(menum.valueToKey(value));
}
static QString qtscript_QMessageBox_Icon_toStringHelper(QMessageBox::Icon value)
{
    const QMetaObject *meta = qtscript_QMessageBox_metaObject();
    int idx = meta->indexOfEnumerator("Icon");
    Q_ASSERT(idx != -1);
    QMetaEnum menum = meta->enumerator(idx);
    return QString::fromLatin1(menum.valueToKey(value));
}
示例#22
0
static QString qtscript_QAction_MenuRole_toStringHelper(QAction::MenuRole value)
{
    const QMetaObject *meta = qtscript_QAction_metaObject();
    int idx = meta->indexOfEnumerator("MenuRole");
    Q_ASSERT(idx != -1);
    QMetaEnum menum = meta->enumerator(idx);
    return QString::fromLatin1(menum.valueToKey(value));
}
示例#23
0
static QString qtscript_QGradient_CoordinateMode_toStringHelper(QGradient::CoordinateMode value)
{
    const QMetaObject *meta = qtscript_QGradient_metaObject();
    int idx = meta->indexOfEnumerator("CoordinateMode");
    Q_ASSERT(idx != -1);
    QMetaEnum menum = meta->enumerator(idx);
    return QString::fromLatin1(menum.valueToKey(value));
}
示例#24
0
static QString qtscript_QPalette_ColorRole_toStringHelper(QPalette::ColorRole value)
{
    const QMetaObject *meta = qtscript_QPalette_metaObject();
    int idx = meta->indexOfEnumerator("ColorRole");
    Q_ASSERT(idx != -1);
    QMetaEnum menum = meta->enumerator(idx);
    return QString::fromLatin1(menum.valueToKey(value));
}
示例#25
0
static QString qtscript_QMdiArea_WindowOrder_toStringHelper(QMdiArea::WindowOrder value)
{
    const QMetaObject *meta = qtscript_QMdiArea_metaObject();
    int idx = meta->indexOfEnumerator("WindowOrder");
    Q_ASSERT(idx != -1);
    QMetaEnum menum = meta->enumerator(idx);
    return QString::fromLatin1(menum.valueToKey(value));
}
示例#26
0
QString TorcPlayer::PropertyToString(PlayerProperty Property)
{
    const QMetaObject &mo = TorcPlayer::staticMetaObject;
    int enum_index        = mo.indexOfEnumerator("PlayerProperty");
    QMetaEnum metaEnum    = mo.enumerator(enum_index);
    return metaEnum.valueToKey((int)Property);

}
示例#27
0
static QString qtscript_QMovie_CacheMode_toStringHelper(QMovie::CacheMode value)
{
    const QMetaObject *meta = qtscript_QMovie_metaObject();
    int idx = meta->indexOfEnumerator("CacheMode");
    Q_ASSERT(idx != -1);
    QMetaEnum menum = meta->enumerator(idx);
    return QString::fromLatin1(menum.valueToKey(value));
}
示例#28
0
static QString qtscript_QWizard_WizardStyle_toStringHelper(QWizard::WizardStyle value)
{
    const QMetaObject *meta = qtscript_QWizard_metaObject();
    int idx = meta->indexOfEnumerator("WizardStyle");
    Q_ASSERT(idx != -1);
    QMetaEnum menum = meta->enumerator(idx);
    return QString::fromLatin1(menum.valueToKey(value));
}
示例#29
0
QDebug operator<<(QDebug debug, const PacketType& type) {
    QMetaObject metaObject = PacketTypeEnum::staticMetaObject;
    QMetaEnum metaEnum = metaObject.enumerator(metaObject.enumeratorOffset());
    QString typeName = metaEnum.valueToKey((int) type);

    debug.nospace().noquote() << (uint8_t) type << " (" << typeName << ")";
    return debug.space();
}
示例#30
0
static QString qtscript_QColorDialog_ColorDialogOption_toStringHelper(QColorDialog::ColorDialogOption value)
{
    const QMetaObject *meta = qtscript_QColorDialog_metaObject();
    int idx = meta->indexOfEnumerator("ColorDialogOption");
    Q_ASSERT(idx != -1);
    QMetaEnum menum = meta->enumerator(idx);
    return QString::fromLatin1(menum.valueToKey(value));
}