本文整理汇总了C++中QMap::unite方法的典型用法代码示例。如果您正苦于以下问题:C++ QMap::unite方法的具体用法?C++ QMap::unite怎么用?C++ QMap::unite使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMap
的用法示例。
在下文中一共展示了QMap::unite方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadEffectNamesGL
void MainDialog::loadEffectNamesGL()
{
m_effectsComboBox->clear();
QStringList effects;
QMap<QString, QString> effectNames;
QMap<QString, QString>::Iterator it;
// Load slideshowgl effects
effectNames = SlideShowGL::effectNamesI18N();
// Add Ken Burns effect
effectNames.unite(SlideShowKB::effectNamesI18N());
for (it = effectNames.begin(); it != effectNames.end(); ++it)
{
effects.append(it.value());
}
// Update GUI
effects.sort();
m_effectsComboBox->insertItems(0, effects);
for (int i = 0; i < m_effectsComboBox->count(); ++i)
{
if (effectNames[m_sharedData->effectNameGL] == m_effectsComboBox->itemText(i))
{
m_effectsComboBox->setCurrentIndex(i);
break;
}
}
}
示例2: buildAuthHeader
QString OAuthPrivate::buildAuthHeader(const QString & method, const QString & url, const Params & data, const QString & verifier)
{
QMap<QString, QString> params;
params.insert("oauth_consumer_key", consumerKey.toAscii());
params.insert("oauth_nonce", Helper::identifier(42));
params.insert("oauth_signature_method", "HMAC-SHA1");
params.insert("oauth_timestamp", QString("%1").arg(Helper::timestamp()));
params.insert("oauth_version", "1.0");
if(!verifier.isEmpty())
params.insert("oauth_verifier", verifier);
if(!oauthToken.isEmpty())
params.insert("oauth_token", oauthToken.toAscii());
params.unite(data);
QString authStr;
Params::const_iterator i = params.constBegin();
params.insert("oauth_signature", signature(signingKey(consumerSecret, oauthTokenSecret), baseString(method, url, paramsString(params))));
while (i != params.constEnd()){
authStr += QUrl::toPercentEncoding(i.key()) + "=\"" + QUrl::toPercentEncoding(i.value()) + "\", ";
++i;
}
return authStr.mid(0, authStr.length() - 2);
}
示例3: timerEvent
void SkyNet::timerEvent(QTimerEvent *e)
{
if (self_aware)
{
if (write_mutex.tryLock(10))
{
QMap<QByteArray, QList<QString> > queues = msgqueues;
queues.unite(sndfilequeues);
QList<QByteArray> c2c_peer_ids = queues.uniqueKeys();
c2c_peer_ids = filter_existing_chans(c2c_peer_ids);
for (int i = 0; i < c2c_peer_ids.size(); i++)
{
int ret;
struct PICA_chaninfo *chan = NULL;
ret = PICA_create_channel(nodelink, (const unsigned char*)c2c_peer_ids[i].constData(), &chan);
qDebug()<<"restoring channel to "<<c2c_peer_ids[i]<<" ret ="<<ret<<" in timer event\n";
}
write_mutex.unlock();
}
}
else
{
killTimer(e->timerId());
Accounts::AccountRecord acc = this->CurrentAccount();
Join(acc);
}
}
示例4: getGSDefaultExeName
QString getGSDefaultExeName(void)
{
QString gsName("gs");
#if defined _WIN32
// Set gsName to its default value
gsName = "gswin32c.exe";
QMap<int, QString> gplGS = getGSExePaths("SOFTWARE\\GPL Ghostscript");
QMap<int, QString> afplGS = getGSExePaths("SOFTWARE\\AFPL Ghostscript");
QMap<int, QString> gsVersions = gplGS.unite(afplGS);
if (gsVersions.isEmpty())
return gsName;
int currentVer = 0;
QString gsPath;
QMap<int, QString>::ConstIterator it, itEnd = gsVersions.constEnd();
for (it = gsVersions.constBegin(); it != itEnd; ++it)
{
int version = it.key();
if (version > currentVer)
{
gsPath = it.value();
QFileInfo fInfo(gsPath);
if (fInfo.exists())
{
gsName = gsPath;
currentVer = version;
}
}
}
#endif
#if defined Q_OS_MAC
QStringList gsPaths;
gsPaths << "/usr/bin/gs" << "/usr/local/bin/gs" << "/opt/local/bin/gs" << "/sw/bin/gs";
for (int i = 0; i < gsPaths.size(); ++i)
{
QFileInfo fInfo(gsPaths.at(i));
if (fInfo.exists())
{
gsName = gsPaths.at(i);
break;
}
}
#endif
return gsName;
}
示例5:
//----------------------------------------------------------------------------
QMap<QString, QVariant> ctkDICOMServerNodeWidget::serverNodeParameters(const QString &node)const
{
Q_D(const ctkDICOMServerNodeWidget);
QMap<QString, QVariant> parameters;
const int count = d->NodeTable->rowCount();
for (int row = 0; row < count; row++)
{
if ( d->NodeTable->item(row,0)->text() == node )
{
// TBD: not sure what it means to merge parameters
parameters.unite(this->serverNodeParameters(row));
}
}
return parameters;
}
示例6: addIdentityAttributes
void RecognitionDatabase::addIdentityAttributes(int id, const QMap<QString, QString>& attributes)
{
if (!d || !d->dbAvailable)
{
return;
}
QMutexLocker lock(&d->mutex);
QHash<int, Identity>::iterator it = d->identityCache.find(id);
if (it != d->identityCache.end())
{
QMap<QString, QString> map = it->attributesMap();
map.unite(attributes);
it->setAttributesMap(map);
DatabaseFaceAccess(d->db).db()->updateIdentity(*it);
}
}
示例7: nodethread_connected
void SkyNet::nodethread_connected(QString addr, quint16 port, NodeThread *thread)
{
if (self_aware)
{
emit BecameSelfAware();
//restore old peer connections, if any
QList<QByteArray> c2c_peer_ids;
//load undelivered messages from history
if (msgqueues.isEmpty())
{
History h(config_dbname, Accounts::GetCurrentAccount().id);
msgqueues = h.GetUndeliveredMessages();
}
//load file transfers to be completed
// sndfilequeues = ...
QMap<QByteArray, QList<QString> > queues = msgqueues;
queues.unite(sndfilequeues);
c2c_peer_ids = queues.uniqueKeys();
for (int i = 0; i < c2c_peer_ids.size(); i++)
{
int ret;
write_mutex.lock();
struct PICA_chaninfo *chan = NULL;
ret = PICA_create_channel(nodelink, (const unsigned char*)c2c_peer_ids[i].constData(), &chan);
qDebug()<<"restoring channel to "<<c2c_peer_ids[i]<<" ret ="<<ret<<"\n";
write_mutex.unlock();
}
//start timer
timer_id = startTimer(10000);
}
}
示例8: identifyVectorLayer
bool QgsMapToolIdentify::identifyVectorLayer( QList<IdentifyResult> *results, QgsVectorLayer *layer, const QgsPoint& point )
{
if ( !layer || !layer->hasGeometryType() )
return false;
if ( layer->hasScaleBasedVisibility() &&
( layer->minimumScale() > mCanvas->mapSettings().scale() ||
layer->maximumScale() <= mCanvas->mapSettings().scale() ) )
{
QgsDebugMsg( "Out of scale limits" );
return false;
}
QApplication::setOverrideCursor( Qt::WaitCursor );
QMap< QString, QString > commonDerivedAttributes;
commonDerivedAttributes.insert( tr( "(clicked coordinate)" ), point.toString() );
int featureCount = 0;
QgsFeatureList featureList;
// toLayerCoordinates will throw an exception for an 'invalid' point.
// For example, if you project a world map onto a globe using EPSG 2163
// and then click somewhere off the globe, an exception will be thrown.
try
{
// create the search rectangle
double searchRadius = searchRadiusMU( mCanvas );
QgsRectangle r;
r.setXMinimum( point.x() - searchRadius );
r.setXMaximum( point.x() + searchRadius );
r.setYMinimum( point.y() - searchRadius );
r.setYMaximum( point.y() + searchRadius );
r = toLayerCoordinates( layer, r );
QgsFeatureIterator fit = layer->getFeatures( QgsFeatureRequest().setFilterRect( r ).setFlags( QgsFeatureRequest::ExactIntersect ) );
QgsFeature f;
while ( fit.nextFeature( f ) )
featureList << QgsFeature( f );
}
catch ( QgsCsException & cse )
{
Q_UNUSED( cse );
// catch exception for 'invalid' point and proceed with no features found
QgsDebugMsg( QString( "Caught CRS exception %1" ).arg( cse.what() ) );
}
QgsFeatureList::iterator f_it = featureList.begin();
bool filter = false;
QgsRenderContext context( QgsRenderContext::fromMapSettings( mCanvas->mapSettings() ) );
context.expressionContext() << QgsExpressionContextUtils::layerScope( layer );
QgsFeatureRendererV2* renderer = layer->rendererV2();
if ( renderer && renderer->capabilities() & QgsFeatureRendererV2::ScaleDependent )
{
// setup scale for scale dependent visibility (rule based)
renderer->startRender( context, layer->fields() );
filter = renderer->capabilities() & QgsFeatureRendererV2::Filter;
}
for ( ; f_it != featureList.end(); ++f_it )
{
QMap< QString, QString > derivedAttributes = commonDerivedAttributes;
QgsFeatureId fid = f_it->id();
context.expressionContext().setFeature( *f_it );
if ( filter && !renderer->willRenderFeature( *f_it, context ) )
continue;
featureCount++;
derivedAttributes.unite( featureDerivedAttributes( &( *f_it ), layer, toLayerCoordinates( layer, point ) ) );
derivedAttributes.insert( tr( "feature id" ), fid < 0 ? tr( "new feature" ) : FID_TO_STRING( fid ) );
results->append( IdentifyResult( qobject_cast<QgsMapLayer *>( layer ), *f_it, derivedAttributes ) );
}
if ( renderer && renderer->capabilities() & QgsFeatureRendererV2::ScaleDependent )
{
renderer->stopRender( context );
}
QgsDebugMsg( "Feature count on identify: " + QString::number( featureCount ) );
QApplication::restoreOverrideCursor();
return featureCount > 0;
}
示例9: identifyRasterLayer
//.........这里部分代码省略.........
// the return value should be interpreted as QMetaType::Type"
if ( static_cast<QMetaType::Type>( value.type() ) == QMetaType::Float )
{
valueString = QgsRasterBlock::printValue( value.toFloat() );
}
else
{
valueString = QgsRasterBlock::printValue( value.toDouble() );
}
}
attributes.insert( dprovider->generateBandName( it.key() ), valueString );
}
QString label = layer->name();
results->append( IdentifyResult( qobject_cast<QgsMapLayer *>( layer ), label, attributes, derivedAttributes ) );
}
else if ( format == QgsRaster::IdentifyFormatFeature )
{
for ( auto it = values.constBegin(); it != values.constEnd(); ++it )
{
QVariant value = it.value();
if ( value.type() == QVariant::Bool && !value.toBool() )
{
// sublayer not visible or not queryable
continue;
}
if ( value.type() == QVariant::String )
{
// error
// TODO: better error reporting
QString label = layer->subLayers().value( it.key() );
attributes.clear();
attributes.insert( tr( "Error" ), value.toString() );
results->append( IdentifyResult( qobject_cast<QgsMapLayer *>( layer ), label, attributes, derivedAttributes ) );
continue;
}
// list of feature stores for a single sublayer
const QgsFeatureStoreList featureStoreList = it.value().value<QgsFeatureStoreList>();
for ( const QgsFeatureStore &featureStore : featureStoreList )
{
const QgsFeatureList storeFeatures = featureStore.features();
for ( QgsFeature feature : storeFeatures )
{
attributes.clear();
// WMS sublayer and feature type, a sublayer may contain multiple feature types.
// Sublayer name may be the same as layer name and feature type name
// may be the same as sublayer. We try to avoid duplicities in label.
QString sublayer = featureStore.params().value( QStringLiteral( "sublayer" ) ).toString();
QString featureType = featureStore.params().value( QStringLiteral( "featureType" ) ).toString();
// Strip UMN MapServer '_feature'
featureType.remove( QStringLiteral( "_feature" ) );
QStringList labels;
if ( sublayer.compare( layer->name(), Qt::CaseInsensitive ) != 0 )
{
labels << sublayer;
}
if ( featureType.compare( sublayer, Qt::CaseInsensitive ) != 0 || labels.isEmpty() )
{
labels << featureType;
}
QMap< QString, QString > derAttributes = derivedAttributes;
derAttributes.unite( featureDerivedAttributes( &feature, layer ) );
IdentifyResult identifyResult( qobject_cast<QgsMapLayer *>( layer ), labels.join( QStringLiteral( " / " ) ), featureStore.fields(), feature, derAttributes );
identifyResult.mParams.insert( QStringLiteral( "getFeatureInfoUrl" ), featureStore.params().value( QStringLiteral( "getFeatureInfoUrl" ) ) );
results->append( identifyResult );
}
}
}
}
else // text or html
{
QgsDebugMsg( QString( "%1 HTML or text values" ).arg( values.size() ) );
for ( auto it = values.constBegin(); it != values.constEnd(); ++it )
{
QString value = it.value().toString();
attributes.clear();
attributes.insert( QLatin1String( "" ), value );
QString label = layer->subLayers().value( it.key() );
results->append( IdentifyResult( qobject_cast<QgsMapLayer *>( layer ), label, attributes, derivedAttributes ) );
}
}
}
else
{
attributes.clear();
QString value = identifyResult.error().message( QgsErrorMessage::Text );
attributes.insert( tr( "Error" ), value );
QString label = tr( "Identify error" );
results->append( IdentifyResult( qobject_cast<QgsMapLayer *>( layer ), label, attributes, derivedAttributes ) );
}
return true;
}
示例10: identifyVectorLayer
bool QgsMapToolIdentify::identifyVectorLayer( QList<IdentifyResult> *results, QgsVectorLayer *layer, QgsPoint point )
{
if ( !layer )
return false;
if ( layer->hasScaleBasedVisibility() &&
( layer->minimumScale() > mCanvas->mapRenderer()->scale() ||
layer->maximumScale() <= mCanvas->mapRenderer()->scale() ) )
{
QgsDebugMsg( "Out of scale limits" );
return false;
}
QMap< QString, QString > derivedAttributes;
derivedAttributes.insert( tr( "(clicked coordinate)" ), point.toString() );
// load identify radius from settings
QSettings settings;
double identifyValue = settings.value( "/Map/identifyRadius", QGis::DEFAULT_IDENTIFY_RADIUS ).toDouble();
if ( identifyValue <= 0.0 )
identifyValue = QGis::DEFAULT_IDENTIFY_RADIUS;
int featureCount = 0;
QgsFeatureList featureList;
// toLayerCoordinates will throw an exception for an 'invalid' point.
// For example, if you project a world map onto a globe using EPSG 2163
// and then click somewhere off the globe, an exception will be thrown.
try
{
// create the search rectangle
double searchRadius = mCanvas->extent().width() * ( identifyValue / 100.0 );
QgsRectangle r;
r.setXMinimum( point.x() - searchRadius );
r.setXMaximum( point.x() + searchRadius );
r.setYMinimum( point.y() - searchRadius );
r.setYMaximum( point.y() + searchRadius );
r = toLayerCoordinates( layer, r );
QgsFeatureIterator fit = layer->getFeatures( QgsFeatureRequest().setFilterRect( r ).setFlags( QgsFeatureRequest::ExactIntersect ) );
QgsFeature f;
while ( fit.nextFeature( f ) )
featureList << QgsFeature( f );
}
catch ( QgsCsException & cse )
{
Q_UNUSED( cse );
// catch exception for 'invalid' point and proceed with no features found
QgsDebugMsg( QString( "Caught CRS exception %1" ).arg( cse.what() ) );
}
QgsFeatureList::iterator f_it = featureList.begin();
bool filter = false;
QgsFeatureRendererV2* renderer = layer->rendererV2();
if ( renderer && renderer->capabilities() & QgsFeatureRendererV2::ScaleDependent )
{
// setup scale for scale dependent visibility (rule based)
renderer->startRender( *( mCanvas->mapRenderer()->rendererContext() ), layer );
filter = renderer->capabilities() & QgsFeatureRendererV2::Filter;
}
for ( ; f_it != featureList.end(); ++f_it )
{
QgsFeatureId fid = f_it->id();
if ( filter && !renderer->willRenderFeature( *f_it ) )
continue;
featureCount++;
derivedAttributes.unite( featureDerivedAttributes( &( *f_it ), layer ) );
derivedAttributes.insert( tr( "feature id" ), fid < 0 ? tr( "new feature" ) : FID_TO_STRING( fid ) );
results->append( IdentifyResult( qobject_cast<QgsMapLayer *>( layer ), *f_it, derivedAttributes ) );
}
if ( renderer && renderer->capabilities() & QgsFeatureRendererV2::ScaleDependent )
{
renderer->stopRender( *( mCanvas->mapRenderer()->rendererContext() ) );
}
QgsDebugMsg( "Feature count on identify: " + QString::number( featureCount ) );
return featureCount > 0;
}
示例11: getColumnTypeMap
}
}
Q_ASSERT(false);
return false;
}
//Retrieve field types
QMap<QString,QVariant::Type> columnTypeMap = getColumnTypeMap();
QMap<QString,QVariant::Type> datumTypeMap = _exampleDatum->getFieldTypeMap();
//TODO: Simplify type names
//Validate types
QMap<QString,QVariant::Type> typeMap = columnTypeMap.unite(datumTypeMap);
QList<QString> fieldNames = typeMap.uniqueKeys();
//Verify we have two entries per fieldName
for(int i=0; i<fieldNames.length(); i++){
QString name = fieldNames[i];
//Field present in database table?
if(!columnTypeMap.contains(name)){
DEBUG_MSG() << "Field[" << name << "] not present in existing table["
<< _tableName << "]";
success = false;
break;
}