Skip to content

Commit

Permalink
ObjectQuery: Find objects based on symbol number
Browse files Browse the repository at this point in the history
Extend the 'Find' functionality to search for objects with a specific
symbol number as described by the Mapper manual (e.g.,'SYMBOL 123').

Closes OpenOrienteering#2183
  • Loading branch information
dl3sdo committed Oct 3, 2023
1 parent 0359901 commit f7f6dee
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/core/objects/object_query.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright 2016 Mitchell Krome
* Copyright 2017-2022 Kai Pastor
* Copyright 2017-2023 Kai Pastor
*
* This file is part of OpenOrienteering.
*
Expand Down Expand Up @@ -416,6 +416,16 @@ bool ObjectQuery::operator()(const Object* object) const
return it != container.end() && it->value.contains(tags.value);
} (object->tags(), tags);
case OperatorSearch:
if (tags.value.startsWith(QLatin1String("SYMBOL"), Qt::CaseSensitive))
{
auto start_number = tags.value.lastIndexOf(QLatin1Char(' ')) + 1;
if (start_number > 0 && tags.value.length() > start_number)
{
if (object->getSymbol() && object->getSymbol()->getNumberAsString() == tags.value.mid(start_number))
return true;
}
return false;
}
if (object->getSymbol() && object->getSymbol()->getName().contains(tags.value, Qt::CaseInsensitive))
return true;
for (auto const& current : object->tags())
Expand Down

0 comments on commit f7f6dee

Please sign in to comment.