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


C++ QList::takeAt方法代码示例

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


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

示例1: takeAt

void tst_QList::takeAt() const
{
    QList<QString> list;
    list << "foo" << "bar" << "baz";

    QCOMPARE(list.takeAt(0), QLatin1String("foo"));
    QVERIFY(list.size() == 2);
    QCOMPARE(list.takeAt(1), QLatin1String("baz"));
    QVERIFY(list.size() == 1);
    QCOMPARE(list.takeAt(0), QLatin1String("bar"));
    QVERIFY(list.size() == 0);
}
开发者ID:KDE,项目名称:android-qt,代码行数:12,代码来源:tst_qlist.cpp

示例2: reindexList

static QList<int> reindexList(const GlobalConfig *config, Phonon::Category category, QList<int>newOrder, bool output)
{
    Q_ASSERT(config);
#ifdef QT_NO_PHONON_AUDIOCAPTURE
    Q_ASSERT(output);
#endif

    /*QString sb;
    sb = QString("(Size %1)").arg(currentList.size());
    foreach (int i, currentList)
    sb += QString("%1, ").arg(i);
    fprintf(stderr, "=== Reindex Current: %s\n", sb.toUtf8().constData());
    sb = QString("(Size %1)").arg(newOrder.size());
    foreach (int i, newOrder)
    sb += QString("%1, ").arg(i);
    fprintf(stderr, "=== Reindex Before : %s\n", sb.toUtf8().constData());*/

    QList<int> currentList;
    if (output)
        currentList = config->audioOutputDeviceListFor(category, GlobalConfig::ShowUnavailableDevices|GlobalConfig::ShowAdvancedDevices);
#ifndef QT_NO_PHONON_AUDIOCAPTURE
    else
        currentList = config->audioCaptureDeviceListFor(category, GlobalConfig::ShowUnavailableDevices|GlobalConfig::ShowAdvancedDevices);
#endif

    QList<int> newList;

    foreach (int i, newOrder) {
        int found = currentList.indexOf(i);
        if (found < 0) {
            // It's not in the list, so something is odd (e.g. client error). Ignore it.
            continue;
        }

        // Iterate through the list from this point onward. If there are hidden devices
        // immediately following, take them too.
        newList.append(currentList.takeAt(found));
        while (found < currentList.size()) {
            bool hidden = true;
            if (output)
                hidden = isHiddenAudioOutputDevice(config, currentList.at(found));
#ifndef QT_NO_PHONON_AUDIOCAPTURE
            else
                hidden = isHiddenAudioCaptureDevice(config, currentList.at(found));
#endif

            if (!hidden)
                break;
            newList.append(currentList.takeAt(found));
        }
    }
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.vendor,代码行数:51,代码来源:globalconfig.cpp

示例3: setSelections

void SelectableTextEditorWidget::setSelections(const QMap<int, QList<DiffSelection> > &selections)
{
    m_diffSelections.clear();
    for (auto it = selections.cbegin(), end = selections.cend(); it != end; ++it) {
        const QList<DiffSelection> diffSelections = it.value();
        QList<DiffSelection> workingList;
        for (const DiffSelection &diffSelection : diffSelections) {
            if (diffSelection.start == -1 && diffSelection.end == 0)
                continue;

            if (diffSelection.start == diffSelection.end && diffSelection.start >= 0)
                continue;

            int j = 0;
            while (j < workingList.count()) {
                const DiffSelection existingSelection = workingList.takeAt(j);
                const QList<DiffSelection> newSelection = subtractSelection(existingSelection, diffSelection);
                for (int k = 0; k < newSelection.count(); k++)
                    workingList.insert(j + k, newSelection.at(k));
                j += newSelection.count();
            }
            workingList.append(diffSelection);
        }
        m_diffSelections.insert(it.key(), workingList);
    }
}
开发者ID:kai66673,项目名称:qt-creator,代码行数:26,代码来源:selectabletexteditorwidget.cpp

示例4: loadTask

FlightTask* TaskFileManagerOld::loadTask( QString taskName, QString fileName )
{
  QList<FlightTask*> ftl;

  if( taskName.trimmed().isEmpty() || loadTaskList( ftl, fileName ) == false )
    {
      return 0;
    }

  FlightTask* ft = 0;

  // Search desired task by name in list.
  for( int i = 0; i < ftl.size(); i++ )
    {
      ft = ftl.at(i);

      if( ft->getTaskName() == taskName )
	{
	  // Take found element from the list.
	  ft = ftl.takeAt(i);
	  break;
	}
    }

  // Remove all allocated list members
  qDeleteAll(ftl);
  return ft;
}
开发者ID:kflog-project,项目名称:Cumulus,代码行数:28,代码来源:taskfilemanager.cpp

示例5: qt_qdnsmailexchangerecord_sort

static void qt_qdnsmailexchangerecord_sort(QList<QDnsMailExchangeRecord> &records)
{
    // If we have no more than one result, we are done.
    if (records.size() <= 1)
        return;

    // Order the records by preference.
    std::sort(records.begin(), records.end(), qt_qdnsmailexchangerecord_less_than);

    int i = 0;
    while (i < records.size()) {

        // Determine the slice of records with the current preference.
        QList<QDnsMailExchangeRecord> slice;
        const quint16 slicePreference = records.at(i).preference();
        for (int j = i; j < records.size(); ++j) {
            if (records.at(j).preference() != slicePreference)
                break;
            slice << records.at(j);
        }

        // Randomize the slice of records.
        while (!slice.isEmpty()) {
            const unsigned int pos = QRandomGenerator::global()->bounded(slice.size());
            records[i++] = slice.takeAt(pos);
        }
    }
}
开发者ID:,项目名称:,代码行数:28,代码来源:

示例6: stream

bool
PlaylistModel::dropMimeData (const QMimeData *data,
							 Qt::DropAction action,
							 int row, int column,
							 const QModelIndex & parent)
{
	if (parent.internalId () != -1 && parent.isValid ()) {
		return false;
	}

	if (data->hasFormat ("application/x-xmms2poslist")) {
		if (!parent.isValid ())
			return false;

		QByteArray ba = data->data ("application/x-xmms2poslist");
		QDataStream stream (&ba, QIODevice::ReadOnly);
		QList<int> l;
		stream >> l;
		qSort (l);
		int target = parent.row ();

		int mod = 0;

		while (l.size ()) {
			int orow = l.takeAt (0) - mod;
			m_client->playlist ()->moveEntry (orow, target) ();
			if (orow < target) {
				mod ++;
			} else {
				target ++;
			}
		}
		return true;
	} else if (data->hasFormat ("application/x-xmms2mlibid")) {
开发者ID:dsvensson,项目名称:promoe,代码行数:34,代码来源:playlistmodel.cpp

示例7: reorderGridLayout

void reorderGridLayout(QGridLayout* layout, int maxCols)
{
	QList<QLayoutItem*> items;
	for (int i = 0; i < layout->rowCount(); i++) {
		for (int j = 0; j < layout->columnCount(); j++) {
			QLayoutItem* item = layout->itemAtPosition(i, j);
			if (item) {
				layout->removeItem(item);
				if (item->isEmpty()) {
					delete item;
				}
				else {
					items.append(item);
				}
			}
		}
	}
	int col = 0, row = 0;
	while (!items.isEmpty()) {
		QLayoutItem* item = items.takeAt(0);
		layout->addItem(item, row, col);
		col++;
		if (col >= maxCols) {
			col = 0;
			row++;
		}
	}
}
开发者ID:,项目名称:,代码行数:28,代码来源:

示例8:

QLayoutItem *GroupFlowLayout::takeAt(int index)
{
    if (index >= 0 && index < itemList.size())
        return itemList.takeAt(index);
    else
        return 0;
}
开发者ID:crayonink,项目名称:calligra-2,代码行数:7,代码来源:ActionOptionWidget.cpp

示例9: slotCertificateAccepted

//called during the validation of the client certificate.
void OwncloudSetupPage::slotCertificateAccepted()
{
    QSslCertificate sslCertificate;

    resultP12ToPem certif = p12ToPem(addCertDial->getCertificatePath().toStdString() , addCertDial->getCertificatePasswd().toStdString());
    if(certif.ReturnCode){
        QString s = QString::fromStdString(certif.Certificate);
        QByteArray ba = s.toLocal8Bit();

        QList<QSslCertificate> sslCertificateList = QSslCertificate::fromData(ba, QSsl::Pem);
        sslCertificate = sslCertificateList.takeAt(0);

        _ocWizard->ownCloudCertificate = ba;
        _ocWizard->ownCloudPrivateKey = certif.PrivateKey.c_str();
        _ocWizard->ownCloudCertificatePath = addCertDial->getCertificatePath();
        _ocWizard->ownCloudCertificatePasswd = addCertDial->getCertificatePasswd();

        AccountPtr acc = _ocWizard->account();
        acc->setCertificate(_ocWizard->ownCloudCertificate, _ocWizard->ownCloudPrivateKey);
        addCertDial->reinit();
        validatePage();
    } else {
        QString message;
        message = certif.Comment.c_str();
        addCertDial->showErrorMessage(message);
        addCertDial->show();
    }
}
开发者ID:dariaphoebe,项目名称:owncloudclient,代码行数:29,代码来源:owncloudsetuppage.cpp

示例10: updateDroppedUserLayouts

void Preferences::updateDroppedUserLayouts(int newRow, int oldRow)
{
  int userLayoutIndex = this->m_Data[UserLayoutIndex].toInt();
  QList<QVariant> userLayouts = this->m_Data[UserLayouts].toList();
  QVariant name = userLayouts.takeAt(oldRow*2);
  QVariant data = userLayouts.takeAt(oldRow*2);
  userLayouts.insert(newRow*2, data);
  userLayouts.insert(newRow*2, name);
  
  if (userLayoutIndex != -1)
  {
    if (userLayoutIndex == oldRow)
      userLayoutIndex = newRow;
    else
    {
      if ((newRow > oldRow) && (oldRow < userLayoutIndex))
        userLayoutIndex -= 1;
      else if ((newRow < oldRow) && (newRow < userLayoutIndex))
        userLayoutIndex += 1;
    }
  }
  
  this->m_Data[UserLayoutIndex] = userLayoutIndex;
  this->m_Data[UserLayouts] = userLayouts;
};
开发者ID:moorepants,项目名称:BTKCore,代码行数:25,代码来源:Preferences.cpp

示例11: generate

void StackMaze::generate()
{
	// Generate cell lists
	m_visited = QVector< QVector<bool> >(columns(), QVector<bool>(rows()));
	QList<QPoint> active;

	// Start maze
	QPoint start(0, randomInt(rows()));
	m_visited[start.x()][start.y()] = true;
	active.append(start);

	// Loop through active list
	QPoint cell, neighbor;
	int pos;
	while (!active.isEmpty()) {
		pos = nextActive(active.size());
		cell = active.at(pos);
		neighbor = randomNeighbor(m_visited, cell);
		if (neighbor.x() != -1) {
			mergeCells(cell, neighbor);
			active.append(neighbor);
		} else {
			active.takeAt(pos);
		}
	}

	m_visited.clear();
}
开发者ID:gottcode,项目名称:cutemaze,代码行数:28,代码来源:maze.cpp

示例12:

//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo> RimCellPropertyFilter::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly)
{
    QList<caf::PdmOptionItemInfo> optionItems = resultDefinition->calculateValueOptions(fieldNeedingOptions, useOptionsOnly);

    std::vector<int> indicesToRemove;
    for (int i = 0; i < optionItems.size(); i++)
    {
        QString text = optionItems[i].optionUiText;

        if (RimDefines::isPerCellFaceResult(text))
        {
            indicesToRemove.push_back(i);
        }
    }

    std::sort(indicesToRemove.begin(), indicesToRemove.end());
    
    std::vector<int>::reverse_iterator rit;
    for (rit = indicesToRemove.rbegin(); rit != indicesToRemove.rend(); ++rit)
    {
        optionItems.takeAt(*rit);
    }

    return optionItems;
}
开发者ID:JacobStoren,项目名称:ResInsight,代码行数:28,代码来源:RimCellPropertyFilter.cpp

示例13:

QList<ESIndividual*> ESMarriage::doMarriage(const QList<ESIndividual*> &parents, 
																						int rho,
																					  const ESInformation &information) 
{
	QList<ESIndividual*> marriagedParents;
	
	// list with indexes from the possible parents
	QList<int> possibleParents;
	
	for(int i = 0; i < rho; i++)
	{
		// generate list with indexes of possible parents if it is empty
		if(possibleParents.size() <= 0)
		{
			for(int i = 0; i < parents.size();i++){
				possibleParents.append(i);
			}
		}
	
		// select a random parent and delete it from the list of possible parents
		int currentParentIndex = Random::nextInt(possibleParents.size());
		marriagedParents.append(parents.at(possibleParents.takeAt(currentParentIndex)));
	}
	
	return marriagedParents;
}
开发者ID:nerd-toolkit,项目名称:nerd,代码行数:26,代码来源:ESMarriage.cpp

示例14: setElements

void Chromosome::setElements(QList <QPointFWithParent> points,bool random){
	 int pos=0,i=0,size=points.size();
	 QList <QPointFWithParent> newChrom;
	 MySize=points.size();
	 //newChrom.clear();
	 
	 while (i<MySize){
		 size=points.size();
		 ///note: to prevent takin pos out of list range we update size every time we take a value
		 if (random){
			 pos=qrand()%size;
		 }
		 else{
			 pos=i;
		 }
		
		 newChrom.append(points.takeAt(pos));
		 //if (i%2==1) { /// time to compute the distance	
		 ///FIXME: manage to store the distances matrix to recal it when neede instead of recomputing the values
		 ///every time we need them, or is it a time wasting operation to be droped ?
			// routeLength+=dist(newChrom.at(i),newChrom.at(i-1));
			//}
		 i++;		
		}
		 elements =newChrom;
		setRoutelength();
	 //setFitness(routeLength);
	 //qDebug()<<"route length"<<routeLength;
	
	 }
开发者ID:aliceylan,项目名称:camnest,代码行数:30,代码来源:gatsp.cpp

示例15: if

    foreach( const QString &key, keys )
    {
        // --- commit the albums as compilation or normal album

        QList<CollectionScanner::Album*> albums = m_albumNames.values( key );
        // debug() << "commit got" <<albums.count() << "x" << key;

        // if we have multiple albums with the same name, check if it
        // might be a compilation

        for( int i = albums.count() - 1; i >= 0; --i )
        {
            CollectionScanner::Album *album = albums.at( i );
            // commit all albums with a track with the noCompilation flag
            if( album->isNoCompilation() ||
                    nonCompilationAlbumNames.contains( album->name(), Qt::CaseInsensitive ) )
                commitAlbum( albums.takeAt( i ) );
        }

        // only one album left. It's no compilation.
        if( albums.count() == 1 )
        {
            commitAlbum( albums.takeFirst() );
        }

        // compilation
        else if( albums.count() > 1 )
        {
            CollectionScanner::Album compilation( key, QString() );
            for( int i = albums.count() - 1; i >= 0; --i )
            {
                CollectionScanner::Album *album = albums.takeAt( i );
                foreach( CollectionScanner::Track *track, album->tracks() )
                    compilation.addTrack( track );
                compilation.setCovers( album->covers() + compilation.covers() );
            }
            commitAlbum( &compilation );
        }

        // --- unblock every 5 second. Maybe not really needed, but still nice
        if( blockedTime.secsTo( QDateTime::currentDateTime() ) >= 5 )
        {
            unblockUpdates();
            blockedTime = QDateTime::currentDateTime();
            blockUpdates();
        }
    }
开发者ID:phalgun,项目名称:amarok-nepomuk,代码行数:47,代码来源:ScanResultProcessor.cpp


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