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


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

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


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

示例1: onDisplayChangeEvent

void MScenePrivate::onDisplayChangeEvent(MOnDisplayChangeEvent *event)
{
    Q_Q(MScene);

    if (event->state() == MOnDisplayChangeEvent::FullyOnDisplay ||
            event->state() == MOnDisplayChangeEvent::FullyOffDisplay) {
        // Simple cases. Just forward the event as it is.
        sendEventToMWidgets(filterMWidgets(q->items()), event);
        return;
    }

    QList<MWidget *> fullyOnWidgets;
    QList<MWidget *> partiallyOnWidgets;
    QList<MWidget *> fullyOffWidgets;

    QList<MWidget *> intersectingWidgets = filterMWidgets(q->items(event->viewRect(),
            Qt::IntersectsItemBoundingRect));

    QList<MWidget *> allWidgets = filterMWidgets(q->items());

    // Find who is fully on, partially on and fully off

    QSet<MWidget *> fullyOffWidgetsSet = allWidgets.toSet().subtract(intersectingWidgets.toSet());
    fullyOffWidgets = fullyOffWidgetsSet.toList();

    int intersectingWidgetsCount = intersectingWidgets.count();
    MWidget *widget;
    for (int i = 0; i < intersectingWidgetsCount; i++) {
        widget = intersectingWidgets.at(i);
        if (event->viewRect().contains(widget->sceneBoundingRect())) {
            fullyOnWidgets << widget;
        } else {
            partiallyOnWidgets << widget;
        }
    }

    // Send the events to the corresponding MWidgets

    if (fullyOnWidgets.count() > 0) {
        MOnDisplayChangeEvent fullyOnEvent(MOnDisplayChangeEvent::FullyOnDisplay,
                                             event->viewRect());

        sendEventToMWidgets(fullyOnWidgets, &fullyOnEvent);
    }

    if (fullyOffWidgets.count() > 0) {
        MOnDisplayChangeEvent fullyOffEvent(MOnDisplayChangeEvent::FullyOffDisplay,
                                              event->viewRect());

        sendEventToMWidgets(fullyOffWidgets, &fullyOffEvent);
    }

    if (partiallyOnWidgets.count() > 0) {
        MOnDisplayChangeEvent partiallyOnEvent(MOnDisplayChangeEvent::PartiallyOnDisplay,
                event->viewRect());

        sendEventToMWidgets(partiallyOnWidgets, &partiallyOnEvent);
    }

}
开发者ID:dudochkin-victor,项目名称:libgogootouch,代码行数:60,代码来源:mscene.cpp

示例2: selectFormat

