LeechCraft
0.6.70-18450-gabe19ee3b0
Modular cross-platform feature rich live environment.
Toggle main menu visibility
Loading...
Searching...
No Matches
buildtagstree.cpp
Go to the documentation of this file.
1
/**********************************************************************
2
* LeechCraft - modular cross-platform feature rich internet client.
3
* Copyright (C) 2006-2014 Georg Rudoy
4
*
5
* Distributed under the Boost Software License, Version 1.0.
6
* (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7
**********************************************************************/
8
9
#include "
buildtagstree.h
"
10
#include <QDomDocument>
11
12
namespace
LC::Util
13
{
14
QDomElement
BuildTagsTree
(QStringList tags,
15
QDomNode& node,
16
QDomDocument& document,
17
const
QString& elementName,
18
const
std::function<QString (QDomElement)>& tagGetter,
19
const
std::function<
void
(QDomElement&, QString)>& tagSetter)
20
{
21
if
(tags.isEmpty ())
22
return
node.toElement ();
23
24
const
auto
& tag = tags.value (0);
25
tags.removeFirst ();
26
27
auto
elements = node.childNodes ();
28
for
(
int
i = 0; i < elements.size (); ++i)
29
{
30
auto
elem = elements.at (i).toElement ();
31
if
(tagGetter (elem) == tag)
32
return
BuildTagsTree
(tags, elem,
33
document, elementName,
34
tagGetter, tagSetter);
35
}
36
37
auto
result = document.createElement (elementName);
38
tagSetter (result, tag);
39
node.appendChild (result);
40
return
BuildTagsTree
(tags, result,
41
document, elementName,
42
tagGetter, tagSetter);
43
}
44
}
buildtagstree.h
LC::Util
Definition
icoreproxy.h:34
LC::Util::BuildTagsTree
QDomElement BuildTagsTree(QStringList tags, QDomNode &node, QDomDocument &document, const QString &elementName, const std::function< QString(QDomElement)> &tagGetter, const std::function< void(QDomElement &, QString)> &tagSetter)
Builds a nested sequence of DOM elements representing a list of tags.
Definition
buildtagstree.cpp:14
src
util
sll
buildtagstree.cpp
Generated by
1.17.0