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


C++ QSet::insert方法代码示例

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


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

示例1: isComplexRichText

/*!
  Returns true if \a text contains any HTML tags, attributes or CSS properties which are unrelated
   to text, fonts or text layout. Otherwise the function returns false. If the return value is
  false, \a text is considered to be easily representable in the scenegraph. If it returns true,
  then the text should be prerendered into a pixmap before it's displayed on screen.
*/
bool QSGTextNode::isComplexRichText(QTextDocument *doc)
{
    if (doc == 0)
        return false;

    static QSet<QString> supportedTags;
    if (supportedTags.isEmpty()) {
        supportedTags.insert(QLatin1String("i"));
        supportedTags.insert(QLatin1String("b"));
        supportedTags.insert(QLatin1String("u"));
        supportedTags.insert(QLatin1String("div"));
        supportedTags.insert(QLatin1String("big"));
        supportedTags.insert(QLatin1String("blockquote"));
        supportedTags.insert(QLatin1String("body"));
        supportedTags.insert(QLatin1String("br"));
        supportedTags.insert(QLatin1String("center"));
        supportedTags.insert(QLatin1String("cite"));
        supportedTags.insert(QLatin1String("code"));
        supportedTags.insert(QLatin1String("tt"));
        supportedTags.insert(QLatin1String("dd"));
        supportedTags.insert(QLatin1String("dfn"));
        supportedTags.insert(QLatin1String("em"));
        supportedTags.insert(QLatin1String("font"));
        supportedTags.insert(QLatin1String("h1"));
        supportedTags.insert(QLatin1String("h2"));
        supportedTags.insert(QLatin1String("h3"));
        supportedTags.insert(QLatin1String("h4"));
        supportedTags.insert(QLatin1String("h5"));
        supportedTags.insert(QLatin1String("h6"));
        supportedTags.insert(QLatin1String("head"));
        supportedTags.insert(QLatin1String("html"));
        supportedTags.insert(QLatin1String("meta"));
        supportedTags.insert(QLatin1String("nobr"));
        supportedTags.insert(QLatin1String("p"));
        supportedTags.insert(QLatin1String("pre"));
        supportedTags.insert(QLatin1String("qt"));
        supportedTags.insert(QLatin1String("s"));
        supportedTags.insert(QLatin1String("samp"));
        supportedTags.insert(QLatin1String("small"));
        supportedTags.insert(QLatin1String("span"));
        supportedTags.insert(QLatin1String("strong"));
        supportedTags.insert(QLatin1String("sub"));
        supportedTags.insert(QLatin1String("sup"));
        supportedTags.insert(QLatin1String("title"));
        supportedTags.insert(QLatin1String("var"));
        supportedTags.insert(QLatin1String("style"));
    }

    static QSet<QCss::Property> supportedCssProperties;
    if (supportedCssProperties.isEmpty()) {
        supportedCssProperties.insert(QCss::Color);
        supportedCssProperties.insert(QCss::Float);
        supportedCssProperties.insert(QCss::Font);
        supportedCssProperties.insert(QCss::FontFamily);
        supportedCssProperties.insert(QCss::FontSize);
        supportedCssProperties.insert(QCss::FontStyle);
        supportedCssProperties.insert(QCss::FontWeight);
        supportedCssProperties.insert(QCss::Margin);
        supportedCssProperties.insert(QCss::MarginBottom);
        supportedCssProperties.insert(QCss::MarginLeft);
        supportedCssProperties.insert(QCss::MarginRight);
        supportedCssProperties.insert(QCss::MarginTop);
        supportedCssProperties.insert(QCss::TextDecoration);
        supportedCssProperties.insert(QCss::TextIndent);
        supportedCssProperties.insert(QCss::TextUnderlineStyle);
        supportedCssProperties.insert(QCss::VerticalAlignment);
        supportedCssProperties.insert(QCss::Whitespace);
        supportedCssProperties.insert(QCss::Padding);
        supportedCssProperties.insert(QCss::PaddingLeft);
        supportedCssProperties.insert(QCss::PaddingRight);
        supportedCssProperties.insert(QCss::PaddingTop);
        supportedCssProperties.insert(QCss::PaddingBottom);
        supportedCssProperties.insert(QCss::PageBreakBefore);
        supportedCssProperties.insert(QCss::PageBreakAfter);
        supportedCssProperties.insert(QCss::Width);
        supportedCssProperties.insert(QCss::Height);
        supportedCssProperties.insert(QCss::MinimumWidth);
        supportedCssProperties.insert(QCss::MinimumHeight);
        supportedCssProperties.insert(QCss::MaximumWidth);
        supportedCssProperties.insert(QCss::MaximumHeight);
        supportedCssProperties.insert(QCss::Left);
        supportedCssProperties.insert(QCss::Right);
        supportedCssProperties.insert(QCss::Top);
        supportedCssProperties.insert(QCss::Bottom);
        supportedCssProperties.insert(QCss::Position);
        supportedCssProperties.insert(QCss::TextAlignment);
        supportedCssProperties.insert(QCss::FontVariant);
    }

    QXmlStreamReader reader(doc->toHtml("utf-8"));
    while (!reader.atEnd()) {
        reader.readNext();

        if (reader.isStartElement()) {
//.........这里部分代码省略.........
开发者ID:yinyunqiao,项目名称:qtdeclarative,代码行数:101,代码来源:qsgtextnode.cpp

示例2: sublayersOfEmbeddedGroup

QSet<QString> QgsServerProjectParser::findRestrictedLayers() const
{
  QSet<QString> restrictedLayerSet;

  if ( !mXMLDoc )
  {
    return restrictedLayerSet;
  }

  //names of unpublished layers / groups
  QDomElement propertiesElem = mXMLDoc->documentElement().firstChildElement( "properties" );
  if ( !propertiesElem.isNull() )
  {
    QDomElement wmsLayerRestrictionElem = propertiesElem.firstChildElement( "WMSRestrictedLayers" );
    if ( !wmsLayerRestrictionElem.isNull() )
    {
      QStringList restrictedLayersAndGroups;
      QDomNodeList wmsLayerRestrictionValues = wmsLayerRestrictionElem.elementsByTagName( "value" );
      for ( int i = 0; i < wmsLayerRestrictionValues.size(); ++i )
      {
        restrictedLayerSet.insert( wmsLayerRestrictionValues.at( i ).toElement().text() );
      }
    }
  }

  //get legend dom element
  if ( restrictedLayerSet.size() < 1 || !mXMLDoc )
  {
    return restrictedLayerSet;
  }

  QDomElement legendElem = mXMLDoc->documentElement().firstChildElement( "legend" );
  if ( legendElem.isNull() )
  {
    return restrictedLayerSet;
  }

  //go through all legend groups and insert names of subgroups / sublayers if there is a match
  QDomNodeList legendGroupList = legendElem.elementsByTagName( "legendgroup" );
  for ( int i = 0; i < legendGroupList.size(); ++i )
  {
    //get name
    QDomElement groupElem = legendGroupList.at( i ).toElement();
    QString groupName = groupElem.attribute( "name" );
    if ( restrictedLayerSet.contains( groupName ) ) //match: add names of subgroups and sublayers to set
    {
      //embedded group? -> also get names of subgroups and sublayers from embedded projects
      if ( groupElem.attribute( "embedded" ) == "1" )
      {
        sublayersOfEmbeddedGroup( convertToAbsolutePath( groupElem.attribute( "project" ) ), groupName, restrictedLayerSet );
      }
      else //local group
      {
        QDomNodeList subgroupList = groupElem.elementsByTagName( "legendgroup" );
        for ( int j = 0; j < subgroupList.size(); ++j )
        {
          restrictedLayerSet.insert( subgroupList.at( j ).toElement().attribute( "name" ) );
        }
        QDomNodeList sublayerList = groupElem.elementsByTagName( "legendlayer" );
        for ( int k = 0; k < sublayerList.size(); ++k )
        {
          restrictedLayerSet.insert( sublayerList.at( k ).toElement().attribute( "name" ) );
        }
      }
    }
  }
  return restrictedLayerSet;
}
开发者ID:dgstl,项目名称:QGIS,代码行数:68,代码来源:qgsserverprojectparser.cpp

示例3: mergeContiguous

// This is a lighter weight merge since we know at this stage everything stays
// within its own task and the partitions that must be merged are contiguous
// Therefore we only need to merge the groups and remove the previous ones
// from the partition list -- so we create the new ones and point the old
// ones toward it so we can make a single pass to remove those that point to
// a new partition.
void OTFConverter::mergeContiguous(QList<QList<Partition * > *> * groups)
{
    // Create the new partitions and store them in new parts
    QList<Partition *> * newparts = new QList<Partition *>();

    for (QList<QList<Partition *> *>::Iterator group = groups->begin();
         group != groups->end(); ++group)
    {
        Partition * p = new Partition();
        for (QList<Partition *>::Iterator part = (*group)->begin();
             part != (*group)->end(); ++part)
        {
            (*part)->new_partition = p;
            for (QMap<int, QList<CommEvent *> *>::Iterator proc
                 = (*part)->events->begin();
                 proc != (*part)->events->end(); ++proc)
            {
                for (QList<CommEvent *>::Iterator evt
                     = (proc.value())->begin();
                     evt != (proc.value())->end(); ++evt)
                {
                    (*evt)->partition = p;
                    p->addEvent(*evt);
                }
            }
        }
        p->new_partition = p;
        //newparts->append(p);
    }

    // Add in the partitions in order -- those that didn't get changed
    // just added in normally. Add the first instance of the others so
    // that order can be maintained and delete the ones that represent
    // changes.
    QSet<Partition *> sortSet = QSet<Partition *>();
    QList<Partition *> toDelete = QList<Partition *>();
    for (QList<Partition *>::Iterator part = trace->partitions->begin();
         part != trace->partitions->end(); ++part)
    {
        if ((*part)->new_partition == *part)
        {
            newparts->append(*part);
        }
        else
        {
            if (!sortSet.contains((*part)->new_partition))
            {
                newparts->append((*part)->new_partition);
                sortSet.insert((*part)->new_partition);
            }
            toDelete.append(*part);
        }
    }

    // Delete old parts
    for (QList<Partition *>::Iterator oldpart = toDelete.begin();
         oldpart != toDelete.end(); ++oldpart)
    {
        delete *oldpart;
        *oldpart = NULL;
    }

    // Add the new partitions to trace->partitions
    delete trace->partitions;
    trace->partitions = newparts;
}
开发者ID:bertwesarg,项目名称:ravel,代码行数:72,代码来源:otfconverter.cpp

示例4: runTagsTest

  void runTagsTest()
  {
    ImplicitTagRulesSqliteReader reader;
    reader.setAddTopTagOnly(false);
    reader.setAllowWordsInvolvedInMultipleRules(false);
    reader.open("test-files/io/ImplicitTagRulesSqliteReaderTest/rules.sqlite");

    QSet<QString> words;
    QSet<QString> wordsInvolved;
    bool wordsInvolvedInMultipleRules = false;
    Tags tags;

    words.insert("Mosque");
    tags = reader.getImplicitTags(words, wordsInvolved, wordsInvolvedInMultipleRules);
    CPPUNIT_ASSERT_EQUAL(2, tags.size());
    CPPUNIT_ASSERT(tags["amenity"] == "place_of_worship");
    CPPUNIT_ASSERT(tags["leisure"] == "park");
    CPPUNIT_ASSERT_EQUAL(1, wordsInvolved.size());
    CPPUNIT_ASSERT(wordsInvolved.contains("Mosque"));
    CPPUNIT_ASSERT(!wordsInvolvedInMultipleRules);
    words.clear();

    words.insert("MOSQUE");
    tags = reader.getImplicitTags(words, wordsInvolved, wordsInvolvedInMultipleRules);
    CPPUNIT_ASSERT_EQUAL(2, tags.size());
    CPPUNIT_ASSERT(tags["amenity"] == "place_of_worship");
    CPPUNIT_ASSERT(tags["leisure"] == "park");
    CPPUNIT_ASSERT_EQUAL(1, wordsInvolved.size());
    CPPUNIT_ASSERT(wordsInvolved.contains("Mosque"));
    CPPUNIT_ASSERT(!wordsInvolvedInMultipleRules);
    words.clear();

    words.insert("mosque");
    tags = reader.getImplicitTags(words, wordsInvolved, wordsInvolvedInMultipleRules);
    CPPUNIT_ASSERT_EQUAL(2, tags.size());
    CPPUNIT_ASSERT(tags["amenity"] == "place_of_worship");
    CPPUNIT_ASSERT(tags["leisure"] == "park");
    CPPUNIT_ASSERT_EQUAL(1, wordsInvolved.size());
    CPPUNIT_ASSERT(wordsInvolved.contains("Mosque"));
    CPPUNIT_ASSERT(!wordsInvolvedInMultipleRules);
    words.clear();

    words.insert("mosque2");
    tags = reader.getImplicitTags(words, wordsInvolved, wordsInvolvedInMultipleRules);
    CPPUNIT_ASSERT_EQUAL(0, tags.size());
    CPPUNIT_ASSERT_EQUAL(0, wordsInvolved.size());
    CPPUNIT_ASSERT(!wordsInvolvedInMultipleRules);
    words.clear();

    words.insert("mosque 3");
    tags = reader.getImplicitTags(words, wordsInvolved, wordsInvolvedInMultipleRules);
    CPPUNIT_ASSERT_EQUAL(0, tags.size());
    CPPUNIT_ASSERT_EQUAL(0, wordsInvolved.size());
    CPPUNIT_ASSERT(!wordsInvolvedInMultipleRules);
    words.clear();

    words.insert("Eid Prayer Ground");
    tags = reader.getImplicitTags(words, wordsInvolved, wordsInvolvedInMultipleRules);
    CPPUNIT_ASSERT_EQUAL(1, tags.size());
    CPPUNIT_ASSERT(tags["amenity"] == "place_of_worship");
    CPPUNIT_ASSERT_EQUAL(1, wordsInvolved.size());
    CPPUNIT_ASSERT(wordsInvolved.contains("Eid Prayer Ground"));
    CPPUNIT_ASSERT(!wordsInvolvedInMultipleRules);
    words.clear();

    words.insert("Mustashfa");
    tags = reader.getImplicitTags(words, wordsInvolved, wordsInvolvedInMultipleRules);
    CPPUNIT_ASSERT_EQUAL(1, tags.size());
    CPPUNIT_ASSERT(tags["amenity"] == "hospital");
    CPPUNIT_ASSERT_EQUAL(1, wordsInvolved.size());
    CPPUNIT_ASSERT(wordsInvolved.contains("Mustashfa"));
    CPPUNIT_ASSERT(!wordsInvolvedInMultipleRules);
    words.clear();

    words.insert("alwhdt");
    tags = reader.getImplicitTags(words, wordsInvolved, wordsInvolvedInMultipleRules);
    CPPUNIT_ASSERT_EQUAL(1, tags.size());
    CPPUNIT_ASSERT(tags["amenity"] == "clinic");
    CPPUNIT_ASSERT_EQUAL(1, wordsInvolved.size());
    CPPUNIT_ASSERT(wordsInvolved.contains("alwhdt"));
    CPPUNIT_ASSERT(!wordsInvolvedInMultipleRules);
    words.clear();

    words.insert("Mustashfa alwhdt");
    tags = reader.getImplicitTags(words, wordsInvolved, wordsInvolvedInMultipleRules);
    CPPUNIT_ASSERT_EQUAL(1, tags.size());
    CPPUNIT_ASSERT(tags["amenity"] == "hospital");
    CPPUNIT_ASSERT_EQUAL(1, wordsInvolved.size());
    CPPUNIT_ASSERT(wordsInvolved.contains("Mustashfa alwhdt"));
    CPPUNIT_ASSERT(!wordsInvolvedInMultipleRules);
    words.clear();

    //the AddImplicitlyDerivedTagsPoiVisitor won't pass a word phrase and its constituent
    //tokens in the same tags request, but if it did, then it should identify the words as
    //belonging to multiple rules
    words.insert("Mustashfa");
    words.insert("alwhdt");
    words.insert("Mustashfa alwhdt");
    tags = reader.getImplicitTags(words, wordsInvolved, wordsInvolvedInMultipleRules);
    CPPUNIT_ASSERT_EQUAL(0, tags.size());
//.........这里部分代码省略.........
开发者ID:ngageoint,项目名称:hootenanny,代码行数:101,代码来源:ImplicitTagRulesSqliteReaderTest.cpp

示例5: canonicalized

/*!
    \internal

    Returns the canonicalized form of \a path (i.e., with all symlinks
    resolved, and all redundant path elements removed.
*/
QString QFSFileEnginePrivate::canonicalized(const QString &path)
{
    if (path.isEmpty())
        return path;

    // FIXME let's see if this stuff works, then we might be able to remove some of the other code.
#if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN)
    if (path.size() == 1 && path.at(0) == QLatin1Char('/'))
        return path;
#endif
#if defined(Q_OS_UNIX)
    // ... but Linux with uClibc does not have it
#if !defined(__UCLIBC__)
    char *ret = 0;
#if defined(Q_OS_MAC)
    // Mac OS X 10.5.x doesn't support the realpath(X,0) extension we use here.
    if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_6) {
        ret = realpath(path.toLocal8Bit().constData(), (char*)0);
    } else {
        // on 10.5 we can use FSRef to resolve the file path.
        FSRef fsref;
        if (FSPathMakeRef((const UInt8 *)QDir::cleanPath(path).toUtf8().data(), &fsref, 0) == noErr) {
            CFURLRef urlref = CFURLCreateFromFSRef(NULL, &fsref);
            CFStringRef canonicalPath = CFURLCopyFileSystemPath(urlref, kCFURLPOSIXPathStyle);
            QString ret = QCFString::toQString(canonicalPath);
            CFRelease(canonicalPath);
            CFRelease(urlref);
            return ret;
        }
    }
#else
    ret = realpath(path.toLocal8Bit().constData(), (char*)0);
#endif
    if (ret) {
        QString canonicalPath = QDir::cleanPath(QString::fromLocal8Bit(ret));
        free(ret);
        return canonicalPath;
    }
#endif
#endif

    QFileInfo fi;
    const QChar slash(QLatin1Char('/'));
    QString tmpPath = path;
    int separatorPos = 0;
    QSet<QString> nonSymlinks;
    QSet<QString> known;

    known.insert(path);
    do {
#if defined(Q_OS_WIN) || defined(Q_OS_CYGWIN)
        // UNC, skip past the first two elements
        if (separatorPos == 0 && tmpPath.startsWith(QLatin1String("//")))
            separatorPos = tmpPath.indexOf(slash, 2);
        if (separatorPos != -1)
#endif
        separatorPos = tmpPath.indexOf(slash, separatorPos + 1);
        QString prefix = separatorPos == -1 ? tmpPath : tmpPath.left(separatorPos);
        if (
#ifdef Q_OS_SYMBIAN
            // Symbian doesn't support directory symlinks, so do not check for link unless we
            // are handling the last path element. This not only slightly improves performance,
            // but also saves us from lot of unnecessary platform security check failures
            // when dealing with files under *:/private directories.
            separatorPos == -1 &&
#endif
            !nonSymlinks.contains(prefix)) {
            fi.setFile(prefix);
            if (fi.isSymLink()) {
                QString target = fi.symLinkTarget();
                if (separatorPos != -1) {
                    if (fi.isDir() && !target.endsWith(slash))
                        target.append(slash);
                    target.append(tmpPath.mid(separatorPos));
                }
                tmpPath = QDir::cleanPath(target);
                separatorPos = 0;

                if (known.contains(tmpPath))
                    return QString();
                known.insert(tmpPath);
            } else {
                nonSymlinks.insert(prefix);
            }
        }
    } while (separatorPos != -1);

    return QDir::cleanPath(tmpPath);
}
开发者ID:chid,项目名称:CygwinLyx,代码行数:95,代码来源:qfsfileengine.cpp

示例6: gotStickerSet

void ApiWrap::gotStickerSet(uint64 setId, const MTPmessages_StickerSet &result) {
	_stickerSetRequests.remove(setId);
	
	if (result.type() != mtpc_messages_stickerSet) return;
	const MTPDmessages_stickerSet &d(result.c_messages_stickerSet());
	
	if (d.vset.type() != mtpc_stickerSet) return;
	const MTPDstickerSet &s(d.vset.c_stickerSet());

	StickerSets &sets(cRefStickerSets());
	StickerSets::iterator it = sets.find(setId);
	if (it == sets.cend()) return;

	it->access = s.vaccess_hash.v;
	it->hash = s.vhash.v;
	it->shortName = qs(s.vshort_name);
	QString title = qs(s.vtitle);
	if ((it->flags & MTPDstickerSet_flag_official) && !title.compare(qstr("Great Minds"), Qt::CaseInsensitive)) {
		title = lang(lng_stickers_default_set);
	}
	it->title = title;
	it->flags = s.vflags.v;

	const QVector<MTPDocument> &d_docs(d.vdocuments.c_vector().v);
	StickerSets::iterator custom = sets.find(CustomStickerSetId);

	QSet<DocumentData*> found;
	int32 wasCount = -1;
	for (int32 i = 0, l = d_docs.size(); i != l; ++i) {
		DocumentData *doc = App::feedDocument(d_docs.at(i));
		if (!doc || !doc->sticker()) continue;

		if (wasCount < 0) wasCount = it->stickers.size();
		if (it->stickers.indexOf(doc) < 0) {
			it->stickers.push_back(doc);
		} else {
			found.insert(doc);
		}

		if (custom != sets.cend()) {
			int32 index = custom->stickers.indexOf(doc);
			if (index >= 0) {
				custom->stickers.removeAt(index);
			}
		}
	}
	if (custom != sets.cend() && custom->stickers.isEmpty()) {
		sets.erase(custom);
		custom = sets.end();
	}

	bool writeRecent = false;
	RecentStickerPack &recent(cGetRecentStickers());

	if (wasCount < 0) { // no stickers received
		for (RecentStickerPack::iterator i = recent.begin(); i != recent.cend();) {
			if (it->stickers.indexOf(i->first) >= 0) {
				i = recent.erase(i);
				writeRecent = true;
			} else {
				++i;
			}
		}
		cRefStickerSetsOrder().removeOne(setId);
		sets.erase(it);
	} else {
		for (int32 j = 0, l = wasCount; j < l;) {
			if (found.contains(it->stickers.at(j))) {
				++j;
			} else {
				for (RecentStickerPack::iterator i = recent.begin(); i != recent.cend();) {
					if (it->stickers.at(j) == i->first) {
						i = recent.erase(i);
						writeRecent = true;
					} else {
						++i;
					}
				}
				it->stickers.removeAt(j);
				--l;
			}
		}
		if (it->stickers.isEmpty()) {
			cRefStickerSetsOrder().removeOne(setId);
			sets.erase(it);
		}
	}

	if (writeRecent) {
		Local::writeUserSettings();
	}

	Local::writeStickers();

	if (App::main()) emit App::main()->stickersUpdated();
}
开发者ID:noikiy,项目名称:tdesktop,代码行数:96,代码来源:apiwrap.cpp

示例7: defaultSource

/*!
  Returns a list with the default source in it.

  \sa defaultSource()
*/
QSet<QPimSource> QDependentEventsContext::sources() const
{
    QSet<QPimSource> list;
    list.insert(defaultSource());
    return list;
}
开发者ID:Camelek,项目名称:qtmoko,代码行数:11,代码来源:qdependentcontexts.cpp

示例8: begin

bool JQNetworkServer::begin()
{
    JQNETWORK_THISNULL_CHECK( "JQNetworkServer::begin", false );

    nodeMarkSummary_ = JQNetworkNodeMark::calculateNodeMarkSummary( serverSettings_->dutyMark );

    if ( globalServerThreadPool_ )
    {
        serverThreadPool_ = globalServerThreadPool_.toStrongRef();
    }
    else
    {
        serverThreadPool_ = QSharedPointer< JQNetworkThreadPool >( new JQNetworkThreadPool( serverSettings_->globalServerThreadCount ) );
        globalServerThreadPool_ = serverThreadPool_.toWeakRef();
    }

    if ( globalSocketThreadPool_ )
    {
        socketThreadPool_ = globalSocketThreadPool_.toStrongRef();
    }
    else
    {
        socketThreadPool_ = QSharedPointer< JQNetworkThreadPool >( new JQNetworkThreadPool( serverSettings_->globalSocketThreadCount ) );
        globalSocketThreadPool_ = socketThreadPool_.toWeakRef();
    }

    if ( globalCallbackThreadPool_ )
    {
        callbackThreadPool_ = globalCallbackThreadPool_.toStrongRef();
    }
    else
    {
        callbackThreadPool_ = QSharedPointer< JQNetworkThreadPool >( new JQNetworkThreadPool( serverSettings_->globalCallbackThreadCount ) );
        globalCallbackThreadPool_ = callbackThreadPool_.toWeakRef();
    }

    if ( !processors_.isEmpty() )
    {
        QSet< QThread * > receivedPossibleThreads;

        callbackThreadPool_->waitRunEach( [ &receivedPossibleThreads ]()
        {
            receivedPossibleThreads.insert( QThread::currentThread() );
        } );

        for ( const auto &processor: processors_ )
        {
            processor->setReceivedPossibleThreads( receivedPossibleThreads );
        }
    }

    bool listenSucceed = false;

    serverThreadPool_->waitRun(
                [
                    this,
                    &listenSucceed
                ]()
                {
                    this->tcpServer_ = QSharedPointer< QTcpServer >( new JQNetworkServerHelper( [ this ]( auto socketDescriptor )
                        { this->incomingConnection( socketDescriptor ); } ) );

                    listenSucceed = this->tcpServer_->listen(
                                this->serverSettings_->listenAddress,
                                this->serverSettings_->listenPort
                            );
                }
    );

    if ( !listenSucceed ) { return false; }

    socketThreadPool_->waitRunEach(
                [
                    this
                ]()
                {
                    JQNetworkConnectPoolSettingsSharedPointer connectPoolSettings( new JQNetworkConnectPoolSettings( *this->connectPoolSettings_ ) );
                    JQNetworkConnectSettingsSharedPointer connectSettings( new JQNetworkConnectSettings( *this->connectSettings_ ) );

                    connectPoolSettings->connectToHostErrorCallback     = bind( &JQNetworkServer::onConnectToHostError, this, _1, _2 );
                    connectPoolSettings->connectToHostTimeoutCallback   = bind( &JQNetworkServer::onConnectToHostTimeout, this, _1, _2 );
                    connectPoolSettings->connectToHostSucceedCallback   = bind( &JQNetworkServer::onConnectToHostSucceed, this, _1, _2 );
                    connectPoolSettings->remoteHostClosedCallback       = bind( &JQNetworkServer::onRemoteHostClosed, this, _1, _2 );
                    connectPoolSettings->readyToDeleteCallback          = bind( &JQNetworkServer::onReadyToDelete, this, _1, _2 );
                    connectPoolSettings->packageSendingCallback         = bind( &JQNetworkServer::onPackageSending, this, _1, _2, _3, _4, _5, _6 );
                    connectPoolSettings->packageReceivingCallback       = bind( &JQNetworkServer::onPackageReceiving, this, _1, _2, _3, _4, _5, _6 );
                    connectPoolSettings->packageReceivedCallback        = bind( &JQNetworkServer::onPackageReceived, this, _1, _2, _3 );

                    connectSettings->randomFlagRangeStart = 1000000000;
                    connectSettings->randomFlagRangeEnd = 1999999999;

                    connectPools_[ QThread::currentThread() ] = JQNetworkConnectPoolSharedPointer(
                                new JQNetworkConnectPool(
                                    connectPoolSettings,
                                    connectSettings
                                )
                            );
                }
    );

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

示例9:

QSet<QString> ElementAvailableFN::allXSLTInstructions()
{
    enum
    {
        StringSetSize = 27
    };

    QSet<QString> retval;
    retval.reserve(StringSetSize);

    /* Alphabetically. */
    retval.insert(QLatin1String("analyze-string"));
    retval.insert(QLatin1String("apply-imports"));
    retval.insert(QLatin1String("apply-templates"));
    retval.insert(QLatin1String("attribute"));
    retval.insert(QLatin1String("attribute-set"));
    retval.insert(QLatin1String("call-template"));
    retval.insert(QLatin1String("character-map"));
    retval.insert(QLatin1String("choose"));
    retval.insert(QLatin1String("comment"));
    retval.insert(QLatin1String("copy"));
    retval.insert(QLatin1String("copy-of"));
    retval.insert(QLatin1String("document"));
    retval.insert(QLatin1String("element"));
    retval.insert(QLatin1String("fallback"));
    retval.insert(QLatin1String("for-each"));
    retval.insert(QLatin1String("for-each-group"));
    retval.insert(QLatin1String("if"));
    retval.insert(QLatin1String("message"));
    retval.insert(QLatin1String("namespace"));
    retval.insert(QLatin1String("next-match"));
    retval.insert(QLatin1String("number"));
    retval.insert(QLatin1String("perform-sort"));
    retval.insert(QLatin1String("processing-instruction"));
    retval.insert(QLatin1String("result-document"));
    retval.insert(QLatin1String("sequence"));
    retval.insert(QLatin1String("text"));
    retval.insert(QLatin1String("variable"));

    Q_ASSERT(retval.count() == StringSetSize);
    return retval;
}
开发者ID:krysanto,项目名称:steamlink-sdk,代码行数:42,代码来源:qelementavailablefn.cpp

示例10: checkUnicodeEscape

bool checkUnicodeEscape(QString & source,
                        QString const & locationFilename,
                        std::size_t const locationLine)
{
    QFile inFile(inFilePath + '/' + locationFilename);
    if (!inFile.open(QIODevice::ReadOnly)) {
        std::cerr << inFilename << ": Failed to open source file: "
                  << locationFilename.toStdString() << std::endl;
        return false;
    }
    QTextStream in(&inFile);
    for (std::size_t line = 1u; line < locationLine; ++line)
        if (in.readLine().isNull())
            return false;
    auto line(in.readLine());
    if (line.isNull())
        return false;
    line = line.trimmed();

    QStringList strings;
    int start = 0;
    for (;;) {
        start = line.indexOf('"', start);
        if (start < 0)
            break;
        ++start;
        auto end = line.indexOf('"', start);
        if (end < 0)
            break;
        if (start != end) {
            auto str(line.mid(start, end - start));
            strings.append(std::move(str));
        }
        start = end;
        ++start;
    }

    for (;;) {
        line = in.readLine();
        if (line.isNull())
            break;
        line = line.trimmed();
        if (line.isEmpty())
            continue;
        while (line.startsWith('"')) {
            auto end = line.indexOf('"', 1);
            if (end < 0)
                goto finish;
            if (end > 1) {
                auto str(line.mid(1, end - 1));
                strings.last().append(std::move(str));
            }
            line = line.mid(end + 1).trimmed();
        }
        if (!line.isEmpty())
            break;
    }

finish:

    QSet<QString> rStrings;
    for (auto const & str : strings) {
        auto s(str);
        s.replace("\\u", "u");
        if (source == s)
            rStrings.insert(str);
    }

    switch (rStrings.size()) {
        case 0:
            return false;
        case 1:
        {
            source = *rStrings.begin();
            int from = 0;
            for (;;) {
                int const i = source.indexOf(unicodeEscape, from);
                if (i < 0)
                    break;
                bool ok = false;
                ushort const codePoint = source.mid(i + 2, 4).toUShort(&ok, 16);
                assert(ok);
                source = (source.left(i) + QChar(codePoint))
                         + source.mid(i + 6);
                from = i + 1;
            }
            return true;
        }
        default:
            std::cerr << inFilename << ": Strange strings in "
                      << locationFilename.toStdString() << ':' << locationLine
                      << std::endl;
            return false;
    }
}
开发者ID:bibletime,项目名称:bibletime,代码行数:95,代码来源:qtbug-35164-patcher.cpp

示例11: TileEntry


//.........这里部分代码省略.........
            const auto dataFilter_End = std::chrono::high_resolution_clock::now();
            const std::chrono::duration<float> dataRead_Elapsed = dataFilter_End - dataFilter_Begin;
            dataFilter += dataRead_Elapsed.count();
#endif // OSMAND_PERFORMANCE_METRICS

            return true;
        }

        // Otherwise, this map object can be shared, so it should be checked for
        // being present in shared mapObjects storage, or be reserved there
        std::shared_ptr<const Model::BinaryMapObject> sharedMapObjectReference;
        proper::shared_future< std::shared_ptr<const Model::BinaryMapObject> > futureSharedMapObjectReference;
        if (_sharedMapObjects.obtainReferenceOrFutureReferenceOrMakePromise(id, zoom, Utilities::enumerateZoomLevels(firstZoomLevel, lastZoomLevel), sharedMapObjectReference, futureSharedMapObjectReference))
        {
            if (sharedMapObjectReference)
            {
                // If map object is already in shared objects cache and is available, use that one
                referencedMapObjects.push_back(qMove(sharedMapObjectReference));
            }
            else
            {
                futureReferencedMapObjects.push_back(qMove(futureSharedMapObjectReference));
            }

#if OSMAND_PERFORMANCE_METRICS
            const auto dataFilter_End = std::chrono::high_resolution_clock::now();
            const std::chrono::duration<float> dataRead_Elapsed = dataFilter_End - dataFilter_Begin;
            dataFilter += dataRead_Elapsed.count();
#endif // OSMAND_PERFORMANCE_METRICS
            return false;
        }

        // This map object was reserved, and is going to be shared, but needs to be loaded
        loadedSharedMapObjects.insert(id);
        return true;
    },
#if OSMAND_PERFORMANCE_METRICS > 1
        & dataRead_Metric
#else
        nullptr
#endif // OSMAND_PERFORMANCE_METRICS > 1
        );

#if OSMAND_PERFORMANCE_METRICS
    const auto dataRead_End = std::chrono::high_resolution_clock::now();
    const std::chrono::duration<float> dataRead_Elapsed = dataRead_End - dataRead_Begin;

    const auto dataIdsProcess_Begin = std::chrono::high_resolution_clock::now();
#endif // OSMAND_PERFORMANCE_METRICS

    // Process loaded-and-shared map objects
    for (auto& mapObject : loadedMapObjects)
    {
        // Check if this map object is shared
        if (!loadedSharedMapObjects.contains(mapObject->id))
            continue;

        // Add unique map object under lock to all zoom levels, for which this map object is valid
        assert(mapObject->level);
        _sharedMapObjects.fulfilPromiseAndReference(
            mapObject->id,
            Utilities::enumerateZoomLevels(mapObject->level->minZoom, mapObject->level->maxZoom),
            mapObject);
    }

    for (auto& futureMapObject : futureReferencedMapObjects)
开发者ID:rotorliu,项目名称:OsmAnd-core,代码行数:67,代码来源:BinaryMapDataProvider_P.cpp

示例12: resolveStringProperty

void ClassTemplate::resolveStringProperty(ClassProperty *aProperty, QSet<ClassProperty *> &aCleanSet,
										  QSet<ClassProperty *> &aCallstack, QSet<ClassProperty *>aAll)
{
	//qDebug() << "resolveStringProperty " << aProperty->name();
	if(aCallstack.contains(aProperty))
	{
		qDebug() << "Property tokens circular dependency! " + aProperty->name();
		return;
	}

	if(aCleanSet.contains(aProperty))
	{
		//resolved already
		return;
	}

	QString value = aProperty->defaultValue();
	if((!value.contains("{") && !value.contains("}")) || aProperty->isConst())
	{
		aCleanSet.insert(aProperty);
		if(!aProperty->isConst())
			initializationSection_ +=
				"\t" + aProperty->name() + " = " + wrap(value) + ";\n";
		//nothing to resolve
		return;
	}

	QRegularExpression token("\\{([^\\}]+)\\}");
	QString temp = value;
	QRegularExpressionMatchIterator i = token.globalMatch(value);
	while (i.hasNext())
	{
		QRegularExpressionMatch match = i.next();
		QString toReplace = match.captured(0);
		if(toReplace == "{a}")
			continue;//skipping article
		QString token = toReplace;
		token = token.replace("{", "");
		token = token.replace("}", "");
		ClassProperty *property = propertyByName(token, aAll);
		if(!property)
		{
			temp = temp.replace(toReplace, "\" + " + toCamelCase(token, false) + "() + \"");
		}
		else if(aCleanSet.contains(property))
		{
			temp = temp.replace(toReplace, "\" + " + toCamelCase(token, false) + "() + \"");
		}
		else
		{
			/*aCallstack.insert(aProperty);
			resolveStringProperty(property, aCleanSet, aCallstack, aAll);//recursion
			temp = temp.replace(toReplace, "\" + " + toCamelCase(token, false) + "_ + \"");
			aCallstack.remove(aProperty);*/
			qDebug() << "Pattern contains non-const tokens: " + value;
		}
	}

	aCleanSet.insert(aProperty);	
	initializationSection_ +=
			"\t" + aProperty->name() + " = " + wrap(temp) + ";\n";
}
开发者ID:idea-lua-edit,项目名称:cppmud-generator,代码行数:62,代码来源:ClassTemplate.cpp

示例13: execute

// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void MergeColonies::execute()
{
  setErrorCondition(0);
  dataCheck();
  if(getErrorCondition() < 0) { return; }

  axisTolerance = m_AxisTolerance * SIMPLib::Constants::k_Pi / 180.0f;

  GroupFeatures::execute();

  size_t totalFeatures = m_ActivePtr.lock()->getNumberOfTuples();
  if (totalFeatures < 2)
  {
    setErrorCondition(-87000);
    notifyErrorMessage(getHumanLabel(), "The number of Grouped Features was 0 or 1 which means no grouped Features were detected. A grouping value may be set too high", getErrorCondition());
    return;
  }

  int32_t numParents = 0;
  size_t totalPoints = m_FeatureIdsPtr.lock()->getNumberOfTuples();
  for (size_t k = 0; k < totalPoints; k++)
  {
    int32_t featurename = m_FeatureIds[k];
    m_CellParentIds[k] = m_FeatureParentIds[featurename];
    if (m_FeatureParentIds[featurename] > numParents) { numParents = m_FeatureParentIds[featurename]; }
  }
  numParents += 1;

  notifyStatusMessage(getHumanLabel(), "Characterizing Colonies");
  characterize_colonies();

  if (true == m_RandomizeParentIds)
  {
    // Generate all the numbers up front
    const int32_t rangeMin = 1;
    const int32_t rangeMax = numParents - 1;
    typedef boost::uniform_int<int32_t> NumberDistribution;
    typedef boost::mt19937 RandomNumberGenerator;
    typedef boost::variate_generator < RandomNumberGenerator&,
            NumberDistribution > Generator;

    NumberDistribution distribution(rangeMin, rangeMax);
    RandomNumberGenerator generator;
    Generator numberGenerator(generator, distribution);

    generator.seed(static_cast<boost::uint32_t>( QDateTime::currentMSecsSinceEpoch() )); // seed with the current time

    DataArray<int32_t>::Pointer rndNumbers = DataArray<int32_t>::CreateArray(numParents, "_INTERNAL_USE_ONLY_NewParentIds");
    int32_t* pid = rndNumbers->getPointer(0);
    pid[0] = 0;
    QSet<int32_t> parentIdSet;
    parentIdSet.insert(0);
    for (int32_t i = 1; i < numParents; ++i)
    {
      pid[i] = i; // numberGenerator();
      parentIdSet.insert(pid[i]);
    }

    int32_t r = 0;
    int32_t temp = 0;

    //--- Shuffle elements by randomly exchanging each with one other.
    for (int32_t i = 1; i < numParents; i++)
    {
      r = numberGenerator(); // Random remaining position.
      if (r >= numParents)
      {
        continue;
      }
      temp = pid[i];
      pid[i] = pid[r];
      pid[r] = temp;
    }

    // Now adjust all the Feature Id values for each Voxel
    for (size_t i = 0; i < totalPoints; ++i)
    {
      m_CellParentIds[i] = pid[ m_CellParentIds[i] ];
      m_FeatureParentIds[m_FeatureIds[i]] = m_CellParentIds[i];
    }
  }

  if (m_IdentifyGlobAlpha == true)
  {
    identify_globAlpha();
  }

  notifyStatusMessage(getHumanLabel(), "Complete");
}
开发者ID:kglowins,项目名称:DREAM3D,代码行数:92,代码来源:MergeColonies.cpp

示例14: readXML

bool QgsComposerAttributeTable::readXML( const QDomElement& itemElem, const QDomDocument& doc )
{
  if ( itemElem.isNull() )
  {
    return false;
  }

  //read general table properties
  if ( !tableReadXML( itemElem, doc ) )
  {
    return false;
  }

  mShowOnlyVisibleFeatures = itemElem.attribute( "showOnlyVisibleFeatures", "1" ).toInt();
  mFilterFeatures = itemElem.attribute( "filterFeatures", "false" ) == "true" ? true : false;
  mFeatureFilter = itemElem.attribute( "featureFilter", "" );

  //composer map
  int composerMapId = itemElem.attribute( "composerMap", "-1" ).toInt();
  if ( composerMapId == -1 )
  {
    mComposerMap = 0;
  }

  if ( composition() )
  {
    mComposerMap = composition()->getComposerMapById( composerMapId );
  }
  else
  {
    mComposerMap = 0;
  }

  if ( mComposerMap )
  {
    //if we have found a valid map item, listen out to extent changes on it and refresh the table
    QObject::connect( mComposerMap, SIGNAL( extentChanged() ), this, SLOT( refreshAttributes() ) );
  }

  //vector layer
  QString layerId = itemElem.attribute( "vectorLayer", "not_existing" );
  if ( layerId == "not_existing" )
  {
    mVectorLayer = 0;
  }
  else
  {
    QgsMapLayer* ml = QgsMapLayerRegistry::instance()->mapLayer( layerId );
    if ( ml )
    {
      mVectorLayer = dynamic_cast<QgsVectorLayer*>( ml );
      if ( mVectorLayer )
      {
        //if we have found a valid vector layer, listen for modifications on it and refresh the table
        QObject::connect( mVectorLayer, SIGNAL( layerModified() ), this, SLOT( refreshAttributes() ) );
      }
    }
  }

  //restore display attribute map. This is required to upgrade pre 2.4 projects.
  QSet<int> displayAttributes;
  QDomNodeList displayAttributeList = itemElem.elementsByTagName( "displayAttributes" );
  if ( displayAttributeList.size() > 0 )
  {
    QDomElement displayAttributesElem =  displayAttributeList.at( 0 ).toElement();
    QDomNodeList attributeEntryList = displayAttributesElem.elementsByTagName( "attributeEntry" );
    for ( int i = 0; i < attributeEntryList.size(); ++i )
    {
      QDomElement attributeEntryElem = attributeEntryList.at( i ).toElement();
      int index = attributeEntryElem.attribute( "index", "-1" ).toInt();
      if ( index != -1 )
      {
        displayAttributes.insert( index );
      }
    }
    setDisplayAttributes( displayAttributes, false );
  }

  //restore alias map. This is required to upgrade pre 2.4 projects.
  QMap<int, QString> fieldAliasMap;
  QDomNodeList aliasMapNodeList = itemElem.elementsByTagName( "attributeAliasMap" );
  if ( aliasMapNodeList.size() > 0 )
  {
    QDomElement attributeAliasMapElem = aliasMapNodeList.at( 0 ).toElement();
    QDomNodeList aliasMepEntryList = attributeAliasMapElem.elementsByTagName( "aliasEntry" );
    for ( int i = 0; i < aliasMepEntryList.size(); ++i )
    {
      QDomElement aliasEntryElem = aliasMepEntryList.at( i ).toElement();
      int key = aliasEntryElem.attribute( "key", "-1" ).toInt();
      QString value = aliasEntryElem.attribute( "value", "" );
      fieldAliasMap.insert( key, value );
    }
    restoreFieldAliasMap( fieldAliasMap );
  }

  //restore sort columns. This is required to upgrade pre 2.4 projects.
  QDomElement sortColumnsElem = itemElem.firstChildElement( "sortColumns" );
  if ( !sortColumnsElem.isNull() && mVectorLayer )
  {
    QDomNodeList columns = sortColumnsElem.elementsByTagName( "column" );
//.........这里部分代码省略.........
开发者ID:AaronGaim,项目名称:QGIS,代码行数:101,代码来源:qgscomposerattributetable.cpp

示例15: addItemsToEditor

/** Add items to the table in order to edit them. */
bool TagEditorTableWidget::addItemsToEditor(const QStringList &tracks, QMap<int, Cover*> &covers)
{
	QSet<QPair<QString, QString>> artistAlbumSet;
	for (QString track : tracks) {
		FileHelper fh(track);
		if (!fh.isValid()) {
			continue;
		}

		/// XXX: warning, this information is difficult to find even if public
		QTableWidgetItem *fileName = new QTableWidgetItem(fh.fileInfo().fileName());
		fileName->setData(Qt::UserRole, fh.fileInfo().absoluteFilePath());

		// The second column is not editable
		QTableWidgetItem *absPath = new QTableWidgetItem(QDir::toNativeSeparators(fh.fileInfo().path()));
		absPath->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);

		QTableWidgetItem *title = new QTableWidgetItem(fh.title());
		QTableWidgetItem *artist = new QTableWidgetItem(fh.artist());
		QTableWidgetItem *artistAlbum = new QTableWidgetItem(fh.artistAlbum());
		QTableWidgetItem *album = new QTableWidgetItem(fh.album());
		QTableWidgetItem *trackNumber = NULL;
		if (fh.trackNumber() == "00") {
			trackNumber = new QTableWidgetItem();
		} else {
			trackNumber = new QTableWidgetItem(fh.trackNumber());
		}

		QTableWidgetItem *disc;
		if (fh.discNumber() == 0) {
			disc = new QTableWidgetItem;
		} else {
			disc = new QTableWidgetItem(QString::number(fh.discNumber()));
		}
		QTableWidgetItem *year = new QTableWidgetItem(fh.year());
		QTableWidgetItem *genre = new QTableWidgetItem(fh.genre());
		QTableWidgetItem *comment = new QTableWidgetItem(fh.comment());

		QList<QTableWidgetItem*> items;
		items << fileName << absPath << title << artist << artistAlbum << album << trackNumber << disc << year << genre << comment;

		// Check if there's only one album in the list, used for the context menu of the cover
		artistAlbumSet.insert(qMakePair(artist->text(), album->text()));

		// Create a new row with right data
		int row = rowCount();
		this->insertRow(row);
		for (int column = 0; column < items.size(); column++) {
			this->setItem(row, column, items.at(column));
		}
		_indexes.insert(row, fh.fileInfo().absoluteFilePath());

		/// XXX is it really necessary to extract cover in this class?
		/// It might be better to build a fileHelper outside, in the container (TagEditor), and iterate 2 times
		/// One in this class, one in TagEditor class ? But here is quite easy!
		/*Cover *cover = fh.extractCover();
		if (cover != NULL && !cover->byteArray().isEmpty()) {
			covers.insert(row, cover);
		}*/
	}
	return (artistAlbumSet.size() == 1);
}
开发者ID:arnolddumas,项目名称:Miam-Player,代码行数:63,代码来源:tageditortablewidget.cpp


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