void tst_QFuture::statePropagation() { QFuture<void> f1; QFuture<void> f2; QCOMPARE(f1.isStarted(), true); QFutureInterface<void> result; result.reportStarted(); f1 = result.future(); f2 = f1; QCOMPARE(f2.isStarted(), true); result.reportCanceled(); QCOMPARE(f2.isStarted(), true); QCOMPARE(f2.isCanceled(), true); QFuture<void> f3 = f2; QCOMPARE(f3.isStarted(), true); QCOMPARE(f3.isCanceled(), true); result.reportFinished(); QCOMPARE(f2.isStarted(), true); QCOMPARE(f2.isCanceled(), true); QCOMPARE(f3.isStarted(), true); QCOMPARE(f3.isCanceled(), true); }
QFuture<QImage> PhotoStorage::GetImage (const QUrl& url) { QFutureInterface<QImage> iface; iface.reportStarted (); if (Pending_.contains (url)) return Pending_.value (url); const auto& future = iface.future (); Pending_ [url] = future; FetchQueue_->Schedule ([=] () mutable { const auto& reply = NAM_->get (QNetworkRequest (url)); new Util::SlotClosure<Util::DeleteLaterPolicy> { [=] { Pending_.remove (url); HandleReplyFinished (reply, iface); }, reply, SIGNAL (finished ()), reply }; }); return future; }
QList<LocatorFilterEntry> FileSystemFilter::matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future, const QString &entry) { QList<LocatorFilterEntry> goodEntries; QList<LocatorFilterEntry> betterEntries; QFileInfo entryInfo(entry); QString name = entryInfo.fileName(); QString directory = entryInfo.path(); QString filePath = entryInfo.filePath(); if (entryInfo.isRelative()) { if (filePath.startsWith(QLatin1String("~/"))) { directory.replace(0, 1, QDir::homePath()); } else { IDocument *document= EditorManager::currentDocument(); if (document && !document->filePath().isEmpty()) { QFileInfo info(document->filePath()); directory.prepend(info.absolutePath() + QLatin1Char('/')); } } } QDir dirInfo(directory); QDir::Filters dirFilter = QDir::Dirs|QDir::Drives|QDir::NoDot; QDir::Filters fileFilter = QDir::Files; if (m_includeHidden) { dirFilter |= QDir::Hidden; fileFilter |= QDir::Hidden; } const Qt::CaseSensitivity caseSensitivity_ = caseSensitivity(entry); QStringList dirs = dirInfo.entryList(dirFilter, QDir::Name|QDir::IgnoreCase|QDir::LocaleAware); QStringList files = dirInfo.entryList(fileFilter, QDir::Name|QDir::IgnoreCase|QDir::LocaleAware); foreach (const QString &dir, dirs) { if (future.isCanceled()) break; if (QList<LocatorFilterEntry> *category = categorize(name, dir, caseSensitivity_, &betterEntries, &goodEntries)) { const QString fullPath = dirInfo.filePath(dir); LocatorFilterEntry filterEntry(this, dir, QVariant()); filterEntry.fileName = fullPath; category->append(filterEntry); } } // file names can match with +linenumber or :linenumber name = entry; const QString lineNoSuffix = EditorManager::splitLineNumber(&name); name = QFileInfo(name).fileName(); foreach (const QString &file, files) { if (future.isCanceled()) break; if (QList<LocatorFilterEntry> *category = categorize(name, file, caseSensitivity_, &betterEntries, &goodEntries)) { const QString fullPath = dirInfo.filePath(file); LocatorFilterEntry filterEntry(this, file, QString(fullPath + lineNoSuffix)); filterEntry.fileName = fullPath; category->append(filterEntry); } } betterEntries.append(goodEntries); return betterEntries; }
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()); }
void BlackBerryAbstractDeployStep::run(QFutureInterface<bool> &fi) { m_timer = new QTimer(); connect(m_timer, SIGNAL(timeout()), this, SLOT(checkForCancel()), Qt::DirectConnection); m_timer->start(500); m_eventLoop = new QEventLoop; fi.setProgressRange(0, 100 * m_params.size()); Q_ASSERT(!m_futureInterface); m_futureInterface = &fi; runCommands(); bool returnValue = m_eventLoop->exec(); // Finished m_params.clear(); m_processCounter = -1; m_timer->stop(); delete m_timer; m_timer = 0; delete m_process; m_process = 0; delete m_eventLoop; m_eventLoop = 0; m_futureInterface = 0; fi.reportResult(returnValue); }
static void findProcessPID(QFutureInterface<qint64> &fi, QStringList selector, const QString &packageName, bool preNougat) { qCDebug(androidRunWorkerLog) << "Finding PID. PreNougat:" << preNougat; if (packageName.isEmpty()) return; qint64 processPID = -1; chrono::high_resolution_clock::time_point start = chrono::high_resolution_clock::now(); selector.append("shell"); selector.append(preNougat ? pidScriptPreNougat : pidScript.arg(packageName)); do { QThread::msleep(200); SdkToolResult result = AndroidManager::runAdbCommand(selector); if (preNougat) { processPID = extractPID(result.stdOut(), packageName); } else { if (!result.stdOut().isEmpty()) processPID = result.stdOut().trimmed().toLongLong(); } } while (processPID == -1 && !isTimedOut(start) && !fi.isCanceled()); qCDebug(androidRunWorkerLog) << "PID found:" << processPID; if (!fi.isCanceled()) fi.reportResult(processPID); }
void DirectoryFilter::refresh(QFutureInterface<void> &future) { QStringList directories; { QMutexLocker locker(&m_lock); if (m_directories.count() < 1) { files().clear(); generateFileNames(); future.setProgressRange(0, 1); future.setProgressValueAndText(1, tr("%1 filter update: 0 files").arg(displayName())); return; } directories = m_directories; } Utils::SubDirFileIterator it(directories, m_filters); future.setProgressRange(0, it.maxProgress()); QStringList filesFound; while (!future.isCanceled() && it.hasNext()) { filesFound << it.next(); if (future.isProgressUpdateNeeded() || future.progressValue() == 0 /*workaround for regression in Qt*/) { future.setProgressValueAndText(it.currentProgress(), tr("%1 filter update: %n files", 0, filesFound.size()).arg(displayName())); } } if (!future.isCanceled()) { QMutexLocker locker(&m_lock); files() = filesFound; generateFileNames(); future.setProgressValue(it.maxProgress()); } else { future.setProgressValueAndText(it.currentProgress(), tr("%1 filter update: canceled").arg(displayName())); } }
void AbstractProcessStep::run(QFutureInterface<bool> &fi) { m_futureInterface = &fi; QDir wd(m_param.effectiveWorkingDirectory()); if (!wd.exists()) { if (!wd.mkpath(wd.absolutePath())) { emit addOutput(tr("Could not create directory \"%1\"") .arg(QDir::toNativeSeparators(wd.absolutePath())), BuildStep::ErrorMessageOutput); fi.reportResult(false); emit finished(); return; } } QString effectiveCommand = m_param.effectiveCommand(); if (!QFileInfo::exists(effectiveCommand)) { processStartupFailed(); fi.reportResult(false); emit finished(); return; } m_process = new Utils::QtcProcess(); if (Utils::HostOsInfo::isWindowsHost()) m_process->setUseCtrlCStub(true); m_process->setWorkingDirectory(wd.absolutePath()); m_process->setEnvironment(m_param.environment()); connect(m_process, SIGNAL(readyReadStandardOutput()), this, SLOT(processReadyReadStdOutput())); connect(m_process, SIGNAL(readyReadStandardError()), this, SLOT(processReadyReadStdError())); connect(m_process, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(slotProcessFinished(int,QProcess::ExitStatus))); m_process->setCommand(effectiveCommand, m_param.effectiveArguments()); m_process->start(); if (!m_process->waitForStarted()) { processStartupFailed(); delete m_process; m_process = 0; fi.reportResult(false); emit finished(); return; } processStarted(); m_timer = new QTimer(); connect(m_timer, SIGNAL(timeout()), this, SLOT(checkForCancel())); m_timer->start(500); m_killProcess = false; }
void tst_QFuture::progressText() { QFutureInterface<void> i; i.reportStarted(); QFuture<void> f = i.future(); QCOMPARE(f.progressText(), QLatin1String("")); i.setProgressValueAndText(1, QLatin1String("foo")); QCOMPARE(f.progressText(), QLatin1String("foo")); i.reportFinished(); }
void GoEditorDocumentProcessor::runParser(QFutureInterface<void> &future, GoEditorDocumentParser::Ptr parser, const QByteArray &source, unsigned revision, const QString &goRoot, const QString &goPath) { future.setProgressRange(0, 1); if (!future.isCanceled()) parser->update(source, revision, goRoot, goPath); future.setProgressValue(1); }
void VcsCommand::run(QFutureInterface<void> &future) { // Check that the binary path is not empty if (binaryPath().isEmpty()) { emit errorText(tr("Unable to start process, binary is empty")); return; } QString stdOut; QString stdErr; if (d->m_progressParser) d->m_progressParser->setFuture(&future); else future.setProgressRange(0, 1); const int count = d->m_jobs.size(); d->m_lastExecExitCode = -1; d->m_lastExecSuccess = true; for (int j = 0; j < count; j++) { const Internal::VcsCommandPrivate::Job &job = d->m_jobs.at(j); const int timeOutSeconds = job.timeout; Utils::SynchronousProcessResponse resp = runVcs( job.arguments, timeOutSeconds >= 0 ? timeOutSeconds * 1000 : -1, job.exitCodeInterpreter); stdOut += resp.stdOut; stdErr += resp.stdErr; d->m_lastExecExitCode = resp.exitCode; d->m_lastExecSuccess = resp.result == Utils::SynchronousProcessResponse::Finished; if (!d->m_lastExecSuccess) break; } if (!d->m_aborted) { if (!d->m_progressiveOutput) { emit output(stdOut); if (!stdErr.isEmpty()) emit errorText(stdErr); } emit finished(d->m_lastExecSuccess, d->m_lastExecExitCode, cookie()); if (d->m_lastExecSuccess) emit success(cookie()); future.setProgressValue(future.progressMaximum()); } if (d->m_progressParser) d->m_progressParser->setFuture(0); // As it is used asynchronously, we need to delete ourselves this->deleteLater(); }
static void parse(QFutureInterface<void> &future, QSharedPointer<SnapshotUpdater> updater) { future.setProgressRange(0, 1); if (future.isCanceled()) { future.setProgressValue(1); return; } CppModelManager *cmm = qobject_cast<CppModelManager *>(CppModelManager::instance()); updater->update(cmm->workingCopy()); cmm->finishedRefreshingSourceFiles(QStringList(updater->fileInEditor())); future.setProgressValue(1); }
void QMakeStep::run(QFutureInterface<bool> &fi) { if (qobject_cast<Qt4Project *>(project())->rootProjectNode()->projectType() == ScriptTemplate) { fi.reportResult(true); return; } if (!enabled(m_buildConfiguration)) { emit addToOutputWindow(tr("<font color=\"#0000ff\">Configuration unchanged, skipping QMake step.</font>")); fi.reportResult(true); return; } AbstractProcessStep::run(fi); }
QList<FilterEntry> FileSystemFilter::matchesFor(QFutureInterface<Locator::FilterEntry> &future, const QString &entry) { QList<FilterEntry> value; QFileInfo entryInfo(entry); QString name = entryInfo.fileName(); QString directory = entryInfo.path(); QString filePath = entryInfo.filePath(); if (entryInfo.isRelative()) { if (filePath.startsWith(QLatin1String("~/"))) { directory.replace(0, 1, QDir::homePath()); } else { IEditor *editor = m_editorManager->currentEditor(); if (editor && !editor->file()->fileName().isEmpty()) { QFileInfo info(editor->file()->fileName()); directory.prepend(info.absolutePath() + QLatin1Char('/')); } } } QDir dirInfo(directory); QDir::Filters dirFilter = QDir::Dirs|QDir::Drives; QDir::Filters fileFilter = QDir::Files; if (m_includeHidden) { dirFilter |= QDir::Hidden; fileFilter |= QDir::Hidden; } QStringList dirs = dirInfo.entryList(dirFilter, QDir::Name|QDir::IgnoreCase|QDir::LocaleAware); QStringList files = dirInfo.entryList(fileFilter, QDir::Name|QDir::IgnoreCase|QDir::LocaleAware); foreach (const QString &dir, dirs) { if (future.isCanceled()) break; if (dir != QLatin1String(".") && (name.isEmpty() || dir.startsWith(name, Qt::CaseInsensitive))) { FilterEntry filterEntry(this, dir, dirInfo.filePath(dir)); filterEntry.resolveFileIcon = true; value.append(filterEntry); } } foreach (const QString &file, files) { if (future.isCanceled()) break; if (name.isEmpty() || file.startsWith(name, Qt::CaseInsensitive)) { const QString fullPath = dirInfo.filePath(file); FilterEntry filterEntry(this, file, fullPath); filterEntry.resolveFileIcon = true; value.append(filterEntry); } } return value; }
/* Test that QFuture<T> can be implicitly converted to T */ void tst_QFuture::implicitConversions() { QFutureInterface<QString> iface; iface.reportStarted(); QFuture<QString> f(&iface); const QString input("FooBar 2000"); iface.reportFinished(&input); const QString result = f; QCOMPARE(result, input); QCOMPARE(QString(f), input); QCOMPARE(static_cast<QString>(f), input); }
void MakeStep::run(QFutureInterface<bool> & fi) { if (qobject_cast<Qt4Project *>(project())->rootProjectNode()->projectType() == ScriptTemplate) { fi.reportResult(true); return; } if (!enabled(m_buildConfiguration)) { emit addToOutputWindow(tr("<font color=\"#0000ff\"><b>No Makefile found, assuming project is clean.</b></font>")); fi.reportResult(true); return; } AbstractMakeStep::run(fi); }
void AndroidDeployQtStep::run(QFutureInterface<bool> &fi) { if (!m_avdName.isEmpty()) { QString serialNumber = AndroidConfigurations::instance().waitForAvd(m_deviceAPILevel, m_targetArch); if (serialNumber.isEmpty()) { fi.reportResult(false); return; } m_serialNumber = serialNumber; QString args = processParameters()->arguments(); Utils::QtcProcess::addArg(&args, QLatin1String("--device")); Utils::QtcProcess::addArg(&args, serialNumber); processParameters()->setArguments(args); } AbstractProcessStep::run(fi); emit addOutput(tr("Pulling files necessary for debugging."), MessageOutput); runCommand(AndroidConfigurations::instance().adbToolPath().toString(), AndroidDeviceInfo::adbSelector(m_serialNumber) << QLatin1String("pull") << QLatin1String("/system/bin/app_process") << QString::fromLatin1("%1/app_process").arg(m_buildDirectory)); runCommand(AndroidConfigurations::instance().adbToolPath().toString(), AndroidDeviceInfo::adbSelector(m_serialNumber) << QLatin1String("pull") << QLatin1String("/system/lib/libc.so") << QString::fromLatin1("%1/libc.so").arg(m_buildDirectory)); }
QList<LocatorFilterEntry> OpenDocumentsFilter::matchesFor(QFutureInterface<LocatorFilterEntry> &future, const QString &entry) { QList<LocatorFilterEntry> goodEntries; QList<LocatorFilterEntry> betterEntries; const EditorManager::FilePathInfo fp = EditorManager::splitLineAndColumnNumber(entry); const QRegularExpression regexp = createRegExp(fp.filePath); if (!regexp.isValid()) return goodEntries; const QList<Entry> editorEntries = editors(); for (const Entry &editorEntry : editorEntries) { if (future.isCanceled()) break; QString fileName = editorEntry.fileName.toString(); if (fileName.isEmpty()) continue; QString displayName = editorEntry.displayName; const QRegularExpressionMatch match = regexp.match(displayName); if (match.hasMatch()) { LocatorFilterEntry filterEntry(this, displayName, QString(fileName + fp.postfix)); filterEntry.extraInfo = FileUtils::shortNativePath(FileName::fromString(fileName)); filterEntry.fileName = fileName; filterEntry.highlightInfo = highlightInfo(match); if (match.capturedStart() == 0) betterEntries.append(filterEntry); else goodEntries.append(filterEntry); } } betterEntries.append(goodEntries); return betterEntries; }
QList<FilterEntry> OpenDocumentsFilter::matchesFor(QFutureInterface<Locator::FilterEntry> &future, const QString &entry_) { QList<FilterEntry> goodEntries; QList<FilterEntry> betterEntries; QString entry = entry_; const QString lineNoSuffix = EditorManager::splitLineNumber(&entry); const QChar asterisk = QLatin1Char('*'); QString pattern = QString(asterisk); pattern += entry; pattern += asterisk; QRegExp regexp(pattern, Qt::CaseInsensitive, QRegExp::Wildcard); if (!regexp.isValid()) return goodEntries; const Qt::CaseSensitivity caseSensitivityForPrefix = caseSensitivity(entry); foreach (const DocumentModel::Entry &editorEntry, m_editors) { if (future.isCanceled()) break; QString fileName = editorEntry.fileName(); if (fileName.isEmpty()) continue; QString displayName = editorEntry.displayName(); if (regexp.exactMatch(displayName)) { QFileInfo fi(fileName); FilterEntry fiEntry(this, fi.fileName(), QString(fileName + lineNoSuffix)); fiEntry.extraInfo = FileUtils::shortNativePath(FileName(fi)); fiEntry.fileName = fileName; QList<FilterEntry> &category = displayName.startsWith(entry, caseSensitivityForPrefix) ? betterEntries : goodEntries; category.append(fiEntry); } } betterEntries.append(goodEntries); return betterEntries; }
QList<Locator::FilterEntry> CppCurrentDocumentFilter::matchesFor(QFutureInterface<Locator::FilterEntry> &future, const QString & origEntry) { QString entry = trimWildcards(origEntry); QList<Locator::FilterEntry> goodEntries; QList<Locator::FilterEntry> betterEntries; QStringMatcher matcher(entry, Qt::CaseInsensitive); const QChar asterisk = QLatin1Char('*'); QRegExp regexp(asterisk + entry + asterisk, Qt::CaseInsensitive, QRegExp::Wildcard); if (!regexp.isValid()) return goodEntries; bool hasWildcard = (entry.contains(asterisk) || entry.contains(QLatin1Char('?'))); if (m_currentFileName.isEmpty()) return goodEntries; if (m_itemsOfCurrentDoc.isEmpty()) { Snapshot snapshot = m_modelManager->snapshot(); Document::Ptr thisDocument = snapshot.document(m_currentFileName); if (thisDocument) m_itemsOfCurrentDoc = search(thisDocument); } const Qt::CaseSensitivity caseSensitivityForPrefix = caseSensitivity(entry); foreach (const ModelItemInfo & info, m_itemsOfCurrentDoc) { if (future.isCanceled()) break; QString matchString = info.symbolName; if (info.type == ModelItemInfo::Declaration) matchString = ModelItemInfo::representDeclaration(info.symbolName, info.symbolType); else if (info.type == ModelItemInfo::Method) matchString += info.symbolType; if ((hasWildcard && regexp.exactMatch(matchString)) || (!hasWildcard && matcher.indexIn(matchString) != -1)) { QVariant id = qVariantFromValue(info); QString name = matchString; QString extraInfo = info.symbolScope; if (info.type == ModelItemInfo::Method) { if (info.unqualifiedNameAndScope(matchString, &name, &extraInfo)) name += info.symbolType; } Locator::FilterEntry filterEntry(this, name, id, info.icon); filterEntry.extraInfo = extraInfo; if (matchString.startsWith(entry, caseSensitivityForPrefix)) betterEntries.append(filterEntry); else goodEntries.append(filterEntry); } } // entries are unsorted by design! betterEntries += goodEntries; return betterEntries; }
void AutogenStep::run(QFutureInterface<bool> &interface) { BuildConfiguration *bc = buildConfiguration(); // Check whether we need to run autogen.sh const QString projectDir(bc->target()->project()->projectDirectory().toString()); const QFileInfo configureInfo(projectDir + QLatin1String("/configure")); const QFileInfo configureAcInfo(projectDir + QLatin1String("/configure.ac")); const QFileInfo makefileAmInfo(projectDir + QLatin1String("/Makefile.am")); if (!configureInfo.exists() || configureInfo.lastModified() < configureAcInfo.lastModified() || configureInfo.lastModified() < makefileAmInfo.lastModified()) { m_runAutogen = true; } if (!m_runAutogen) { emit addOutput(tr("Configuration unchanged, skipping autogen step."), BuildStep::MessageOutput); interface.reportResult(true); emit finished(); return; } m_runAutogen = false; AbstractProcessStep::run(interface); }
QList<LocatorFilterEntry> BaseFileFilter::matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future, const QString &origEntry) { updateFiles(); QList<LocatorFilterEntry> betterEntries; QList<LocatorFilterEntry> goodEntries; QString needle = trimWildcards(QDir::fromNativeSeparators(origEntry)); const QString lineNoSuffix = EditorManager::splitLineNumber(&needle); QStringMatcher matcher(needle, Qt::CaseInsensitive); const QChar asterisk = QLatin1Char('*'); QRegExp regexp(asterisk + needle+ asterisk, Qt::CaseInsensitive, QRegExp::Wildcard); if (!regexp.isValid()) return betterEntries; const QChar pathSeparator(QLatin1Char('/')); const bool hasPathSeparator = needle.contains(pathSeparator); const bool hasWildcard = needle.contains(asterisk) || needle.contains(QLatin1Char('?')); QStringList searchListPaths; QStringList searchListNames; const bool containsPreviousEntry = !m_previousEntry.isEmpty() && needle.contains(m_previousEntry); const bool pathSeparatorAdded = !m_previousEntry.contains(pathSeparator) && needle.contains(pathSeparator); if (!m_forceNewSearchList && containsPreviousEntry && !pathSeparatorAdded) { searchListPaths = m_previousResultPaths; searchListNames = m_previousResultNames; } else { searchListPaths = m_files; searchListNames = m_fileNames; } m_previousResultPaths.clear(); m_previousResultNames.clear(); m_forceNewSearchList = false; m_previousEntry = needle; const Qt::CaseSensitivity caseSensitivityForPrefix = caseSensitivity(needle); QStringListIterator paths(searchListPaths); QStringListIterator names(searchListNames); while (paths.hasNext() && names.hasNext()) { if (future.isCanceled()) break; QString path = paths.next(); QString name = names.next(); QString matchText = hasPathSeparator ? path : name; if ((hasWildcard && regexp.exactMatch(matchText)) || (!hasWildcard && matcher.indexIn(matchText) != -1)) { QFileInfo fi(path); LocatorFilterEntry entry(this, fi.fileName(), QString(path + lineNoSuffix)); entry.extraInfo = FileUtils::shortNativePath(FileName(fi)); entry.fileName = path; if (matchText.startsWith(needle, caseSensitivityForPrefix)) betterEntries.append(entry); else goodEntries.append(entry); m_previousResultPaths.append(path); m_previousResultNames.append(name); } } betterEntries.append(goodEntries); return betterEntries; }
QList<LocatorFilterEntry> OpenDocumentsFilter::matchesFor(QFutureInterface<LocatorFilterEntry> &future, const QString &entry) { QList<LocatorFilterEntry> goodEntries; QList<LocatorFilterEntry> betterEntries; const EditorManager::FilePathInfo fp = EditorManager::splitLineAndColumnNumber(entry); const QChar asterisk = QLatin1Char('*'); QString pattern = QString(asterisk); pattern += fp.filePath; pattern += asterisk; QRegExp regexp(pattern, Qt::CaseInsensitive, QRegExp::Wildcard); if (!regexp.isValid()) return goodEntries; const Qt::CaseSensitivity caseSensitivityForPrefix = caseSensitivity(fp.filePath); foreach (const Entry &editorEntry, editors()) { if (future.isCanceled()) break; QString fileName = editorEntry.fileName.toString(); if (fileName.isEmpty()) continue; QString displayName = editorEntry.displayName; if (regexp.exactMatch(displayName)) { LocatorFilterEntry fiEntry(this, displayName, QString(fileName + fp.postfix)); fiEntry.extraInfo = FileUtils::shortNativePath(FileName::fromString(fileName)); fiEntry.fileName = fileName; QList<LocatorFilterEntry> &category = displayName.startsWith(fp.filePath, caseSensitivityForPrefix) ? betterEntries : goodEntries; category.append(fiEntry); } } betterEntries.append(goodEntries); return betterEntries; }
void MainWindow::runOnExternalEx(QFutureInterface<void>& future) { g_sm->checkCurrentOn(ServiceMgr::EXTERNAL); BfInfo(__FUNCTION__); future.reportFinished(); }
QList<Locator::FilterEntry> PythonFilterBase::matchesFor( QFutureInterface<Locator::FilterEntry>& future, const QString& entry) { QScopedPointer<WorkerClient::ReplyType> reply( worker_pool_->NextHandler()->Search(entry, file_path_, symbol_type_)); reply->WaitForFinished(); QList<Locator::FilterEntry> ret; if (!reply->is_successful() || future.isCanceled()) { return ret; } const pb::SearchResponse* response = &reply->message().search_response(); for (int i=0 ; i<response->result_size() ; ++i) { const pb::SearchResponse_Result* result = &response->result(i); EntryInternalData internal_data(result->file_path(), result->line_number()); Locator::FilterEntry entry(this, result->symbol_name(), QVariant::fromValue(internal_data)); entry.extraInfo = result->module_name(); entry.displayIcon = icons_->IconForSearchResult(*result); ret << entry; } return ret; }
QList<LocatorFilterEntry> ExecuteFilter::matchesFor(QFutureInterface<LocatorFilterEntry> &future, const QString &entry) { QList<LocatorFilterEntry> value; if (!entry.isEmpty()) // avoid empty entry value.append(LocatorFilterEntry(this, entry, QVariant())); QList<LocatorFilterEntry> others; const Qt::CaseSensitivity entryCaseSensitivity = caseSensitivity(entry); for (const QString &cmd : qAsConst(m_commandHistory)) { if (future.isCanceled()) break; if (cmd == entry) // avoid repeated entry continue; LocatorFilterEntry filterEntry(this, cmd, QVariant()); const int index = cmd.indexOf(entry, 0, entryCaseSensitivity); if (index >= 0) { filterEntry.highlightInfo = {index, entry.length()}; value.append(filterEntry); } else { others.append(filterEntry); } } value.append(others); return value; }
void Locator::Internal::runSearch(QFutureInterface<Locator::FilterEntry> &entries, QList<ILocatorFilter *> filters, QString searchText) { QSet<FilterEntry> alreadyAdded; const bool checkDuplicates = (filters.size() > 1); foreach (ILocatorFilter *filter, filters) { if (entries.isCanceled()) break; foreach (const FilterEntry &entry, filter->matchesFor(entries, searchText)) { if (checkDuplicates && alreadyAdded.contains(entry)) continue; entries.reportResult(entry); if (checkDuplicates) alreadyAdded.insert(entry); } } }
void MakeStep::run(QFutureInterface<bool> & fi) { if (qt4BuildConfiguration()->qt4Target()->qt4Project()->rootProjectNode()->projectType() == ScriptTemplate) { fi.reportResult(true); return; } AbstractProcessStep::run(fi); }
void AndroidDeployQtStep::run(QFutureInterface<bool> &fi) { if (!m_avdName.isEmpty()) { QString serialNumber = AndroidConfigurations::currentConfig().waitForAvd(m_deviceAPILevel, m_targetArch, fi); if (serialNumber.isEmpty()) { fi.reportResult(false); emit finished(); return; } m_serialNumber = serialNumber; emit setSerialNumber(serialNumber); } DeployResult returnValue = runDeploy(fi); if (returnValue == AskUinstall) { emit askForUninstall(); if (m_askForUinstall) { m_uninstallPreviousPackageRun = true; returnValue = runDeploy(fi); } } emit addOutput(tr("Pulling files necessary for debugging."), MessageOutput); QString localAppProcessFile = QString::fromLatin1("%1/app_process").arg(m_buildDirectory); runCommand(m_adbPath, AndroidDeviceInfo::adbSelector(m_serialNumber) << QLatin1String("pull") << QLatin1String("/system/bin/app_process") << localAppProcessFile); // Workaround for QTCREATORBUG-14201: /system/bin/app_process might be a link to asan/app_process if (!QFileInfo::exists(localAppProcessFile)) { runCommand(m_adbPath, AndroidDeviceInfo::adbSelector(m_serialNumber) << QLatin1String("pull") << QLatin1String("/system/bin/asan/app_process") << localAppProcessFile); } runCommand(m_adbPath, AndroidDeviceInfo::adbSelector(m_serialNumber) << QLatin1String("pull") << QLatin1String("/system/lib/libc.so") << QString::fromLatin1("%1/libc.so").arg(m_buildDirectory)); fi.reportResult(returnValue == Success ? true : false); fi.reportFinished(); }
void MerEmulatorStartStep::run(QFutureInterface<bool> &fi) { MerConnectionManager *em = MerConnectionManager::instance(); if(em->isConnected(m_vm)) { emit addOutput(tr("Emulator is already running. Nothing to do."),MessageOutput); fi.reportResult(true); emit finished(); } else { emit addOutput(tr("Starting Emulator..."), MessageOutput); QString error = tr("Could not connect to %1 Virtual Machine.").arg(m_vm); MerConnection::createConnectionErrorTask(m_vm,error,Constants::MER_TASKHUB_EMULATOR_CATEGORY); if(!MerVirtualBoxManager::isVirtualMachineRunning(m_vm)) { MerConnectionPrompt *connectioPrompt = new MerConnectionPrompt(m_vm, 0); connectioPrompt->prompt(MerConnectionPrompt::Start); } fi.reportResult(false); emit finished(); } }