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


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

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


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

示例1: set

enum SetResponse dspInventoryAvailabilityByParameterList::set(const ParameterList &pParams)
{
  QVariant param;
  bool     valid;

  param = pParams.value("classcode_id", &valid);
  if (valid)
  {
    _parameter->setType(ParameterGroup::ClassCode);
    _parameter->setId(param.toInt());
  }

  param = pParams.value("classcode_pattern", &valid);
  if (valid)
  {
    _parameter->setType(ParameterGroup::ClassCode);
    _parameter->setPattern(param.toString());
  }

  param = pParams.value("classcode", &valid);
  if (valid)
    _parameter->setType(ParameterGroup::ClassCode);

  param = pParams.value("plancode_id", &valid);
  if (valid)
  {
    _parameter->setType(ParameterGroup::PlannerCode);
    _parameter->setId(param.toInt());
  }

  param = pParams.value("plancode_pattern", &valid);
  if (valid)
  {
    _parameter->setType(ParameterGroup::PlannerCode);
    _parameter->setPattern(param.toString());
  }

  param = pParams.value("plancode", &valid);
  if (valid)
    _parameter->setType(ParameterGroup::PlannerCode);

  param = pParams.value("itemgrp_id", &valid);
  if (valid)
  {
    _parameter->setType(ParameterGroup::ItemGroup);
    _parameter->setId(param.toInt());
  }

  param = pParams.value("itemgrp_pattern", &valid);
  if (valid)
  {
    _parameter->setType(ParameterGroup::ItemGroup);
    _parameter->setPattern(param.toString());
  }

  param = pParams.value("itemgrp", &valid);
  if (valid)
    _parameter->setType(ParameterGroup::ItemGroup);

  switch (_parameter->type())
  {
    case ParameterGroup::ClassCode:
      setWindowTitle(tr("Inventory Availability by Class Code"));
      break;

    case ParameterGroup::PlannerCode:
      setWindowTitle(tr("Inventory Availability by Planner Code"));
      break;

    case ParameterGroup::ItemGroup:
      setWindowTitle(tr("Inventory Availability by Item Group"));
      break;

    default:
      break;
  }

  if (pParams.inList("run"))
  {
    sFillList();
    return NoError_Run;
  }

  return NoError;
}
开发者ID:,项目名称:,代码行数:85,代码来源:

示例2: set

enum SetResponse user::set(const ParameterList &pParams)
{
  XDialog::set(pParams);
  QVariant param;
  bool     valid;

  param = pParams.value("crmacct_id", &valid);
  if (valid)
    _crmacctid = param.toInt();

  param = pParams.value("username", &valid);
  if (valid)
    _cUsername = param.toString();

  if (! _cUsername.isEmpty() || _crmacctid > 0)
    if (! sPopulate())
      return UndefinedError;

  param = pParams.value("mode", &valid);
  if (valid)
  {
    if (param.toString() == "new")
    {
      _mode = cNew;
      _module->setCurrentIndex(0);
      sModuleSelected(_module->itemText(0));

      if (_cUsername.isEmpty())
        _username->setFocus();
      else
      {
        _username->setEnabled(false);
        if(omfgThis->useCloud() && _cUsername.endsWith("_" + omfgThis->company()))
          _username->setText(_cUsername.left(_cUsername.length() - (omfgThis->company().length()+1)));
        else
          _username->setText(_cUsername);
        _active->setFocus();
        sCheck();
      }
      if (_metrics->boolean("MultiWhs"))
        populateSite();
    }
    else if (param.toString() == "edit")
    {
      _mode = cEdit;

      _username->setEnabled(FALSE);

      _save->setFocus();
    }
    else if (param.toString() == "view")
    {
      _mode = cView;

      _close->setText(tr("&Close"));
      _save->hide();

      _close->setFocus();
    }
  }

  bool canEdit = (cNew == _mode || cEdit == _mode);

  _active->setEnabled(canEdit);
  _add->setEnabled(canEdit);
  _addAll->setEnabled(canEdit);
  _addGroup->setEnabled(canEdit);
//  _addSite->setEnabled(canEdit);
  _agent->setEnabled(canEdit);
  _allSites->setEnabled(canEdit);
  _email->setEnabled(canEdit);
  _employee->setReadOnly(! canEdit);
  _enhancedAuth->setEnabled(canEdit);
  _exportContents->setEnabled(canEdit);
  _initials->setEnabled(canEdit);
  _locale->setEnabled(canEdit);
  _passwd->setEnabled(canEdit);
  _properName->setEnabled(canEdit);
  _revoke->setEnabled(canEdit);
  _revokeAll->setEnabled(canEdit);
  _revokeGroup->setEnabled(canEdit);
//  _revokeSite->setEnabled(canEdit);
  _save->setEnabled(canEdit);
  _selectedSites->setEnabled(canEdit);
  _verify->setEnabled(canEdit);
  if (! canEdit)
  {
    _available->setSelectionMode(QAbstractItemView::NoSelection);
    _availableGroup->setSelectionMode(QAbstractItemView::NoSelection);
    _availableSite->setSelectionMode(QAbstractItemView::NoSelection);
    _granted->setSelectionMode(QAbstractItemView::NoSelection);
    _grantedGroup->setSelectionMode(QAbstractItemView::NoSelection);
    _grantedSite->setSelectionMode(QAbstractItemView::NoSelection);
  }

