本文整理汇总了C++中QQueue::enqueue方法的典型用法代码示例。如果您正苦于以下问题:C++ QQueue::enqueue方法的具体用法?C++ QQueue::enqueue怎么用?C++ QQueue::enqueue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QQueue
的用法示例。
在下文中一共展示了QQueue::enqueue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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));
}
}
示例2:
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;
}
示例3: 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);
}
}
示例4: 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()));
}
}
}
}
}
示例5: 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;
}
示例6: 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();
}
示例7: while
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 );
}
}
}
}
示例8: growRegion
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;
}
示例9: fillArea
/*!
* \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();
}
}
}
}
示例10: while
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;
}
示例11: loading
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());
}
}
}
示例12: getTiles
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);
}
示例13: 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
}
示例14: filter
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);
}
示例15: enqueueNodeList
static void enqueueNodeList(QQueue<QDomNode> &queue, const QDomNodeList &list)
{
for (int i = 0; i < list.count(); ++i)
{
queue.enqueue(list.at(i));
}
}