bool Engine::selectFormat()
{
    bool foundSupportedFormat = false;

    if (m_file || QAudioFormat() != m_format) {
        QAudioFormat format = m_format;
        if (m_file)
            // Header is read from the WAV file; just need to check whether
            // it is supported by the audio output device
            format = m_file->fileFormat();
        if (m_audioOutputDevice.isFormatSupported(format)) {
            setFormat(format);
            foundSupportedFormat = true;
        }
    } else {

        QList<int> sampleRatesList;

        if (!m_generateTone)

            sampleRatesList += m_audioOutputDevice.supportedSampleRates();
        sampleRatesList = sampleRatesList.toSet().toList(); // remove duplicates
        qSort(sampleRatesList);
        ENGINE_DEBUG << "Engine::initialize frequenciesList" << sampleRatesList;

        QList<int> channelsList;
        channelsList += m_audioOutputDevice.supportedChannelCounts();
        channelsList = channelsList.toSet().toList();
        qSort(channelsList);
        ENGINE_DEBUG << "Engine::initialize channelsList" << channelsList;

        QAudioFormat format;
        format.setByteOrder(QAudioFormat::LittleEndian);
        format.setCodec("audio/pcm");
        format.setSampleSize(16);
        format.setSampleType(QAudioFormat::SignedInt);
        int sampleRate, channels;
        foreach (sampleRate, sampleRatesList) {
            if (foundSupportedFormat)
                break;
            format.setSampleRate(sampleRate);
            foreach (channels, channelsList) {
                format.setChannelCount(channels);
                const bool outputSupport = m_audioOutputDevice.isFormatSupported(format);
                ENGINE_DEBUG << "Engine::initialize checking " << format
                             << "output" << outputSupport;
                if (outputSupport)
                {
                    foundSupportedFormat = true;
                    break;
                }
            }
        }

        if (!foundSupportedFormat)
            format = QAudioFormat();

        setFormat(format);
    }
开发者ID:sssunsha,项目名称:music,代码行数:59,代码来源:engine.cpp

示例3: updateProfiles

void SelectProfileWidget::updateProfiles()
{
	IDiscoIdentity identity;
	identity.category = "gateway";
	identity.type = FDescriptor.type;

	QList<Jid> nativeGates;
	if (FDescriptor.id == GSID_RAMBLER)
		nativeGates.append(streamJid());

	QList<Jid> gates = FGateways->gateDescriptorServices(streamJid(),FDescriptor,FDescriptor.needLogin);
	for (QList<Jid>::iterator it=gates.begin(); it!=gates.end(); )
	{
		if (!(FGateways->serviceRestrictions(streamJid(),*it) & GSR_ADD_CONTACT))
		{
			IGateServiceDescriptor descriptor = FGateways->serviceDescriptor(streamJid(),*it);
			if (FDescriptor.id == descriptor.id)
				nativeGates.append(*it);
			it++;
		}
		else
		{
			it = gates.erase(it);
		}
	}

	Jid oldSelected = selectedProfile();
	QList<Jid> newProfiles = (gates.toSet() - FProfiles.keys().toSet()).toList();
	QList<Jid> oldProfiles = (FProfiles.keys().toSet() - gates.toSet()).toList();

	qSort(newProfiles);
	if (!FDescriptor.needGate && !FProfiles.contains(streamJid()))
		newProfiles.prepend(streamJid());
	else if (FDescriptor.needGate && FProfiles.contains(streamJid()))
		oldProfiles.prepend(streamJid());
	else
		oldProfiles.removeAll(streamJid());

	foreach(Jid serviceJid, newProfiles)
	{
		QRadioButton *button = new QRadioButton(ui.wdtProfiles);
		button->setAutoExclusive(true);
		connect(button,SIGNAL(toggled(bool)),SLOT(onProfileButtonToggled(bool)));
		FProfiles.insert(serviceJid,button);

		QLabel *label = new QLabel(ui.wdtProfiles);
		connect(label,SIGNAL(linkActivated(const QString &)),SLOT(onProfileLabelLinkActivated(const QString &)));
		FProfileLabels.insert(serviceJid,label);

		QHBoxLayout *layout = new QHBoxLayout();
		layout->setMargin(0);
		layout->setSpacing(0);
		layout->addWidget(button);
		layout->addWidget(label);
		layout->addStretch();
		qobject_cast<QVBoxLayout *>(ui.wdtProfiles->layout())->addLayout(layout);
	}
开发者ID:RandomWalkEagle,项目名称:Contacts,代码行数:57,代码来源:selectprofilewidget.cpp

示例4: clearProfileAssignments

void AutoProfileWatcher::clearProfileAssignments()
{
    QSet<AutoProfileInfo*> terminateProfiles;

    QListIterator<QList<AutoProfileInfo*> > iterDelete(appProfileAssignments.values());
    while (iterDelete.hasNext())
    {
        QList<AutoProfileInfo*> templist = iterDelete.next();
        terminateProfiles.unite(templist.toSet());
    }
    appProfileAssignments.clear();

    QListIterator<QList<AutoProfileInfo*> > iterClassDelete(windowClassProfileAssignments.values());
    while (iterClassDelete.hasNext())
    {
        QList<AutoProfileInfo*> templist = iterClassDelete.next();
        terminateProfiles.unite(templist.toSet());
    }
    windowClassProfileAssignments.clear();

    QListIterator<QList<AutoProfileInfo*> > iterNameDelete(windowNameProfileAssignments.values());
    while (iterNameDelete.hasNext())
    {
        QList<AutoProfileInfo*> templist = iterNameDelete.next();
        terminateProfiles.unite(templist.toSet());
    }
    windowNameProfileAssignments.clear();

    QSetIterator<AutoProfileInfo*> iterTerminate(terminateProfiles);
    while (iterTerminate.hasNext())
    {
        AutoProfileInfo *info = iterTerminate.next();
        if (info)
        {
            delete info;
            info = 0;
        }
    }

    QListIterator<AutoProfileInfo*> iterDefaultsDelete(defaultProfileAssignments.values());
    while (iterDefaultsDelete.hasNext())
    {
        AutoProfileInfo *info = iterDefaultsDelete.next();
        if (info)
        {
            delete info;
            info = 0;
        }
    }
    defaultProfileAssignments.clear();

    allDefaultInfo = 0;
    guidSet.clear();
}
开发者ID:cotton765,项目名称:antimicro,代码行数:54,代码来源:autoprofilewatcher.cpp

示例5: toSet

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

    // no duplicates
    QCOMPARE(list.toSet(), QSet<QString>() << "foo" << "bar" << "baz");
    QCOMPARE(list, QList<QString>() << "foo" << "bar" << "baz");

    // duplicates (is this more of a QSet test?)
    list << "foo" << "bar" << "baz";
    QCOMPARE(list.toSet(), QSet<QString>() << "foo" << "bar" << "baz");
    QCOMPARE(list, QList<QString>() << "foo" << "bar" << "baz" << "foo" << "bar" << "baz");
}
开发者ID:KDE,项目名称:android-qt,代码行数:14,代码来源:tst_qlist.cpp

示例6: cut

void SubgraphMatching::cut(Solution *sol, CutMethod cm) {
    LinearConstraint *c;
    QList<Variable *> vars = sol->getVariables().keys();
    switch(cm) {
        case SOLUTION:
            c = new LinearConstraint(LinearExpression::sum(vars), Constraint::LESS_EQ, vars.size() - 1);
            break;
        case MATCHINGS:
            c = new LinearConstraint(LinearExpression::sum(vars), Constraint::EQUAL, 0);
            break;
        case ELEMENTS: {
            QStringList sl;
            QSet<Variable *> vset = vars.toSet();
            for(auto s : vars) {
                if(s->getID().startsWith("x")) {
                    sl = s->getID().mid(2).split(',');
                    for(auto v : x_variables.getCol(sl[1].toInt())) {
                        vset.insert(v);
                    }
                }
            }
            c = new LinearConstraint(LinearExpression::sum(vset.toList()), Constraint::EQUAL, 0);
            break;
        }
        default:
            break;
    }
    *lp_ += c;
}
开发者ID:jlerouge,项目名称:GEMpp,代码行数:29,代码来源:SubgraphMatching.cpp

示例7: SetVector

bool BloombergVector::SetVector(const QList<QDate>& Dates, const QList<double>& Values) {
    Q_D(BloombergVector);
	if (
		Dates.size() != Values.size() //Each date has a value and vice versa
		|| Values.isEmpty() //The vectors are not empty
		|| Dates.toSet().size()!=Dates.size() //There are no duplicates in the dates
	) return false;
	QMap<QDate, double> SortedValues;
	for (int i = 0; i <Dates.size(); i++) {
		if (Dates.at(i).isNull())
            return false;
		if (Values.at(i)<0.0)
            return false;
		SortedValues.insert(Dates.at(i), Values.at(i));
	}
	d->m_AnchorDate = SortedValues.firstKey();
    d->m_VectVal.clear();
	int NumMonths;
	for (auto i = SortedValues.constBegin()+1; i != SortedValues.constEnd(); i++) {
		NumMonths = MonthDiff(i.key(), (i - 1).key());
		for (int j = 0; j < NumMonths; j++)
            d->m_VectVal.append((i - 1).value());
	}
    d->m_VectVal.append(SortedValues.last());

	RepackVector();
	return true;
}
开发者ID:bubble501,项目名称:CLOModel,代码行数:28,代码来源:BloombergVector.cpp

示例8: ba

QOpenGLExtensionMatcher::QOpenGLExtensionMatcher()
{
    QOpenGLContext *ctx = QOpenGLContext::currentContext();
    QOpenGLFunctions *funcs = ctx->functions();
    const char *extensionStr = 0;

    if (ctx->isOpenGLES() || ctx->format().majorVersion() < 3)
        extensionStr = reinterpret_cast<const char *>(funcs->glGetString(GL_EXTENSIONS));

    if (extensionStr) {
        QByteArray ba(extensionStr);
        QList<QByteArray> extensions = ba.split(' ');
        m_extensions = extensions.toSet();
    } else {
#ifdef QT_OPENGL_3
        // clear error state
        while (funcs->glGetError()) {}

        if (ctx) {
            qt_glGetStringi glGetStringi = (qt_glGetStringi)ctx->getProcAddress("glGetStringi");

            if (!glGetStringi)
                return;

            GLint numExtensions;
            funcs->glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions);

            for (int i = 0; i < numExtensions; ++i) {
                const char *str = reinterpret_cast<const char *>(glGetStringi(GL_EXTENSIONS, i));
                m_extensions.insert(str);
            }
        }
#endif // QT_OPENGL_3
    }
}
开发者ID:AlexSoehn,项目名称:qt-base-deb,代码行数:35,代码来源:qopengl.cpp