  if(canEdit)
  {
    XSqlQuery begin;
    _inTransaction = begin.exec("BEGIN;");
  }
//.........这里部分代码省略.........
开发者ID:Wushaowei001,项目名称:xtuple-1,代码行数:101,代码来源:user.cpp

示例3: readChoices

 void readChoices()
 {
     QVariant value = settings->defaultValue(QStringLiteral("testChoices"));
     QCOMPARE(value.toString(), QStringLiteral("one"));
 }
开发者ID:qmlos,项目名称:libqmlos,代码行数:5,代码来源:tst_qgsettings.cpp

示例4: paintEvent

void KxMenuItemWidget::paintEvent(QPaintEvent *event)
{
    // Do not draw invisible menu items
    if(!fMenuItem->isVisible()) return;

    QStylePainter painter(this);
    QStyleOptionMenuItem opt = getStyleOption();
    QRect boxRect;
    bool inOptionBox = false;

    QWidget *q = parentWidget();

    const int hmargin = q->style()->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, 0, q),
        iconWidth = q->style()->pixelMetric(QStyle::PM_SmallIconSize, 0, q);

    if(!fMenuItem->isSeparator()) {
        if(fMenuItem->hasOptionBox()) {
            boxRect.setRect(rect().right() - hmargin - iconWidth, rect().top(), iconWidth, rect().height());
            QPoint p = QCursor::pos();
            p = mapFromGlobal(p);
            if(boxRect.contains(p)) {
                inOptionBox = true;
            } else {
                // Subtract option box rect from style option rect
                int newRight = opt.rect.right() - iconWidth - hmargin;
                opt.rect.setRight(newRight);
            }
        }
    }
    // Draw general menu item
    opt.rect.adjust(0, 0, -1, 0);
    painter.drawControl(QStyle::CE_MenuItem, opt);
    // Draw shortcut
    QKeySequence shortcutSeq = fMenuItem->shortcut();
    if(!shortcutSeq.isEmpty()) {
        // shortcut bounds
        QRect scRect = opt.rect;
        QString shortcut = shortcutSeq.toString(QKeySequence::NativeText);
        QMenu *menu = qobject_cast<QMenu *>(parentWidget());
        Q_ASSERT(menu != NULL);
        int shortcutWidth = 12;	// default value in case there is no font
        if ( menu ) {
            QFontMetrics metrics(fMenuItem->font().resolve(menu->font()));
            shortcutWidth = metrics.width(shortcut);
        }
        scRect.setLeft(scRect.right() - shortcutWidth);
        if(inOptionBox || !fMenuItem->hasOptionBox()) {
            scRect.translate(-iconWidth, 0);
        }
        scRect.translate(-kShortcutRightMargin, 0);
        painter.drawItemText(scRect, Qt::AlignRight | Qt::AlignVCenter, palette(), true, shortcut);
    }
    // Draw option box
    if(!fMenuItem->isSeparator() && fMenuItem->hasOptionBox()) {
        QIcon* boxIcon = NULL;
        QVariant v = fMenuItem->optionBoxAction()->property( "optionBoxIcon" );
        if ( v.isValid() ) {
            QString optionBoxIcon;
            optionBoxIcon = v.toString();
            boxIcon = KxQtHelper::createIcon( optionBoxIcon );
        }
        if ( boxIcon == NULL ) {
            boxIcon = new QIcon(":/optionBox.png");
        }
        boxRect.setRect(rect().right() - hmargin - iconWidth, rect().top()+(rect().height()-iconWidth)/2, iconWidth, iconWidth);
        boxIcon->paint(&painter, boxRect, Qt::AlignCenter, fMenuItem->isEnabled() ? QIcon::Normal : QIcon::Disabled);
        delete boxIcon;
    }
}
开发者ID:lihw,项目名称:glf,代码行数:69,代码来源:KxMenuItem.cpp

示例5: setDataDefinedValues


