void tst_QList::takeAt() const { QList<QString> list; list << "foo" << "bar" << "baz"; QCOMPARE(list.takeAt(0), QLatin1String("foo")); QVERIFY(list.size() == 2); QCOMPARE(list.takeAt(1), QLatin1String("baz")); QVERIFY(list.size() == 1); QCOMPARE(list.takeAt(0), QLatin1String("bar")); QVERIFY(list.size() == 0); }
static QList<int> reindexList(const GlobalConfig *config, Phonon::Category category, QList<int>newOrder, bool output) { Q_ASSERT(config); #ifdef QT_NO_PHONON_AUDIOCAPTURE Q_ASSERT(output); #endif /*QString sb; sb = QString("(Size %1)").arg(currentList.size()); foreach (int i, currentList) sb += QString("%1, ").arg(i); fprintf(stderr, "=== Reindex Current: %s\n", sb.toUtf8().constData()); sb = QString("(Size %1)").arg(newOrder.size()); foreach (int i, newOrder) sb += QString("%1, ").arg(i); fprintf(stderr, "=== Reindex Before : %s\n", sb.toUtf8().constData());*/ QList<int> currentList; if (output) currentList = config->audioOutputDeviceListFor(category, GlobalConfig::ShowUnavailableDevices|GlobalConfig::ShowAdvancedDevices); #ifndef QT_NO_PHONON_AUDIOCAPTURE else currentList = config->audioCaptureDeviceListFor(category, GlobalConfig::ShowUnavailableDevices|GlobalConfig::ShowAdvancedDevices); #endif QList<int> newList; foreach (int i, newOrder) { int found = currentList.indexOf(i); if (found < 0) { // It's not in the list, so something is odd (e.g. client error). Ignore it. continue; } // Iterate through the list from this point onward. If there are hidden devices // immediately following, take them too. newList.append(currentList.takeAt(found)); while (found < currentList.size()) { bool hidden = true; if (output) hidden = isHiddenAudioOutputDevice(config, currentList.at(found)); #ifndef QT_NO_PHONON_AUDIOCAPTURE else hidden = isHiddenAudioCaptureDevice(config, currentList.at(found)); #endif if (!hidden) break; newList.append(currentList.takeAt(found)); } }
void SelectableTextEditorWidget::setSelections(const QMap<int, QList<DiffSelection> > &selections) { m_diffSelections.clear(); for (auto it = selections.cbegin(), end = selections.cend(); it != end; ++it) { const QList<DiffSelection> diffSelections = it.value(); QList<DiffSelection> workingList; for (const DiffSelection &diffSelection : diffSelections) { if (diffSelection.start == -1 && diffSelection.end == 0) continue; if (diffSelection.start == diffSelection.end && diffSelection.start >= 0) continue; int j = 0; while (j < workingList.count()) { const DiffSelection existingSelection = workingList.takeAt(j); const QList<DiffSelection> newSelection = subtractSelection(existingSelection, diffSelection); for (int k = 0; k < newSelection.count(); k++) workingList.insert(j + k, newSelection.at(k)); j += newSelection.count(); } workingList.append(diffSelection); } m_diffSelections.insert(it.key(), workingList); } }
FlightTask* TaskFileManagerOld::loadTask( QString taskName, QString fileName ) { QList<FlightTask*> ftl; if( taskName.trimmed().isEmpty() || loadTaskList( ftl, fileName ) == false ) { return 0; } FlightTask* ft = 0; // Search desired task by name in list. for( int i = 0; i < ftl.size(); i++ ) { ft = ftl.at(i); if( ft->getTaskName() == taskName ) { // Take found element from the list. ft = ftl.takeAt(i); break; } } // Remove all allocated list members qDeleteAll(ftl); return ft; }
static void qt_qdnsmailexchangerecord_sort(QList<QDnsMailExchangeRecord> &records) { // If we have no more than one result, we are done. if (records.size() <= 1) return; // Order the records by preference. std::sort(records.begin(), records.end(), qt_qdnsmailexchangerecord_less_than); int i = 0; while (i < records.size()) { // Determine the slice of records with the current preference. QList<QDnsMailExchangeRecord> slice; const quint16 slicePreference = records.at(i).preference(); for (int j = i; j < records.size(); ++j) { if (records.at(j).preference() != slicePreference) break; slice << records.at(j); } // Randomize the slice of records. while (!slice.isEmpty()) { const unsigned int pos = QRandomGenerator::global()->bounded(slice.size()); records[i++] = slice.takeAt(pos); } } }
bool PlaylistModel::dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex & parent) { if (parent.internalId () != -1 && parent.isValid ()) { return false; } if (data->hasFormat ("application/x-xmms2poslist")) { if (!parent.isValid ()) return false; QByteArray ba = data->data ("application/x-xmms2poslist"); QDataStream stream (&ba, QIODevice::ReadOnly); QList<int> l; stream >> l; qSort (l); int target = parent.row (); int mod = 0; while (l.size ()) { int orow = l.takeAt (0) - mod; m_client->playlist ()->moveEntry (orow, target) (); if (orow < target) { mod ++; } else { target ++; } } return true; } else if (data->hasFormat ("application/x-xmms2mlibid")) {
void reorderGridLayout(QGridLayout* layout, int maxCols) { QList<QLayoutItem*> items; for (int i = 0; i < layout->rowCount(); i++) { for (int j = 0; j < layout->columnCount(); j++) { QLayoutItem* item = layout->itemAtPosition(i, j); if (item) { layout->removeItem(item); if (item->isEmpty()) { delete item; } else { items.append(item); } } } } int col = 0, row = 0; while (!items.isEmpty()) { QLayoutItem* item = items.takeAt(0); layout->addItem(item, row, col); col++; if (col >= maxCols) { col = 0; row++; } } }
QLayoutItem *GroupFlowLayout::takeAt(int index) { if (index >= 0 && index < itemList.size()) return itemList.takeAt(index); else return 0; }
//called during the validation of the client certificate. void OwncloudSetupPage::slotCertificateAccepted() { QSslCertificate sslCertificate; resultP12ToPem certif = p12ToPem(addCertDial->getCertificatePath().toStdString() , addCertDial->getCertificatePasswd().toStdString()); if(certif.ReturnCode){ QString s = QString::fromStdString(certif.Certificate); QByteArray ba = s.toLocal8Bit(); QList<QSslCertificate> sslCertificateList = QSslCertificate::fromData(ba, QSsl::Pem); sslCertificate = sslCertificateList.takeAt(0); _ocWizard->ownCloudCertificate = ba; _ocWizard->ownCloudPrivateKey = certif.PrivateKey.c_str(); _ocWizard->ownCloudCertificatePath = addCertDial->getCertificatePath(); _ocWizard->ownCloudCertificatePasswd = addCertDial->getCertificatePasswd(); AccountPtr acc = _ocWizard->account(); acc->setCertificate(_ocWizard->ownCloudCertificate, _ocWizard->ownCloudPrivateKey); addCertDial->reinit(); validatePage(); } else { QString message; message = certif.Comment.c_str(); addCertDial->showErrorMessage(message); addCertDial->show(); } }
void Preferences::updateDroppedUserLayouts(int newRow, int oldRow) { int userLayoutIndex = this->m_Data[UserLayoutIndex].toInt(); QList<QVariant> userLayouts = this->m_Data[UserLayouts].toList(); QVariant name = userLayouts.takeAt(oldRow*2); QVariant data = userLayouts.takeAt(oldRow*2); userLayouts.insert(newRow*2, data); userLayouts.insert(newRow*2, name); if (userLayoutIndex != -1) { if (userLayoutIndex == oldRow) userLayoutIndex = newRow; else { if ((newRow > oldRow) && (oldRow < userLayoutIndex)) userLayoutIndex -= 1; else if ((newRow < oldRow) && (newRow < userLayoutIndex)) userLayoutIndex += 1; } } this->m_Data[UserLayoutIndex] = userLayoutIndex; this->m_Data[UserLayouts] = userLayouts; };
void StackMaze::generate() { // Generate cell lists m_visited = QVector< QVector<bool> >(columns(), QVector<bool>(rows())); QList<QPoint> active; // Start maze QPoint start(0, randomInt(rows())); m_visited[start.x()][start.y()] = true; active.append(start); // Loop through active list QPoint cell, neighbor; int pos; while (!active.isEmpty()) { pos = nextActive(active.size()); cell = active.at(pos); neighbor = randomNeighbor(m_visited, cell); if (neighbor.x() != -1) { mergeCells(cell, neighbor); active.append(neighbor); } else { active.takeAt(pos); } } m_visited.clear(); }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- QList<caf::PdmOptionItemInfo> RimCellPropertyFilter::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) { QList<caf::PdmOptionItemInfo> optionItems = resultDefinition->calculateValueOptions(fieldNeedingOptions, useOptionsOnly); std::vector<int> indicesToRemove; for (int i = 0; i < optionItems.size(); i++) { QString text = optionItems[i].optionUiText; if (RimDefines::isPerCellFaceResult(text)) { indicesToRemove.push_back(i); } } std::sort(indicesToRemove.begin(), indicesToRemove.end()); std::vector<int>::reverse_iterator rit; for (rit = indicesToRemove.rbegin(); rit != indicesToRemove.rend(); ++rit) { optionItems.takeAt(*rit); } return optionItems; }
QList<ESIndividual*> ESMarriage::doMarriage(const QList<ESIndividual*> &parents, int rho, const ESInformation &information) { QList<ESIndividual*> marriagedParents; // list with indexes from the possible parents QList<int> possibleParents; for(int i = 0; i < rho; i++) { // generate list with indexes of possible parents if it is empty if(possibleParents.size() <= 0) { for(int i = 0; i < parents.size();i++){ possibleParents.append(i); } } // select a random parent and delete it from the list of possible parents int currentParentIndex = Random::nextInt(possibleParents.size()); marriagedParents.append(parents.at(possibleParents.takeAt(currentParentIndex))); } return marriagedParents; }
void Chromosome::setElements(QList <QPointFWithParent> points,bool random){ int pos=0,i=0,size=points.size(); QList <QPointFWithParent> newChrom; MySize=points.size(); //newChrom.clear(); while (i<MySize){ size=points.size(); ///note: to prevent takin pos out of list range we update size every time we take a value if (random){ pos=qrand()%size; } else{ pos=i; } newChrom.append(points.takeAt(pos)); //if (i%2==1) { /// time to compute the distance ///FIXME: manage to store the distances matrix to recal it when neede instead of recomputing the values ///every time we need them, or is it a time wasting operation to be droped ? // routeLength+=dist(newChrom.at(i),newChrom.at(i-1)); //} i++; } elements =newChrom; setRoutelength(); //setFitness(routeLength); //qDebug()<<"route length"<<routeLength; }
foreach( const QString &key, keys ) { // --- commit the albums as compilation or normal album QList<CollectionScanner::Album*> albums = m_albumNames.values( key ); // debug() << "commit got" <<albums.count() << "x" << key; // if we have multiple albums with the same name, check if it // might be a compilation for( int i = albums.count() - 1; i >= 0; --i ) { CollectionScanner::Album *album = albums.at( i ); // commit all albums with a track with the noCompilation flag if( album->isNoCompilation() || nonCompilationAlbumNames.contains( album->name(), Qt::CaseInsensitive ) ) commitAlbum( albums.takeAt( i ) ); } // only one album left. It's no compilation. if( albums.count() == 1 ) { commitAlbum( albums.takeFirst() ); } // compilation else if( albums.count() > 1 ) { CollectionScanner::Album compilation( key, QString() ); for( int i = albums.count() - 1; i >= 0; --i ) { CollectionScanner::Album *album = albums.takeAt( i ); foreach( CollectionScanner::Track *track, album->tracks() ) compilation.addTrack( track ); compilation.setCovers( album->covers() + compilation.covers() ); } commitAlbum( &compilation ); } // --- unblock every 5 second. Maybe not really needed, but still nice if( blockedTime.secsTo( QDateTime::currentDateTime() ) >= 5 ) { unblockUpdates(); blockedTime = QDateTime::currentDateTime(); blockUpdates(); } }
void SearchDialog::toggleItems(bool enabled) { QCheckBox *checkBox = qobject_cast<QCheckBox*>(sender()); for (QListView *list : this->findChildren<QListView*>()) { QStandardItemModel *m = qobject_cast<QStandardItemModel*>(list->model()); // Hiding / restoring items has to be done in 2-steps // First step is for finding items that are about to be moved // Second step is for iterating backward on marked items -> you cannot remove items on a single for loop if (enabled) { // Restore hidden items for every list QList<QStandardItem*> items = _hiddenItems.value(list); QList<int> indexes; for (int i = 0; i < items.size(); i++) { QStandardItem *item = items.at(i); // Extract only matching items if (item->data(AbstractSearchDialog::DT_Origin) == checkBox->text()) { indexes.prepend(i); } } // Moving back from hidden to visible for (int i = 0; i < indexes.size(); i++) { QStandardItem *item = items.takeAt(indexes.at(i)); m->appendRow(item); } // Replace existing values with potentially empty list _hiddenItems.insert(list, items); m->sort(0); } else { // Hide items for every list QStandardItemModel *m = qobject_cast<QStandardItemModel*>(list->model()); QList<QStandardItem*> items; QList<QPersistentModelIndex> indexes; for (int i = 0; i < m->rowCount(); i++) { QStandardItem *item = m->item(i, 0); if (item->data(AbstractSearchDialog::DT_Origin).toString() == checkBox->text()) { indexes << m->index(i, 0); // Default copy-constructor is protected! QStandardItem *copy = new QStandardItem(item->text()); copy->setData(checkBox->text(), AbstractSearchDialog::DT_Origin); copy->setIcon(item->icon()); items.append(copy); } } for (const QPersistentModelIndex &i : indexes) { m->removeRow(i.row()); } // Finally, hide selected items if (!items.isEmpty()) { QList<QStandardItem*> hItems = _hiddenItems.value(list); hItems.append(items); _hiddenItems.insert(list, hItems); } } } }
QPair<int, QObject*> takeObjectInWList(int id) { for (int i=0; i<waitingCtrlMsgs.size(); i++) { if (waitingCtrlMsgs.at(i).first == id) return waitingCtrlMsgs.takeAt(i); } return QPair<int, QObject*>(-1,0); }
~QGLSgImageTextureCleanup() { QList<qint64> keys = m_cache.keys(); while(keys.size() > 0) { QGLPixmapData *data = m_cache.take(keys.takeAt(0)); if (data) data->destroyTexture(); } }
void MainWindow::on_pushButton_randomize_clicked() { QList<qint8> availableValues; for(qint8 i=0; i<_solver->getDimension()*_solver->getDimension(); ++i) { availableValues.append(i); } foreach(QSpinBox * sb, _spinBoxes) { sb->setValue(availableValues.takeAt(qrand() % availableValues.count()) + 1); }
QLayoutItem *takeAt(int i) { bool aboutToTakeSOI = false; if (i == zoomedIndex) aboutToTakeSOI = true; Wrapper * w = list.takeAt(i); if (!w) return NULL; if (aboutToTakeSOI) zoomedIndex = -1; QWidgetItem * item = w->item; delete w; return item; }
void ToolBar::randomize() { QList<QAction *> randomized; QList<QAction *> actions = this->actions(); while (!actions.isEmpty()) { QAction *action = actions.takeAt(rand() % actions.size()); randomized.append(action); } clear(); addActions(randomized); orderAction->setEnabled(true); }
/** * @brief CardUtil::dealCard 发牌 * @param myList * @param leftList * @param rightList */ void CardUtil::dealCard(QList<CardItem *> &myList, QList<CardItem *> &leftList, QList<CardItem *> &rightList, QList<CardItem *> &bottomList) { QList<CardItem *> itemList = makeAllCard(); for(int i=0;i<17;i++){ qsrand(QTime::currentTime().msec()); int index = qrand()%(itemList.size()); CardItem *item = itemList.takeAt(index); item->isFront = true; item->setSelected(true); myList.append(item); qsrand(QTime::currentTime().msec()); index = qrand()%(itemList.size()); item = itemList.takeAt(index); leftList.append(item); qsrand(QTime::currentTime().msec()); index = qrand()%(itemList.size()); item = itemList.takeAt(index); rightList.append(item); } bottomList = itemList; }
QColor MoodLampManager::generateColor() { static QList<QColor> unselectedColors; if (unselectedColors.empty()) { for (int i = 0; i < ColorsMoodLampCount; i++) unselectedColors << m_colorsMoodLamp[i]; } int randIndex = PrismatikMath::rand(unselectedColors.size()); return unselectedColors.takeAt(randIndex); }
void SeamCarver::init(){ QList<QPolygon *> listLignes; QPoint item; int strengthValue; QList<int> listStrengthValue; QList<int> listOrderedStrengthValue; QPolygon *polyg; for(int h=0;h<imgOrigine->height();h++){ polyg = new QPolygon(); item = QPoint(0,h); *polyg << item; strengthValue = imA->getDyIndex(h,0); for (int w=1; w<(imgOrigine->width()-1); w++) { item = leastRouteNextPointAt(item,strengthValue); *polyg << item; } *polyg << QPoint(imgOrigine->width()-1,item.y()); listStrengthValue << strengthValue; listOrderedStrengthValue << strengthValue; listLignes <<polyg; } qSort(listOrderedStrengthValue); int strLeast; int index=1; int count=0; while((count <= NB_LIGNES_SEAM_CARVING)&&(index>0)) { strLeast = listOrderedStrengthValue.takeFirst(); index = listStrengthValue.indexOf(strLeast); listStrengthValue.takeAt(index); listLignesMostSuitable << listLignes.takeAt(index); count++; } qDeleteAll(listLignes); count=0; }
void SelectableTextEditorWidget::setSelections(const QMap<int, QList<DiffSelection> > &selections) { m_diffSelections.clear(); QMapIterator<int, QList<DiffSelection> > itBlock(selections); while (itBlock.hasNext()) { itBlock.next(); const QList<DiffSelection> diffSelections = itBlock.value(); QList<DiffSelection> workingList; for (int i = 0; i < diffSelections.count(); i++) { const DiffSelection &diffSelection = diffSelections.at(i); if (diffSelection.start == -1 && diffSelection.end == 0) continue; if (diffSelection.start == diffSelection.end && diffSelection.start >= 0) continue; int j = 0; while (j < workingList.count()) { const DiffSelection existingSelection = workingList.takeAt(j); const QList<DiffSelection> newSelection = subtractSelection(existingSelection, diffSelection); for (int k = 0; k < newSelection.count(); k++) workingList.insert(j + k, newSelection.at(k)); j += newSelection.count(); } workingList.append(diffSelection); } const int blockNumber = itBlock.key(); QVector<QTextLayout::FormatRange> selList; for (int i = 0; i < workingList.count(); i++) { const DiffSelection &diffSelection = workingList.at(i); if (diffSelection.format) { QTextLayout::FormatRange formatRange; formatRange.start = diffSelection.start; if (formatRange.start < 0) formatRange.start = 0; formatRange.length = diffSelection.end < 0 ? INT_MAX : diffSelection.end - diffSelection.start; formatRange.format = *diffSelection.format; if (diffSelection.end < 0) formatRange.format.setProperty(QTextFormat::FullWidthSelection, true); selList.append(formatRange); } } m_diffSelections.insert(blockNumber, workingList); } }
QRect QQuickContext2DTexture::createTiles(const QRect& window) { QList<QQuickContext2DTile*> oldTiles = m_tiles; m_tiles.clear(); if (window.isEmpty()) { return QRect(); } QRect r = tiledRect(window, adjustedTileSize(m_tileSize)); const int tw = m_tileSize.width(); const int th = m_tileSize.height(); const int h1 = window.left() / tw; const int v1 = window.top() / th; const int htiles = r.width() / tw; const int vtiles = r.height() / th; for (int yy = 0; yy < vtiles; ++yy) { for (int xx = 0; xx < htiles; ++xx) { int ht = xx + h1; int vt = yy + v1; QQuickContext2DTile* tile = 0; QPoint pos(ht * tw, vt * th); QRect rect(pos, m_tileSize); for (int i = 0; i < oldTiles.size(); i++) { if (oldTiles[i]->rect() == rect) { tile = oldTiles.takeAt(i); break; } } if (!tile) tile = createTile(); tile->setRect(rect); m_tiles.append(tile); } } qDeleteAll(oldTiles); return r; }
static void qt_qdnsservicerecord_sort(QList<QDnsServiceRecord> &records) { // If we have no more than one result, we are done. if (records.size() <= 1) return; // Order the records by priority, and for records with an equal // priority, put records with a zero weight first. std::sort(records.begin(), records.end(), qt_qdnsservicerecord_less_than); int i = 0; while (i < records.size()) { // Determine the slice of records with the current priority. QList<QDnsServiceRecord> slice; const quint16 slicePriority = records.at(i).priority(); unsigned int sliceWeight = 0; for (int j = i; j < records.size(); ++j) { if (records.at(j).priority() != slicePriority) break; sliceWeight += records.at(j).weight(); slice << records.at(j); } #ifdef QDNSLOOKUP_DEBUG qDebug("qt_qdnsservicerecord_sort() : priority %i (size: %i, total weight: %i)", slicePriority, slice.size(), sliceWeight); #endif // Order the slice of records. while (!slice.isEmpty()) { const unsigned int weightThreshold = QRandomGenerator::global()->bounded(sliceWeight + 1); unsigned int summedWeight = 0; for (int j = 0; j < slice.size(); ++j) { summedWeight += slice.at(j).weight(); if (summedWeight >= weightThreshold) { #ifdef QDNSLOOKUP_DEBUG qDebug("qt_qdnsservicerecord_sort() : adding %s %i (weight: %i)", qPrintable(slice.at(j).target()), slice.at(j).port(), slice.at(j).weight()); #endif // Adjust the slice weight and take the current record. sliceWeight -= slice.at(j).weight(); records[i++] = slice.takeAt(j); break; } } } } }
void InstallOperation::simplify(QList<InstallOperation*> ops) { for (int i = 0; i < ops.size(); ) { InstallOperation* op = ops.at(i); int found = -1; for (int j = i + 1; j < ops.size(); j++) { InstallOperation* op2 = ops.at(j); if (op->package == op2->package && op->version == op2->version && !op->install && op2->install) { found = j; break; } } if (found >= 0) { delete ops.takeAt(i); delete ops.takeAt(found); } else { i++; } } }
/** Maps to what groups the source row belongs by returning the data of those groups. * * @returns a list of data for the rows the argument belongs to. In common cases this list will * contain only one entry. An empty list means that the source item will be placed in the root of * this proxyModel. There is no support for hiding source items. * * Group data can be pre-loaded in the return value so it's added to the cache maintained by this * class. This is required if you want to have data that is not present in the source model. */ QList<RowData> QtGroupingProxy::belongsTo( const QModelIndex &idx ) { //qDebug() << __FILE__ << __FUNCTION__; QList<RowData> rowDataList; //get all the data for this index from the model ItemData itemData = sourceModel()->itemData( idx ); QMapIterator<int, QVariant> i( itemData ); while( i.hasNext() ) { i.next(); int role = i.key(); QVariant variant = i.value(); // qDebug() << "role " << role << " : (" << variant.typeName() << ") : "<< variant; if( variant.type() == QVariant::List ) { //a list of variants get's expanded to multiple rows QVariantList list = variant.toList(); for( int i = 0; i < list.length(); i++ ) { //take an existing row data or create a new one RowData rowData = (rowDataList.count() > i) ? rowDataList.takeAt( i ) : RowData(); //we only gather data for the first column ItemData indexData = rowData.contains( 0 ) ? rowData.take( 0 ) : ItemData(); indexData.insert( role, list.value( i ) ); rowData.insert( 0, indexData ); //for the grouped column the data should not be gathered from the children //this will allow filtering on the content of this column with a //QSortFilterProxyModel rowData.insert( m_groupedColumn, indexData ); rowDataList.insert( i, rowData ); } } else if( !variant.isNull() ) { //it's just a normal item. Copy all the data and break this loop. RowData rowData; rowData.insert( 0, itemData ); rowDataList << rowData; break; } } return rowDataList; }
void NetworkConnectorEngine::createConnectionsToNodesStoringPrivateMessages() { if ( iPrivateMessagePollWishList.size() == 0 ) { iProfileToPollPrivateMessages = KNullHash ; // no poll in progress } if ( ( iProfileToPollPrivateMessages == KNullHash && (iTimeOfLastMsgPoll + 60) < QDateTime::currentDateTimeUtc().toTime_t()) || ( iProfileToPollPrivateMessages != KNullHash && (iTimeOfLastMsgPoll + 600) < QDateTime::currentDateTimeUtc().toTime_t() ) ) { LOG_STR2("Checking private msg poll, seconds since last = %u " ,(unsigned)( ( QDateTime::currentDateTimeUtc().toTime_t() - iTimeOfLastMsgPoll))) ; iTimeOfLastMsgPoll = QDateTime::currentDateTimeUtc().toTime_t() ; // in here find a profile that we have private keys for and // that has not had its private messages polled for given // time (say, 15 minutes). when such a profile is found, // initiate connections to nodes supposed to contain private // messages destined to profile. iModel->lock() ; iProfileToPollPrivateMessages = iModel->profileModel().profileWithOldestTimeSinceMsgPoll(&iTimeOfLastMsgPollForProfile) ; if ( iProfileToPollPrivateMessages != KNullHash ) { iPrivateMessagePollWishList.clear() ; QLOG_STR("Polling private messages for " + iProfileToPollPrivateMessages.toString()) ; QList<Node *>* nodeListFromModel = NULL ; // so try get 5 nodes no older than 60 minutes nodeListFromModel = iModel->nodeModel().getNodesAfterHash (iProfileToPollPrivateMessages, 5, 60) ; // then from that list check nodes that are already connected // and send a query to those nodes if ( nodeListFromModel ) { iPrivateMessagePollWishList.clear() ; for ( int i = nodeListFromModel->size()-1 ; i >= 0 ; i -- ) { if ( iModel->nodeModel().isNodeAlreadyConnected(nodeListFromModel->value(i)->nodeFingerPrint() ) ) { sendPrivateMessagesPoll(nodeListFromModel->value(i)->nodeFingerPrint()) ; } else { // put node into wishlist iPrivateMessagePollWishList << nodeListFromModel->value(i)->nodeFingerPrint() ; iModel->nodeModel().addNodeToConnectionWishList(nodeListFromModel->value(i)->nodeFingerPrint()) ; } delete nodeListFromModel->takeAt(i) ; } delete nodeListFromModel ; nodeListFromModel = NULL ; } } iModel->unlock() ; } }