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


C++ QVector::contains方法代码示例

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


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

示例1: unifyTilesets

/**
 * Replaces tilesets in \a map by similar tilesets in this map when possible,
 * and adds tilesets to \a missingTilesets whenever there is a tileset without
 * replacement in this map.
 *
 * \warning This method assumes that the tilesets in \a map are managed by
 *          the TilesetManager!
 */
void MapDocument::unifyTilesets(Map *map, QVector<SharedTileset> &missingTilesets)
{
    QVector<SharedTileset> availableTilesets = mMap->tilesets();
    for (const SharedTileset &tileset : qAsConst(missingTilesets))
        if (!availableTilesets.contains(tileset))
            availableTilesets.append(tileset);

    TilesetManager *tilesetManager = TilesetManager::instance();

    // Iterate over a copy because map->replaceTileset may invalidate iterator
    const QVector<SharedTileset> tilesets = map->tilesets();
    for (const SharedTileset &tileset : tilesets) {
        // tileset already added
        if (availableTilesets.contains(tileset))
            continue;

        SharedTileset replacement = tileset->findSimilarTileset(availableTilesets);

        // tileset not present and no replacement tileset found
        if (!replacement) {
            missingTilesets.append(tileset);
            availableTilesets.append(tileset);
            continue;
        }

        // replacement tileset found, change given map
        if (map->replaceTileset(tileset, replacement))
            tilesetManager->addReference(replacement);
        tilesetManager->removeReference(tileset);
    }
}
开发者ID:stt,项目名称:tiled,代码行数:39,代码来源:mapdocument.cpp

示例2: vectSub

//
//	Creates recursively the dotted line points
//
QVector<Point3f> vectSub(int part, Point3f p1, Point3f p2)
{
	if(part==2)
	{
		QVector<Point3f> toRet(3);
		toRet[0]=p1;
		toRet[1]=(p1+p2)/2;
		toRet[2]=p2;
		return toRet;
	}
	else
	{
		QVector<Point3f> L;
		QVector<Point3f> R;

		int np=(int)(part/2);

		L = vectSub(np, p1, (p1+p2)/2);
		R = vectSub(np, (p1+p2)/2, p2);
		
		QVector<Point3f> toRet;
		for(int i=0; i<L.size(); i++)
			if(!toRet.contains(L.at(i)))
				toRet.push_back(L.at(i));
		for(int i=0; i<R.size(); i++)
			if(!toRet.contains(R.at(i)))
				toRet.push_back(R.at(i));

		return toRet;
	}
}
开发者ID:Booley,项目名称:nbis,代码行数:34,代码来源:edit_topo.cpp

示例3:

QVector<QPointF> jpsRoom::get_vertices() const
{
    QVector<QPointF> vertices;

    for (int i=0; i<item_list.size(); i++)
    {
        if (vertices.contains(item_list[i]->get_line()->line().p1())==false)
        {
            vertices.push_back(item_list[i]->get_line()->line().p1());
        }
        if (vertices.contains(item_list[i]->get_line()->line().p2())==false)
        {
            vertices.push_back(item_list[i]->get_line()->line().p2());
        }
    }
    for (jpsCrossing* crossing:_doorList)
    {
        if (vertices.contains(crossing->get_cLine()->get_line()->line().p1())==false)
        {
            vertices.push_back(crossing->get_cLine()->get_line()->line().p1());
        }

        if (vertices.contains(crossing->get_cLine()->get_line()->line().p1())==false)
        {
            vertices.push_back(crossing->get_cLine()->get_line()->line().p1());
        }

    }

    return vertices;
}
开发者ID:JuPedSim,项目名称:jpseditor,代码行数:31,代码来源:rooms.cpp

