Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
83 lines (64 loc) · 1.82 KB

File metadata and controls

83 lines (64 loc) · 1.82 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include "joinrole.h"
#include "qqmlsortfilterproxymodel.h"
namespace qqsfpm {
/*!
\qmltype JoinRole
\inherits SingleRole
\inqmlmodule SortFilterProxyModel
\ingroup ProxyRoles
\brief a role made from concatenating other roles.
A JoinRole is a simple \l ProxyRole that concatenates other roles.
In the following example, the \c fullName role is computed by the concatenation of the \c firstName role and the \c lastName role separated by a space :
\code
SortFilterProxyModel {
sourceModel: contactModel
proxyRoles: JoinRole {
name: "fullName"
roleNames: ["firstName", "lastName"]
}
}
\endcode
*/
/*!
\qmlproperty list<string> JoinRole::roleNames
This property holds the role names that are joined by this role.
*/
QStringList JoinRole::roleNames() const
{
return m_roleNames;
}
void JoinRole::setRoleNames(const QStringList& roleNames)
{
if (m_roleNames == roleNames)
return;
m_roleNames = roleNames;
Q_EMIT roleNamesChanged();
invalidate();
}
/*!
\qmlproperty string JoinRole::separator
This property holds the separator that is used to join the roles specified in \l roleNames.
By default, it's a space.
*/
QString JoinRole::separator() const
{
return m_separator;
}
void JoinRole::setSeparator(const QString& separator)
{
if (m_separator == separator)
return;
m_separator = separator;
Q_EMIT separatorChanged();
invalidate();
}
QVariant JoinRole::data(const QModelIndex &sourceIndex, const QQmlSortFilterProxyModel& proxyModel)
{
QString result;
for (const QString& roleName : m_roleNames)
result += proxyModel.sourceData(sourceIndex, roleName).toString() + m_separator;
if (!m_roleNames.isEmpty())
result.chop(m_separator.length());
return result;
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.