示例9: stream

QMimeData *MsgListModel::mimeData(const QModelIndexList &indexes) const
{
    if (indexes.isEmpty())
        return 0;

    QMimeData *res = new QMimeData();
    QByteArray encodedData;
    QDataStream stream(&encodedData, QIODevice::WriteOnly);
    stream.setVersion(QDataStream::Qt_4_6);

    TreeItemMailbox *mailbox = dynamic_cast<TreeItemMailbox *>(Model::realTreeItem(
                                   indexes.front())->parent()->parent());
    Q_ASSERT(mailbox);
    stream << mailbox->mailbox() << mailbox->syncState.uidValidity();

    QList<uint> uids;
    for (QModelIndexList::const_iterator it = indexes.begin(); it != indexes.end(); ++it) {
        TreeItemMessage *message = dynamic_cast<TreeItemMessage *>(Model::realTreeItem(*it));
        Q_ASSERT(message);
        Q_ASSERT(message->parent()->parent() == mailbox);
        Q_ASSERT(message->uid() > 0);
        uids << message->uid();
    }
    uids = uids.toSet().toList();
    stream << uids;
    res->setData(QLatin1String("application/x-trojita-message-list"), encodedData);
    return res;
}
开发者ID:adamkudrna,项目名称:trojita,代码行数:28,代码来源:MsgListModel.cpp