//.........这里部分代码省略.........
        mShowLabelChkbx->setChecked( !ok || showLabel != 0 );
        break;
      }
      case QgsPalLayerSettings::AlwaysShow:
        mAlwaysShowChkbx->setChecked( result.toBool() );
        break;
      case QgsPalLayerSettings::MinScale:
      {
        int minScale = result.toInt( &ok );
        if ( ok )
        {
          mMinScaleSpinBox->setValue( minScale );
        }
        break;
      }
      case QgsPalLayerSettings::MaxScale:
      {
        int maxScale = result.toInt( &ok );
        if ( ok )
        {
          mMaxScaleSpinBox->setValue( maxScale );
        }
        break;
      }
      case QgsPalLayerSettings::BufferSize:
      {
        double bufferSize = result.toDouble( &ok );
        if ( ok )
        {
          mBufferSizeSpinBox->setValue( bufferSize );
        }
        break;
      }
      case QgsPalLayerSettings::PositionX:
      {
        double posX = result.toDouble( &ok );
        if ( ok )
        {
          mXCoordSpinBox->setValue( posX );
        }
        break;
      }
      case QgsPalLayerSettings::PositionY:
      {
        double posY = result.toDouble( &ok );
        if ( ok )
        {
          mYCoordSpinBox->setValue( posY );
        }
        break;
      }
      case QgsPalLayerSettings::LabelDistance:
      {
        double labelDist = result.toDouble( &ok );
        if ( ok )
        {
          mLabelDistanceSpinBox->setValue( labelDist );
        }
        break;
      }
      case QgsPalLayerSettings::Hali:
        mHaliComboBox->setCurrentIndex( mHaliComboBox->findData( result.toString() ) );
        break;
      case QgsPalLayerSettings::Vali:
        mValiComboBox->setCurrentIndex( mValiComboBox->findData( result.toString() ) );
        break;
      case QgsPalLayerSettings::BufferColor:
        mBufferColorButton->setColor( QColor( result.toString() ) );
        break;
      case QgsPalLayerSettings::Color:
        mFontColorButton->setColor( QColor( result.toString() ) );
        break;
      case QgsPalLayerSettings::Rotation:
      {
        double rot = result.toDouble( &ok );
        if ( ok )
        {
          mRotationSpinBox->setValue( rot );
        }
        break;
      }

      case QgsPalLayerSettings::Size:
      {
        double size = result.toDouble( &ok );
        if ( ok )
        {
          mFontSizeSpinBox->setValue( size );
        }
        else
        {
          mFontSizeSpinBox->setValue( 0 );
        }
        break;
      }
      default:
        break;
    }
  }
}
开发者ID:redwoodxiao,项目名称:QGIS,代码行数:101,代码来源:qgslabelpropertydialog.cpp

示例6: writeValue

bool JArchive::writeValue(const QString &key,const QVariant &value,bool compress) {
	//This is how we used to do it, in version 2
	/*
		if (value.type()==QVariant::StringList) {
			QStringList list=value.toStringList();
			QString str="StringList::";
			for (int i=0; i<list.count(); i++) {
				str+=QString("{%1}").arg(list[i].count());
				str+=list[i];
			}
			return writeValue(key,str);
		}
		else {
			QByteArray tmp=value.toString().toAscii();
			return writeData(key,tmp,false,"Value");
		}
	}*/
	
	{ //as of version 3
		if (value.type()==QVariant::StringList) {
			QByteArray tmp;
			tmp.append("StringList");
			tmp.append((char)0);
			QStringList val=value.toStringList();
			for (int ii=0; ii<val.count(); ii++) {
				tmp.append(val[ii].toAscii());
				if (ii+1<val.count()) tmp.append((char)0);				
			}
			return writeData(key,tmp,compress,"Value");
		}
		else if (value.type()==QVariant::Image) {
			QImage img=value.value<QImage>();
			QString img_format="JPG";
			//if (img.hasAlphaChannel()) img_format="PNG";
			img_format="PNG"; //for now, use only PNG, because it seems that the static MAC version of the rwclient cannot handle JPG.
			QByteArray tmp;
			tmp.append("Image::"+img_format);
			tmp.append((char)0);
 			QBuffer buffer(&tmp);
 			buffer.open(QIODevice::Append);
 			img.save(&buffer,img_format.toAscii().data(),99);
 			buffer.close();
 			return writeData(key,tmp,compress,"Value");
		}
		else if (value.type()==QVariant::ByteArray) {
			QByteArray data=value.toByteArray();
			QByteArray tmp;
			tmp.append("ByteArray");
			tmp.append((char)0);
			tmp.append(data);
			return writeData(key,tmp,compress,"Value");
		}
		else if (value.type()==QVariant::PointF) {
			QPointF vvv=value.toPointF();
			QByteArray tmp;
			tmp.append("PointF");
			tmp.append((char)0);
			tmp.append(QString("%1,%2").arg(vvv.x()).arg(vvv.y()).toAscii());
			return writeData(key,tmp,compress,"Value");
		}
		else if (value.type()==QVariant::DateTime) {
			//added on 1/11/2012 to handle milliseconds!
			QByteArray tmp;
			tmp.append("DateTime");
			tmp.append((char)0);
			tmp.append(value.toDateTime().toString("yyyy-MM-ddThh:mm:ss.zzz"));
			return writeData(key,tmp,compress,"Value");
		}
		else if (value.type()==QVariant::Time) {
			//added on 1/11/2012 to handle milliseconds!
			QByteArray tmp;
			tmp.append("Time");
			tmp.append((char)0);
			tmp.append(value.toTime().toString("hh:mm:ss.zzz"));
			return writeData(key,tmp,compress,"Value");
		}
		else {
			QByteArray tmp;
			tmp.append(value.typeName());
			tmp.append((char)0);
			tmp.append(value.toString().toAscii());
			return writeData(key,tmp,compress,"Value");
		}
	}
}
开发者ID:magland,项目名称:viewmda,代码行数:85,代码来源:jarchive.cpp

