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)); } }
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; }
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); } }
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())); } } } } }
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; }
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(); }
void EffectNode::renderSubNodes( void ) { QList<EffectNode*> effectsNodes = m_enf.getEffectNodeInstancesList(); QList<EffectNode*>::iterator effectsNodesIt = effectsNodes.begin(); QList<EffectNode*>::iterator effectsNodesEnd = effectsNodes.end(); QList<OutSlot<LightVideoFrame>*> intOuts = m_connectedInternalsStaticVideosOutputs.getObjectsReferencesList() ; QList<OutSlot<LightVideoFrame>*>::iterator intOutsIt = intOuts.begin(); QList<OutSlot<LightVideoFrame>*>::iterator intOutsEnd = intOuts.end(); QQueue<EffectNode*> nodeQueue; EffectNode* toQueueNode; EffectNode* currentNode; InSlot<LightVideoFrame>* currentIn; for ( ; effectsNodesIt != effectsNodesEnd; ++effectsNodesIt ) { if ( ( (*effectsNodesIt)->getNBConnectedStaticsVideosInputs() == 0 ) && ( (*effectsNodesIt)->getNBConnectedStaticsVideosOutputs() > 0 ) ) { (*effectsNodesIt)->setVisited(); nodeQueue.enqueue( (*effectsNodesIt) ); } } for ( ; intOutsIt != intOutsEnd; ++intOutsIt ) { currentIn = (*intOutsIt)->getInSlotPtr(); toQueueNode = currentIn->getPrivateFather(); if ((toQueueNode != this) && ( toQueueNode->wasItVisited() == false )) { toQueueNode->setVisited(); nodeQueue.enqueue( toQueueNode ); } } while ( nodeQueue.empty() == false ) { currentNode = nodeQueue.dequeue(); QList<OutSlot<LightVideoFrame>*> outs = currentNode->getConnectedStaticsVideosOutputsList(); QList<OutSlot<LightVideoFrame>*>::iterator outsIt = outs.begin(); QList<OutSlot<LightVideoFrame>*>::iterator outsEnd = outs.end(); currentNode->render(); for ( ; outsIt != outsEnd; ++outsIt ) { currentIn = (*outsIt)->getInSlotPtr(); toQueueNode = currentIn->getPrivateFather(); if ((toQueueNode != this) && ( toQueueNode->wasItVisited() == false )) { toQueueNode->setVisited(); nodeQueue.enqueue( toQueueNode ); } } } }
QRect ImageOverlayRegionFinder::growRegion(int row, int column, QBitArray &mask) { QRect region; region.setCoords(column, row, column, row); QQueue<int> queue; queue.enqueue(getDataIndex(row, column)); while (!queue.isEmpty()) { int i = queue.dequeue(); if (m_overlay.getData()[i] > 0 && !mask.testBit(i)) { mask.setBit(i); row = getRowIndex(i); column = getColumnIndex(i); if (row < region.top()) { region.setTop(row); } if (row > region.bottom()) { region.setBottom(row); } if (column < region.left()) { region.setLeft(column); } if (column > region.right()) { region.setRight(column); } if (column - 1 >= 0) { queue.enqueue(getDataIndex(row, column - 1)); } if (column + 1 < static_cast<signed>(m_overlay.getColumns())) { queue.enqueue(getDataIndex(row, column + 1)); } if (row - 1 >= 0) { queue.enqueue(getDataIndex(row - 1, column)); } if (row + 1 < static_cast<signed>(m_overlay.getRows())) { queue.enqueue(getDataIndex(row + 1, column)); } } } return region; }
/*! * \brief DrawingArea::fillArea - Залить область. * \param point Точка начала заливки. * \param act Цвет области, которую нужно залить. * * Заливает область пользовательским цветом, ограниченную линией другого цвета. * Для заливки используется floodFill алгоритм, использующий очередь из точек и * продвигающийся по четырем направлениям. */ void DrawingArea::fillArea(const QPoint &point, QColor act) { QPainter painter(&image); printf("painтттting!!!1\n"); QPen myPen(myPenColor); myPen.setWidth(1); painter.setPen(myPen); QQueue<QPoint> pixels; pixels.enqueue(point); while(pixels.isEmpty() == 0) { QPoint newPoint = pixels.dequeue(); QColor actual; actual.fromRgb(image.pixel(newPoint)); if(actual == act) { painter.drawPoint(newPoint); update(); QPoint left((newPoint.x()-1), newPoint.y()); if(left.x() >0 && left.x() < image.width() && image.pixel(left) == act.rgb()) { pixels.enqueue(left); painter.drawPoint(left); update(); } QPoint right((newPoint.x()+1), newPoint.y()); if(right.x() > 0 && right.x() < image.width() && image.pixel(right) == act.rgb()) { pixels.enqueue(right); painter.drawPoint(right); update(); } QPoint up((newPoint.x()), (newPoint.y()-1)); if(up.y() > 0 && up.y() < image.height() && image.pixel(up) == act.rgb()) { pixels.enqueue(up); painter.drawPoint(up); update(); } QPoint down((newPoint.x()), (newPoint.y()+1)); if(down.y() > 0 && down.y() < image.height() && image.pixel(down) == act.rgb()) { pixels.enqueue(down); painter.drawPoint(down); update(); } } } }
void FileAnalyzer::handlePlaylistFiles(void) { QQueue<QVariant> queue; QStringList importedFromPlaylist; //Import playlist files into "hierarchical" list while(!m_inputFiles.isEmpty()) { const QString currentFile = m_inputFiles.takeFirst(); QStringList importedFiles; if(PlaylistImporter::importPlaylist(importedFiles, currentFile)) { queue.enqueue(importedFiles); importedFromPlaylist << importedFiles; } else { queue.enqueue(currentFile); } } //Reduce temporary list importedFromPlaylist.removeDuplicates(); //Now build the complete "flat" file list (files imported from playlist take precedence!) while(!queue.isEmpty()) { const QVariant current = queue.dequeue(); if(current.type() == QVariant::String) { const QString temp = current.toString(); if(!importedFromPlaylist.contains(temp, Qt::CaseInsensitive)) { SAFE_APPEND_STRING(m_inputFiles, temp); } } else if(current.type() == QVariant::StringList) { const QStringList temp = current.toStringList(); for(QStringList::ConstIterator iter = temp.constBegin(); iter != temp.constEnd(); iter++) { SAFE_APPEND_STRING(m_inputFiles, (*iter)); } } else { qWarning("Encountered an unexpected variant type!"); } } }
QSet<QPoint> RedEyeDetection::expandRedEye(const QImage &image, const QPoint ¢er, const QRect &area) const { QSet<QPoint> visited, included; QQueue<QPoint> active; visited << center; included << center; active.enqueue(center); QPoint neighbors[8]; while (!active.isEmpty()) { QPoint point = active.dequeue(); neighbors[0] = point+QPoint(-1, -1); neighbors[1] = point+QPoint(0, -1); neighbors[2] = point+QPoint(+1, -1); neighbors[3] = point+QPoint(-1, 0); neighbors[4] = point+QPoint(+1, 0); neighbors[5] = point+QPoint(-1, +1); neighbors[6] = point+QPoint(0, +1); neighbors[7] = point+QPoint(+1, +1); for (int i=0; i<8; i++) { if (!visited.contains(neighbors[i])) { visited << neighbors[i]; // Mark only red neighbors as active and included if (isRedEyePixel(image.pixel(neighbors[i]))) { included << neighbors[i]; active.enqueue(neighbors[i]); if (!area.contains(neighbors[i], true)) { included.clear(); active.clear(); break; } } } } } return included; }
void QuickAndroidTests::loading() { QStringList res; QQueue<QString> queue; queue.enqueue(":/QuickAndroid"); QQmlEngine engine; engine.addImportPath("qrc:///"); while (queue.size()) { QString path = queue.dequeue(); QDir dir(path); QFileInfoList infos = dir.entryInfoList(QStringList()); for (int i = 0 ; i < infos.size();i++) { QFileInfo info = infos.at(i); if (info.fileName() == "." || info.fileName() == "..") continue; if (info.isDir()) { queue.enqueue(info.absoluteFilePath()); continue; } QUrl url = info.absoluteFilePath().remove(0,1); url.setScheme("qrc"); if (info.suffix() != "qml") { continue; } QFile file(":" + url.path()); QVERIFY(file.open(QIODevice::ReadOnly)); QString content = file.readAll(); content = content.toLower(); // Skip singleton module as it can not be loaded directly if (content.indexOf("pragma singleton") != -1) { qDebug() << QString("%1 : Skipped (singleton)").arg(url.toString()); continue; } QQmlComponent comp(&engine); comp.loadUrl(url); if (comp.isError()) { qDebug() << QString("%1 : Load Failed. Reason : %2").arg(info.absoluteFilePath()).arg(comp.errorString()); } QVERIFY(!comp.isError()); qDebug() << QString("%1 : Passed").arg(info.absoluteFilePath()); } } }
void OpenstreetmapMapProvider::getTiles(const QGeoCoordinate& topleft, int zoomLevel, int width, int height) { cancelDownload(); double tilex_exact = long2tilex(topleft.longitude(), zoomLevel); double tiley_exact = lat2tiley(topleft.latitude(), zoomLevel); int x_start = (int)floor(tilex_exact); int y_start = (int)floor(tiley_exact); int x_end = (int)floor(tilex_exact) + width / TILE_DIMENSION + 1; int y_end = (int)floor(tiley_exact) + height / TILE_DIMENSION + 1; QQueue<Tile> list; for (int y = y_start; y <= y_end; y++) { for (int x = x_start; x <= x_end; x++) { Tile info; info.x = x * TILE_DIMENSION; info.y = y * TILE_DIMENSION; info.w = TILE_DIMENSION; info.h = TILE_DIMENSION; info.zoom = zoomLevel; list.enqueue(info); } } startDownload(list); }
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 }
bool DiscardDeint::filter(QQueue<FrameBuffer> &framesQueue) { addFramesToDeinterlace(framesQueue); if (!internalQueue.isEmpty()) { FrameBuffer dequeued = internalQueue.dequeue(); VideoFrame &videoFrame = dequeued.frame; const bool TFF = isTopFieldFirst(videoFrame); videoFrame.setNoInterlaced(); for (int p = 0; p < 3; ++p) { const int linesize = videoFrame.linesize[p]; quint8 *data = videoFrame.buffer[p].data(); const int lines = (videoFrame.size.getHeight(p) >> 1) - 1; if (!TFF) { memcpy(data, data + linesize, linesize); data += linesize; } data += linesize; for (int i = 0; i < lines; ++i) { VideoFilters::averageTwoLines(data, data - linesize, data + linesize, linesize); data += linesize << 1; } if (TFF) memcpy(data, data - linesize, linesize); } framesQueue.enqueue(dequeued); }
static void enqueueNodeList(QQueue<QDomNode> &queue, const QDomNodeList &list) { for (int i = 0; i < list.count(); ++i) { queue.enqueue(list.at(i)); } }
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); }
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; }
void WallTransformer::transform(Game *game) { QSharedPointer<Board> board = game->getBoard(); foreach(const QSharedPointer<Snake> &snake, board->getSnakes()) { QQueue<QPoint> body = snake->getBody(); QPoint head = body.last(); if (head.y() < 0) { head.setY(board->getHeight() - 1); } else if (head.y() >= board->getHeight()) { head.setY(0); } if (head.x() < 0) { head.setX(board->getWidth() - 1); } else if (head.x() >= board->getWidth()) { head.setX(0); } if (head != body.last()) { body.pop_back(); body.enqueue(head); snake->setBody(body); } } }
void VisualSubtreeHighlighter::UpdateSubtreeExtents() { if(!m_node || !isVisible()) return; prepareGeometryChange(); QRectF bb = m_node->boundingRect(); float xMin = bb.left() + m_node->x(); float xMax = bb.right() + m_node->x(); float yMin = bb.top() + m_node->y(); float yMax = bb.bottom() + m_node->y(); QQueue<VisualNode*> queue; queue.enqueue(m_node); while(!queue.empty()) { VisualNode* node = queue.dequeue(); if(node->IsCollapsed() || node->IsLeaf()) { QRectF bb = node->boundingRect(); if(bb.left() + node->x() < xMin) xMin = bb.left() + node->x(); if(bb.right() + node->x() > xMax) xMax = bb.right() + node->x(); if(bb.top() + node->y() < yMin) yMin = bb.top() + node->y(); if(bb.bottom() + node->y() > yMax) yMax = bb.bottom() + node->y(); } else // not collapsed and not a leaf node { foreach(VisualNode* child, node->GetChildren()) queue.enqueue(child); } } m_extents = QRectF(xMin - HIGHLIGHTER_OFFSET, yMin - HIGHLIGHTER_OFFSET, (xMax-xMin) + 2*HIGHLIGHTER_OFFSET, (yMax-yMin) + 2*HIGHLIGHTER_OFFSET); update(); }
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(); }
void HttpWindow::downloadFile() { const QString urlSpec = "http://www.youtubeinmp3.com/fetch/?video=" + urlLineEdit->text().trimmed(); if (urlSpec.isEmpty()) return; const QUrl newUrl = QUrl::fromUserInput(urlSpec); if (!newUrl.isValid()) { QMessageBox::information(this, tr("Error"), tr("Invalid URL: %1: %2").arg(urlSpec, newUrl.errorString())); return; } QString fileName = newUrl.fileName(); if (fileName.isEmpty()) fileName = defaultFileLineEdit->text().trimmed(); if (fileName.isEmpty()) fileName = defaultFileName; QString downloadDirectory = QDir::cleanPath(downloadDirectoryLineEdit->text().trimmed()); if (!downloadDirectory.isEmpty() && QFileInfo(downloadDirectory).isDir()) fileName.prepend(downloadDirectory + '/'); if (QFile::exists(fileName)) { if (QMessageBox::question(this, tr("Overwrite Existing File"), tr("There already exists a file called %1 in " "the current directory. Overwrite?").arg(fileName), QMessageBox::Yes|QMessageBox::No, QMessageBox::No) == QMessageBox::No) return; QFile::remove(fileName); } file = openFileForWrite(fileName); if (!file) return; downloadButton->setEnabled(false); // schedule the request //Download QQueue if (songBeingDownloaded == true)//song is being downloaded currently songsThatNeedToBeDownloaded.enqueue(newUrl); else startRequest(newUrl); /** else if (!songsThatNeedToBeDownloaded.isEmpty()) { songsThatNeedToBeDownloaded.enqueue(newUrl); while (!songsThatNeedToBeDownloaded.isEmpty() && songBeingDownloaded == false) { QUrl tempURL = songsThatNeedToBeDownloaded.dequeue(); startRequest(tempURL); } } else startRequest(newUrl); */ }
QHash<Cell*, QSet<char> > Grid::fixArcConsistency(Cell* dirtyCell) { QHash<Cell*, QSet<char> > changes; QQueue<Cell*> dirtyCells; // initialize the set of cells to check // if no dirty cell specified, assume all are dirty if( dirtyCell != nullptr ){ auto depCells = dirtyCell->dependentCells(); for( auto dep=depCells.constBegin(); dep!=depCells.constEnd(); ++dep ) { dirtyCells.enqueue(*dep); } } else { for( int i=0; i<cells.count(); i++ ){ dirtyCells.enqueue( cells.at(i) ); } } // loop until there are no more dirty cells while( !dirtyCells.empty() ) { // update domain of dirty cell Cell* cell = dirtyCells.dequeue(); QSet<char> cellChanges = cell->restrictDomain(); // if the domain changes if( !cellChanges.empty() ) { // add changes to the running diff changes[cell] += cellChanges; // add dependents to queue auto depCells = cell->dependentCells(); for( auto dep=depCells.constBegin(); dep!=depCells.constEnd(); ++dep ) { dirtyCells.enqueue(*dep); } } // else nothing to be done } return changes; }
/// \brief Format and send a log message into the queue. This is called from /// the LOG() macro. The intention is minimal blocking of the caller. /// \param mask Verbosity mask of the message (VB_*) /// \param level Log level of this message (LOG_* - matching syslog levels) /// \param file Filename of source code logging the message /// \param line Line number within the source of log message source /// \param function Function name of the log message source /// \param fromQString true if this message originated from QString /// \param format printf format string (when not from QString), log message /// (when from QString) /// \param ... printf arguments (when not from QString) void LogPrintLine( uint64_t mask, LogLevel_t level, const char *file, int line, const char *function, int fromQString, const char *format, ... ) { va_list arguments; int type = kMessage; type |= (mask & VB_FLUSH) ? kFlush : 0; type |= (mask & VB_STDIO) ? kStandardIO : 0; LoggingItem *item = LoggingItem::create(file, function, line, level, (LoggingType)type); if (!item) return; char *formatcopy = NULL; if( fromQString && strchr(format, '%') ) { QString string(format); format = strdup(string.replace(logRegExp, "%%").toLocal8Bit() .constData()); formatcopy = (char *)format; } va_start(arguments, format); vsnprintf(item->m_message, LOGLINE_MAX, format, arguments); va_end(arguments); if (formatcopy) free(formatcopy); QMutexLocker qLock(&logQueueMutex); #if defined( _MSC_VER ) && defined( _DEBUG ) OutputDebugStringA( item->m_message ); OutputDebugStringA( "\n" ); #endif logQueue.enqueue(item); if (logThread && logThreadFinished && !logThread->isRunning()) { while (!logQueue.isEmpty()) { item = logQueue.dequeue(); qLock.unlock(); logThread->handleItem(item); logThread->logConsole(item); item->DecrRef(); qLock.relock(); } } else if (logThread && !logThreadFinished && (type & kFlush)) { logThread->flush(); } }
inline void addLetterToQueue(QQueue<letter_node *> & queue, node * current_node) { QVector<letter_node* > current_letter_children = current_node->getLetterChildren(); int num_letter = current_letter_children.count(); for(int i=0; i< num_letter; i++) { if(current_letter_children[i] != NULL) { queue.enqueue(current_letter_children[i]); } } return; }
void StemEnumerate::traverse(ATTrie::Position pos) { QChar jeem = QChar(0x062C); QChar ghain = QChar(0x063A); QChar kaf = QChar(0x0643); QVector<QChar> letters; letters << hamza << alef_madda_above << alef_hamza_above << waw_hamza_above << alef_hamza_below << ya2_hamza_above << alef << ba2 << ta2_marbouta << ta2 << tha2 << jeem << _7a2 << kha2 << dal << thal << ra2 << zain << seen << sheen << sad << dad << tah << zah << _3yn << ghain << feh << qaf << kaf << lam << meem << noon << ha2 << waw << alef_maksoura << ya2 << alef_wasla; QQueue<ATTrie::Position> queue; queue.enqueue(pos); while(!queue.isEmpty()) { ATTrie::Position current_pos = queue.dequeue(); for(int i=0; (i< letters.count()) & (!stop); i++) { QChar current_letter = letters[i]; if (trie->isWalkable(current_pos,current_letter)) { ATTrie::Position temp_pos = trie->clonePosition(current_pos); trie->walk(temp_pos, current_letter); queue.enqueue(temp_pos); check_for_terminal(temp_pos); const StemNode * node=NULL; if (trie->isTerminal(temp_pos)) { ATTrie::Position pos2 = trie->clonePosition(temp_pos); trie->walk(pos2, '\0'); node = trie->getData(pos2); trie->freePosition(pos2); if (node != NULL) { } } } } trie->freePosition(current_pos); } }
QVector< QVector<Structure::Node*> > Structure::Graph::getComponents() { QVector< QVector<Structure::Node*> > cs; // set tag QString visitedTag = "visitedtagforgraphcomponent"; for (Node* n : nodes) n->removeTag(visitedTag); // find all components for (Node* n : nodes) { if (n->hasTag(visitedTag)) continue; // nodes connecting to n QVector<Node*> component; QQueue<Node*> activeNodes; activeNodes.enqueue(n); while (!activeNodes.isEmpty()) { Node* curr = activeNodes.dequeue(); component << curr; curr->addTag(visitedTag); for (Node* nei : getNeighbourNodes(curr)) { if (!nei->hasTag(visitedTag)) { activeNodes.enqueue(nei); nei->addTag(visitedTag); } } } // store cs << component; } // clean up for (Node* n : nodes) n->removeTag(visitedTag); return cs; }
bool UpdateClient::copyFiles(const QDir &srcDir, const QDir &destDir) { bool withoutErrors = true; if (!srcDir.exists()) return false; // list all directories QStringList entries = srcDir.entryList(QDir::NoDotAndDotDot | QDir::Dirs | QDir::Files); QQueue<FileToCopyInfo> files; foreach (QString entry, entries) { QFileInfo entryInfo(QString("%1/%2").arg(srcDir.path()).arg(entry)); if (entryInfo.isSymLink()) continue; if (entryInfo.isDir()) { QDir nextSrcDir(srcDir); QDir nextDestDir(destDir); //change directory deeper nextSrcDir.cd(entryInfo.fileName()); //if can't change destination directory (probably doesn't exists) if (!nextDestDir.cd(entryInfo.fileName())) { // create directory nextDestDir.mkpath(entryInfo.fileName()); //try change directory if (!nextDestDir.cd(entryInfo.fileName())) { //stop copy and return return false; } } // go deeper withoutErrors &= copyFiles(nextSrcDir, nextDestDir); } else { FileToCopyInfo fileInfo; fileInfo.srcDir = srcDir.path(); fileInfo.destDir = destDir.path(); fileInfo.fileName = entryInfo.fileName(); files.enqueue(fileInfo); } }
void TreeWidgetEditor::moveColumns(int fromColumn, int toColumn, int step) { ui.treeWidget->blockSignals(true); moveColumnItems(treeHeaderPropList, ui.treeWidget->headerItem(), fromColumn, toColumn, step); 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)); moveColumnItems(treeItemColumnPropList, item, fromColumn, toColumn, step); } ui.treeWidget->blockSignals(false); }
inline bool addLetterToQueue(QQueue<letter_node *> &queue, QQueue<letter_node *> &queue_emptyCharacters, node *current_node, QChar future_letter) { bool added = false; letter_node *let_node = current_node->getLetterChild(future_letter); if (let_node != NULL) { queue.enqueue(let_node); added = true; } if (future_letter != '\0') { //just needed to traverse also the empty character always QChar l = '\0'; let_node = current_node->getLetterChild(l); if (let_node != NULL) { queue_emptyCharacters.enqueue(let_node); } } return added; }