本文整理汇总了C++中QQueue类的典型用法代码示例。如果您正苦于以下问题:C++ QQueue类的具体用法?C++ QQueue怎么用?C++ QQueue使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QQueue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cancelDownload
void OpenstreetmapMapProvider::getTile(const QGeoCoordinate& coord,
int zoomLevel)
{
cancelDownload();
double tilex_exact = long2tilex(coord.longitude(), zoomLevel);
double tiley_exact = lat2tiley(coord.latitude(), zoomLevel);
Tile info;
info.x = tilex_exact;
info.y = tiley_exact;
info.w = TILE_DIMENSION;
info.h = TILE_DIMENSION;
info.zoom = zoomLevel;
QQueue<Tile> queue;
queue.enqueue(info);
startDownload(queue);
}
示例2: moveColumnItems
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);
}
示例3: printQueue
void AbstractLexer::printQueue(const QQueue<TOKEN>& q) const
{
QStringList res;
foreach(const TOKEN& t, q)
{
if(m_longOperators.values().contains(t.type)) res += m_longOperators.key(t.type);
else if(m_operators.values().contains(t.type)) res += m_operators.key(t.type);
else res+= (t.val + ';' + QString::number(t.type) + error());
}
qDebug() << q.count() << ":::" << "(" << res.join(QStringLiteral("|")) << ")";
}
示例4: deserializeItems
void RecentItemsModel::deserializeItems(const QString &serialized) {
LOG_DEBUG << "#";
QByteArray originalData;
originalData.append(serialized.toLatin1());
QByteArray serializedBA = QByteArray::fromBase64(originalData);
// historical reasons to have QQueue there
// now only thing left is to be backward compatible
QQueue<QString> items;
QDataStream ds(&serializedBA, QIODevice::ReadOnly);
ds >> items;
Q_ASSERT(m_LRUcache.size() == 0);
for (auto it = items.rbegin(); it != items.rend(); it++) {
m_LRUcache.put(*it, 0);
}
rebuild();
emit recentItemsCountChanged();
}
示例5: QLatin1String
DisassemblerModelItem DisassemblerModel::decodeInstruction(word *currentPC)
{
DisassemblerModelItem newItem;
QTextStream resultStream;
QString result;
resultStream.setString(&result, QIODevice::WriteOnly);
byte readByte = d->controller->memory()->readByte( *currentPC );
DisassemblerEntry entry = disassemblerTable[readByte];
newItem.ramIndex = *currentPC;
newItem.opcodeSize = entry.numBytes;
// Print the RAM address
resultStream << "0x" << QString::number( static_cast<int>(*currentPC), 16) << QLatin1String(": ");
// Fetch the values (if any)
QQueue<byte> values;
int numBytesToFetch = entry.numBytes-1;
for(int i=0; i<numBytesToFetch; i++)
{
values.enqueue( d->controller->memory()->readByte( ++(*currentPC) ) );
}
// Output bytes
QString tempNumber = QString::number(readByte,16).toUpper();
if(tempNumber.size() == 1)
{
tempNumber.prepend('0');
}
resultStream << ' ' << tempNumber << ' ';
foreach(byte argByte, values)
{
QString tempNumber = QString::number(argByte,16).toUpper();
if(tempNumber.size() == 1)
{
tempNumber.prepend('0');
}
resultStream << tempNumber << ' ';
}
示例6: breadthSearch
void Algorithms::breadthSearch(Vertex * firstVertex, GraphSearchWorker *worker)
{
if(firstVertex == nullptr || worker == nullptr) {
return;
}
QQueue<Edge *> edgeQueue;
QSet<int> visitedVertexId;
Edge * tmpEdge;
worker->firstVertex(firstVertex);
visitedVertexId.insert(firstVertex->id());
// firstVertex->setBitToken(0, true);
for(Edge *edge : firstVertex->outEdges()) {
// qDebug() << "111";
edgeQueue.append(edge);
}
while( !edgeQueue.empty() ) {
tmpEdge = edgeQueue.takeFirst();
// qDebug() << tmpEdge->vertex()->id();
if(visitedVertexId.contains(tmpEdge->targetVertex()->id())) {
// qDebug() << "if" << tmpEdge->vertex()->id() << edgeQueue.empty();
// if(tmpEdge->vertex()->bitToken(0) == true) {
continue;
}
worker->nextVertexEdge(tmpEdge);
if(worker->isEnd()) {
break;
}
visitedVertexId.insert(tmpEdge->targetVertex()->id());
for(Edge * edge : tmpEdge->targetVertex()->outEdges()) {
edgeQueue.append(edge);
}
}
worker->searchEnded();
}
示例7: EnterMoviesOnThread
void UBQuickTimeFile::run()
{
EnterMoviesOnThread(kCSAcceptThreadSafeComponentsOnlyMode);
mSouldStopCompression = false;
mPendingFrames = 0;
createCompressionSession();
mCompressionSessionRunning = true;
emit compressionSessionStarted();
while(!mSouldStopCompression)
{
frameQueueMutex.lock();
//qDebug() << "run .... wait" << QTime::currentTime();
frameBufferNotEmpty.wait(&UBQuickTimeFile::frameQueueMutex);
//qDebug() << "awakend ..." << QTime::currentTime();
if (!frameQueue.isEmpty())
{
QQueue<VideoFrame> localQueue = frameQueue;
frameQueue.clear();
frameQueueMutex.unlock();
while (!localQueue.isEmpty())
{
VideoFrame frame = localQueue.dequeue();
appendVideoFrame(frame.buffer, frame.timestamp);
}
}
else
{
frameQueueMutex.unlock();
}
}
flushPendingFrames();
}
示例8: addLetterToQueue
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;
}
示例9: tryConnectListList
QQueue<QString> Data::getListList()
{
tryConnectListList();
QQueue <QString> q;
QSqlQuery query;
query.exec("select * from listlist order by id;");
while (query.next())
{
q.push_back(query.value(0).toString());
qDebug() << "Get list" << query.value(1).toInt() << ":" << query.value(0).toString()<< endl;
}
if (q.size() == 0)
{
query.exec("insert into listlist"
"(name, id, count) values('默认列表', 0, 0);");
Data::changeListCount(1);
q.push_back(QString("默认列表"));
qDebug() << "Create list:默认列表" << endl;
}
return q;
}
示例10: readData
void MusicWindow::readData()
{
if (!Data::connectData()) return;
this->setBackgroud(Data::getCurrentBackground());
this->bottomBar->setPlayMode(Data::getPlayMode());
this->bottomBar->setSoundLevel(Data::getSoundLevel());
QQueue <QString> qq = Data::getListList();
QString listName;
QQueue <MusicInfo> q;
while (!qq.empty())
{
listName = qq.front();
qq.pop_front();
musicPage->createList(listName);
q = Data::getMusicList(listName);
musicPage->addMusics(Data::getListId(listName), q);
player->addMusics(listName, q);
}
musicPage->setCurrentList(0);
}
示例11: setMenu
void BFS::initializeAnimation(){
setMenu(false);
int r=255, g=255, b=0;
int color_step= 25;
m_operations.push_back([=,this](){ getNode(_currentNode)->setColor(QColor(r, g, b));colorNode(_currentNode); });
r-=color_step;
g-=color_step;
QQueue<int> queue;
queue.append(_currentNode);
getNode(_currentNode)->setVisited(true);
while(!queue.empty()){
int curr = queue.at(0);
queue.pop_front();
NodeList list = getNeighbours(curr);
for (auto iter : list){
if(!getNode(iter)->visited()){
getNode(iter)->setVisited(true);
m_operations.push_back([=,this](){getEdge(curr, iter)->setColor(QColor(r,g,b)); colorEdge(curr, iter); emit highlightLine(10);});
m_operations.push_back([=,this](){getNode(iter)->setColor(QColor(r,g,b)); colorNode(iter);});
queue.append(iter);
}
}
r-=color_step;
g-=color_step;
}
m_animationInitialized= true;
m_currentStepInAnimation= 0;
m_numberOfStepsInAnimation= m_operations.size();
}
示例12: propagateNeedsUpdate
void IPProcessGrid::propagateNeedsUpdate(IPLProcess* process)
{
QQueue<IPProcessStep*> tmpQueue;
// find step from process
for(auto it = _scene->steps()->begin(); it < _scene->steps()->end(); ++it)
{
IPProcessStep* step = (IPProcessStep*) *it;
IPLProcess* tmpProcess = step->process();
if(tmpProcess == process)
{
step->process()->requestUpdate();
tmpQueue.enqueue(step);
break;
}
}
// add all following processes via BFS
int counter = 0;
int limit = 100;
while(!tmpQueue.isEmpty() && counter < limit)
{
// set status
IPProcessStep* step = tmpQueue.dequeue();
for(auto it = step->edgesOut()->begin(); it < step->edgesOut()->end(); ++it)
{
IPProcessEdge* edge = (IPProcessEdge*) *it;
IPProcessStep* nextStep = edge->to();
nextStep->process()->requestUpdate();
// add to queue and list
tmpQueue.enqueue(nextStep);
}
}
}
示例13:
QQueue<CustomerSite> ControlThread::buildCustomerList()
{
QQueue<CustomerSite> newCustomerSiteQueue;
QSqlQuery customersitequery;
customersitequery.prepare("SELECT customer_sites.* FROM customer_sites INNER JOIN users ON customer_sites.user=users.id WHERE customer_sites.site=? AND active=1");
customersitequery.addBindValue(site_id);
customersitequery.exec();
if(customersitequery.isActive())
{
while(customersitequery.next()) {
CustomerSite site;
site.setId(customersitequery.record().value("id").toULongLong());
site.setUserId(customersitequery.record().value("user").toULongLong());
site.setRepeatTime(customersitequery.record().value("repeat_time").toUInt());
site.setLogSuccessful(customersitequery.record().value("log_successful").toBool());
site.setFullPage(customersitequery.record().value("full_page").toBool());
site.setName(customersitequery.record().value("name").toString());
site.setUrl(customersitequery.record().value("url").toString());
site.setMaxTimeOut(customersitequery.record().value("max_timeout").toUInt());
if(customersitequery.record().value("host").toString() != "")
{
site.setHost(customersitequery.record().value("host").toString());
}
else
{
site.setHost(QUrl(site.getUrl()).host());
}
site.setFetchRemote(customersitequery.record().value("fetch_remote").toBool());
site.setMonitorSiteId(site_id);
newCustomerSiteQueue.enqueue(site);
}
}
else {
// qDebug() << "ControlThread::BuildSiteList - Query Failed" << customersitequery.lastError().text();
}
return newCustomerSiteQueue;
}
示例14: moveColumnsRight
void TreeWidgetEditor::moveColumnsRight(int fromColumn, int toColumn)
{
if (fromColumn >= toColumn)
return;
QTreeWidgetItem *headerItem = ui.treeWidget->headerItem();
const QString text = headerItem->text(fromColumn);
const QIcon icon = headerItem->icon(fromColumn);
const QVariant data = headerItem->data(fromColumn, QAbstractFormBuilder::resourceRole());
for (int i = fromColumn; i < toColumn; i++) {
headerItem->setText(i, headerItem->text(i + 1));
headerItem->setIcon(i, headerItem->icon(i + 1));
headerItem->setData(i, QAbstractFormBuilder::resourceRole(), headerItem->data(i + 1, QAbstractFormBuilder::resourceRole()));
}
headerItem->setText(toColumn, text);
headerItem->setIcon(toColumn, icon);
headerItem->setData(toColumn, QAbstractFormBuilder::resourceRole(), data);
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));
const QString text = item->text(fromColumn);
const QIcon icon = item->icon(fromColumn);
const QVariant data = item->data(fromColumn, QAbstractFormBuilder::resourceRole());
for (int i = fromColumn; i < toColumn; i++) {
item->setText(i, item->text(i + 1));
item->setIcon(i, item->icon(i + 1));
item->setData(i, QAbstractFormBuilder::resourceRole(), item->data(i + 1, QAbstractFormBuilder::resourceRole()));
}
item->setText(toColumn, text);
item->setIcon(toColumn, icon);
item->setData(toColumn, QAbstractFormBuilder::resourceRole(), icon);
}
}
示例15: Q_ASSERT
Node *Node::getNode(const int index)
{
Q_ASSERT(index < getSize() && index >= 0);
// Check a valid index is given
if (index >= getSize() || index < 0)
return NULL;
// Do depth-first traversal until we reach the target index
QQueue<Node *> queue;
queue.enqueue(this);
for (int i = 0; i < index; i++)
{
Node *node = queue.dequeue();
foreach (Node *child, node->getChildren())
queue.enqueue(child);
}
return queue.front();
}