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


C++ QVariant类代码示例

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


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

示例1: switch

QVariant ParameterFileModel::data(const QModelIndex& ind, int role) const {
	// mapper to convert parameter.type into QVariant::Type
	const VarTypeMap& mapper = VarTypeMap::instance();
	int row = ind.row();
	int col = ind.column();
	QString key = _keys[row];
	QString val;
	QVariant res;

	switch (role) {

	case Qt::EditRole:
	case Qt::DisplayRole:
		if ((row >= 0) && (row < _keys.size())) {
			switch (col) {
			case 0:
				// parameter name (without prefix)
				if (!_prefix.isEmpty())
					key.remove(0, _prefix.length());

				// remove dot after valid prefix
				if (key[0] == '.')
					key.remove(0, 1);
				return key;

			case 1:
				if (_parameterFile->isSet(_keys[row])) {
					val = _parameterFile->get(_keys[row]);
				}
				else if (_onlyParams) {
					val = getDefault(_keys[row]);
				}

				// handle parameter links
				if (val.startsWith('@')) {
					QString ref = val.mid(1);
					if(_parameterFile->isSet(ref)) {
						val = _parameterFile->get(ref);
					}
					else if(role == Qt::DisplayRole) {
						val = tr("[invalid reference to %1]").arg(ref);
					}
				}

				// handle QVariant type
				res = val;
				if (_useMetaInfo && isParameter(key)) {
					QString typestring = getType(key);
					QVariant::Type type = mapper[typestring];
					Q_ASSERT(res.canConvert(type));
					res.convert(type);
				}
				return res;

			case 2:
				if (role == Qt::DisplayRole) {
					return QVariant();
				}
				return getValue(key + ".editorpriority").toUInt();
			}
		}
		break;

	case Qt::ToolTipRole:
		if (_useMetaInfo) {
			QString ret = _metaInfos->getDocString(key, getClass(key));
			return ret.isEmpty() ? QVariant() : ret;
		}
		break;

	case Qt::ForegroundRole:
		if (_onlyParams && !isSet(key)) {
			return QColor(Qt::lightGray);
		}
		break;

	case Qt::BackgroundRole:
		switch (getValue(key+".editorpriority").toInt()) {
		case 1:
			return QColor("#8f8");
		case 2:
			return QColor("#ff8");
		case 3:
			return QColor("#f80");
		default:
			break;
		}
		break;

	case Qt::CheckStateRole:
		if (_useMetaInfo && col == 1 &&
				isParameter(key) && getType(key) == "bool") {
			const bool& checked = isSet(key) ?
					QVariant(getValue(key)).toBool() :
					QVariant(getDefault(key)).toBool();
			return checked ? Qt::Checked : Qt::Unchecked;
		}
		break;

	case Qt::StatusTipRole:
//.........这里部分代码省略.........
开发者ID:flowexpert,项目名称:charon,代码行数:101,代码来源:ParameterFileModel.cpp

示例2: qCritical

void ServerConfig::load() {
  tree = config.parse();
  valid = tree;

  if (config.getErrors().testFlag(Config::PathNonExistent)) {
    return;
  }

  if (!valid) {
    qCritical() << "Could not load/parse config file:" << config.getPath();
    return;
  }

  // Set the values for type-safe retrieval.
  valid = false;
  qDebug() << "Checking configuration file.. ";

  ConfigTreeNode *node = tree->searchNode("ServerConfig");
  if (!node) {
    qCritical() << "The root element must be 'ServerConfig'!";
    return;
  }

  // ServerConfig/Port
  node = tree->searchNode("ServerConfig/Port");
  if (!node) {
    qCritical() << "Must have an entry 'ServerConfig/Port'!";
    return;
  }
  QVariant var = node->getValue();
  bool ok;
  portVar = var.toString().toUInt(&ok);  
  if (var.isNull() || !ok) {
    qCritical() << "ServerConfig/Port needs to be an unsigned 16-bit integer!";
    return;
  }

  // ServerConfig/SslCert
  node = tree->searchNode("ServerConfig/SslCert");
  if (!node) {
    qCritical() << "Must have an entry 'ServerConfig/SslCert'!";
    return;
  }
  var = node->getValue();
  sslCertVar = var.toString();
  if (var.isNull() || !Ssl::checkCert(sslCertVar).testFlag(Ssl::NoError)) {
    qCritical() << "ServerConfig/SslCert needs to point to a X.509 certificate in PEM format!";
    return;
  }

  // ServerConfig/SslKey
  node = tree->searchNode("ServerConfig/SslKey");
  if (!node) {
    qCritical() << "Must have an entry 'ServerConfig/SslKey'!";
    return;
  }
  var = node->getValue();
  sslKeyVar = var.toString();
  if (var.isNull() || !Ssl::checkKey(sslKeyVar).testFlag(Ssl::NoError)) {
    qCritical() << "ServerConfig/SslKey needs to point to a X.509 private key in PEM format!";
    return;
  }    

  valid = true;
}
开发者ID:netromdk,项目名称:backup,代码行数:65,代码来源:ServerConfig.cpp

示例3: apiVariantToString

QString
apiVariantToString(const QVariant &variant, bool multiLine)
{
    if (variant.isNull()) {
        return QLatin1String("?");
    }

    if (variant.userType() == QMetaType::Float) {
        return QString::number(variant.toFloat());
    }
    if (variant.userType() == QVariant::Double) {
        return QString::number(variant.toDouble());
    }
    if (variant.userType() == QVariant::ByteArray) {
        if (variant.toByteArray().size() < 1024) {
            int bytes = variant.toByteArray().size();
            return QObject::tr("[binary data, size = %1 bytes]").arg(bytes);
        } else {
            float kb = variant.toByteArray().size()/1024.;
            return QObject::tr("[binary data, size = %1 kb]").arg(kb);
        }
    }

    if (variant.userType() == QVariant::String) {
        return plainTextToHTML(variant.toString(), multiLine);
    }

    if (variant.userType() < QVariant::UserType) {
        return variant.toString();
    }

    if (variant.canConvert<ApiPointer>()) {
        return variant.value<ApiPointer>().toString();
    }
    if (variant.canConvert<ApiBitmask>()) {
        return variant.value<ApiBitmask>().toString();
    }
    if (variant.canConvert<ApiStruct>()) {
        return variant.value<ApiStruct>().toString(multiLine);
    }
    if (variant.canConvert<ApiArray>()) {
        return variant.value<ApiArray>().toString(multiLine);
    }
    if (variant.canConvert<ApiEnum>()) {
        return variant.value<ApiEnum>().toString();
    }

    return QString();
}
开发者ID:Aganlengzi,项目名称:apitrace,代码行数:49,代码来源:apitracecall.cpp

示例4: switch

void NcQuickView::keyPressEvent(QKeyEvent *event)
{
    QQuickView::keyPressEvent(event);
    if (event->isAccepted()) return;
	QObject *obj = this->rootObject();
	QObject *timeLine = obj->findChild<QObject*>("slideBar");
	
    switch(event->key()){
		case Qt::Key_C:
			{
				break;
			}
		case Qt::Key_M:
			{	
				std::vector< std::vector<float> > areaSum = this->map->getAreaSum();
				QObject *qchartView = obj->findChild<QObject*>("chart");
			
				QMetaObject::invokeMethod(qchartView, "clearLine");//, Q_RETURN_ARG(QVariant, retValue), Q_ARG(QVariant, i), Q_ARG(QVariant,areaSum[i]));I
				qchartView->setProperty("maxX",(int) areaSum[0].size());

				float maxY = INT_MIN, minY = INT_MAX;
				for (int idx = 0; idx < 3; idx ++)
					for (int i=0;i<areaSum[idx].size();i++)
						{
							maxY = maxY<areaSum[idx][i]?areaSum[idx][i]:maxY;
							minY = minY>areaSum[idx][i]?areaSum[idx][i]:minY;
						}
				qDebug()<<minY<<" "<<maxY;
				qchartView->setProperty("minY",(int)minY*0.9);
				qchartView->setProperty("maxY",(int)maxY*1.1);
				
				for (int idx = 0 ; idx < 3 ; idx++)
				{			
	
					QVariant retValue;	

					
					for (int i=0;i<areaSum[idx].size();i++)
					{
						if (idx == 0) QMetaObject::invokeMethod(qchartView, "createXYPoint1", Q_RETURN_ARG(QVariant, retValue), Q_ARG(QVariant, i), Q_ARG(QVariant,areaSum[idx][i]));
						if (idx == 1) QMetaObject::invokeMethod(qchartView, "createXYPoint2", Q_RETURN_ARG(QVariant, retValue), Q_ARG(QVariant, i), Q_ARG(QVariant,areaSum[idx][i]));
						if (idx == 2) QMetaObject::invokeMethod(qchartView, "createXYPoint3", Q_RETURN_ARG(QVariant, retValue), Q_ARG(QVariant, i), Q_ARG(QVariant,areaSum[idx][i]));	
					}
					qDebug()<<retValue.toString();
				}
				
					qDebug()<<"qchart is fixed";
				
				break;
			}
        default:
			this->map->keyPressEvent(event);
    }
/*
	int timeStamp = this->map->getTimestamp();
	if (timeLine)
	//	timeLine->setProperty("x",timeStamp * 10);	
	//	timeLine->setProperty("timeStamp",timeStamp);	
	
	else qDebug()<<"didnt find QML component";
  */
    NcQuickView::update();
}
开发者ID:MeepoLi,项目名称:inforProject,代码行数:63,代码来源:NcQuickView.cpp

示例5: msgCannotWriteProperty

static QString msgCannotWriteProperty(const QString &pname, const QVariant &v)
{
    return QCoreApplication::translate("QFormBuilder", "The property %1 could not be written. The type %2 is not supported yet.").
           arg(pname).arg(QLatin1String(v.typeName()));

}
开发者ID:selebro,项目名称:qt,代码行数:6,代码来源:properties.cpp

示例6: set

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

  param = pParams.value("mode", &valid);
  if (valid)
  {
    if (param.toString() == "new")
    {
      _mode = cNew;

      _name->setFocus();
    }
    else if (param.toString() == "edit")
    {
      _mode = cEdit;

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

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

      _name->setEnabled(FALSE);
      _descrip->setEnabled(FALSE);
      _dates->setEnabled(FALSE);
      _currency->setEnabled(FALSE);
      _new->setEnabled(FALSE);
      _close->setText(tr("&Close"));
      _save->hide();

      _close->setFocus();
    }
  }

  param = pParams.value("ipshead_id", &valid);
  if (valid)
  {
    _ipsheadid = param.toInt();
    populate();
  }

  if ( (_mode == cNew) || (_mode == cEdit) || (_mode == cCopy) )
  {
    connect(_ipsitem, SIGNAL(valid(bool)), _edit, SLOT(setEnabled(bool)));
    connect(_ipsitem, SIGNAL(valid(bool)), _delete, SLOT(setEnabled(bool)));
    connect(_ipsitem, SIGNAL(itemSelected(int)), _edit, SLOT(animateClick()));
  }

  if ( (_mode == cNew) || (_mode == cCopy) )
  {
    int oldIpsheadid = _ipsheadid;
    q.exec("SELECT NEXTVAL('ipshead_ipshead_id_seq') AS ipshead_id;");
    if (q.first())
      _ipsheadid = q.value("ipshead_id").toInt();

    if(_mode == cCopy)
    {
      q.prepare(" INSERT "
                "   INTO ipsitem "
                "       (ipsitem_ipshead_id, ipsitem_item_id, "
                "        ipsitem_qtybreak, ipsitem_price,"
                "        ipsitem_qty_uom_id, ipsitem_price_uom_id) "
                " SELECT :ipshead_id, ipsitem_item_id, "
                "        ipsitem_qtybreak, ipsitem_price,"
                "        ipsitem_qty_uom_id, ipsitem_price_uom_id "
                "   FROM ipsitem "
                "  WHERE (ipsitem_ipshead_id=:oldipshead_id); "
                " INSERT "
                "   INTO ipsprodcat "
                "       (ipsprodcat_ipshead_id, ipsprodcat_prodcat_id, "
                "        ipsprodcat_qtybreak, ipsprodcat_discntprcnt) "
                " SELECT :ipshead_id, ipsprodcat_prodcat_id, "
                "        ipsprodcat_qtybreak, ipsprodcat_discntprcnt "
                "   FROM ipsprodcat "
                "  WHERE (ipsprodcat_ipshead_id=:oldipshead_id); ");
      q.bindValue(":ipshead_id", _ipsheadid);
      q.bindValue(":oldipshead_id", oldIpsheadid);
      q.exec();
    }
  }

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

示例7: updateFilenameExpression

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

  if ( !mCoverageLayer )
  {
    return 0;
  }

  updateFilenameExpression();

  // select all features with all attributes
  QgsFeatureIterator fit = mCoverageLayer->getFeatures();

  std::auto_ptr<QgsExpression> filterExpression;
  if ( mFilterFeatures && !mFeatureFilter.isEmpty() )
  {
    filterExpression = std::auto_ptr<QgsExpression>( new QgsExpression( mFeatureFilter ) );
    if ( filterExpression->hasParserError() )
    {
      throw std::runtime_error( tr( "Feature filter parser error: %1" ).arg( filterExpression->parserErrorString() ).toLocal8Bit().data() );
    }
  }

  // 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();
  while ( fit.nextFeature( feat ) )
  {
    if ( mFilterFeatures && !mFeatureFilter.isEmpty() )
    {
      QVariant result = filterExpression->evaluate( &feat, mCoverageLayer->pendingFields() );
      if ( filterExpression->hasEvalError() )
      {
        throw std::runtime_error( tr( "Feature filter eval error: %1" ).arg( filterExpression->evalErrorString() ).toLocal8Bit().data() );
      }

      // skip this feature if the filter evaluation if false
      if ( !result.toBool() )
      {
        continue;
      }
    }
    mFeatureIds.push_back( feat.id() );

    if ( mSortFeatures )
    {
      mFeatureKeys.insert( feat.id(), feat.attributes()[ mSortKeyAttributeIdx ] );
    }
  }

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

  QgsExpression::setSpecialColumn( "$numfeatures", QVariant(( int )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:FlavioFalcao,项目名称:QGIS,代码行数:71,代码来源:qgsatlascomposition.cpp

示例8: specieDataChange

bool CQSpecieDM::specieDataChange(
  UndoSpeciesData *pUndoSpeciesData,
  const QVariant &value,
  int column)
{
  switchToWidget(CCopasiUndoCommand::SPECIES);

  GET_MODEL_OR(pModel, return false);

  mpSpecies =
    dynamic_cast<CMetab*>(pUndoSpeciesData->getObject(pModel));

  if (mpSpecies == NULL)
    return false;

  const CCompartment * pCompartment = NULL;

  if (column == COL_COMPARTMENT ||
      column == COL_ICONCENTRATION ||
      column == COL_INUMBER)
    {
      try
        {
          pCompartment = mpSpecies->getCompartment();
        }
      catch (...) {}
    }

  if (column == COL_NAME_SPECIES)
    {
      mpSpecies->setObjectName(TO_UTF8(value.toString()));
      pUndoSpeciesData->setCN(mpSpecies->getCN());
    }
  else if (column == COL_COMPARTMENT)
    {
      // This must be set first for setInitialConcentration and
      // setInitialNumber to work correctly.
      std::string Compartment(TO_UTF8(value.toString()));

      if (Compartment != pCompartment->getObjectName())
        {
          std::string CompartmentToRemove = mpSpecies->getCompartment()->getObjectName();

          if (!(pModel->getCompartments()[Compartment].addMetabolite(mpSpecies)))
            {
              QString msg;
              msg = "Unable to move species '" + FROM_UTF8(mpSpecies->getObjectName()) + "'\n"
                    + "from compartment '" + FROM_UTF8(CompartmentToRemove) + "' to compartment '" + FROM_UTF8(Compartment) + "'\n"
                    + "since a species with that name already exist in the target compartment.";

              CQMessageBox::information(NULL,
                                        "Unable to move Species",
                                        msg,
                                        QMessageBox::Ok, QMessageBox::Ok);
              return false;
            }
          else
            {
              pModel->getCompartments()[CompartmentToRemove].getMetabolites().remove(mpSpecies->getObjectName());
              pModel->setCompileFlag();
              pModel->initializeMetabolites();

              if (mpSpecies && pCompartment)
                {
                  C_FLOAT64 Factor = 1.0 / pCompartment->getInitialValue();
                  Factor *= pCompartment->getInitialValue();

                  mpSpecies->setInitialValue(Factor * pUndoSpeciesData->getINumber());
                  mpSpecies->setValue(Factor * mpSpecies->getValue());
                }

              emit notifyGUI(ListViews::METABOLITE, ListViews::CHANGE, mpSpecies->getKey());
              emit notifyGUI(ListViews::COMPARTMENT, ListViews::CHANGE, pCompartment->getKey());
            }
        }
    }
  else if (column == COL_TYPE_SPECIES)
    mpSpecies->setStatus((CModelEntity::Status) mItemToType[value.toInt()]);
  else if (column == COL_ICONCENTRATION)
    {
      if (mFlagConc)
        mpSpecies->setInitialConcentration(value.toDouble());

      if (mpSpecies && pCompartment)
        {
          const C_FLOAT64 initialValue =
            CMetab::convertToNumber(pUndoSpeciesData->getIConc(),
                                    *pCompartment,
                                    *pModel);
          mpSpecies->setInitialValue(initialValue);
        }
    }
  else if (column == COL_INUMBER)
    {
      if (!mFlagConc)
        mpSpecies->setInitialValue(value.toDouble());

      if (mpSpecies && pCompartment)
        {
          mpSpecies->setInitialConcentration(
//.........这里部分代码省略.........
开发者ID:jonasfoe,项目名称:COPASI,代码行数:101,代码来源:CQSpecieDM.cpp

示例9: QVariant

QPair<QVariant, QVariant>
RemapHDF4::rawValue(int d, int w, int h)
{
  QPair<QVariant, QVariant> pair;

  if (d < 0 || d >= m_depth ||
      w < 0 || w >= m_width ||
      h < 0 || h >= m_height)
    {
      pair.first = QVariant("OutOfBounds");
      pair.second = QVariant("OutOfBounds");
      return pair;
    }

  uchar *hdftmp = new uchar[m_bytesPerVoxel];
  int32 start[2], edges[2];
  start[0] = w;
  start[1] = h;
  edges[0] = 1;
  edges[1] = 1;

  int32 sd_id = SDstart(m_imageList[d].toAscii().data(),
			DFACC_READ);
  int32 sds_id = SDselect(sd_id, m_Index);
  int status = SDreaddata(sds_id,
			  start, NULL, edges,
			  (VOIDP)hdftmp);
  if (status == -1)
    QMessageBox::information(0, "error", "Cannot read");

  status = SDendaccess(sds_id);
  status = SDend(sd_id);


  QVariant v;

  if (m_voxelType == _UChar)
    {
      uchar *aptr = (uchar*) hdftmp;
      uchar a = *aptr;
      v = QVariant((uint)a);
    }
  else if (m_voxelType == _Char)
    {
      char *aptr = (char*) hdftmp;
      char a = *aptr;
      v = QVariant((int)a);
    }
  else if (m_voxelType == _UShort)
    {
      ushort *aptr = (ushort*) hdftmp;
      ushort a = *aptr;
      v = QVariant((uint)a);
    }
  else if (m_voxelType == _Short)
    {
      short *aptr = (short*) hdftmp;
      short a = *aptr;
      v = QVariant((int)a);
    }
  else if (m_voxelType == _Int)
    {
      int *aptr = (int*) hdftmp;
      int a = *aptr;
      v = QVariant((int)a);
    }
  else if (m_voxelType == _Float)
    {
      float *aptr = (float*) hdftmp;
      double a = *aptr;
      v = QVariant((double)a);
    }

  int rawSize = m_rawMap.size()-1;
  int idx = rawSize;
  float frc = 0;
  float val;

  if (v.type() == QVariant::UInt)
    val = v.toUInt();
  else if (v.type() == QVariant::Int)
    val = v.toInt();
  else if (v.type() == QVariant::Double)
    val = v.toDouble();


  if (val <= m_rawMap[0])
    {
      idx = 0;
      frc = 0;
    }
  else if (val >= m_rawMap[rawSize])
    {
      idx = rawSize-1;
      frc = 1;
    }
  else
    {
      for(uint m=0; m<rawSize; m++)
	{
//.........这里部分代码省略.........
开发者ID:TheProjecter,项目名称:drishtislicer,代码行数:101,代码来源:remaphdf4.cpp

示例10: main

int main(int argc, char **argv)
{
	KAboutData about("kdedtester", I18N_NOOP("KDED Module tester"), version, description,
		     KAboutData::License_GPL, "(C) 2004 Diego 'Flameeyes' Pettenò", 0, 0, "[email protected]");
	about.addAuthor( "Diego 'Flameeyes' Pettenò", 0, "[email protected]" );
	KCmdLineArgs::init(argc, argv, &about);
	KCmdLineArgs::addCmdLineOptions( options );
	KApplication app;

	// no session.. just start up normally
	KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
	
	if ( args->count() == 0 )
	{
		kdError() << "You must call kdedtester with a valid kded module name." << endl;
		return -1;
	}

	/// @todo do something with the command line args here
	QCString modulename = args->arg(0);
	args->clear();
	
	if ( modulename.isEmpty() )
	{
		kdError() << "You must call kdedtester with a valid kded module name." << endl;
		return -1;
	}
	
	KService::Ptr s = KService::serviceByDesktopPath("kded/"+modulename+".desktop");
	if ( ! s || s->library().isEmpty() )
	{
		kdError() << "Unable to load the service for requested module." << endl;
		return -2;
	}
	
	// get the library loader instance
	KLibLoader *loader = KLibLoader::self();
	
	QVariant v = s->property("X-KDE-Factory");
	QString factory = v.isValid() ? v.toString() : QString::null;
	if (factory.isEmpty())
		factory = s->library();

	factory = "create_" + factory;
	QString libname = "kded_"+s->library();
	
	kdWarning() << "Recap: the factory is '" << factory << "', and the library '" << libname << "'." << endl;

	KLibrary *lib = loader->library(QFile::encodeName(libname));
	if ( ! lib )
	{
		kdWarning() << "Library not found, trying '" << libname << "' instead" << endl
			<< "KLibLoader says: " << loader->lastErrorMessage() << endl;
		
		libname.prepend("lib");
		lib = loader->library(QFile::encodeName(libname));
	}
	
	if ( ! lib )
	{
		kdError() << "Library still not found. Exiting." << endl
			<< "KLibLoader says: " << loader->lastErrorMessage() << endl;
		return -3;
	}
	
	void *create = lib->symbol(QFile::encodeName(factory));
	if ( ! create )
	{
		kdError() << "Unable to find factory symbol into library. Exiting." << endl;
		loader->unloadLibrary(QFile::encodeName(libname));
		return -4;
	}
	
        KDEDModule* (*func)(const QCString &);
        func = (KDEDModule* (*)(const QCString &)) create;
	
	KDEDModule *module = func(modulename);
	if ( ! module )
	{
		kdError() << "Factory returned NULL module. Exiting." << endl;
		loader->unloadLibrary(QFile::encodeName(libname));
		return -5;
	}
	
	delete module;
	loader->unloadLibrary(QFile::encodeName(libname));
	kdWarning() << "Module loaded (and already unloaded) correctly." << endl;
	return 0;
}
开发者ID:Flameeyes,项目名称:kdedtester,代码行数:89,代码来源:main.cpp

示例11: setData

bool CQSpecieDM::setData(const QModelIndex &index, const QVariant &value,
                         int role)
{
  //change is only accepted if the new value is different from the old value and also the old value is not equal to "New Species" for the 'name' column
  // in that case no new species will be created!
  if (index.data() == value)
    return false;

  if (index.column() == COL_TYPE_SPECIES &&
      index.data().toString() == QString(FROM_UTF8(CModelEntity::StatusName[mItemToType[value.toInt()]])))
    return false;

  if (index.column() == COL_COMPARTMENT && value == "")
    return false;

  bool defaultRow = isDefaultRow(index);

  if (defaultRow)
    {
      mpUndoStack->push(new InsertSpecieRowsCommand(rowCount(), 1, this, index, value));
    }
  else
    {
      mpUndoStack->push(new SpecieDataChangeCommand(mpSpecies, value, index.data(), index.column(), this));
    }

  return true;
}
开发者ID:jonasfoe,项目名称:COPASI,代码行数:28,代码来源:CQSpecieDM.cpp

示例12: if

bool ParseTreeModel::setData(const QModelIndex &index, const QVariant &value,
                             int role)
{
    if(role != Qt::EditRole)
        return false;

    if(index.column() != valueColumn)
        return false;

    ParseTreeNode* node = static_cast<ParseTreeNode*>
                             (index.internalPointer());

    if(node->isParam())
    {
        struct skin_tag_parameter* param = node->getParam();

        /* Now that we've established that we do, in fact, have a parameter,
         * set it to its new value if an acceptable one has been entered
         */
        if(value.toString().trimmed() == QString(QChar(DEFAULTSYM)))
        {
            if(islower(param->type_code))
                param->type = skin_tag_parameter::DEFAULT;
            else
                return false;
        }
        else if(tolower(param->type_code) == 's'
                || tolower(param->type_code) == 'f')
        {
            if(param->type == skin_tag_parameter::STRING)
                free(param->data.text);

            param->type = skin_tag_parameter::STRING;
            param->data.text = strdup(value.toString().trimmed().toAscii());
        }
        else if(tolower(param->type_code) == 'i')
        {
            if(!value.canConvert(QVariant::Int))
                return false;

            param->type = skin_tag_parameter::INTEGER;
            param->data.number = value.toInt();
        }
        else
        {
            return false;
        }
    }
    else
    {
        struct skin_element* element = node->getElement();

        if(element->type != COMMENT && element->type != TEXT)
            return false;

        free(element->data);
        element->data = strdup(value.toString().trimmed().toAscii());
    }

    emit dataChanged(index, index);
    return true;
}
开发者ID:shuffle2,项目名称:rockbox_psgroove,代码行数:62,代码来源:parsetreemodel.cpp

示例13: SetValueInternal

void QtPropertyDataDavaVariant::SetValueInternal(const QVariant &value)
{
	switch(curVariantValue.type)
	{
	case DAVA::VariantType::TYPE_BOOLEAN:
		curVariantValue.SetBool(value.toBool());
		break;
	case DAVA::VariantType::TYPE_FLOAT:
		curVariantValue.SetFloat(value.toFloat());
		break;
	case DAVA::VariantType::TYPE_INT32:
		curVariantValue.SetInt32(value.toInt());
		break;
	case DAVA::VariantType::TYPE_INT64:
		curVariantValue.SetInt64(value.toLongLong());
		break;
	case DAVA::VariantType::TYPE_UINT32:
		curVariantValue.SetUInt32(value.toUInt());
		break;
	case DAVA::VariantType::TYPE_UINT64:
		curVariantValue.SetUInt64(value.toULongLong());
		break;
	case DAVA::VariantType::TYPE_KEYED_ARCHIVE:
		ToKeyedArchive(value);
		break;
	case DAVA::VariantType::TYPE_STRING:
		curVariantValue.SetString(value.toString().toStdString());
		break;
	case DAVA::VariantType::TYPE_MATRIX2:
		ToMatrix2(value);
		break;
	case DAVA::VariantType::TYPE_MATRIX3:
		ToMatrix3(value);
		break;
	case DAVA::VariantType::TYPE_MATRIX4:
		ToMatrix4(value);
		break;
	case DAVA::VariantType::TYPE_VECTOR2:
		ToVector2(value);
		break;
	case DAVA::VariantType::TYPE_VECTOR3:
		ToVector3(value);
		break;
	case DAVA::VariantType::TYPE_VECTOR4:
		ToVector4(value);
		break;
    case DAVA::VariantType::TYPE_COLOR:
        ToColor(value);
        break;
    case DAVA::VariantType::TYPE_FASTNAME:
        curVariantValue.SetFastName(DAVA::FastName(value.toString().toStdString().c_str()));
        break;
	case DAVA::VariantType::TYPE_AABBOX3:
		ToAABBox3(value);
		break;

	case DAVA::VariantType::TYPE_BYTE_ARRAY:
	default:
		break;
	}
}
开发者ID:abaradulkin,项目名称:dava.framework,代码行数:61,代码来源:QtPropertyDataDavaVariant.cpp

示例14: toVariant

QVariant IdListHelper::toVariant(IdList const &list)
{
	QVariant v;
	v.setValue(list);
	return v;
}
开发者ID:Natalie-S,项目名称:qreal,代码行数:6,代码来源:ids.cpp

示例15: switch

	QString LogError::insertArgs(const QString &rMessage) const
	{
	    QString result;
	    
	    /*
	     
	    // Don't use a loop to be able to handle arguments that conatin strings
	    // like %1.
	    // Using this method only 9 arguments can be handled as the %1
	    // in %11 gets also replaced with the first argument.
	
	    switch (mArgs.count())
	    {
	        case 0:
	            break;
	        case 1:
	            result = rMessage.arg(mArgs.at(0));
	            break;
	        case 2:
	            result = rMessage.arg(mArgs.at(0), mArgs.at(1));
	            break;
	        case 3:
	            result = rMessage.arg(mArgs.at(0), mArgs.at(1), mArgs.at(2));
	            break;
	        case 4:
	            result = rMessage.arg(mArgs.at(0), mArgs.at(1), mArgs.at(2), mArgs.at(3));
	            break;
	        case 5:
	            result = rMessage.arg(mArgs.at(0), mArgs.at(1), mArgs.at(2), mArgs.at(3), mArgs.at(4));
	            break;
	        case 6:
	            result = rMessage.arg(mArgs.at(0), mArgs.at(1), mArgs.at(2), mArgs.at(3), mArgs.at(4), mArgs.at(5));
	            break;
	        case 7:
	            result = rMessage.arg(mArgs.at(0), mArgs.at(1), mArgs.at(2), mArgs.at(3), mArgs.at(4), mArgs.at(5), mArgs.at(6));
	            break;
	        case 8:
	            result = rMessage.arg(mArgs.at(0), mArgs.at(1), mArgs.at(2), mArgs.at(3), mArgs.at(4), mArgs.at(5), mArgs.at(6), mArgs.at(7));
	            break;
	        default:
	            result = rMessage.arg(mArgs.at(0), mArgs.at(1), mArgs.at(2), mArgs.at(3), mArgs.at(4), mArgs.at(5), mArgs.at(6), mArgs.at(7), mArgs.at(8));
	            break;
	    }
	
	    if (mArgs.count() > 9)
	    {
	        int i = 9;
	        while(i < mArgs.count())
	        {
	            result = result.arg(mArgs.at(i));
	            i++;
	        }
	    }
	    */
	    
	    result = rMessage;
	    QVariant arg;
	    Q_FOREACH(arg, mArgs)
	        result = result.arg(arg.toString());
	    return result;
	}
开发者ID:wilbert2000,项目名称:wzplayer,代码行数:61,代码来源:logerror.cpp


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