示例7: renderPoint

void QgsEllipseSymbolLayer::renderPoint( QPointF point, QgsSymbolRenderContext &context )
{
  double scaledWidth = mSymbolWidth;
  double scaledHeight = mSymbolHeight;

  if ( mDataDefinedProperties.hasActiveProperties() )
  {
    bool ok;
    context.setOriginalValueVariable( mStrokeWidth );
    QVariant exprVal = mDataDefinedProperties.value( QgsSymbolLayer::PropertyStrokeWidth, context.renderContext().expressionContext() );
    if ( exprVal.isValid() )
    {
      double width = exprVal.toDouble( &ok );
      if ( ok )
      {
        width = context.renderContext().convertToPainterUnits( width, mStrokeWidthUnit, mStrokeWidthMapUnitScale );
        mPen.setWidthF( width );
      }
    }

    context.setOriginalValueVariable( QgsSymbolLayerUtils::encodePenStyle( mStrokeStyle ) );
    exprVal = mDataDefinedProperties.value( QgsSymbolLayer::PropertyStrokeStyle, context.renderContext().expressionContext() );
    if ( exprVal.isValid() )
    {
      mPen.setStyle( QgsSymbolLayerUtils::decodePenStyle( exprVal.toString() ) );
    }

    context.setOriginalValueVariable( QgsSymbolLayerUtils::encodePenJoinStyle( mPenJoinStyle ) );
    exprVal = mDataDefinedProperties.value( QgsSymbolLayer::PropertyJoinStyle, context.renderContext().expressionContext() );
    if ( exprVal.isValid() )
    {
      mPen.setJoinStyle( QgsSymbolLayerUtils::decodePenJoinStyle( exprVal.toString() ) );
    }

    context.setOriginalValueVariable( QgsSymbolLayerUtils::encodeColor( mColor ) );
    mBrush.setColor( mDataDefinedProperties.valueAsColor( QgsSymbolLayer::PropertyFillColor, context.renderContext().expressionContext(), mColor ) );

    context.setOriginalValueVariable( QgsSymbolLayerUtils::encodeColor( mStrokeColor ) );
    mPen.setColor( mDataDefinedProperties.valueAsColor( QgsSymbolLayer::PropertyStrokeColor, context.renderContext().expressionContext(), mStrokeColor ) );

    if ( mDataDefinedProperties.isActive( QgsSymbolLayer::PropertyWidth ) || mDataDefinedProperties.isActive( QgsSymbolLayer::PropertyHeight ) || mDataDefinedProperties.isActive( QgsSymbolLayer::PropertyName ) )
    {
      QString symbolName = mSymbolName;
      context.setOriginalValueVariable( mSymbolName );
      exprVal = mDataDefinedProperties.value( QgsSymbolLayer::PropertyName, context.renderContext().expressionContext() );
      if ( exprVal.isValid() )
      {
        symbolName = exprVal.toString();
      }
      preparePath( symbolName, context, &scaledWidth, &scaledHeight, context.feature() );
    }
  }

  //offset and rotation
  bool hasDataDefinedRotation = false;
  QPointF offset;
  double angle = 0;
  calculateOffsetAndRotation( context, scaledWidth, scaledHeight, hasDataDefinedRotation, offset, angle );

  QPainter *p = context.renderContext().painter();
  if ( !p )
  {
    return;
  }

  QMatrix transform;
  transform.translate( point.x() + offset.x(), point.y() + offset.y() );
  if ( !qgsDoubleNear( angle, 0.0 ) )
  {
    transform.rotate( angle );
  }

  p->setPen( mPen );
  p->setBrush( mBrush );
  p->drawPath( transform.map( mPainterPath ) );
}
开发者ID:CS-SI,项目名称:QGIS,代码行数:76,代码来源:qgsellipsesymbollayer.cpp

