Union::ElementQuery Class
class Union::ElementQueryA class encapsulating lookup of style properties based on a list of elements. More...
Header: | #include <ElementQuery> |
CMake: | find_package(Union REQUIRED) target_link_libraries(mytarget PRIVATE Union::Union) |
Public Functions
ElementQuery(std::shared_ptr<Union::Theme> theme = nullptr) | |
QList<Union::Element::Ptr> | elements() const |
bool | execute() |
bool | hasMatches() const |
QList<Union::StyleRule::Ptr> | matchedRules() const |
const Union::Properties::StyleProperty & | properties() const |
void | setElements(const QList<Union::Element::Ptr> &elements) |
Detailed Description
This class will try find which style rules match a certain list of elements. The list of elements is expected to represent a chain of elements from the root of the application to a specific element.
Lookup is done for individual properties, so requesting for example the background color would result in checking if the first matched rule has the background color set and if so, return that. If not the second rule would be checked and so on.
Member Function Documentation
[explicit]
ElementQuery::ElementQuery(std::shared_ptr<Union::Theme> theme = nullptr)
Constructor.
theme An instance of Theme that is used to get the style rules from.
QList<Union::Element::Ptr> ElementQuery::elements() const
The list of elements that should be matched against.
This list is treated as a hierarchy, with the first element as the bottom most element and the last the top most.
See also setElements().
bool ElementQuery::execute()
Execute the query.
This will perform matching of style rules from the query's theme against the list of elements in this query.
Returns true if the query was successful, false if nothing was matched.
bool ElementQuery::hasMatches() const
Returns if the last call to execute() had any matches.
QList<Union::StyleRule::Ptr> ElementQuery::matchedRules() const
Returns the list of matched style rules for this query.
const Union::Properties::StyleProperty &ElementQuery::properties() const
Returns the root of the combined matched set of properties.
This will contain all the resolved properties of the matched style rules.
void ElementQuery::setElements(const QList<Union::Element::Ptr> &elements)
Set the list of elements to match against.
elements The elements to match.
See also elements().