示例4: shouldNotifyWhenTabPropertiesChange

    void shouldNotifyWhenTabPropertiesChange()
    {
        qRegisterMetaType<QVector<int> >();
        QSignalSpy spy(model, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&, const QVector<int>&)));
        QQuickItem* tab = createTab();
        model->add(tab);

        QQmlProperty(tab, "url").write(QUrl("http://ubuntu.com"));
        QCOMPARE(spy.count(), 1);
        QList<QVariant> args = spy.takeFirst();
        QCOMPARE(args.at(0).toModelIndex().row(), 0);
        QCOMPARE(args.at(1).toModelIndex().row(), 0);
        QVector<int> roles = args.at(2).value<QVector<int> >();
        QCOMPARE(roles.size(), 1);
        QVERIFY(roles.contains(TabsModel::Url));

        QQmlProperty(tab, "title").write(QString("Lorem Ipsum"));
        QCOMPARE(spy.count(), 1);
        args = spy.takeFirst();
        QCOMPARE(args.at(0).toModelIndex().row(), 0);
        QCOMPARE(args.at(1).toModelIndex().row(), 0);
        roles = args.at(2).value<QVector<int> >();
        QCOMPARE(roles.size(), 1);
        QVERIFY(roles.contains(TabsModel::Title));

        QQmlProperty(tab, "icon").write(QUrl("image://webicon/123"));
        QCOMPARE(spy.count(), 1);
        args = spy.takeFirst();
        QCOMPARE(args.at(0).toModelIndex().row(), 0);
        QCOMPARE(args.at(1).toModelIndex().row(), 0);
        roles = args.at(2).value<QVector<int> >();
        QCOMPARE(roles.size(), 1);
        QVERIFY(roles.contains(TabsModel::Icon));
    }
开发者ID:ubuntu-touch-apps,项目名称:webbrowser-app,代码行数:34,代码来源:tst_TabsModelTests.cpp

示例5: QPoint

TEST( tBridge, RemoveSeveralPreset )
{
    tDisplayId id1 = { QUuid::createUuid() };
    tDisplayId id2 = { QUuid::createUuid() };
    tPosition position1 = { QPoint( 1, 2 ) };
    tPosition position2 = { QPoint( 3, 4 ) };
    tBridge bridge;
    bridge.SetDisplay( id1, position1 );
    bridge.SetDisplay( id2, position2 );

    tPage page1 = { ePanelLayoutRowLower, QVector<PanelID>() << DATA, 0, 0 };
    tPage page2 = { ePanelLayoutRowLower, QVector<PanelID>() << POSITION, 0, 0 };
    tPreset preset1;
    preset1.SetDisplay( id1, page1 );
    tPreset preset2;
    preset2.SetDisplay( id2, page2 );
    tPreset preset3;
    preset3.SetDisplay( id1, page2 );

    bridge.AddPreset( preset1 );
    bridge.AddPreset( preset2 );
    bridge.AddPreset( preset3 );

    bridge.RemovePreset( preset2 );
    QVector<tPreset> presets = bridge.Presets();
    EXPECT_EQ( 2, presets.size() );
    EXPECT_TRUE( presets.contains( preset1 ) );
    EXPECT_TRUE( presets.contains( preset3 ) );
    bridge.RemovePreset( preset1 );
    presets = bridge.Presets();
    EXPECT_EQ( 1, presets.size() );
    EXPECT_TRUE( presets.contains( preset3 ) );
}
开发者ID:dulton,项目名称:53_hero,代码行数:33,代码来源:TestBridge.cpp

示例6: getDeviceModeFramerates

static QVector<unsigned short> getDeviceModeFramerates(int fd, unsigned w, unsigned h,
                                                       uint32_t pixelFormat)
{
    QVector<unsigned short> rates;
    v4l2_frmivalenum vfve{};
    vfve.pixel_format = pixelFormat;
    vfve.height = h;
    vfve.width = w;

    while (!ioctl(fd, VIDIOC_ENUM_FRAMEINTERVALS, &vfve)) {
        int rate;
        switch (vfve.type) {
        case V4L2_FRMSIZE_TYPE_DISCRETE:
            rate = vfve.discrete.denominator / vfve.discrete.numerator;
            if (!rates.contains(rate))
                rates.append(rate);
            break;
        case V4L2_FRMSIZE_TYPE_CONTINUOUS:
        case V4L2_FRMSIZE_TYPE_STEPWISE:
            rate = vfve.stepwise.min.denominator / vfve.stepwise.min.numerator;
            if (!rates.contains(rate))
                rates.append(rate);
        }
        vfve.index++;
    }

    return rates;
}
开发者ID:Grokafar,项目名称:qTox,代码行数:28,代码来源:v4l2.cpp

