forked from qt-creator/qt-creator
Use const iterator with std::find_if where possible
Make the resulting interator const. Change-Id: I4aadcfff35f6b1015e506bc75bcfc2a1f1be4d65 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -486,14 +486,14 @@ AndroidDeviceInfo AndroidDeviceDialog::device()
|
||||
refreshDeviceList();
|
||||
|
||||
if (!m_defaultDevice.isEmpty()) {
|
||||
auto device = std::find_if(m_connectedDevices.begin(),
|
||||
m_connectedDevices.end(),
|
||||
auto device = std::find_if(m_connectedDevices.cbegin(),
|
||||
m_connectedDevices.cend(),
|
||||
[this](const AndroidDeviceInfo &info) {
|
||||
return info.serialNumber == m_defaultDevice ||
|
||||
info.avdname == m_defaultDevice;
|
||||
});
|
||||
|
||||
if (device != m_connectedDevices.end())
|
||||
if (device != m_connectedDevices.cend())
|
||||
return *device;
|
||||
m_defaultDevice.clear();
|
||||
}
|
||||
|
||||
@@ -97,10 +97,10 @@ static QString quickTestSrcDir(const CppTools::CppModelManager *cppMM,
|
||||
if (parts.size() > 0) {
|
||||
const ProjectExplorer::Macros ¯os = parts.at(0)->projectMacros;
|
||||
auto found = std::find_if(
|
||||
macros.begin(),
|
||||
macros.end(),
|
||||
macros.cbegin(),
|
||||
macros.cend(),
|
||||
[] (const ProjectExplorer::Macro ¯o) { return macro.key == "QUICK_TEST_SOURCE_DIR"; });
|
||||
if (found != macros.end()) {
|
||||
if (found != macros.cend()) {
|
||||
QByteArray result = found->value;
|
||||
if (result.startsWith('"'))
|
||||
result.remove(result.length() - 1, 1).remove(0, 1);
|
||||
|
||||
@@ -118,14 +118,14 @@ static QString methodDefinitionParameters(const CodeCompletionChunks &chunks)
|
||||
{
|
||||
QString result;
|
||||
|
||||
auto typedTextChunkIt = std::find_if(chunks.begin(), chunks.end(),
|
||||
auto typedTextChunkIt = std::find_if(chunks.cbegin(), chunks.cend(),
|
||||
[](const CodeCompletionChunk &chunk) {
|
||||
return chunk.kind == CodeCompletionChunk::TypedText;
|
||||
});
|
||||
if (typedTextChunkIt == chunks.end())
|
||||
if (typedTextChunkIt == chunks.cend())
|
||||
return result;
|
||||
|
||||
std::for_each(++typedTextChunkIt, chunks.end(), [&result](const CodeCompletionChunk &chunk) {
|
||||
std::for_each(++typedTextChunkIt, chunks.cend(), [&result](const CodeCompletionChunk &chunk) {
|
||||
if (chunk.kind == CodeCompletionChunk::Placeholder && chunk.text.contains('=')) {
|
||||
Utf8String text = chunk.text.mid(0, chunk.text.indexOf('='));
|
||||
if (text.endsWith(' '))
|
||||
|
||||
@@ -426,7 +426,7 @@ private:
|
||||
|
||||
auto updateDialog = [&generatorList, generatorCombo, extraGeneratorCombo,
|
||||
platformEdit, toolsetEdit](const QString &name) {
|
||||
auto it = std::find_if(generatorList.constBegin(), generatorList.constEnd(),
|
||||
const auto it = std::find_if(generatorList.constBegin(), generatorList.constEnd(),
|
||||
[name](const CMakeTool::Generator &g) { return g.name == name; });
|
||||
QTC_ASSERT(it != generatorList.constEnd(), return);
|
||||
generatorCombo->setCurrentText(name);
|
||||
|
||||
@@ -561,7 +561,7 @@ QList<ProjectPart::Ptr> fetchProjectParts(CppTools::CppModelManager *modelManage
|
||||
ProjectPart *findProjectPartForCurrentProject(const QList<ProjectPart::Ptr> &projectParts,
|
||||
ProjectExplorer::Project *currentProject)
|
||||
{
|
||||
auto found = std::find_if(projectParts.cbegin(),
|
||||
const auto found = std::find_if(projectParts.cbegin(),
|
||||
projectParts.cend(),
|
||||
[&](const CppTools::ProjectPart::Ptr &projectPart) {
|
||||
return projectPart->project == currentProject;
|
||||
|
||||
@@ -328,11 +328,11 @@ QVector<HandleItem *> CurveItem::handles() const
|
||||
CurveSegment CurveItem::segment(const KeyframeItem *keyframe, HandleItem::Slot slot) const
|
||||
{
|
||||
auto finder = [keyframe](KeyframeItem *item) { return item == keyframe; };
|
||||
auto iter = std::find_if(m_keyframes.begin(), m_keyframes.end(), finder);
|
||||
if (iter == m_keyframes.end())
|
||||
const auto iter = std::find_if(m_keyframes.cbegin(), m_keyframes.cend(), finder);
|
||||
if (iter == m_keyframes.cend())
|
||||
return CurveSegment();
|
||||
|
||||
int index = static_cast<int>(std::distance(m_keyframes.begin(), iter));
|
||||
int index = static_cast<int>(std::distance(m_keyframes.cbegin(), iter));
|
||||
if (slot == HandleItem::Slot::Left && index > 0)
|
||||
return CurveSegment(m_keyframes[index - 1]->keyframe(), keyframe->keyframe());
|
||||
else if (slot == HandleItem::Slot::Right && index < (m_keyframes.size() - 1))
|
||||
|
||||
@@ -504,9 +504,9 @@ void DesignDocument::paste()
|
||||
targetNode = targetNode.parentProperty().parentModelNode();
|
||||
} else {
|
||||
// if selection is empty and copied nodes are all 3D nodes, paste them under the active scene
|
||||
bool all3DNodes = std::find_if(selectedNodes.begin(), selectedNodes.end(),
|
||||
bool all3DNodes = std::find_if(selectedNodes.cbegin(), selectedNodes.cend(),
|
||||
[](const ModelNode &node) { return !node.isSubclassOf("QtQuick3D.Node"); })
|
||||
== selectedNodes.end();
|
||||
== selectedNodes.cend();
|
||||
if (all3DNodes) {
|
||||
int activeSceneId = rootModelNode().auxiliaryData("active3dScene").toInt();
|
||||
if (activeSceneId != -1) {
|
||||
|
||||
@@ -404,7 +404,7 @@ void QnxConfiguration::setDefaultConfiguration(const Utils::FilePath &envScript)
|
||||
const QnxConfiguration::Target *QnxConfiguration::findTargetByDebuggerPath(
|
||||
const FilePath &path) const
|
||||
{
|
||||
auto it = std::find_if(m_targets.begin(), m_targets.end(),
|
||||
const auto it = std::find_if(m_targets.begin(), m_targets.end(),
|
||||
[path](const Target &target) { return target.m_debuggerPath == path; });
|
||||
return it == m_targets.end() ? nullptr : &(*it);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user