示例8: keyboardPaletteButtonSizeChanged

void UBKeyboardPalette::keyboardPaletteButtonSizeChanged(QVariant size)
{
    setKeyButtonSize(size.toString());
}
开发者ID:fightersheart,项目名称:myLiveNotes,代码行数:4,代码来源:UBKeyboardPalette.cpp

示例9: render


//.........这里部分代码省略.........

    currentY += cellHeaderHeight;
    currentY += gridSizeY;
  }

  //now draw the body cells
  int rowsDrawn = 0;
  if ( drawContents )
  {
    //draw the attribute values
    for ( int row = rowsToShow.first; row < rowsToShow.second; ++row )
    {
      rowsDrawn++;
      currentX = gridSizeX;
      int col = 0;

      //calculate row height
      double rowHeight = mMaxRowHeightMap[row + 1] + 2 * mCellMargin;


      for ( const QgsLayoutTableColumn *column : qgis::as_const( mColumns ) )
      {
        //draw background
        p->save();
        p->setPen( Qt::NoPen );
        p->setBrush( backgroundColor( row, col ) );
        p->drawRect( QRectF( currentX, currentY, mMaxColumnWidthMap[col] + 2 * mCellMargin, rowHeight ) );
        p->restore();

        // currentY = gridSize;
        currentX += mCellMargin;

        QVariant cellContents = mTableContents.at( row ).at( col );
        QString str = cellContents.toString();

        Qt::TextFlag textFlag = static_cast< Qt::TextFlag >( 0 );
        if ( column->width() <= 0 && mWrapBehavior == TruncateText )
        {
          //automatic column width, so we use the Qt::TextDontClip flag when drawing contents, as this works nicer for italicised text
          //which may slightly exceed the calculated width
          //if column size was manually set then we do apply text clipping, to avoid painting text outside of columns width
          textFlag = Qt::TextDontClip;
        }
        else if ( textRequiresWrapping( str, column->width(), mContentFont ) )
        {
          str = wrappedText( str, column->width(), mContentFont );
        }

        cell = QRectF( currentX, currentY, mMaxColumnWidthMap[col], rowHeight );
        QgsLayoutUtils::drawText( p, cell, str, mContentFont, mContentFontColor, column->hAlignment(), column->vAlignment(), textFlag );

        currentX += mMaxColumnWidthMap[ col ];
        currentX += mCellMargin;
        currentX += gridSizeX;
        col++;
      }
      currentY += rowHeight;
      currentY += gridSizeY;
    }
  }

  if ( numberRowsToDraw > rowsDrawn )
  {
    p->save();
    p->setPen( Qt::NoPen );
开发者ID:AlisterH,项目名称:Quantum-GIS,代码行数:66,代码来源:qgslayouttable.cpp

示例10: setData

bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, int role)
{
    bool successful = true; /* set to false on parse error */
    if(role == Qt::EditRole)
    {
        QSettings settings;
        switch(index.row())
        {
        case StartAtStartup:
            successful = GUIUtil::SetStartOnSystemStartup(value.toBool());
            break;
        case MinimizeToTray:
            fMinimizeToTray = value.toBool();
            settings.setValue("fMinimizeToTray", fMinimizeToTray);
            break;
        case MapPortUPnP:
            settings.setValue("fUseUPnP", value.toBool());
            MapPort(value.toBool());
            break;
        case MinimizeOnClose:
            fMinimizeOnClose = value.toBool();
            settings.setValue("fMinimizeOnClose", fMinimizeOnClose);
            break;
        case ProxyUse:
            settings.setValue("fUseProxy", value.toBool());
            ApplyProxySettings();
            break;
        case ProxyIP: {
            proxyType proxy;
            proxy = CService("127.0.0.1", 9050);
            GetProxy(NET_IPV4, proxy);

            CNetAddr addr(value.toString().toStdString());
            proxy.SetIP(addr);
            settings.setValue("addrProxy", proxy.ToStringIPPort().c_str());
            successful = ApplyProxySettings();
        }
        break;
        case ProxyPort: {
            proxyType proxy;
            proxy = CService("127.0.0.1", 9050);
            GetProxy(NET_IPV4, proxy);

            proxy.SetPort(value.toInt());
            settings.setValue("addrProxy", proxy.ToStringIPPort().c_str());
            successful = ApplyProxySettings();
        }
        break;
        case Fee:
            nTransactionFee = value.toLongLong();
            settings.setValue("nTransactionFee", (qint64) nTransactionFee);
            emit transactionFeeChanged(nTransactionFee);
            break;
        case ReserveBalance:
            nReserveBalance = value.toLongLong();
            settings.setValue("nReserveBalance", (qint64) nReserveBalance);
            emit reserveBalanceChanged(nReserveBalance);
            break;
        case DisplayUnit:
            nDisplayUnit = value.toInt();
            settings.setValue("nDisplayUnit", nDisplayUnit);
            emit displayUnitChanged(nDisplayUnit);
            break;
        case Language:
            settings.setValue("language", value);
            break;
        case CoinControlFeatures: {
            fCoinControlFeatures = value.toBool();
            settings.setValue("fCoinControlFeatures", fCoinControlFeatures);
            emit coinControlFeaturesChanged(fCoinControlFeatures);
            }
            break;
        case MinimizeCoinAge:
           fMinimizeCoinAge = value.toBool();
           settings.setValue("fMinimizeCoinAge", fMinimizeCoinAge);
           break;
        case UseBlackTheme:
            fUseBlackTheme = value.toBool();
            settings.setValue("fUseBlackTheme", fUseBlackTheme);
            break;
        case DarksendRounds:
            nDarksendRounds = value.toInt();
            settings.setValue("nDarksendRounds", nDarksendRounds);
            emit darksendRoundsChanged(nDarksendRounds);
            break;
        case anonymizeGravitonAmount:
            nAnonymizeGravitonAmount = value.toInt();
            settings.setValue("nAnonymizeGravitonAmount", nAnonymizeGravitonAmount);
            emit anonymizeGravitonAmountChanged(nAnonymizeGravitonAmount);
            break;
        default:
            break;
        }
    }
    emit dataChanged(index, index);

    return successful;
}
开发者ID:Cinnicoin,项目名称:graviton,代码行数:98,代码来源:optionsmodel.cpp

