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


C++ QVariant::isValid方法代码示例

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


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

示例1: setSettings

void OptionsDialog::setSettings() {
    passwordEdit->setText(getSetting("password", "").toString());
    coreEdit->setText(getSetting("coreAddress", "localhost").toString());
    refreshSpin->setValue(getSetting("refresh", 3).toInt());
    savePassword->setChecked(getSetting("savePassword", false).toBool());
    useCompression->setChecked(getSetting("useCompression", false).toBool());
    showSplash->setChecked(getSetting("showSplash", true).toBool());
    trayCheckBox->setChecked(getSetting("useTray", false).toBool());
    altRowsCheckBox->setChecked(getSetting("altRows", false).toBool());
    serverEdit->setText(getSetting("serverURL", "http://www.applejuicenet.de/18.0.html").toString());
    launchCombo->setEditText(getSetting("launcher", launchCombo->itemText(0)).toString());
    int location = getSetting("location", AjSettings::SAME).toInt();
    sameComputerRadio->setChecked(location == AjSettings::SAME);
    specificRadio->setChecked(location == AjSettings::SPECIFIC);
    ftpRadio->setChecked(location == AjSettings::FTP);
    incomingSpecificEdit->setText(getSetting("incomingDirSpecific", "/").toString());
    tempSpecificEdit->setText(getSetting("tempDirSpecific", "/").toString());
    ftpServerEdit->setText(getSetting("ftp", "server", "localhost").toString());
    ftpPortEdit->setText(getSetting("ftp", "port", "21").toString());
    ftpUserEdit->setText(getSetting("ftp", "user", "anonymous").toString());
    ftpPasswordEdit->setText(getSetting("ftp", "password", "").toString());
    ftpInDirEdit->setText(getSetting("ftp", "inDir", "/").toString());
    ftpTmpDirEdit->setText(getSetting("ftp", "tmpDir", "/").toString());
    ftpActiveRadioButton->setChecked(getSetting("ftp", "mode", QFtp::Active) == QFtp::Active);
    ftpPassiveRadioButton->setChecked(getSetting("ftp", "mode", QFtp::Active) == QFtp::Passive);
    ftpMbSpinBox->setValue(getSetting("ftp", "mb", "10").toInt());
    bool ftpFull = getSetting("ftp", "full", false).toBool();
    ftpFullRadioButton->setChecked(ftpFull);
    ftpMbRadioButton->setChecked(!ftpFull);
    fetchServersCheckBox->setChecked(getSetting("fetchServersOnStartup", false).toBool());
    languageComboBox->setCurrentIndex(languageComboBox->findData(getSetting("language", "en").toString().split("_")[0]));

    // -- lists for optionaly showing columns/labales --
    statusbarList->clear();
    QList<QVariant> statusbarShow = getStatusbarShows(juicer->statusBarWidgets.size());
    for(int i=0; i<juicer->statusBarWidgets.size(); i++) {
        statusbarList->addItem(juicer->statusBarWidgets.at(i)->toolTip());
        statusbarList->item(statusbarList->count()-1)->setCheckState(
            statusbarShow.at(i).toBool()?Qt::Checked:Qt::Unchecked);
    }
    downloadTabList->clear();
    QTreeWidgetItem* h = juicer->downloadsTreeWidget->headerItem();
    for(int i=0; i<h->columnCount(); i++) {
        downloadTabList->addItem(h->text(i));
        downloadTabList->item(downloadTabList->count()-1)->setCheckState(
            juicer->downloadsTreeWidget->isColumnHidden(i)?Qt::Unchecked:Qt::Checked);
    }
    uploadTabList->clear();
    h = juicer->uploadsTreeWidget->headerItem();
    for(int i=0; i<h->columnCount(); i++) {
        uploadTabList->addItem(h->text(i));
        uploadTabList->item(uploadTabList->count()-1)->setCheckState(
            juicer->uploadsTreeWidget->isColumnHidden(i)?Qt::Unchecked:Qt::Checked);
    }

    QFont font;
    QVariant v = getSetting("font", QApplication::font());
    if (v.isValid() && ! v.toString().isEmpty()) {
        font = v.value<QFont>();
    }
    else {
      font = QFont("Arial", 9, QFont::Normal);
    }
    QApplication::setFont(font);
    fontComboBox->setCurrentFont(font);
    setFontSizes(font);
#ifdef Q_WS_WIN
    handlerCheckCheckBox->setChecked(!OptionsDialog::hasSetting("handler") || OptionsDialog::getSetting("handler", false).toBool());
    handlerDefaultCheckBox->setChecked(OptionsDialog::hasSetting("handler") && OptionsDialog::getSetting("handler", false).toBool());
    handlerDefaultCheckBox->setEnabled(handlerCheckCheckBox->isChecked());
#endif
    checkUpdatesCheckBox->setChecked(getSetting("checkUpdates", true).toBool());
    observeClipboardCheckBox->setChecked(getSetting("observeClipboard", false).toBool());
    quitGUIAfterCoreExitCheckBox->setChecked(getSetting("quitGUIAfterCoreExit", true).toBool());
    profilesStatusbarCheckBox->setChecked(getSetting("profilesStatusbar", false).toBool());
    videoEdit->setText(video());
    audioEdit->setText(audio());
    imageEdit->setText(image());
    textEdit->setText(text());
    archiveEdit->setText(archive());
    cddvdEdit->setText(cddvd());
}
开发者ID:BackupTheBerlios,项目名称:juicer-svn,代码行数:82,代码来源:optionsdialog.cpp

示例2: logged

