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


C++ QQueue::dequeue方法代码示例

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


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

示例1: moveColumnsRight

void TreeWidgetEditor::moveColumnsRight(int fromColumn, int toColumn)
{
    if (fromColumn >= toColumn)
        return;

    QTreeWidgetItem *headerItem = ui.treeWidget->headerItem();
    QString text = headerItem->text(fromColumn);
    QIcon icon = headerItem->icon(fromColumn);
    for (int i = fromColumn; i < toColumn; i++) {
        headerItem->setText(i, headerItem->text(i + 1));
        headerItem->setIcon(i, headerItem->icon(i + 1));
    }
    headerItem->setText(toColumn, text);
    headerItem->setIcon(toColumn, icon);

    QQueue<QTreeWidgetItem *> pendingQueue;
    for (int i = 0; i < ui.treeWidget->topLevelItemCount(); i++)
        pendingQueue.enqueue(ui.treeWidget->topLevelItem(i));

    while (!pendingQueue.isEmpty()) {
        QTreeWidgetItem *item = pendingQueue.dequeue();
        for (int i = 0; i < item->childCount(); i++)
            pendingQueue.enqueue(item->child(i));

        QString text = item->text(fromColumn);
        QIcon icon = item->icon(fromColumn);
        for (int i = fromColumn; i < toColumn; i++) {
            item->setText(i, item->text(i + 1));
            item->setIcon(i, item->icon(i + 1));
        }
        item->setText(toColumn, text);
        item->setIcon(toColumn, icon);
    }
}
开发者ID:muromec,项目名称:qtopia-ezx,代码行数:34,代码来源:treewidgeteditor.cpp

示例2: lookupBases