示例7: notifyTransfersChanged

void Application::notifyTransfersChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles)
{
    // Display notifications if one of the following happens:
    // - the device name is known (receiving only)
    // - transfer fails or succeeds
    for(int row = topLeft.row(); row <= bottomRight.row(); ++row) {

        QModelIndex index = mTransferModel.index(row, 0);
        if(roles.contains(TransferModel::DeviceNameRole)) {

            mIcon->showMessage(tr("Receiving transfer from %1.").arg(
                index.data(TransferModel::DeviceNameRole).toString()
            ));
        } else if(roles.contains(TransferModel::StateRole)) {

            switch(index.data(TransferModel::StateRole).toInt()) {
            case TransferModel::Failed:
                mIcon->showMessage(tr("Transfer with %1 failed.").arg(
                    index.data(TransferModel::DeviceNameRole).toString()
                ));
                break;
            case TransferModel::Succeeded:
                mIcon->showMessage(tr("Transfer with %1 succeeded.").arg(
                    index.data(TransferModel::DeviceNameRole).toString()
                ));
                break;
            }
        }
    }
}
开发者ID:houzhenggang,项目名称:nitroshare-desktop,代码行数:30,代码来源:application.cpp

示例8: testDUChainBuddyVote

void TestBuddies::testDUChainBuddyVote()
{
    /*
     * Test that the DUChain buddy system finds the buddy file with the most
     * common declarations/definitions
     */

    enableBuddies();
    enableOpenAfterCurrent();

    QTemporaryDir dirA;

    TestFile header("void func1();\nvoid func2();\nvoid func3();\n", "h", nullptr, dirA.path());
    TestFile source1(
        QString("#include \"%1\"\nvoid func1() {}\n").arg(header.url().toUrl().fileName()),
        "cpp", nullptr, dirA.path()
    );
    TestFile source2(
        QString("#include \"%1\"\nvoid func2() {}\nvoid func3() {}\n").arg(header.url().toUrl().fileName()),
        "cpp", nullptr, dirA.path()
    );

    // -> buddy(header) should resolve to source2

    header.parseAndWait();
    source1.parseAndWait();
    source2.parseAndWait();

    // Test IBuddyDocumentFinder::getPotentialBuddies()
    QMimeDatabase db;
    IBuddyDocumentFinder* sourceBuddyFinder = IBuddyDocumentFinder::finderForMimeType(db.mimeTypeForUrl(source1.url().toUrl()).name());
    QVector< QUrl > sourceBuddies = sourceBuddyFinder->getPotentialBuddies(source1.url().toUrl());
    if (!sourceBuddies.contains(header.url().toUrl())) {
        qDebug() << "got source buddies: " << sourceBuddies;
        qDebug() << "expected: " << header.url().toUrl();
        QFAIL("Failed to find buddy for source file");
    }

    IBuddyDocumentFinder* source2BuddyFinder = IBuddyDocumentFinder::finderForMimeType(db.mimeTypeForUrl(source2.url().toUrl()).name());
    QVector< QUrl > source2Buddies = source2BuddyFinder->getPotentialBuddies(source2.url().toUrl());
    if (!source2Buddies.contains(header.url().toUrl())) {
        qDebug() << "got source2 buddies: " << source2Buddies;
        qDebug() << "expected: " << header.url().toUrl();
        QFAIL("Failed to find buddy for source2 file");
    }

    IBuddyDocumentFinder* headerBuddyFinder = IBuddyDocumentFinder::finderForMimeType(db.mimeTypeForUrl(header.url().toUrl()).name());
    QVector< QUrl > headerBuddies = headerBuddyFinder->getPotentialBuddies(header.url().toUrl());
    if (!headerBuddies.contains(source2.url().toUrl())) {
        qDebug() << "got header buddies: " << headerBuddies;
        qDebug() << "expected: " << source2.url().toUrl();
        QFAIL("Failed to find buddy for header file");
    }
    QVERIFY2(!headerBuddies.contains(source1.url().toUrl()), "header buddy list contains weaker file");
}
开发者ID:KDE,项目名称:kdevelop,代码行数:55,代码来源:test_buddies.cpp