示例10: shouldCallHandlersWithJob

    void shouldCallHandlersWithJob()
    {
        // GIVEN
        int callCount = 0;
        QList<KJob*> seenJobs;

        auto handlerWithJob = [&](KJob *job) {
            callCount++;
            seenJobs << job;
        };

        FakeJob *job1 = new FakeJob(this);
        FakeJob *job2 = new FakeJob(this);
        CompositeJob *compositeJob = new CompositeJob(this);
        compositeJob->setAutoDelete(false);
        QVERIFY(compositeJob->install(job1, handlerWithJob));
        QVERIFY(compositeJob->install(job2, handlerWithJob));

        // WHEN
        compositeJob->start();
        QTest::qWait(FakeJob::DURATION + 10);

        // THEN
        QCOMPARE(callCount, 2);
        QCOMPARE(seenJobs.toSet(), QSet<KJob*>() << job1 << job2);
        QVERIFY(!compositeJob->error());
        delete compositeJob;
    }
开发者ID:sandsmark,项目名称:zanshin,代码行数:28,代码来源:compositejobtest.cpp

示例11: removeFile

void
SourceFileModel::removeFiles(QList<SourceFile *> const &files) {
  auto filesToRemove  = files.toSet();
  auto tracksToRemove = QSet<Track *>{};

  for (auto const &file : files) {
    for (auto const &track : file->m_tracks)
      tracksToRemove << track.get();

    for (auto const &appendedFile : file->m_appendedFiles) {
      filesToRemove << appendedFile.get();
      for (auto const &track : appendedFile->m_tracks)
        tracksToRemove << track.get();
    }
  }

  m_tracksModel->reDistributeAppendedTracksForFileRemoval(filesToRemove);
  m_tracksModel->removeTracks(tracksToRemove);

  auto filesToRemoveLast = QList<SourceFile *>{};
  for (auto &file : filesToRemove)
    if (!file->isRegular())
      removeFile(file);
    else
      filesToRemoveLast << file;

  for (auto &file : filesToRemoveLast)
    if (file->isRegular())
      removeFile(file);
}
开发者ID:autoscatto,项目名称:mkvtoolnix,代码行数:30,代码来源:source_file_model.cpp