void _LogListener::logged(ctkLogEntryPtr entry)
{
    // This is where the assembly as specified in 133.6.6 OSGi R4
    // compendium is taking place (i.e., the log entry is adapted to
    // an event and posted via the ctkEventAdmin)

    ctkDictionary properties;

    QSharedPointer<ctkPlugin> plugin = entry->getPlugin();
    if (plugin)
    {
        properties.insert("plugin.id", QVariant::fromValue<long>(plugin->getPluginId()));

        const QString symbolicName = plugin->getSymbolicName();

        if (!symbolicName.isEmpty())
        {
            properties.insert(ctkEventConstants::PLUGIN_SYMBOLICNAME,
                              symbolicName);
        }

        properties.insert("plugin", QVariant::fromValue(plugin));
    }

    properties.insert("log.level", entry->getLevel());
    properties.insert(ctkEventConstants::MESSAGE, entry->getMessage());
    properties.insert(ctkEventConstants::TIMESTAMP, entry->getTime());
    properties.insert("log.entry", QVariant::fromValue(entry));

    const std::exception* exc = entry->getException();
    if (exc)
    {
        //properties.insert(ctkEventConstants::EXCEPTION_CLASS,
        //        exception.getClass().getName());

        const QString message(exc->what());
        if (!message.isEmpty())
        {
            properties.insert(ctkEventConstants::EXCEPTION_MESSAGE,
                              message);
        }

        properties.insert(ctkEventConstants::EXCEPTION, exc);
    }

    ctkServiceReference service = entry->getServiceReference();
    if (service)
    {
        properties.insert(ctkEventConstants::SERVICE, QVariant::fromValue(service));

        QVariant id = service.getProperty(ctkEventConstants::SERVICE_ID);

        if (id.isValid())
        {
            properties.insert(ctkEventConstants::SERVICE_ID, id);
            QVariant pid = service.getProperty(ctkEventConstants::SERVICE_PID);
            if (pid.isValid())
            {
                properties.insert(ctkEventConstants::SERVICE_PID, pid);
            }

            QVariant objectClass = service.getProperty(ctkPluginConstants::OBJECTCLASS);
            if (objectClass.isValid())
            {
                properties.insert(ctkEventConstants::SERVICE_OBJECTCLASS, objectClass);
            }
        }
    }

    QString topic("org/commontk/service/log/LogEntry/");

    int level = entry->getLevel();
    if (level == ctkLogService::LOG_ERROR)
    {
        topic.append("LOG_ERROR");
    }
    else if (level == ctkLogService::LOG_WARNING)
    {
        topic.append("LOG_WARNING");
    }
    else if (level == ctkLogService::LOG_INFO)
    {
        topic.append("LOG_INFO");
    }
    else if (level == ctkLogService::LOG_DEBUG)
    {
        topic.append("LOG_DEBUG");
    }
    else
    {
        topic.append("LOG_OTHER");
    }

    try
    {
        adapter->getEventAdmin()->postEvent(ctkEvent(topic, properties));
    }
    catch(const std::logic_error&)
    {
        // This is o.k. - indicates that we are stopped.
//.........这里部分代码省略.........
开发者ID:benoitbleuze,项目名称:CTK,代码行数:101,代码来源:ctkEALogEventAdapter.cpp

示例3: settings

/*!

*/
void
DebugMessageWindow::readSettings()
{
#ifndef Q_WS_WIN
    QSettings settings( QDir::homePath() + "/.soccerwindow2-qt4",
                        QSettings::IniFormat );
#else
    QSettings settings( QDir::currentPath() + "/soccerwindow2.ini",
                        QSettings::IniFormat );
#endif
    //QSettings settings( QSettings::IniFormat,
    //                    QSettings::UserScope,
    //                    PACKAGE_NAME );

    settings.beginGroup( "DebugMessageWindow" );

    // read debug view switch status
    {
        QVariant val;

        val = settings.value( tr( "debug_view_all" ) );
        if ( val.isValid() )
        {
            M_show_debug_view_all_act->setChecked( val.toBool() );
            toggleShowDebugViewAll( val.toBool() );
        }

        val = settings.value( tr( "debug_view_self" ) );
        if ( val.isValid() )
        {
            M_show_debug_view_self_act->setChecked( val.toBool() );
            toggleShowDebugViewSelf( val.toBool() );
        }

        val = settings.value( tr( "debug_view_ball" ) );
        if ( val.isValid() )
        {
            M_show_debug_view_ball_act->setChecked( val.toBool() );
            toggleShowDebugViewBall( val.toBool() );
        }

        val = settings.value( tr( "debug_view_teammates" ) );
        if ( val.isValid() )
        {
            M_show_debug_view_teammates_act->setChecked( val.toBool() );
            toggleShowDebugViewTeammates( val.toBool() );
        }

        val = settings.value( tr( "debug_view_opponents" ) );
        if ( val.isValid() )
        {
            M_show_debug_view_opponents_act->setChecked( val.toBool() );
            toggleShowDebugViewOpponents( val.toBool() );
        }

        val = settings.value( tr( "debug_view_comment" ) );
        if ( val.isValid() )
        {
            M_show_debug_view_comment_act->setChecked( val.toBool() );
            toggleShowDebugViewComment( val.toBool() );
        }

        val = settings.value( tr( "debug_view_shape" ) );
        if ( val.isValid() )
        {
            M_show_debug_view_shape_act->setChecked( val.toBool() );
            toggleShowDebugViewShape( val.toBool() );
        }

        val = settings.value( tr( "debug_view_target" ) );
        if ( val.isValid() )
        {
            M_show_debug_view_target_act->setChecked( val.toBool() );
            toggleShowDebugViewTarget( val.toBool() );
        }

        val = settings.value( tr( "debug_view_message" ) );
        if ( val.isValid() )
        {
            M_show_debug_view_message_act->setChecked( val.toBool() );
            toggleShowDebugViewMessage( val.toBool() );
        }

        val = settings.value( tr( "debug_log_objects" ) );
        if ( val.isValid() )
        {
            M_show_debug_log_objects_act->setChecked( val.toBool() );
            toggleShowDebugLogObjects( val.toBool() );
        }

    }

    // read debug switch status
    for ( int i = 0; i < 32; ++i )
    {
        //snprintf( key, 16, "debug%02d", i + 1 );
        QVariant val = settings.value( QString( "debug%1" ).arg( i + 1, 2, 10, QChar( '0' ) ) );
//.........这里部分代码省略.........
开发者ID:mhauskn,项目名称:soccerwindow2,代码行数:101,代码来源:debug_message_window.cpp

示例4: onFinished

void LocationManager::onFinished(QNetworkReply *reply) {
	if (!manager) return;
	if (reply->error() != QNetworkReply::NoError) return onFailed(reply);

	QVariant statusCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute);
	if (statusCode.isValid()) {
		int status = statusCode.toInt();
		if (status == 301 || status == 302) {
			QString loc = reply->header(QNetworkRequest::LocationHeader).toString();
			if (!loc.isEmpty()) {
				QMap<QNetworkReply*, LocationData*>::iterator i = dataLoadings.find(reply);
				if (i != dataLoadings.cend()) {
					LocationData *d = i.value();
					if (serverRedirects.constFind(d) == serverRedirects.cend()) {
						serverRedirects.insert(d, 1);
					} else if (++serverRedirects[d] > MaxHttpRedirects) {
						DEBUG_LOG(("Network Error: Too many HTTP redirects in onFinished() for image link: %1").arg(loc));
						return onFailed(reply);
					}
					dataLoadings.erase(i);
					dataLoadings.insert(manager->get(QNetworkRequest(loc)), d);
					return;
				} else if ((i = imageLoadings.find(reply)) != imageLoadings.cend()) {
					LocationData *d = i.value();
					if (serverRedirects.constFind(d) == serverRedirects.cend()) {
						serverRedirects.insert(d, 1);
					} else if (++serverRedirects[d] > MaxHttpRedirects) {
						DEBUG_LOG(("Network Error: Too many HTTP redirects in onFinished() for image link: %1").arg(loc));
						return onFailed(reply);
					}
					imageLoadings.erase(i);
					imageLoadings.insert(manager->get(QNetworkRequest(loc)), d);
					return;
				}
			}
		}
		if (status != 200) {
			DEBUG_LOG(("Network Error: Bad HTTP status received in onFinished() for image link: %1").arg(status));
			return onFailed(reply);
		}
	}

	LocationData *d = 0;
	QMap<QNetworkReply*, LocationData*>::iterator i = dataLoadings.find(reply);
	if (i != dataLoadings.cend()) {
		d = i.value();
		dataLoadings.erase(i);

		QJsonParseError e;
		QJsonDocument doc = QJsonDocument::fromJson(reply->readAll(), &e);
		if (e.error != QJsonParseError::NoError) {
			DEBUG_LOG(("JSON Error: Bad json received in onFinished() for image link"));
			return onFailed(reply);
		}
		failed(d);

		if (App::main()) App::main()->update();
	} else {
		i = imageLoadings.find(reply);
		if (i != imageLoadings.cend()) {
			d = i.value();
			imageLoadings.erase(i);

			QPixmap thumb;
			QByteArray format;
			QByteArray data(reply->readAll());
			{
				QBuffer buffer(&data);
				QImageReader reader(&buffer);
#ifndef OS_MAC_OLD
				reader.setAutoTransform(true);
#endif // OS_MAC_OLD
				thumb = QPixmap::fromImageReader(&reader, Qt::ColorOnly);
				format = reader.format();
				thumb.setDevicePixelRatio(cRetinaFactor());
				if (format.isEmpty()) format = QByteArray("JPG");
			}
			d->loading = false;
			d->thumb = thumb.isNull() ? (*notLoadedPlaceholder) : ImagePtr(thumb, format);
			serverRedirects.remove(d);
			if (App::main()) App::main()->update();
		}
	}
}
开发者ID:2asoft,项目名称:tdesktop,代码行数:84,代码来源:history_location_manager.cpp

示例5: execute

/*!
  Applies the given \a command to the given \a backend.
*/
QScriptDebuggerResponse QScriptDebuggerCommandExecutor::execute(
    QScriptDebuggerBackend *backend,
    const QScriptDebuggerCommand &command)
{
    QScriptDebuggerResponse response;
    switch (command.type()) {
    case QScriptDebuggerCommand::None:
        break;

    case QScriptDebuggerCommand::Interrupt:
        backend->interruptEvaluation();
        break;

    case QScriptDebuggerCommand::Continue:
        if (backend->engine()->isEvaluating()) {
            backend->continueEvalution();
            response.setAsync(true);
        }
        break;

    case QScriptDebuggerCommand::StepInto: {
        QVariant attr = command.attribute(QScriptDebuggerCommand::StepCount);
        int count = attr.isValid() ? attr.toInt() : 1;
        backend->stepInto(count);
        response.setAsync(true);
    }   break;

    case QScriptDebuggerCommand::StepOver: {
        QVariant attr = command.attribute(QScriptDebuggerCommand::StepCount);
        int count = attr.isValid() ? attr.toInt() : 1;
        backend->stepOver(count);
        response.setAsync(true);
    }   break;

    case QScriptDebuggerCommand::StepOut:
        backend->stepOut();
        response.setAsync(true);
        break;

    case QScriptDebuggerCommand::RunToLocation:
        backend->runToLocation(command.fileName(), command.lineNumber());
        response.setAsync(true);
        break;

    case QScriptDebuggerCommand::RunToLocationByID:
        backend->runToLocation(command.scriptId(), command.lineNumber());
        response.setAsync(true);
        break;

    case QScriptDebuggerCommand::ForceReturn: {
        int contextIndex = command.contextIndex();
        QScriptDebuggerValue value = command.scriptValue();
        QScriptEngine *engine = backend->engine();
        QScriptValue realValue = value.toScriptValue(engine);
        backend->returnToCaller(contextIndex, realValue);
        response.setAsync(true);
    }   break;

    case QScriptDebuggerCommand::Resume:
        backend->resume();
        response.setAsync(true);
        break;

    case QScriptDebuggerCommand::SetBreakpoint: {
        QScriptBreakpointData data = command.breakpointData();
        if (!data.isValid())
            data = QScriptBreakpointData(command.fileName(), command.lineNumber());
        int id = backend->setBreakpoint(data);
        response.setResult(id);
    }   break;

    case QScriptDebuggerCommand::DeleteBreakpoint: {
        int id = command.breakpointId();
        if (!backend->deleteBreakpoint(id))
            response.setError(QScriptDebuggerResponse::InvalidBreakpointID);
    }   break;

    case QScriptDebuggerCommand::DeleteAllBreakpoints:
        backend->deleteAllBreakpoints();
        break;

    case QScriptDebuggerCommand::GetBreakpoints: {
        QScriptBreakpointMap bps = backend->breakpoints();
        if (!bps.isEmpty())
            response.setResult(bps);
    }   break;

    case QScriptDebuggerCommand::GetBreakpointData: {
        int id = command.breakpointId();
        QScriptBreakpointData data = backend->breakpointData(id);
        if (data.isValid())
            response.setResult(data);
        else
            response.setError(QScriptDebuggerResponse::InvalidBreakpointID);
    }   break;

    case QScriptDebuggerCommand::SetBreakpointData: {
//.........这里部分代码省略.........
开发者ID:Blizzard,项目名称:qt4,代码行数:101,代码来源:qscriptdebuggercommandexecutor.cpp

示例6: createEditor

QWidget* QmitkPropertyDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option
  , const QModelIndex &index) const
{
  QVariant data = index.data(Qt::EditRole);
  QVariant displayData = index.data(Qt::DisplayRole);
  QString name = index.model()->data(index.model()->index(index.row(), index.column()-1)).value<QString>();

  if(data.isValid())
  {

    QWidget* editorWidget = NULL;

    if(data.type() == QVariant::Color)
    {
      QPushButton* colorBtn = new QPushButton(parent);
      QColor color = data.value<QColor>();

      QColor result = QColorDialog::getColor(color);
      if(result.isValid())
      {
        QPalette palette = colorBtn->palette();
        palette.setColor(QPalette::Button, result);
        colorBtn->setPalette(palette);
        colorBtn->setStyleSheet(QString("background-color: %1;foreground-color: %1; border-style: none;").arg(result.name()));
      }
      // QColorDialog closed by 'Cancel' button, use the old property color
      else
      {
        QPalette palette = colorBtn->palette();
        palette.setColor(QPalette::Button, color);
        colorBtn->setPalette(palette);
        colorBtn->setStyleSheet(QString("background-color: %1;foreground-color: %1; border-style: none;").arg(color.name()));

      }

      connect(colorBtn, SIGNAL(pressed()), this, SLOT(commitAndCloseEditor()));

      editorWidget = colorBtn;
    }

    else if(data.type() == QVariant::Int)
    {
      QSpinBox* spinBox = new QSpinBox(parent);
      spinBox->setSingleStep(1);
      spinBox->setMinimum(std::numeric_limits<int>::min());
      spinBox->setMaximum(std::numeric_limits<int>::max());
      editorWidget = spinBox;
    }
    // see qt documentation. cast is correct, it would be obsolete if we
    // store doubles
    else if(static_cast<QMetaType::Type>(data.type()) == QMetaType::Float)
    {
      QDoubleSpinBox* spinBox = new QDoubleSpinBox(parent);
      spinBox->setDecimals(2);
      spinBox->setSingleStep(0.1);
      if(name == "opacity")
      {
        spinBox->setMinimum(0.0);
        spinBox->setMaximum(1.0);
      }
      else
      {
        spinBox->setMinimum(std::numeric_limits<float>::min());
        spinBox->setMaximum(std::numeric_limits<float>::max());
      }

      editorWidget = spinBox;
    }

    else if(data.type() == QVariant::StringList)
    {
      QStringList entries = data.value<QStringList>();
      QComboBox* comboBox = new QComboBox(parent);
      comboBox->setEditable(false);
      comboBox->addItems(entries);

      editorWidget = comboBox;
    }


    else
    {
      editorWidget = QStyledItemDelegate::createEditor(parent, option, index);
    }

    if ( editorWidget )
    {
      // install event filter
      editorWidget->installEventFilter( const_cast<QmitkPropertyDelegate*>(this) );
    }

    return editorWidget;

  }
  else
    return new QLabel(displayData.toString(), parent);

}
开发者ID:GHfangxin,项目名称:MITK,代码行数:98,代码来源:QmitkPropertyDelegate.cpp

示例7: openLastFiles

void MainWindow::openLastFiles()
{
    mSettings.beginGroup(QLatin1String("recentFiles"));

    QStringList lastOpenFiles = mSettings.value(
                QLatin1String("lastOpenFiles")).toStringList();
    QVariant openCountVariant = mSettings.value(
                QLatin1String("recentOpenedFiles"));

    // Backwards compatibility mode
    if (openCountVariant.isValid()) {
        const QStringList recentFiles = mSettings.value(
                    QLatin1String("fileNames")).toStringList();
        int openCount = qMin(openCountVariant.toInt(), recentFiles.size());
        for (; openCount; --openCount)
            lastOpenFiles.append(recentFiles.at(openCount - 1));
        mSettings.remove(QLatin1String("recentOpenedFiles"));
    }

    QStringList mapScales = mSettings.value(
                QLatin1String("mapScale")).toStringList();
    QStringList scrollX = mSettings.value(
                QLatin1String("scrollX")).toStringList();
    QStringList scrollY = mSettings.value(
                QLatin1String("scrollY")).toStringList();
    QStringList selectedLayer = mSettings.value(
                QLatin1String("selectedLayer")).toStringList();

    for (int i = 0; i < lastOpenFiles.size(); i++) {
        if (!(i < mapScales.size()))
            continue;
        if (!(i < scrollX.size()))
            continue;
        if (!(i < scrollY.size()))
            continue;
        if (!(i < selectedLayer.size()))
            continue;

        if (openFile(lastOpenFiles.at(i))) {
            MapView *mapView = mDocumentManager->currentMapView();

            // Restore camera to the previous position
            qreal scale = mapScales.at(i).toDouble();
            if (scale > 0)
                mapView->zoomable()->setScale(scale);

            const int hor = scrollX.at(i).toInt();
            const int ver = scrollY.at(i).toInt();
            mapView->horizontalScrollBar()->setSliderPosition(hor);
            mapView->verticalScrollBar()->setSliderPosition(ver);

            int layer = selectedLayer.at(i).toInt();
            if (layer > 0 && layer < mMapDocument->map()->layerCount())
                mMapDocument->setCurrentLayerIndex(layer);
        }
    }
    QString lastActiveDocument =
            mSettings.value(QLatin1String("lastActive")).toString();
    int documentIndex = mDocumentManager->findDocument(lastActiveDocument);
    if (documentIndex != -1)
        mDocumentManager->switchToDocument(documentIndex);

    mSettings.endGroup();
}
开发者ID:,项目名称:,代码行数:64,代码来源:

示例8: setForeignKey

void QgsRelationReferenceWidget::setForeignKey( const QVariant& value )
{
  if ( !value.isValid() || value.isNull() )
  {
    deleteForeignKey();
    return;
  }

  if ( !mReferencedLayer )
    return;

  QgsFeatureIterator fit;

  // TODO: Rewrite using expression
  if ( mMasterModel )
  {
    fit = mMasterModel->layerCache()->getFeatures( QgsFeatureRequest() );
  }
  else
  {
    fit = mReferencedLayer->getFeatures( QgsFeatureRequest() );
  }
  while ( fit.nextFeature( mFeature ) )
  {
    if ( mFeature.attribute( mFkeyFieldIdx ) == value )
    {
      break;
    }
  }

  if ( !mFeature.isValid() )
  {
    deleteForeignKey();
    return;
  }

  mForeignKey = mFeature.attribute( mFkeyFieldIdx );

  if ( mReadOnlySelector )
  {
    QgsExpression expr( mReferencedLayer->displayExpression() );
    QString title = expr.evaluate( &mFeature ).toString();
    if ( expr.hasEvalError() )
    {
      title = mFeature.attribute( mFkeyFieldIdx ).toString();
    }
    mLineEdit->setText( title );
  }
  else
  {
    int i = mComboBox->findData( value, QgsAttributeTableModel::FeatureIdRole );
    if ( i == -1 && mAllowNull )
    {
      mComboBox->setCurrentIndex( 0 );
    }
    else
    {
      mComboBox->setCurrentIndex( i );
    }
  }

  mRemoveFKButton->setEnabled( mIsEditable );
  highlightFeature( mFeature );
  updateAttributeEditorFrame( mFeature );
  emit foreignKeyChanged( foreignKey() );
}
开发者ID:Vivu-github,项目名称:QGIS,代码行数:66,代码来源:qgsrelationreferencewidget.cpp

示例9: paint

void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const
{
	QString byteUnits[4] = {tr("B"), tr("KB"), tr("MB"), tr("GB")};
	QStyleOptionViewItem opt = option;
	QStyleOptionProgressBarV2 newopt;
	QRect pixmapRect;
	QPixmap pixmap;
	qlonglong fileSize;
	double dlspeed, multi;
	int seconds,minutes, hours, days;
	qlonglong remaining;
    QString temp ;
	qlonglong completed;
	qlonglong downloadtime;
    qint64 qi64Value;

	// prepare
	painter->save();
	painter->setClipRect(opt.rect);

	//set text color
        QVariant value = index.data(Qt::TextColorRole);
        if(value.isValid() && qvariant_cast<QColor>(value).isValid()) {
                opt.palette.setColor(QPalette::Text, qvariant_cast<QColor>(value));
        }
        QPalette::ColorGroup cg = option.state & QStyle::State_Enabled ? QPalette::Normal : QPalette::Disabled;
        if(option.state & QStyle::State_Selected){
                painter->setPen(opt.palette.color(cg, QPalette::HighlightedText));
        } else {
                painter->setPen(opt.palette.color(cg, QPalette::Text));
        }

        // draw the background color if not the progress column or if progress is not displayed
        if(index.column() != COLUMN_PROGRESS) {
                if(option.showDecorationSelected && (option.state & QStyle::State_Selected)) {
                        if(cg == QPalette::Normal && !(option.state & QStyle::State_Active)) {
                                cg = QPalette::Inactive;
                        }
                        painter->fillRect(option.rect, option.palette.brush(cg, QPalette::Highlight));
                } else {
                        value = index.data(Qt::BackgroundRole);
                        if(value.isValid() && qvariant_cast<QColor>(value).isValid()) {
                                painter->fillRect(option.rect, qvariant_cast<QColor>(value));
                        }
                }
        }
	switch(index.column()) {
        case COLUMN_SIZE:
			fileSize = index.data().toLongLong();
                        if(fileSize <= 0){
                                temp = "";
			} else {
				multi = 1.0;
				for(int i = 0; i < 5; ++i) {
					if (fileSize < 1024) {
						fileSize = index.data().toLongLong();
						temp.sprintf("%.2f ", fileSize / multi);
						temp += byteUnits[i];
						break;
					}
					fileSize /= 1024;
					multi *= 1024.0;
				}
			}
			painter->drawText(option.rect, Qt::AlignRight, temp);
			break;
        case COLUMN_REMAINING:
			remaining = index.data().toLongLong();
			if(remaining <= 0){
        temp = "";
			} else {
				multi = 1.0;
				for(int i = 0; i < 5; ++i) {
					if (remaining < 1024) {
						remaining = index.data().toLongLong();
						temp.sprintf("%.2f ", remaining / multi);
						temp += byteUnits[i];
						break;
					}
					remaining /= 1024;
					multi *= 1024.0;
				}
			}
			painter->drawText(option.rect, Qt::AlignRight, temp);
			break;
        case COLUMN_COMPLETED:
			completed = index.data().toLongLong();
                        if(completed <= 0){
                                temp = "";
			} else {
				multi = 1.0;
				for(int i = 0; i < 5; ++i) {
					if (completed < 1024) {
						completed = index.data().toLongLong();
						temp.sprintf("%.2f ", completed / multi);
						temp += byteUnits[i];
						break;
					}
					completed /= 1024;
					multi *= 1024.0;
//.........这里部分代码省略.........
开发者ID:Naeren,项目名称:RetroShare,代码行数:101,代码来源:DLListDelegate.cpp

示例10: paint

void BWListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const
{
	QString strNA = tr("N/A");
	QStyleOptionViewItem opt = option;

	QString temp ;
	float flValue;
	qint64 qi64Value;

	// prepare
	painter->save();
	painter->setClipRect(opt.rect);

	//set text color
	QVariant value = index.data(Qt::TextColorRole);
	if(value.isValid() && qvariant_cast<QColor>(value).isValid()) {
		opt.palette.setColor(QPalette::Text, qvariant_cast<QColor>(value));
	}
	QPalette::ColorGroup cg = option.state & QStyle::State_Enabled ? QPalette::Normal : QPalette::Disabled;
	if(option.state & QStyle::State_Selected){
		painter->setPen(opt.palette.color(cg, QPalette::HighlightedText));
	} else {
		painter->setPen(opt.palette.color(cg, QPalette::Text));
	}

	// draw the background color
	if(option.showDecorationSelected && (option.state & QStyle::State_Selected)) {
		if(cg == QPalette::Normal && !(option.state & QStyle::State_Active)) {
			cg = QPalette::Inactive;
		}
		painter->fillRect(option.rect, option.palette.brush(cg, QPalette::Highlight));
	} else {
		value = index.data(Qt::BackgroundRole);
		if(value.isValid() && qvariant_cast<QColor>(value).isValid()) {
			painter->fillRect(option.rect, qvariant_cast<QColor>(value));
		}
	}

	switch(index.column()) {
	case COLUMN_IN_RATE:
		temp.sprintf("%.3f ", index.data().toFloat());
		//temp=QString::number(index.data().toFloat());
		painter->drawText(option.rect, Qt::AlignRight, temp);
		break;
	case COLUMN_IN_MAX:
		temp.sprintf("%.3f ", index.data().toFloat());
		//temp=QString::number(index.data().toFloat());
		painter->drawText(option.rect, Qt::AlignRight, temp);
		break;
	case COLUMN_IN_QUEUE:
		temp=QString::number(index.data().toInt());
		painter->drawText(option.rect, Qt::AlignRight, temp);
		break;
	case COLUMN_IN_ALLOC:
		flValue = index.data().toFloat();
		if (flValue < std::numeric_limits<float>::max()){
			temp.sprintf("%.3f ", flValue);
		} else {
			temp=strNA;
		}
		painter->drawText(option.rect, Qt::AlignRight, temp);
		break;
	case COLUMN_IN_ALLOC_SENT:
		qi64Value = index.data().value<qint64>();
		if (qi64Value < std::numeric_limits<qint64>::max()){
			temp= QString::number(qi64Value);
		} else {
			temp = strNA;
		}
		painter->drawText(option.rect, Qt::AlignRight, temp);
		break;
	case COLUMN_OUT_RATE:
		temp.sprintf("%.3f ", index.data().toFloat());
		//temp=QString::number(index.data().toFloat());
		painter->drawText(option.rect, Qt::AlignRight, temp);
		break;
	case COLUMN_OUT_MAX:
		temp.sprintf("%.3f ", index.data().toFloat());
		//temp=QString::number(index.data().toFloat());
		painter->drawText(option.rect, Qt::AlignRight, temp);
		break;
	case COLUMN_OUT_QUEUE:
		temp=QString::number(index.data().toInt());
		painter->drawText(option.rect, Qt::AlignRight, temp);
		break;
	case COLUMN_OUT_ALLOC:
		flValue = index.data().toFloat();
		if (flValue < std::numeric_limits<float>::max()){
			temp=QString::number(flValue);
		} else {
			temp = strNA;
		}
		painter->drawText(option.rect, Qt::AlignRight, temp);
		break;
	case COLUMN_OUT_ALLOC_SENT:
		qi64Value = index.data().value<qint64>();
		if (qi64Value < std::numeric_limits<qint64>::max()){
			temp= QString::number(qi64Value);
		} else {
			temp = strNA;
//.........这里部分代码省略.........
开发者ID:N00D13,项目名称:RetroShare,代码行数:101,代码来源:BwCtrlWindow.cpp

示例11: objectGroup

ObjectGroup *VariantToMapConverter::toObjectGroup(const QVariantMap &variantMap)
{
    typedef QScopedPointer<ObjectGroup> ObjectGroupPtr;
    ObjectGroupPtr objectGroup(new ObjectGroup(variantMap[QLatin1String("name")].toString(),
                                               variantMap[QLatin1String("x")].toInt(),
                                               variantMap[QLatin1String("y")].toInt(),
                                               variantMap[QLatin1String("width")].toInt(),
                                               variantMap[QLatin1String("height")].toInt()));

    const qreal opacity = variantMap[QLatin1String("opacity")].toReal();
    const bool visible = variantMap[QLatin1String("visible")].toBool();

    objectGroup->setOpacity(opacity);
    objectGroup->setVisible(visible);

    objectGroup->setColor(variantMap.value(QLatin1String("color")).value<QColor>());

    const QString drawOrderString = variantMap.value(QLatin1String("draworder")).toString();
    if (!drawOrderString.isEmpty()) {
        objectGroup->setDrawOrder(drawOrderFromString(drawOrderString));
        if (objectGroup->drawOrder() == ObjectGroup::UnknownOrder) {
            mError = tr("Invalid draw order: %1").arg(drawOrderString);
            return nullptr;
        }
    }

    foreach (const QVariant &objectVariant, variantMap[QLatin1String("objects")].toList()) {
        const QVariantMap objectVariantMap = objectVariant.toMap();

        const QString name = objectVariantMap[QLatin1String("name")].toString();
        const QString type = objectVariantMap[QLatin1String("type")].toString();
        const int id = objectVariantMap[QLatin1String("id")].toInt();
        const int gid = objectVariantMap[QLatin1String("gid")].toInt();
        const qreal x = objectVariantMap[QLatin1String("x")].toReal();
        const qreal y = objectVariantMap[QLatin1String("y")].toReal();
        const qreal width = objectVariantMap[QLatin1String("width")].toReal();
        const qreal height = objectVariantMap[QLatin1String("height")].toReal();
        const qreal rotation = objectVariantMap[QLatin1String("rotation")].toReal();

        const QPointF pos(x, y);
        const QSizeF size(width, height);

        MapObject *object = new MapObject(name, type, pos, size);
        object->setId(id);
        object->setRotation(rotation);

        if (gid) {
            bool ok;
            object->setCell(mGidMapper.gidToCell(gid, ok));

            if (!object->cell().isEmpty()) {
                const QSizeF &tileSize = object->cell().tile->size();
                if (width == 0)
                    object->setWidth(tileSize.width());
                if (height == 0)
                    object->setHeight(tileSize.height());
            }
        }

        if (objectVariantMap.contains(QLatin1String("visible")))
            object->setVisible(objectVariantMap[QLatin1String("visible")].toBool());

        object->setProperties(extractProperties(objectVariantMap));
        objectGroup->addObject(object);

        const QVariant polylineVariant = objectVariantMap[QLatin1String("polyline")];
        const QVariant polygonVariant = objectVariantMap[QLatin1String("polygon")];

        if (polygonVariant.isValid()) {
            object->setShape(MapObject::Polygon);
            object->setPolygon(toPolygon(polygonVariant));
        }
        if (polylineVariant.isValid()) {
            object->setShape(MapObject::Polyline);
            object->setPolygon(toPolygon(polylineVariant));
        }
        if (objectVariantMap.contains(QLatin1String("ellipse")))
            object->setShape(MapObject::Ellipse);
    }

    return objectGroup.take();
}
开发者ID:Alturos,项目名称:tiled,代码行数:82,代码来源:varianttomapconverter.cpp

示例12: QWidget

AudioEditor::AudioEditor(QWidget* parent, Audio *audio, Doc* doc)
    : QWidget(parent)
    , m_doc(doc)
    , m_audio(audio)
    , m_speedDials(NULL)
{
    Q_ASSERT(doc != NULL);
    Q_ASSERT(audio != NULL);

    setupUi(this);

    m_nameEdit->setText(m_audio->name());
    m_nameEdit->setSelection(0, m_nameEdit->text().length());

    m_fadeInEdit->setText(Function::speedToString(audio->fadeInSpeed()));
    m_fadeOutEdit->setText(Function::speedToString(audio->fadeOutSpeed()));

    connect(m_nameEdit, SIGNAL(textEdited(const QString&)),
            this, SLOT(slotNameEdited(const QString&)));
    connect(m_fileButton, SIGNAL(clicked()),
            this, SLOT(slotSourceFileClicked()));

    connect(m_speedDialButton, SIGNAL(toggled(bool)),
            this, SLOT(slotSpeedDialToggle(bool)));

    connect(m_fadeInEdit, SIGNAL(returnPressed()),
            this, SLOT(slotFadeInEdited()));
    connect(m_fadeOutEdit, SIGNAL(returnPressed()),
            this, SLOT(slotFadeOutEdited()));

    connect(m_previewButton, SIGNAL(toggled(bool)),
            this, SLOT(slotPreviewToggled(bool)));

    AudioDecoder *adec = m_audio->getAudioDecoder();

    m_filenameLabel->setText(m_audio->getSourceFileName());
    if (adec != NULL)
    {
        AudioParameters ap = adec->audioParameters();
        m_durationLabel->setText(Function::speedToString(m_audio->getDuration()));
        m_srateLabel->setText(QString("%1 Hz").arg(ap.sampleRate()));
        m_channelsLabel->setText(QString("%1").arg(ap.channels()));
        m_bitrateLabel->setText(QString("%1 kb/s").arg(adec->bitrate()));
    }

    QList<AudioDeviceInfo> devList;
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
 #if defined( __APPLE__) || defined(Q_OS_MAC)
    devList = AudioRendererPortAudio::getDevicesInfo();
 #elif defined(WIN32) || defined(Q_OS_WIN)
    devList = AudioRendererWaveOut::getDevicesInfo();
 #else
    devList = AudioRendererAlsa::getDevicesInfo();
 #endif
#else
    devList = AudioRendererQt::getDevicesInfo();
#endif
    QSettings settings;
    QString outputName;
    int i = 0, selIdx = 0;

    m_audioDevCombo->addItem(tr("Default device"), "__qlcplusdefault__");
    if (m_audio->audioDevice().isEmpty())
    {
        QVariant var = settings.value(SETTINGS_AUDIO_OUTPUT_DEVICE);
        if (var.isValid() == true)
            outputName = var.toString();
    }
    else
        outputName = m_audio->audioDevice();

    foreach( AudioDeviceInfo info, devList)
    {
        if (info.capabilities & AUDIO_CAP_OUTPUT)
        {
            m_audioDevCombo->addItem(info.deviceName, info.privateName);

            if (info.privateName == outputName)
                selIdx = i;
            i++;
        }
    }
    m_audioDevCombo->setCurrentIndex(selIdx);
    connect(m_audioDevCombo, SIGNAL(currentIndexChanged(int)),
            this, SLOT(slotAudioDeviceChanged(int)));

    // Set focus to the editor
    m_nameEdit->setFocus();
}
开发者ID:shimaore,项目名称:qlcplus,代码行数:89,代码来源:audioeditor.cpp

示例13: parseMetaData

bool FEMemoryMetaData::parseMetaData(QString json)
{
	QJson::Parser parser;
	QVariant top = parser.parse(json.toStdString().c_str());
	if (!top.isValid())
	{
		QString errormsg = QString("Error parsing JSON from config file on line number: ") + QString::number(parser.errorLine()) + " error text: " + parser.errorString();
		qDebug() << "Error parsing JSON";
		qDebug() << "Line number:" << parser.errorLine() << "error text:" << parser.errorString();
		qDebug() << "Start Json";
		qDebug() << "Json:" << json;
		qDebug() << "End Json";
		return false;
	}
	QVariantMap topmap = top.toMap();
	QVariantMap errormap = topmap["errormap"].toMap();
	QVariantMap::iterator i = errormap.begin();
	while (i != errormap.end())
	{
		bool ok = false;
		m_errorMap[i.value().toString().mid(2).toInt(&ok,16)] = i.key();
		i++;
	}

	QVariantMap ramvars = topmap["ramvars"].toMap();
	i = ramvars.begin();
	while (i != ramvars.end())
	{
		bool ok = false;
		unsigned short locid = i.key().mid(2).toInt(&ok,16);
		m_readOnlyMetaDataMap[locid] = ReadOnlyRamBlock();
		QVariantMap locidlist = i.value().toMap();
		QString title = locidlist["title"].toString();
		m_readOnlyMetaDataMap[locid].title = title;
		QVariantList locidmap = locidlist["vars"].toList();
		int offset = 0;
		for (int j=0;j<locidmap.size();j++)
		{
			QVariantMap newlocidmap = locidmap[j].toMap();
			ReadOnlyRamData rdata;
			rdata.dataTitle = newlocidmap["name"].toString();
			rdata.dataDescription = newlocidmap["title"].toString();
			rdata.locationId = locid;
			rdata.offset = offset;
			rdata.size = newlocidmap["size"].toInt();
			offset += rdata.size;
			m_readOnlyMetaDataMap[locid].m_ramData.append(rdata);
			m_readOnlyMetaData.append(rdata);
		}
		i++;
	}

	QVariantMap lookups = topmap["lookuptables"].toMap();
	i = lookups.begin();
	while (i != lookups.end())
	{
		QVariantMap lookupmap = i.value().toMap();
		QString keystr = i.key();
		bool ok = false;
		unsigned short keyint = keystr.mid(2).toInt(&ok,16);
		LookupMetaData meta;
		meta.locationid = keyint;
		meta.title = lookupmap["title"].toString();
		if (lookupmap["editable"].toString().toLower() == "true")
		{
			meta.editable = true;
		}
		else
		{
			meta.editable = false;
		}
		m_lookupMetaData[keyint] = meta;
		i++;
	}
	qDebug() << m_readOnlyMetaData.size() << "Ram entries found";
	QVariantMap tables = topmap["tables"].toMap();
	i = tables.begin();
	while (i != tables.end())
	{
		QVariantMap tabledata = i.value().toMap();
		if (tabledata["type"] == "3D")
		{
			Table3DMetaData meta;
			QString id = tabledata["locationid"].toString();
			QString xtitle = tabledata["xtitle"].toString();
			QVariantList xcalc = tabledata["xcalc"].toList();
			QString xdp = tabledata["xdp"].toString();
			unsigned int size = tabledata["size"].toInt();

			QString ytitle = tabledata["ytitle"].toString();
			QVariantList ycalc = tabledata["ycalc"].toList();
			QString ydp = tabledata["ydp"].toString();

			QString ztitle = tabledata["ztitle"].toString();
			QVariantList zcalc = tabledata["zcalc"].toList();
			QString zdp = tabledata["zdp"].toString();

			QString xhighlight = tabledata["xhighlight"].toString();
			QString yhighlight = tabledata["yhighlight"].toString();

//.........这里部分代码省略.........
开发者ID:FreeEMS,项目名称:EMStudio,代码行数:101,代码来源:fememorymetadata.cpp

示例14: connect

SeasideCache::SeasideCache()
    : m_manager(managerName())
#ifdef HAS_MLITE
    , m_displayLabelOrderConf(QLatin1String("/org/nemomobile/contacts/display_label_order"))
#endif
    , m_resultsRead(0)
    , m_populated(0)
    , m_cacheIndex(0)
    , m_queryIndex(0)
    , m_selfId(0)
    , m_fetchFilter(SeasideFilteredModel::FilterFavorites)
    , m_displayLabelOrder(SeasideFilteredModel::FirstNameFirst)
    , m_updatesPending(true)
    , m_refreshRequired(false)
{
    Q_ASSERT(!instance);
    instance = this;

    m_timer.start();

#ifdef HAS_MLITE
    connect(&m_displayLabelOrderConf, SIGNAL(valueChanged()), this, SLOT(displayLabelOrderChanged()));
    QVariant displayLabelOrder = m_displayLabelOrderConf.value();
    if (displayLabelOrder.isValid())
        m_displayLabelOrder = SeasideFilteredModel::DisplayLabelOrder(displayLabelOrder.toInt());
#endif

    connect(&m_manager, SIGNAL(dataChanged()), this, SLOT(updateContacts()));
    connect(&m_manager, SIGNAL(contactsChanged(QList<QContactLocalId>)),
            this, SLOT(updateContacts(QList<QContactLocalId>)));
    connect(&m_manager, SIGNAL(contactsAdded(QList<QContactLocalId>)),
            this, SLOT(updateContacts(QList<QContactLocalId>)));
    connect(&m_manager, SIGNAL(contactsRemoved(QList<QContactLocalId>)),
            this, SLOT(contactsRemoved(QList<QContactLocalId>)));

    connect(&m_fetchRequest, SIGNAL(resultsAvailable()), this, SLOT(contactsAvailable()));
    connect(&m_contactIdRequest, SIGNAL(resultsAvailable()), this, SLOT(contactIdsAvailable()));

    connect(&m_fetchRequest, SIGNAL(stateChanged(QContactAbstractRequest::State)),
            this, SLOT(requestStateChanged(QContactAbstractRequest::State)));
    connect(&m_contactIdRequest, SIGNAL(stateChanged(QContactAbstractRequest::State)),
            this, SLOT(requestStateChanged(QContactAbstractRequest::State)));
    connect(&m_removeRequest, SIGNAL(stateChanged(QContactAbstractRequest::State)),
            this, SLOT(requestStateChanged(QContactAbstractRequest::State)));
    connect(&m_saveRequest, SIGNAL(stateChanged(QContactAbstractRequest::State)),
            this, SLOT(requestStateChanged(QContactAbstractRequest::State)));

    m_fetchRequest.setManager(&m_manager);
    m_removeRequest.setManager(&m_manager);
    m_saveRequest.setManager(&m_manager);

#ifdef SEASIDE_SPARQL_QUERIES
    m_contactIdRequest.setQueryData(true);
    m_contactIdRequest.setFavoritesOnly(true);
    m_contactIdRequest.setSortOnFirstName(m_displayLabelOrder == SeasideFilteredModel::FirstNameFirst);

    m_contactIdRequest.start();
#else
    m_selfId = m_manager.selfContactId();
    m_contactIdRequest.setManager(&m_manager);

    QContactFetchHint fetchHint;
    fetchHint.setOptimizationHints(QContactFetchHint::NoRelationships
                                   | QContactFetchHint::NoActionPreferences
                                   | QContactFetchHint::NoBinaryBlobs);
    fetchHint.setDetailDefinitionsHint(QStringList()
                                       << QContactName::DefinitionName
                                       << QContactAvatar::DefinitionName
                                       << QContactPhoneNumber::DefinitionName
                                       << QContactEmailAddress::DefinitionName
                                       << QContactOrganization::DefinitionName
                                       << QContactOnlineAccount::DefinitionName);

    m_fetchRequest.setFetchHint(fetchHint);
    m_fetchRequest.setFilter(QContactFavorite::match());

    QContactSortOrder firstLabelOrder;
    firstLabelOrder.setDetailDefinitionName(
        QContactName::DefinitionName, QContactName::FieldFirstName);
    firstLabelOrder.setCaseSensitivity(Qt::CaseInsensitive);
    firstLabelOrder.setDirection(Qt::AscendingOrder);
    firstLabelOrder.setBlankPolicy(QContactSortOrder::BlanksFirst);

    QContactSortOrder secondLabelOrder;
    secondLabelOrder.setDetailDefinitionName(
        QContactName::DefinitionName, QContactName::FieldLastName);
    secondLabelOrder.setCaseSensitivity(Qt::CaseInsensitive);
    secondLabelOrder.setDirection(Qt::AscendingOrder);
    secondLabelOrder.setBlankPolicy(QContactSortOrder::BlanksFirst);

    QList<QContactSortOrder> sorting = m_displayLabelOrder == SeasideFilteredModel::FirstNameFirst
                                       ? (QList<QContactSortOrder>() << firstLabelOrder << secondLabelOrder)
                                       : (QList<QContactSortOrder>() << secondLabelOrder << firstLabelOrder);

    m_fetchRequest.setSorting(sorting);
    m_contactIdRequest.setSorting(sorting);

    m_fetchRequest.start();
#endif

//.........这里部分代码省略.........
开发者ID:adenexter,项目名称:nemo-qml-plugins,代码行数:101,代码来源:seasidecache.cpp

示例15: httpFinished

    void httpFinished() {
        DEBUG("httpFinished()");
        QVariant redirectionTarget = qreply->attribute(QNetworkRequest::RedirectionTargetAttribute);
        if (!redirectionTarget.isNull())
        {
            QUrl newUrl = url.resolved(redirectionTarget.toUrl());
            DEBUG("Handled redirect to: " << newUrl.toString());
            qreply->deleteLater();
            qreply = nullptr;
            doOperation(newUrl);
            return;
        }
        else if (qreply->error())
        {
            WARN("HTTP ERROR:" << qreply->error() << qreply->errorString());

            httpStatus = HTTPInvocationDefinition::UNDEFINED;
            invocationStatus = Invocation::ERROR;
            result << InvocationErrors::CONNECTION_FAILED
                   << Result::Meta("qnetworkreply_error_string", qreply->errorString())
                   << Result::Meta("qnetworkreply_error_number", qreply->error());

            QNetworkReply::NetworkError err = qreply->error();
            result << NetworkErrorReasons::from(err, qreply->errorString());

            // get possible return data
            replyData = qreply->readAll();
            if (!replyData.isEmpty())
                result << Result::Meta("response_data", replyData);

            emit q->finishedError(q);
        }
        else
        {
            // we have data
            replyData = qreply->readAll();
            QVariant statusCode = qreply->attribute( QNetworkRequest::HttpStatusCodeAttribute );
            if (statusCode.isValid())
            {
                // TODO: handle more codes!
                switch (statusCode.toInt())
                {
                case 200:
                    httpStatus = HTTPInvocationDefinition::OK_200;
                    break;
                default:
                    httpStatus = HTTPInvocationDefinition::UNDEFINED;
                }
            } else {
                result << InvocationErrors::INVOCATION_FAILED
                       << Result::reasonFromDesc("Invalid http status code");
            }

            invocationStatus = Invocation::RESPONSE_RECEIVED;
            TRACE("DATA:" << replyData);
            emit q->finishedOK(q);
        }

        qreply->deleteLater();
        qreply = nullptr;
    }
开发者ID:gberryproject,项目名称:gberry,代码行数:61,代码来源:restinvocationimpl.cpp


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