示例11: createEditor


//.........这里部分代码省略.........
    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()));
        //colorBtn->setFlat(true);
      }
      // 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::Bool)
    {
      QCheckBox *visibilityCheckBox = new QCheckBox(parent);
      connect(visibilityCheckBox, SIGNAL(editingFinished()),
        this, SLOT(commitAndCloseEditor()));

      return visibilityCheckBox;
    }*/


    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:beneon,项目名称:MITK,代码行数:101,代码来源:QmitkPropertyDelegate.cpp

示例12: updateFeatures

int QgsAtlasComposition::updateFeatures()
{
  //needs to be called when layer, filter, sort changes

  if ( !mCoverageLayer )
  {
    return 0;
  }

  QgsExpressionContext expressionContext = createExpressionContext();

  updateFilenameExpression();

  // select all features with all attributes
  QgsFeatureRequest req;

  QScopedPointer<QgsExpression> filterExpression;
  if ( mFilterFeatures && !mFeatureFilter.isEmpty() )
  {
    filterExpression.reset( new QgsExpression( mFeatureFilter ) );
    if ( filterExpression->hasParserError() )
    {
      mFilterParserError = filterExpression->parserErrorString();
      return 0;
    }

    //filter good to go
    req.setFilterExpression( mFeatureFilter );
  }
  mFilterParserError = QString();

  QgsFeatureIterator fit = mCoverageLayer->getFeatures( req );

  QScopedPointer<QgsExpression> nameExpression;
  if ( !mPageNameExpression.isEmpty() )
  {
    nameExpression.reset( new QgsExpression( mPageNameExpression ) );
    if ( nameExpression->hasParserError() )
    {
      nameExpression.reset( nullptr );
    }
    nameExpression->prepare( &expressionContext );
  }

  // We cannot use nextFeature() directly since the feature pointer is rewinded by the rendering process
  // We thus store the feature ids for future extraction
  QgsFeature feat;
  mFeatureIds.clear();
  mFeatureKeys.clear();
  int sortIdx = mCoverageLayer->fieldNameIndex( mSortKeyAttributeName );

  while ( fit.nextFeature( feat ) )
  {
    expressionContext.setFeature( feat );

    QString pageName;
    if ( !nameExpression.isNull() )
    {
      QVariant result = nameExpression->evaluate( &expressionContext );
      if ( nameExpression->hasEvalError() )
      {
        QgsMessageLog::logMessage( tr( "Atlas name eval error: %1" ).arg( nameExpression->evalErrorString() ), tr( "Composer" ) );
      }
      pageName = result.toString();
    }

    mFeatureIds.push_back( qMakePair( feat.id(), pageName ) );

    if ( mSortFeatures && sortIdx != -1 )
    {
      mFeatureKeys.insert( feat.id(), feat.attributes().at( sortIdx ) );
    }
  }

  // sort features, if asked for
  if ( !mFeatureKeys.isEmpty() )
  {
    FieldSorter sorter( mFeatureKeys, mSortAscending );
    qSort( mFeatureIds.begin(), mFeatureIds.end(), sorter );
  }

  emit numberFeaturesChanged( mFeatureIds.size() );

  //jump to first feature if currently using an atlas preview
  //need to do this in case filtering/layer change has altered matching features
  if ( mComposition->atlasMode() == QgsComposition::PreviewAtlas )
  {
    firstFeature();
  }

  return mFeatureIds.size();
}
开发者ID:MrBenjaminLeb,项目名称:QGIS,代码行数:92,代码来源:qgsatlascomposition.cpp