示例12: itemsAboutToRemoved

void AnchorTool::itemsAboutToRemoved(const QList<FormEditorItem*> &removedItems)
{
    QList<FormEditorItem*> newItemList = items().toSet().subtract(removedItems.toSet()).toList();
    setItems(newItemList);
    m_anchorIndicator.setItems(newItemList);
    m_anchorLineIndicator.clear();
}
开发者ID:renatofilho,项目名称:QtCreator,代码行数:7,代码来源:anchortool.cpp

示例13: QSortFilterProxyModel

MessageFilter::MessageFilter(MessageModel *source, const QList<BufferId> &buffers, QObject *parent)
  : QSortFilterProxyModel(parent),
    _validBuffers(buffers.toSet()),
    _messageTypeFilter(0)
{
  init();
  setSourceModel(source);
}
开发者ID:bawNg,项目名称:quassel,代码行数:8,代码来源:messagefilter.cpp

示例14: onServicesChanged

void AddLegacyAccountOptions::onServicesChanged(const Jid &AStreamJid)
{
	if (FStreamJid == AStreamJid)
	{
		QList<Jid> availRegisters = FGateways->availRegistrators(AStreamJid,true);
		foreach(Jid serviceJid, availRegisters.toSet() - FWidgets.keys().toSet())
			appendServiceButton(serviceJid);
		foreach(Jid serviceJid, FWidgets.keys().toSet() - availRegisters.toSet())
			removeServiceButton(serviceJid);

		if (FWidgets.isEmpty())
			ui.lblInfo->setText(tr("All available accounts are already linked"));
		ui.lblInfo->setVisible(FWidgets.isEmpty());

		emit updated();
	}
}
开发者ID:RandomWalkEagle,项目名称:Contacts,代码行数:17,代码来源:addlegacyaccountoptions.cpp

示例15: setFilterGroups

void DraftsModel::setFilterGroups(const QList<int> &list)
{
    Q_D(DraftsModel);
    QSet<int> groupIds = list.toSet();
    if (groupIds == d->filterGroups)
        return;

    d->filterGroups = groupIds;
    emit filterGroupsChanged();
}
开发者ID:sledges,项目名称:libcommhistory,代码行数:10,代码来源:draftsmodel.cpp


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