void CppClass::lookupBases(Symbol *declaration, const LookupContext &context)
{
    using Data = QPair<ClassOrNamespace*, CppClass*>;

    if (ClassOrNamespace *clazz = context.lookupType(declaration)) {
        QSet<ClassOrNamespace *> visited;

        QQueue<Data> q;
        q.enqueue(qMakePair(clazz, this));
        while (!q.isEmpty()) {
            Data current = q.dequeue();
            clazz = current.first;
            visited.insert(clazz);
            const QList<ClassOrNamespace *> &bases = clazz->usings();
            foreach (ClassOrNamespace *baseClass, bases) {
                const QList<Symbol *> &symbols = baseClass->symbols();
                foreach (Symbol *symbol, symbols) {
                    if (symbol->isClass() && (
                        clazz = context.lookupType(symbol)) &&
                        !visited.contains(clazz)) {
                        CppClass baseCppClass(symbol);
                        CppClass *cppClass = current.second;
                        cppClass->bases.append(baseCppClass);
                        q.enqueue(qMakePair(clazz, &cppClass->bases.last()));
                    }
                }
            }
        }
    }
开发者ID:kai66673,项目名称:qt-creator,代码行数:29,代码来源:cppelementevaluator.cpp

示例3: run

void LoggerThread::run(void)
{
    RunProlog();

    logThreadFinished = false;

    QMutexLocker qLock(&logQueueMutex);

    while (!aborted || !logQueue.isEmpty())
    {
        if (logQueue.isEmpty())
        {
            m_waitEmpty->wakeAll();
            m_waitNotEmpty->wait(qLock.mutex(), 100);
            continue;
        }

        LoggingItem *item = logQueue.dequeue();
        qLock.unlock();

        handleItem(item);
        deleteItem(item);

        qLock.relock();
    }

    logThreadFinished = true;

    qLock.unlock();

    RunEpilog();
}
开发者ID:StefanRoss,项目名称:mythtv,代码行数:32,代码来源:logging.cpp

示例4: testQueue

    void testQueue()
    {
        QQueue<QByteArray> values;
        values << "value1";
        values << "value2";

        MessageQueue queue(Akonadi2::Store::storageLocation(), "org.kde.dummy.testqueue");
        for (const QByteArray &value : values) {
            queue.enqueue(value.data(), value.size());
        }

        while (!queue.isEmpty()) {
            const auto expected = values.dequeue();
            bool gotValue = false;
            bool gotError = false;
            queue.dequeue([&](void *ptr, int size, std::function<void(bool success)> callback) {
                if (QByteArray(static_cast<char*>(ptr), size) == expected) {
                    gotValue = true;
                }
                callback(true);
            },
            [&](const MessageQueue::Error &error) {
                gotError = true;
            });
            QVERIFY(gotValue);
            QVERIFY(!gotError);
        }
        QVERIFY(values.isEmpty());
    }
开发者ID:KDE,项目名称:sink,代码行数:29,代码来源:messagequeuetest.cpp

示例5: runtimePlaylist

void CmdPlaylist::runtimePlaylist()
{
    // filter
    MediaLibraryModel::MediaType type = this->mediaTypeFilter(this->m_args, this->cmdAudio, this->cmdVideo, this->cmdModule);

    // search for media
    QList<MediaLibraryModel::Media*> search_results = this->ptr_media_model->findMultiple(this->m_args, type);

    // empty check
    if (search_results.isEmpty())
    {
        this->print_nothingfound();
        return;
    }

    // build runtime playlist
    QQueue<MediaLibraryModel::Media*> plist;
    for (MediaLibraryModel::Media *media : search_results)
        plist.enqueue(media);
    search_results.clear();

    // start the playlist
    if (type == MediaLibraryModel::None)
    {

        KBHIT_NOT_INFINITE(plist.isEmpty())

            MediaPlayerController::i()->play(plist.dequeue(), MediaLibraryModel::Audio);

        KBHIT_NOT_INFINITE_END

    }
开发者ID:GhettoGirl,项目名称:MusicConsole,代码行数:32,代码来源:cmdplaylist.cpp

示例6: main

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    FrameReader r;
    r.setMedia(a.arguments().last());
    QQueue<qint64> t;
    int count = 0;
    qint64 t0 = QDateTime::currentMSecsSinceEpoch();
    while (r.readMore()) {
        while (r.hasEnoughVideoFrames()) {
            const VideoFrame f = r.getVideoFrame(); //TODO: if eof
            if (!f)
                continue;
            count++;
            //r.readMore();
            const qint64 now = QDateTime::currentMSecsSinceEpoch();
            const qint64 dt = now - t0;
            t.enqueue(now);
            printf("decode @%.3f count: %d, elapsed: %lld, fps: %.1f/%.1f\r", f.timestamp(), count, dt, count*1000.0/dt, t.size()*1000.0/(now - t.first()));fflush(0);
            if (t.size() > 10)
                t.dequeue();
        }
    }
    while (r.hasVideoFrame()) {
        const VideoFrame f = r.getVideoFrame();
        qDebug("pts: %.3f", f.timestamp());
    }
    qDebug("read done");
    return 0;
}
开发者ID:Czhian,项目名称:QtAV,代码行数:31,代码来源:main.cpp

示例7: operator

bool TreeEnumerate::operator ()()
{
    QQueue<letter_node *> queue;
    queue.clear();

    filled_details=false;
    queue.enqueue((letter_node*)Tree->getFirstNode());
    bool stop=false;
    while ((!queue.isEmpty())  && !stop) {
        node * current_node=NULL;
        current_node=queue.dequeue();
        addLetterToQueue(queue,current_node);

        QList<result_node *>* current_result_children=current_node->getResultChildren();
        int num_children=current_result_children->count();
        for (int j=0;j<num_children;j++) {
            result_node *current_child=current_result_children->at(j);
            reached_node=current_child;
            resulting_category_idOFCurrentMatch=((result_node *)current_child)->get_resulting_category_id();
            bool isAccept=((result_node *)current_child)->is_accept_state();
            if ( isAccept && shouldcall_onmatch_ex() && !(on_match_helper())) {
                stop=true;
                break;
            } else {
                addLetterToQueue(queue,current_child);
            }
        }
    }
    return (!stop);
}
开发者ID:ZoeLeBlanc,项目名称:atmine,代码行数:30,代码来源:tree_enumerate.cpp

示例8: collectionListResult

void RecursiveMover::collectionListResult( KJob *job )
{
  Q_ASSERT( m_pendingCollections.isEmpty() );
  --m_runningJobs;

  if ( job->error() )
    return; // error handling is in the base class

  // build a parent -> children map for the following topological sorting
  // while we are iterating anyway, also fill m_collections here
  CollectionFetchJob *fetchJob = qobject_cast<CollectionFetchJob*>( job );
  QHash<Collection::Id, Collection::List> colTree;
  foreach ( const Collection &col, fetchJob->collections() ) {
    colTree[col.parentCollection().id()] << col;
    m_collections.insert( col.id(), col );
  }

  // topological sort; BFS traversal of the tree
  m_pendingCollections.push_back( m_movedCollection );
  QQueue<Collection> toBeProcessed;
  toBeProcessed.enqueue( m_movedCollection );
  while ( !toBeProcessed.isEmpty() ) {
    const Collection col = toBeProcessed.dequeue();
    const Collection::List children = colTree.value( col.id() );
    if ( children.isEmpty() )
      continue;
    m_pendingCollections.append( children );
    foreach ( const Collection &child, children )
      toBeProcessed.enqueue( child );
  }

  replayNextCollection();
}
开发者ID:crevetor,项目名称:kcalcore,代码行数:33,代码来源:recursivemover.cpp

示例9: processBytes

void Telnet::processBytes(QByteArray bytes)
{
    QQueue<uchar> buffer;
    foreach (uchar c, bytes)
    {
        switch (_state)
        {
        case TOP_LEVEL:
            handleStateTopLevel(c, &buffer);
            break;
        case SEENCR:
            handleStateSeenCr(c, &buffer);
            break;
        case SEENIAC:
            handleStateSeenIac(c);
            break;
        case SEENWILL:
            handleStateSeenWill(c);
            break;
        case SEENWONT:
            sendCommand(DONT, c);
            _state = TOP_LEVEL;
            break;
        case SEENDO:
            handleStateSeenDo(c);
            break;
        case SEENDONT:
            sendCommand(WONT, c);
            _state = TOP_LEVEL;
            break;
        case SEENSB:
            _sbOption = c;
            _sbBuffer->clear();
            _state = SUBNEGOT;
            break;
        case SUBNEGOT:
            if (c == IAC)
                _state = SUBNEG_IAC;
            else
                _sbBuffer->append(c);
            break;
        case SUBNEG_IAC:
            handleStateSubNegIac(c);
            break;
        default:
            break;
        }
    }

    int chunk_sz = 256;
    while (!buffer.isEmpty())
    {
        QByteArray data;
        int length = buffer.size() < chunk_sz ? buffer.size() : chunk_sz;
        for (int i = 0; i < length; i++)
            data.append(buffer.dequeue());
        emit processedBytes(data);
    }
}
开发者ID:descent,项目名称:Qelly,代码行数:59,代码来源:Telnet.cpp

示例10: streamLoop

void streamLoop(qintptr socketDesc, QQueue<QByteArray> &queue, bool& streaming) {

    QTcpSocket* socket = new QTcpSocket();
    // TCP_NODELAY + disable Nagle's algorithm
    socket->setSocketOption(QAbstractSocket::LowDelayOption, QVariant::fromValue(1));
    // Internetwork control
    socket->setSocketOption(QAbstractSocket::TypeOfServiceOption, QVariant::fromValue(192));
    socket->setSocketDescriptor(socketDesc);
    socket->readAll();

    QByteArray ContentType = ("HTTP/1.1 200 OK\r\n" \
                              "Server: test\r\n" \
                              "Cache-Control: no-cache\r\n" \
                              "Cache-Control: private\r\n" \
                              "Connection: close\r\n"\
                              "Pragma: no-cache\r\n"\
                              "Content-Type: multipart/x-mixed-replace; boundary=--boundary\r\n\r\n");

    socket->write(ContentType);

    while((socket->state() != QAbstractSocket::ClosingState ||
           socket->state() != QAbstractSocket::UnconnectedState) &&
           socket->state() == QAbstractSocket::ConnectedState &&
           streaming) {

        if(queue.empty()) { // no new frame available
            continue;
        }

        // make sure that the queue doesn't grow too big or
        // the OOM killer will kick in
        if(queue.length() > 20) {
            queue.clear();
            continue;
        }

        QByteArray boundary = ("--boundary\r\n" \
                               "Content-Type: image/jpeg\r\n" \
                               "Content-Length: ");

        QByteArray img  = queue.dequeue();
        boundary.append(QString::number(img.length()));
        boundary.append("\r\n\r\n");

        socket->write(boundary);
        socket->waitForBytesWritten();
        boundary.clear();
        socket->write(img);
        socket->waitForBytesWritten();
        img.clear();
    }

    socket->flush();
    socket->abort();
    socket->deleteLater();
    streaming = false;
    queue.clear();
    return;
}
开发者ID:kimmoli,项目名称:SailCast,代码行数:59,代码来源:screenprovider.cpp

示例11: preparePlugins

void PluginManager::preparePlugins() {
    // Ordered by load priority
    QStringList knownRoles = {"core", "service", "widget", "window"};

    QQueue<AdamantPluginInfo*> plugins;

    for (const QString role : knownRoles) {
        for (AdamantPluginInfo* data : _pluginsByRole.values(role)) {
            // Here we want to enqueue plugins to be loaded
            plugins.enqueue(data);
        }
    }

    // Clear master list
    _plugins.clear();

    // Now they should be in the correct role loading order.
    while (!plugins.isEmpty()) {
        AdamantPluginInfo* data = plugins.dequeue();

        // LOADER CODE
        data->loader = new QPluginLoader(data->file.absoluteFilePath(), this);
        bool load = data->loader->load();
        bool loaded = data->loader->isLoaded();
        QString error = data->loader->errorString();
        if (load && loaded) {
            AdamantPlugin* plugin = qobject_cast<AdamantPlugin*>(data->loader->instance());
            if (plugin != nullptr) {
                data->instance = plugin;

                // Now we inject the PluginManager
                injectPluginData(data);

                // The plugin has been created successfully, so we can execute it's script (if it exists).
                const QDir dir = data->file.absoluteDir();
                QFile scriptFile(dir.filePath(data->file.fileName() + ".qs"));
                if (scriptFile.exists() && scriptFile.open(QFile::ReadOnly)) {
                    const QString script = scriptFile.readAll();
                    scriptFile.close();

                    data->script = addScript(scriptFile.fileName(), script, data->instance);
                }

                _plugins.append(data);
                continue;
            }
        }

        // Delete if we couldn't load
        data->loader->deleteLater();
        delete data;
        data = nullptr;
    }

    _pluginsByRole.clear();

    loadAndExecuteScripts();
}
开发者ID:Novynn,项目名称:Adamant,代码行数:58,代码来源:pluginmanager.cpp

示例12: notifyWriteResult

void TrkWriteQueue::notifyWriteResult(bool ok)
{
    // On success, dequeue message and await result
    if (ok) {
        const SharedPointerTrkMessage firstMsg = trkWriteQueue.dequeue();
        writtenTrkMessages.insert(firstMsg->token, firstMsg);
        trkWriteBusy = true;
    }
}
开发者ID:TheProjecter,项目名称:project-qtcreator,代码行数:9,代码来源:trkolddevice.cpp

示例13:

QHash<Cell*, QSet<char> > Grid::broadenDomains(Cell *unsetCell)
{
	QQueue<Cell*> dirtyCells;
	QHash<Cell*, QSet<char> > diff;

	// initialize set of cells to check
	auto depCells = unsetCell->dependentCells();
	for( auto dep=depCells.constBegin(); dep!=depCells.constEnd(); ++dep ){
		dirtyCells.enqueue(*dep);
	}
	diff.insert(unsetCell, QSet<char>());

	while( !dirtyCells.empty() )
	{
		Cell* dirty = dirtyCells.dequeue();

		// broaden domain and re-restrict to check for changes
		const QSet<char> oldDomain = dirty->domain();
		dirty->broadenDomain();
		dirty->restrictDomain();

		// if there are changes, enqueue dirty cell's dependents
		if( dirty->domain() != oldDomain ){
			diff.insert(dirty, QSet<char>());
			auto depCells = dirty->dependentCells();
			for( auto dep=depCells.constBegin(); dep!=depCells.constEnd(); ++dep ){
				dirtyCells.enqueue(*dep);
			}
		}
	}

	unsetCell->restrictDomain();
	return diff;
}
开发者ID:stevenvergenz,项目名称:c-voku,代码行数:34,代码来源:grid_csp.cpp

示例14: createPaths

void QtResourceViewPrivate::createPaths()
{
    if (!m_resourceModel)
        return;

    const QString root(QLatin1Char(':'));

    QMap<QString, QString> contents = m_resourceModel->contents();
    QMapIterator<QString, QString> itContents(contents);
    while (itContents.hasNext()) {
        const QString filePath = itContents.next().key();
        const QFileInfo fi(filePath);
        QString dirPath = fi.absolutePath();
        m_pathToContents[dirPath].append(fi.fileName());
        while (!m_pathToParentPath.contains(dirPath) && dirPath != root) { // create all parent paths
            const QFileInfo fd(dirPath);
            const QString parentDirPath = fd.absolutePath();
            m_pathToParentPath[dirPath] = parentDirPath;
            m_pathToSubPaths[parentDirPath].append(dirPath);
            dirPath = parentDirPath;
        }
    }

    QQueue<QPair<QString, QTreeWidgetItem *> > pathToParentItemQueue;
    pathToParentItemQueue.enqueue(qMakePair(root, static_cast<QTreeWidgetItem *>(0)));
    while (!pathToParentItemQueue.isEmpty()) {
        QPair<QString, QTreeWidgetItem *> pathToParentItem = pathToParentItemQueue.dequeue();
        const QString path = pathToParentItem.first;
        QTreeWidgetItem *item = createPath(path, pathToParentItem.second);
        QStringList subPaths = m_pathToSubPaths.value(path);
        QStringListIterator itSubPaths(subPaths);
        while (itSubPaths.hasNext())
            pathToParentItemQueue.enqueue(qMakePair(itSubPaths.next(), item));
    }
}
开发者ID:Mr-Kumar-Abhishek,项目名称:qt,代码行数:35,代码来源:qtresourceview.cpp

示例15: topologicSorting

void BalanceGraph::topologicSorting()
{
    QQueue<Segment*> queue;
    QList<Segment*> topologicSorted;

    int topologicIndex = 0;
    for(Segment* segment : segments) {
        if(segment->predecessors.isEmpty()) {
            segment->topologicNumber = topologicIndex;
            queue.enqueue(segment);
            topologicSorted.append(segment);
            topologicIndex++;
        }
    }

    while(!queue.isEmpty()) {
        Segment* segment = queue.dequeue();

        for(Segment* succ : segment->successors) {
            succ->predecessors.removeOne(segment);

            if(succ->predecessors.isEmpty()) {
                succ->topologicNumber = topologicIndex;
                queue.enqueue(succ);
                topologicSorted.append(succ);
                topologicIndex++;
            }
        }
    }

    segments = topologicSorted;
}
开发者ID:Oyuret,项目名称:layers,代码行数:32,代码来源:balancegraph.cpp


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