示例9: dataChanged

void CategorizedView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles)
{
//	if (m_updatesDisabled)
//	{
//		return;
//	}

	QListView::dataChanged(topLeft, bottomRight, roles);

	if (roles.contains(CategorizedViewRoles::CategoryRole) || roles.contains(Qt::DisplayRole))
	{
		updateGeometries();
		update();
	}
}
开发者ID:02JanDal,项目名称:GroupView,代码行数:15,代码来源:CategorizedView.cpp

示例10: createGivens

void Puzzle::createGivens()
{
    // Initialize givens
    QList<QPoint> cells;
    for ( int r = 0; r < 9; ++r ) {
        for ( int c = 0; c < 9; ++c ) {
            m_givens[c][r] = m_solution[c][r];
            cells.append ( QPoint ( c, r ) );
        }
    }
    std::random_shuffle ( cells.begin(), cells.end() );

    // Remove as many givens as possible
    QVector<int> values ( m_pattern->count() );
    int count = values.count();
    QList<QPoint> positions;
    foreach ( const QPoint& cell, cells ) {
        positions = m_pattern->pattern ( cell );
        for ( int i = 0; i < count; ++i ) {
            QPoint pos = positions.at ( i );
            values[i] = m_givens[pos.x() ][pos.y() ];
        }
        if ( !values.contains ( 0 ) ) {
            for ( int i = 0; i < count; ++i ) {
                const QPoint& pos = positions.at ( i );
                m_givens[pos.x() ][pos.y() ] = 0;
            }
            if ( !isUnique() ) {
                for ( int i = 0; i < count; ++i ) {
                    const QPoint& pos = positions.at ( i );
                    m_givens[pos.x() ][pos.y() ] = values.at ( i );
                }
            }
        }
    }
开发者ID:TodorGrin,项目名称:boox-opensource,代码行数:35,代码来源:puzzle.cpp

示例11: processChoices

/**
 * Goes through all of the different names in the current data type to populate
 * a selection list to be used for graphing.
 */
void Summary::processChoices(std::vector<std::vector<std::string> > &results){
    std::vector< std::vector<std::string> >::iterator resultIter;
    std::vector<std::string>::iterator fieldIter;
    QVector<QString> names;
    QVector<QString> years;
    resultIter = results.begin();
    ui->nameBox->clear();
    ui->nameBox->addItem("All Names");
    ui->dateSelector->clear();
    while(resultIter != results.end())
    {
      fieldIter = resultIter->begin();
      QString name = QString::fromStdString(*(fieldIter));
      QString year = QString::fromStdString(*(fieldIter + 1));

      if(QString::compare(name,"") != 0 && names.contains(name) == false)
          names.push_back(name);

      if(QString::compare(year,"") != 0)
          years.push_back(year);

      resultIter++;
    }

    names = sortNames(names);
    for(int i=0;i<names.size();i++){
        ui->nameBox->addItem(names[i]);
    }

    years = cleanDates(years);
    for(int i=0;i<years.size();i++){
        ui->dateSelector->addItem(years[i]);
    }
}
开发者ID:Leonmey,项目名称:CS3307-Data-Visualization-Tool,代码行数:38,代码来源:summary.cpp

示例12: removeSelectedTuples

void DemandListModel::removeSelectedTuples(const QModelIndexList &selecteds){

	if(selecteds.empty()){
		return; //nothing to do.
	}

	QVector<int> rows;

	for(QModelIndex selected: selecteds) {
		if(!rows.contains(selected.row())){
			rows.push_back(selected.row());
		}
	}

	std::sort(rows.begin(), rows.end());

	for(int i = 0; i < rows.size(); i++){

		beginRemoveRows(QModelIndex(), rows[i]-i, rows[i]-i);
		_usedIndexes.remove(_tuples[rows[i]-i].index);
		_tuples.removeAt(rows[i]-i);
		endRemoveRows();
	}

	emit(changedDatas());

}
开发者ID:french-paragon,项目名称:aspa,代码行数:27,代码来源:demandlistmodel.cpp

示例13: generate

void Field::generate(int x, int y)
{

    Cell *banned = cellAt(x, y);
    QVector<Cell*> bannedCells = banned->getNeighbors();
    bannedCells.append(banned);



    int minesToPlace = m_numberOfMines;

    while (minesToPlace > 0) {
        Cell *cell = m_cells.at(qrand() % m_cells.count());

        if (cell->haveMine()) {
            continue;
        }
        if (bannedCells.contains(cell)){
            continue;
        }

        cell->setHaveMine(true);
        --minesToPlace;
    }
    m_generated = true;

}
开发者ID:Deadlymouse1,项目名称:Mines,代码行数:27,代码来源:Field.cpp

示例14: getPotentialBuddies

QVector< QUrl > getPotentialBuddies(const QUrl &url, bool checkDUChain)
{
    auto type = basePathAndTypeForUrl(url);
    // Don't do anything for types we don't know
    if (type.second == Unknown) {
        return {};
    }

    // Depending on the buddy's file type we either generate source extensions (for headers)
    // or header extensions (for sources)
    const auto& extensions = ( type.second == Header ? ClangHelpers::sourceExtensions() : ClangHelpers::headerExtensions() );
    QVector< QUrl > buddies;
    for(const QString& extension : extensions) {
        if (!extension.contains(QLatin1Char('.'))) {
            buddies.append(QUrl::fromLocalFile(type.first + QLatin1Char('.') + extension));
        } else {
            buddies.append(QUrl::fromLocalFile(type.first + extension));
        }
    }

    if (checkDUChain) {
        // Also ask DUChain for a guess
        QUrl bestBuddy = duchainBuddyFile(url, type.second);
        if (!buddies.contains(bestBuddy)) {
            buddies.append(bestBuddy);
        }
    }

    return buddies;
}
开发者ID:mali,项目名称:kdevelop,代码行数:30,代码来源:documentfinderhelpers.cpp

示例15: QRadioButton

void UIWizardNewVDPage1::addFormatButton(QWidget *pParent, QVBoxLayout *pFormatLayout, CMediumFormat medFormat)
{
    /* Check that medium format supports creation: */
    ULONG uFormatCapabilities = 0;
    QVector<KMediumFormatCapabilities> capabilities;
    capabilities = medFormat.GetCapabilities();
    for (int i = 0; i < capabilities.size(); i++)
        uFormatCapabilities |= capabilities[i];

    if (!(uFormatCapabilities & MediumFormatCapabilities_CreateFixed ||
          uFormatCapabilities & MediumFormatCapabilities_CreateDynamic))
        return;

    /* Check that medium format supports creation of virtual hard-disks: */
    QVector<QString> fileExtensions;
    QVector<KDeviceType> deviceTypes;
    medFormat.DescribeFileExtensions(fileExtensions, deviceTypes);
    if (!deviceTypes.contains(KDeviceType_HardDisk))
        return;

    /* Create/add corresponding radio-button: */
    QRadioButton *pFormatButton = new QRadioButton(pParent);
    pFormatLayout->addWidget(pFormatButton);
    m_formats << medFormat;
    m_formatNames << medFormat.GetName();
    m_pFormatButtonGroup->addButton(pFormatButton, m_formatNames.size() - 1);
}
开发者ID:bayasist,项目名称:vbox,代码行数:27,代码来源:UIWizardNewVDPageBasic1.cpp


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