示例13: dumpAttributeVariant

static void dumpAttributeVariant(QDebug dbg, const QVariant &var, const QString& indent)
{
    switch (int(var.type())) {
    case QMetaType::Void:
        dbg << QString::asprintf("%sEmpty\n", indent.toUtf8().constData());
        break;
    case QMetaType::UChar:
        dbg << QString::asprintf("%suchar %u\n", indent.toUtf8().constData(), var.toUInt());
        break;
    case QMetaType::UShort:
        dbg << QString::asprintf("%sushort %u\n", indent.toUtf8().constData(), var.toUInt());
        break;
    case QMetaType::UInt:
        dbg << QString::asprintf("%suint %u\n", indent.toUtf8().constData(), var.toUInt());
        break;
    case QMetaType::Char:
        dbg << QString::asprintf("%schar %d\n", indent.toUtf8().constData(), var.toInt());
        break;
    case QMetaType::Short:
        dbg << QString::asprintf("%sshort %d\n", indent.toUtf8().constData(), var.toInt());
        break;
    case QMetaType::Int:
        dbg << QString::asprintf("%sint %d\n", indent.toUtf8().constData(), var.toInt());
        break;
    case QMetaType::QString:
        dbg << QString::asprintf("%sstring %s\n", indent.toUtf8().constData(),
                                 var.toString().toUtf8().constData());
        break;
    case QMetaType::Bool:
        dbg << QString::asprintf("%sbool %d\n", indent.toUtf8().constData(), var.toBool());
        break;
    case QMetaType::QUrl:
        dbg << QString::asprintf("%surl %s\n", indent.toUtf8().constData(),
                                 var.toUrl().toString().toUtf8().constData());
        break;
    case QVariant::UserType:
        if (var.userType() == qMetaTypeId<QBluetoothUuid>()) {
            QBluetoothUuid uuid = var.value<QBluetoothUuid>();
            switch (uuid.minimumSize()) {
            case 0:
                dbg << QString::asprintf("%suuid NULL\n", indent.toUtf8().constData());
                break;
            case 2:
                dbg << QString::asprintf("%suuid2 %04x\n", indent.toUtf8().constData(),
                                         uuid.toUInt16());
                break;
            case 4:
                dbg << QString::asprintf("%suuid %08x\n", indent.toUtf8().constData(),
                                         uuid.toUInt32());
                break;
            case 16:
                dbg << QString::asprintf("%suuid %s\n",
                            indent.toUtf8().constData(),
                            QByteArray(reinterpret_cast<const char *>(uuid.toUInt128().data), 16).toHex().constData());
                break;
            default:
                dbg << QString::asprintf("%suuid ???\n", indent.toUtf8().constData());
            }
        } else if (var.userType() == qMetaTypeId<QBluetoothServiceInfo::Sequence>()) {
            dbg << QString::asprintf("%sSequence\n", indent.toUtf8().constData());
            const QBluetoothServiceInfo::Sequence *sequence = static_cast<const QBluetoothServiceInfo::Sequence *>(var.data());
            foreach (const QVariant &v, *sequence)
                dumpAttributeVariant(dbg, v, indent + QLatin1Char('\t'));
        } else if (var.userType() == qMetaTypeId<QBluetoothServiceInfo::Alternative>()) {
开发者ID:,项目名称:,代码行数:64,代码来源:

示例14: setData

bool TableModelGlobalVariables::setData(QModelIndex const & index,
                                        QVariant const & value,
                                        int role)
{
    if (role != Qt::EditRole) {
        return false;
    }
    if (!index.isValid()) {
        return false;
    }
    int row = index.row();
    if (!(row < globalVariables.size())) {
        return false;
    }
    QPair< QString, QString > & globalVariable_ = globalVariables[row];
    switch (index.column()) {
    case 0 : {
        if (!value.canConvert(QVariant::String)) {
            qWarning() << "Variant contains non string value";
            return false;
        }
        QString name = value.toString();
        if (!Settings::getPersistentSettings().symbolExpression.exactMatch(name)) {
            qWarning() << name + " is not correct symbol name";
            return false;
        }
        if (Settings::getPersistentSettings().dummySymbolExpression.exactMatch(name)) {
            qWarning() << "The underscore symbol used as dummy variable name";
            return false;
        }
        if (Settings::getPersistentSettings().reservedSymbols.contains(name)) {
            qWarning() << "Symbol " + name + " is reserved";
            return false;
        }
        for (QPair< QString, QString > const & globalVariable : globalVariables) {
            if (globalVariable.first == name) {
                qWarning() << "A duplicates of symbols are not allowed";
                return false;
            }
        }
        globalVariable_.first = name;
        break;
    }
    case 1 : {
        if (!value.canConvert(QVariant::String)) {
            qWarning() << "Variant contains non string value";
            return false;
        }
        QString variableValue = value.toString();
        if (!variableValue.isEmpty()) {
            if (!Settings::getPersistentSettings().floatingPointExpression.exactMatch(variableValue)) {
                qWarning() << "Variant contains string which is nonconvertible to floating-point number";
                return false;
            }
        }
        globalVariable_.second = variableValue;
        break;
    }
    default : {
        return false;
    }
    }
    emit dataChanged(index, index);
    return true;
}
开发者ID:tomilov,项目名称:iccad,代码行数:65,代码来源:tablemodelglobalvariables.cpp

示例15: handleOption

void Config::handleOption(const QString &option, const QVariant &value)
{
    bool boolValue = false;

    QStringList booleanFlags;
    booleanFlags << "debug";
    booleanFlags << "disk-cache";
    booleanFlags << "ignore-ssl-errors";
    booleanFlags << "load-images";
    booleanFlags << "local-to-remote-url-access";
    booleanFlags << "remote-debugger-autorun";
    booleanFlags << "web-security";
    if (booleanFlags.contains(option)) {
        if ((value != "true") && (value != "yes") && (value != "false") && (value != "no")) {
            setUnknownOption(QString("Invalid values for '%1' option.").arg(option));
            return;
        }
        boolValue = (value == "true") || (value == "yes");
    }

    if (option == "cookies-file") {
        setCookiesFile(value.toString());
    }

    if (option == "config") {
        loadJsonFile(value.toString());
    }

    if (option == "debug") {
        setPrintDebugMessages(boolValue);
    }

    if (option == "disk-cache") {
        setDiskCacheEnabled(boolValue);
    }

    if (option == "ignore-ssl-errors") {
        setIgnoreSslErrors(boolValue);
    }

    if (option == "load-images") {
        setAutoLoadImages(boolValue);
    }

    if (option == "local-storage-path") {
        setOfflineStoragePath(value.toString());
    }

    if (option == "local-storage-quota") {
        setOfflineStorageDefaultQuota(value.toInt());
    }

    if (option == "local-to-remote-url-access") {
        setLocalToRemoteUrlAccessEnabled(boolValue);
    }

    if (option == "max-disk-cache") {
        setMaxDiskCacheSize(value.toInt());
    }

    if (option == "output-encoding") {
        setOutputEncoding(value.toString());
    }

    if (option == "remote-debugger-autorun") {
        setRemoteDebugAutorun(boolValue);
    }

    if (option == "remote-debugger-port") {
        setDebug(true);
        setRemoteDebugPort(value.toInt());
    }

    if (option == "proxy") {
        setProxy(value.toString());
    }

    if (option == "proxy-type") {
        setProxyType(value.toString());
    }

    if (option == "proxy-auth") {
        setProxyAuth(value.toString());
    }

    if (option == "script-encoding") {
        setScriptEncoding(value.toString());
    }

    if (option == "web-security") {
        setWebSecurityEnabled(boolValue);
    }
    if (option == "ssl-protocol") {
        setSslProtocol(value.toString());
    }
    if (option == "webdriver") {
        setWebdriver(value.toString());
    }
    if (option == "webdriver-selenium-grid-hub") {
        setWebdriverSeleniumGridHub(value.toString());
//.........这里部分代码省略.........
开发者ID:OshinKaramian,项目名称:phantomjs,代码行数:101,代码来源:config.cpp


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