void WidgetDownloads::removeSelectedEntries() { QSet<quint64> downloadIDs; QModelIndexList selectedRows = this->ui->tblDownloads->selectionModel()->selectedRows(); bool allComplete = true; for (QListIterator<QModelIndex> i(selectedRows); i.hasNext();) { const QModelIndex& index = i.next(); downloadIDs += this->currentDownloadsModel->getDownloadIDs(index).toSet(); if (!this->currentDownloadsModel->isFileComplete(index)) allComplete = false; } if (!downloadIDs.isEmpty()) { if (!allComplete) { QMessageBox msgBox(this); msgBox.setWindowIcon(QIcon(":/icons/ressources/delete.png")); msgBox.setWindowTitle(tr("Remove selected downloads")); msgBox.setText(tr("Are you sure to remove the selected downloads? There is one or more unfinished download.")); msgBox.setIcon(QMessageBox::Question); msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); msgBox.setDefaultButton(QMessageBox::Ok); if (msgBox.exec() == QMessageBox::Ok) this->coreConnection->cancelDownloads(downloadIDs.toList()); } else this->coreConnection->cancelDownloads(downloadIDs.toList()); } }
void MultiValuesLineEdit::setMultiValue(QSet<QString> value) { if (value.count() == 0) { mMultiState = MultiValuesEmpty; QLineEdit::setText(""); setPlaceholder(this, ""); mCompleterModel->setStringList(QStringList()); } else if (value.count() == 1) { mMultiState = MultiValuesEmpty; QLineEdit::setText(*(value.constBegin())); setPlaceholder(this, ""); mCompleterModel->setStringList(value.toList()); } else { mMultiState = MultiValuesMulti; QLineEdit::setText(""); setPlaceholder(this, tr("Multiple values")); mCompleterModel->setStringList(value.toList()); } }
void CppModelManagerInterface::ProjectInfo::appendProjectPart(const ProjectPart::Ptr &part) { if (!part) return; m_projectParts.append(part); // Update include paths QSet<QString> incs = QSet<QString>::fromList(m_includePaths); foreach (const QString &ins, part->includePaths) incs.insert(ins); m_includePaths = incs.toList(); // Update framework paths QSet<QString> frms = QSet<QString>::fromList(m_frameworkPaths); foreach (const QString &frm, part->frameworkPaths) frms.insert(frm); m_frameworkPaths = frms.toList(); // Update source files QSet<QString> srcs = QSet<QString>::fromList(m_sourceFiles); foreach (const ProjectFile &file, part->files) srcs.insert(file.path); m_sourceFiles = srcs.toList(); // Update defines if (!m_defines.isEmpty()) m_defines.append('\n'); m_defines.append(part->defines); }
QVector< QPair<int,int> > PartCorresponder::distributeVectors(int x, int y) { QSet< QPair<int,int> > result; if(x == y && x == 1){ result << qMakePair(0,0); return result.toList().toVector(); } int start_i = 0, start_j = 0; int end_i = x-1, end_j = y-1; bool isStopI = false, isStopJ = false; while( true ){ result << qMakePair(start_i,start_j) << qMakePair(end_i, end_j); if(end_i - start_i < 2) { isStopI = true; } if(end_j - start_j < 2) { isStopJ = true; } if( isStopI && isStopJ ) break; if( !isStopI ){ start_i++; end_i--; } if( !isStopJ ){ start_j++; end_j--; } } return result.toList().toVector(); }
/*! Returns the difference between the current checkpoint and the previous checkpoint. The first item in the pair is a list containing the identifiers of the scripts that were added. The second item in the pair is a list containing the identifiers of the scripts that were removed. */ QPair<QList<qint64>, QList<qint64> > QScriptDebuggerAgent::scriptsDelta() const { Q_D(const QScriptDebuggerAgent); QSet<qint64> prevSet = d->previousCheckpointScripts.keys().toSet(); QSet<qint64> currSet = d->checkpointScripts.keys().toSet(); QSet<qint64> addedScriptIds = currSet - prevSet; QSet<qint64> removedScriptIds = prevSet - currSet; return qMakePair(addedScriptIds.toList(), removedScriptIds.toList()); }
static QStringList findAllLibSsl() { QStringList paths; # ifdef Q_OS_DARWIN paths = QString::fromLatin1(qgetenv("DYLD_LIBRARY_PATH")) .split(QLatin1Char(':'), QString::SkipEmptyParts); # else paths = QString::fromLatin1(qgetenv("LD_LIBRARY_PATH")) .split(QLatin1Char(':'), QString::SkipEmptyParts); # endif paths << QLatin1String("/lib") << QLatin1String("/usr/lib") << QLatin1String("/usr/local/lib"); #ifdef Q_OS_LINUX // discover paths of already loaded libraries QSet<QString> loadedPaths; dl_iterate_phdr(dlIterateCallback, &loadedPaths); paths.append(loadedPaths.toList()); #endif QStringList foundSsls; foreach (const QString &path, paths) { QDir dir = QDir(path); QStringList entryList = dir.entryList(QStringList() << QLatin1String("libssl.*"), QDir::Files); qSort(entryList.begin(), entryList.end(), libGreaterThan); foreach (const QString &entry, entryList) foundSsls << path + QLatin1Char('/') + entry; }
void GroupSelWidget::sceneChanged() { QSet<QString> groupSet = _scene->getAllGroups(); if(groupSet == _prevGroupSet) return; _prevGroupSet = groupSet; QList<QString> groups = groupSet.toList(); qSort(groups); for(int i = 0; i < (int)_checkBoxes.size(); ++i) delete _checkBoxes[i]; _checkBoxes.clear(); int childWidth = 0; for(int i = 0; i < (int)groups.size(); ++i) { QCheckBox *box = new QCheckBox(groups[i], this); QFont font = box->font(); font.setPointSize(14); box->setFont(font); box->setCheckState(_scene->isGroupVisible(groups[i]) ? Qt::Checked : Qt::Unchecked); new VisibilitySetter(box, _scene, groups[i]); layout()->addWidget(box); childWidth = max(childWidth, box->sizeHint().width()); _checkBoxes.push_back(box); } setMinimumWidth(150); QWidget *scrollArea = parentWidget()->parentWidget()->parentWidget(); scrollArea->setMinimumWidth(childWidth + 20); }
void VkAccount::handleUsers (const QList<UserInfo>& infos) { QList<QObject*> newEntries; QSet<int> newCountries; bool hadNew = false; for (const auto& info : infos) { if (Entries_.contains (info.ID_)) { Entries_ [info.ID_]->UpdateInfo (info); continue; } auto entry = new VkEntry (info, this); Entries_ [info.ID_] = entry; newEntries << entry; newCountries << info.Country_; hadNew = true; } GeoResolver_->CacheCountries (newCountries.toList ()); if (!newEntries.isEmpty ()) emit gotCLItems (newEntries); if (hadNew) TryPendingMessages (); }
void populateMenu(QSet<ActionInterface* > &actionInterfaces, const QByteArray &category, QMenu* menu, const SelectionContext &selectionContext) { QSet<ActionInterface* > matchingFactories = findMembers(actionInterfaces, category); actionInterfaces.subtract(matchingFactories); QList<ActionInterface* > matchingFactoriesList = matchingFactories.toList(); Utils::sort(matchingFactoriesList, [](ActionInterface *l, ActionInterface *r) { return l->priority() > r->priority(); }); foreach (ActionInterface* actionInterface, matchingFactoriesList) { if (actionInterface->type() == ActionInterface::ContextMenu) { actionInterface->currentContextChanged(selectionContext); QMenu *newMenu = actionInterface->action()->menu(); if (newMenu && !newMenu->title().isEmpty()) menu->addMenu(newMenu); //recurse populateMenu(actionInterfaces, actionInterface->menuId(), newMenu, selectionContext); } else if (actionInterface->type() == ActionInterface::ContextMenuAction || actionInterface->type() == ActionInterface::Action) { QAction* action = actionInterface->action(); actionInterface->currentContextChanged(selectionContext); action->setIconVisibleInMenu(false); menu->addAction(action); } } }
QList<RssFeed*> QRssDisplayModel::SelectedFeeds() { QSet<RssFeed*> res; QModelIndexList selectedIndexes = m_pItemsView->selectionModel()->selectedIndexes(); for (int i = 0 ; i < selectedIndexes.size(); i++) { QModelIndex selectedIndex = selectedIndexes[i]; if (selectedIndex.isValid()) { QVariant data = selectedIndex.data(RssFeedRole); if (data.isValid()) { RssFeed* pFeed = data.value<RssFeed*>(); res.insert(pFeed); } else { data = selectedIndex.data(RssItemRole); if (data.isValid()) { RssItem* pItem = data.value<RssItem*>(); res.insert(pItem->rssFeed()); } } } } return res.toList(); }
static QStringList libraryPathList() { QStringList paths; # ifdef Q_OS_DARWIN paths = QString::fromLatin1(qgetenv("DYLD_LIBRARY_PATH")) .split(QLatin1Char(':'), QString::SkipEmptyParts); # else paths = QString::fromLatin1(qgetenv("LD_LIBRARY_PATH")) .split(QLatin1Char(':'), QString::SkipEmptyParts); # endif paths << QLatin1String("/lib") << QLatin1String("/usr/lib") << QLatin1String("/usr/local/lib"); paths << QLatin1String("/lib64") << QLatin1String("/usr/lib64") << QLatin1String("/usr/local/lib64"); paths << QLatin1String("/lib32") << QLatin1String("/usr/lib32") << QLatin1String("/usr/local/lib32"); #if defined(Q_OS_ANDROID_NO_SDK) paths << QLatin1String("/system/lib"); #elif defined(Q_OS_LINUX) // discover paths of already loaded libraries QSet<QString> loadedPaths; dl_iterate_phdr(dlIterateCallback, &loadedPaths); paths.append(loadedPaths.toList()); #endif return paths; }
static void createProposal(QFutureInterface<QStringList> &future, const QString &text, const QString &wordUnderCursor) { const QRegularExpression wordRE("([a-zA-Z_][a-zA-Z0-9_]{2,})"); QSet<QString> words; QRegularExpressionMatchIterator it = wordRE.globalMatch(text); int wordUnderCursorFound = 0; while (it.hasNext()) { if (future.isCanceled()) return; QRegularExpressionMatch match = it.next(); const QString &word = match.captured(); if (word == wordUnderCursor) { // Only add the word under cursor if it // already appears elsewhere in the text if (++wordUnderCursorFound < 2) continue; } if (!words.contains(word)) words.insert(word); } future.reportResult(words.toList()); }
const QStringList LoadSavePlugin::getExtensionsForColors(const int id) { QList<FileFormat>::const_iterator it(findFormat(id)); QList<FileFormat>::const_iterator itEnd(formats.constEnd()); QStringList filterList; // We know the list is sorted by id, then priority, so we can just take the // highest priority entry for each ID, and we can start with the first entry // in the list. //First, check if we even have any plugins to load with if (it != itEnd) { if ((it->load) && (it->colorReading)) filterList.append(it->fileExtensions); unsigned int lastID = it->formatId; ++it; for ( ; it != itEnd ; ++it) { // Find the next load/save (as appropriate) plugin for the next format type if (((it->load) && (it->colorReading)) && (it->formatId > lastID)) { // And add it to the filter list, since we know it's // the highest priority because of the sort order. filterList.append(it->fileExtensions); lastID = it->formatId; } } } else qDebug("%s", tr("No File Loader Plugins Found").toLocal8Bit().data()); // Avoid duplicate entries in the list QSet<QString> fSet = filterList.toSet(); filterList = fSet.toList(); qSort(filterList); return filterList; }
void MScenePrivate::onDisplayChangeEvent(MOnDisplayChangeEvent *event) { Q_Q(MScene); if (event->state() == MOnDisplayChangeEvent::FullyOnDisplay || event->state() == MOnDisplayChangeEvent::FullyOffDisplay) { // Simple cases. Just forward the event as it is. sendEventToMWidgets(filterMWidgets(q->items()), event); return; } QList<MWidget *> fullyOnWidgets; QList<MWidget *> partiallyOnWidgets; QList<MWidget *> fullyOffWidgets; QList<MWidget *> intersectingWidgets = filterMWidgets(q->items(event->viewRect(), Qt::IntersectsItemBoundingRect)); QList<MWidget *> allWidgets = filterMWidgets(q->items()); // Find who is fully on, partially on and fully off QSet<MWidget *> fullyOffWidgetsSet = allWidgets.toSet().subtract(intersectingWidgets.toSet()); fullyOffWidgets = fullyOffWidgetsSet.toList(); int intersectingWidgetsCount = intersectingWidgets.count(); MWidget *widget; for (int i = 0; i < intersectingWidgetsCount; i++) { widget = intersectingWidgets.at(i); if (event->viewRect().contains(widget->sceneBoundingRect())) { fullyOnWidgets << widget; } else { partiallyOnWidgets << widget; } } // Send the events to the corresponding MWidgets if (fullyOnWidgets.count() > 0) { MOnDisplayChangeEvent fullyOnEvent(MOnDisplayChangeEvent::FullyOnDisplay, event->viewRect()); sendEventToMWidgets(fullyOnWidgets, &fullyOnEvent); } if (fullyOffWidgets.count() > 0) { MOnDisplayChangeEvent fullyOffEvent(MOnDisplayChangeEvent::FullyOffDisplay, event->viewRect()); sendEventToMWidgets(fullyOffWidgets, &fullyOffEvent); } if (partiallyOnWidgets.count() > 0) { MOnDisplayChangeEvent partiallyOnEvent(MOnDisplayChangeEvent::PartiallyOnDisplay, event->viewRect()); sendEventToMWidgets(partiallyOnWidgets, &partiallyOnEvent); } }
QStringList MetadataHub::cleanupTags(const QStringList& toClean) { QSet<QString> deduplicator; for (int index = 0; index < toClean.size(); index++) { QString keyword = toClean.at(index); if (!keyword.isEmpty()) { // _Digikam_root_tag_ is present in some photos tagged with older // version of digiKam, must be removed if (keyword.contains(QRegExp(QLatin1String("(_Digikam_root_tag_/|/_Digikam_root_tag_|_Digikam_root_tag_)")))) { keyword = keyword.replace(QRegExp(QLatin1String("(_Digikam_root_tag_/|/_Digikam_root_tag_|_Digikam_root_tag_)")), QLatin1String("")); } deduplicator.insert(keyword); } } return deduplicator.toList(); }
QT_BEGIN_NAMESPACE static QStringList unique(const QStringList &lst) { const QSet<QString> s = QSet<QString>::fromList(lst); return s.toList(); }
QString PlaylistManager::GetNameForNewPlaylist(const SongList& songs) { if (songs.isEmpty()) { return tr("Playlist"); } QSet<QString> artists; QSet<QString> albums; for (const Song& song : songs) { artists << (song.artist().isEmpty() ? tr("Unknown") : song.artist()); albums << (song.album().isEmpty() ? tr("Unknown") : song.album()); if (artists.size() > 1) { break; } } bool various_artists = artists.size() > 1; QString result; if (various_artists) { result = tr("Various artists"); } else { result = artists.values().first(); } if (!various_artists && albums.size() == 1) { result += " - " + albums.toList().first(); } return result; }
QStringList Hdfs::getLocations(string path, long start, long length, const bool sort) { char*** h = hdfsGetHosts(_getFs(), path.data(), start, length); if (h == NULL) { throw ios_base::failure("Error getting block locations from HDFS."); } QSet<QString> hosts; int i = 0; while (h[i] != NULL) { int j = 0; while (h[i][j] != NULL) { char* host = h[i][j]; hosts.insert(host); j++; } i++; } QStringList hostsList(hosts.toList()); if (sort) { hostsList.sort(); } return hostsList; }
void SubgraphMatching::cut(Solution *sol, CutMethod cm) { LinearConstraint *c; QList<Variable *> vars = sol->getVariables().keys(); switch(cm) { case SOLUTION: c = new LinearConstraint(LinearExpression::sum(vars), Constraint::LESS_EQ, vars.size() - 1); break; case MATCHINGS: c = new LinearConstraint(LinearExpression::sum(vars), Constraint::EQUAL, 0); break; case ELEMENTS: { QStringList sl; QSet<Variable *> vset = vars.toSet(); for(auto s : vars) { if(s->getID().startsWith("x")) { sl = s->getID().mid(2).split(','); for(auto v : x_variables.getCol(sl[1].toInt())) { vset.insert(v); } } } c = new LinearConstraint(LinearExpression::sum(vset.toList()), Constraint::EQUAL, 0); break; } default: break; } *lp_ += c; }
void MetaQueryWidget::populateComboBox( QStringList results ) { QObject* query = sender(); if( !query ) return; QWeakPointer<KComboBox> combo = m_runningQueries.value(query); if( combo.isNull() ) return; // note: adding items seems to reset the edit text, so we have // to take care of that. disconnect( combo.data(), 0, this, 0 ); // want the results unique and sorted const QSet<QString> dataSet = results.toSet(); QStringList dataList = dataSet.toList(); dataList.sort(); combo.data()->addItems( dataList ); KCompletion* comp = combo.data()->completionObject(); comp->setItems( dataList ); // reset the text and re-enable the signal combo.data()->setEditText( m_filter.value ); connect( combo.data(), SIGNAL(editTextChanged( const QString& ) ), SLOT(valueChanged(const QString&)) ); }
void ViMainCorrelationWidget::updateCorrelators() { QObject::disconnect(mUi->correlatorComboBox, SIGNAL(currentTextChanged(QString)), mUi->correlationWidget, SLOT(changeCorrelator(QString))); mUi->scrollArea->show(); // Table must be visible before setting the data, in order to resize properly mUi->correlatorContainer->show(); ViAudioObjectQueue objects = mObjects; if(objects.isEmpty()) objects = mUi->projectLoader->objects(); QSet<QString> correlators; ViCorrelationGroups correlations; QStringList keys; for(int i = 0; i < objects.size(); ++i) { correlations = objects[i]->correlations(); for(int j = 0; j < correlations.size(); ++j) { keys = correlations[j].correlators(); for(int k = 0; k < keys.size(); ++k) { correlators.insert(ViName::formatName(keys[k], "", true)); } } } mUi->correlatorComboBox->clear(); mUi->correlatorComboBox->addItems(correlators.toList()); mUi->correlatorComboBox->setCurrentText(ViCorrelatorManager::defaultName()); QObject::connect(mUi->correlatorComboBox, SIGNAL(currentTextChanged(QString)), mUi->correlationWidget, SLOT(changeCorrelator(QString))); mUi->correlationWidget->changeCorrelator(mUi->correlatorComboBox->currentText()); }
QList<QString> QgsGraduatedSymbolRendererV2::usedAttributes() { QSet<QString> attributes; // mAttrName can contain either attribute name or an expression. // Sometimes it is not possible to distinguish between those two, // e.g. "a - b" can be both a valid attribute name or expression. // Since we do not have access to fields here, try both options. attributes << mAttrName; QgsExpression testExpr( mAttrName ); if ( !testExpr.hasParserError() ) attributes.unite( testExpr.referencedColumns().toSet() ); if ( mRotation.data() ) attributes.unite( mRotation->referencedColumns().toSet() ); if ( mSizeScale.data() ) attributes.unite( mSizeScale->referencedColumns().toSet() ); QgsRangeList::const_iterator range_it = mRanges.constBegin(); for ( ; range_it != mRanges.constEnd(); ++range_it ) { QgsSymbolV2* symbol = range_it->symbol(); if ( symbol ) { attributes.unite( symbol->usedAttributes() ); } } return attributes.toList(); }
static common::GameSession::VisitedMaps visitedMaps() { // Newer versions of the savegame format include a breakdown of the maps previously visited // during the current game session. if(COMMON_GAMESESSION->allVisitedMaps().isEmpty()) { // For backward compatible intermission behavior we'll have to use a specially prepared // version of this information, using the original map progression assumptions. bool isNumber; int oldEpisodeNum = COMMON_GAMESESSION->episodeId().toInt(&isNumber) - 1; // 1-based DENG2_ASSERT(isNumber); DENG2_UNUSED(isNumber); DENG2_ASSERT(wbs); int lastMapNum = G_MapNumberFor(::wbs->currentMap); if(lastMapNum == 8) lastMapNum = G_MapNumberFor(::wbs->nextMap) - 1; // 1-based QSet<de::Uri> visited; for(int i = 0; i <= lastMapNum; ++i) { visited << G_ComposeMapUri(oldEpisodeNum, i); } if(::wbs->didSecret) { visited << G_ComposeMapUri(oldEpisodeNum, 8); } return visited.toList(); } return COMMON_GAMESESSION->allVisitedMaps(); }
QList<QString> QgsGraduatedSymbolRendererV2::usedAttributes() { QSet<QString> attributes; attributes.insert( mAttrName ); if ( !mRotationField.isEmpty() ) { attributes.insert( mRotationField ); } if ( !mSizeScaleField.isEmpty() ) { attributes.insert( mSizeScaleField ); } QgsSymbolV2* symbol = 0; QgsRangeList::const_iterator range_it = mRanges.constBegin(); for ( ; range_it != mRanges.constEnd(); ++range_it ) { symbol = range_it->symbol(); if ( symbol ) { attributes.unite( symbol->usedAttributes() ); } } return attributes.toList(); }
/** * Synchronizes the selection with the given stamp. Ignored when the stamp is * changing because of a selection change in the TilesetDock. */ void TilesetDock::selectTilesInStamp(const TileStamp &stamp) { if (mEmittingStampCaptured) return; QSet<Tile*> processed; QMap<QItemSelectionModel*, QItemSelection> selections; for (const TileStampVariation &variation : stamp.variations()) { const TileLayer &tileLayer = *variation.tileLayer(); for (const Cell &cell : tileLayer) { if (Tile *tile = cell.tile) { if (processed.contains(tile)) continue; processed.insert(tile); // avoid spending time on duplicates Tileset *tileset = tile->tileset(); int tilesetIndex = mTilesets.indexOf(tileset->sharedPointer()); if (tilesetIndex != -1) { TilesetView *view = tilesetViewAt(tilesetIndex); if (!view->model()) // Lazily set up the model setupTilesetModel(view, tileset); const TilesetModel *model = view->tilesetModel(); const QModelIndex modelIndex = model->tileIndex(tile); QItemSelectionModel *selectionModel = view->selectionModel(); selections[selectionModel].select(modelIndex, modelIndex); } } } } if (!selections.isEmpty()) { mSynchronizingSelection = true; // Mark captured tiles as selected for (auto i = selections.constBegin(); i != selections.constEnd(); ++i) { QItemSelectionModel *selectionModel = i.key(); const QItemSelection &selection = i.value(); selectionModel->select(selection, QItemSelectionModel::SelectCurrent); } // Show/edit properties of all captured tiles mMapDocument->setSelectedTiles(processed.toList()); // Update the current tile (useful for animation and collision editors) auto first = selections.begin(); QItemSelectionModel *selectionModel = first.key(); const QItemSelection &selection = first.value(); const QModelIndex currentIndex = selection.first().topLeft(); if (selectionModel->currentIndex() != currentIndex) selectionModel->setCurrentIndex(currentIndex, QItemSelectionModel::NoUpdate); else currentChanged(currentIndex); mSynchronizingSelection = false; } }
QList<QString> QgsSingleSymbolRendererV2::usedAttributes() { QSet<QString> attributes; if ( mSymbol.data() ) attributes.unite( mSymbol->usedAttributes() ); if ( mRotation.data() ) attributes.unite( mRotation->referencedColumns().toSet() ); if ( mSizeScale.data() ) attributes.unite( mSizeScale->referencedColumns().toSet() ); return attributes.toList(); }
QList<QByteArray> QTimeZone::availableTimeZoneIds(QLocale::Country country) { QSet<QByteArray> set = QUtcTimeZonePrivate().availableTimeZoneIds(country) + global_tz->backend->availableTimeZoneIds(country); QList<QByteArray> list = set.toList(); std::sort(list.begin(), list.end()); return list; }
QStringList LabelWidget::getLabels() const { int column = 0; QSet<QString> result; for (int i = 0; i < labeltree->selectedItems().size(); ++i) result << labeltree->selectedItems().at(i)->text(column); return result.toList(); }
QList<QByteArray> QTimeZone::availableTimeZoneIds(int offsetSeconds) { QSet<QByteArray> set = QUtcTimeZonePrivate().availableTimeZoneIds(offsetSeconds) + global_tz->backend->availableTimeZoneIds(offsetSeconds); QList<QByteArray> list = set.toList(); std::sort(list.begin(), list.end()); return list; }
QStringList QuickOpenModel::allTypes() const { QSet<QString> types; foreach( const ProviderEntry& provider, m_providers ) types += provider.types; return types.toList(); }