Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
servicesproxymodel.cpp
Go to the documentation of this file.
1
// Copyright (C) 2016 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4
#
include
"servicesproxymodel.h"
5
6
using
namespace
Qt::StringLiterals;
7
8
ServicesProxyModel
::ServicesProxyModel(QObject *parent)
9
: QSortFilterProxyModel(parent)
10
{
11
}
12
13
QVariant
ServicesProxyModel
::
headerData
(
int
section, Qt::Orientation orientation,
int
role)
const
14
{
15
if
(role != Qt::DisplayRole || orientation != Qt::Horizontal || section != 0)
16
return
QVariant();
17
18
return
tr(
"Services"
);
19
}
20
21
22
bool
ServicesProxyModel
::
lessThan
(
const
QModelIndex &left,
23
const
QModelIndex &right)
const
24
{
25
QString s1 = sourceModel()->data(left).toString();
26
QString s2 = sourceModel()->data(right).toString();
27
28
const
bool
isNumber1 = s1.startsWith(
":1."_L1
);
29
const
bool
isNumber2 = s2.startsWith(
":1."_L1
);
30
if
(isNumber1 == isNumber2) {
31
if
(isNumber1) {
32
int
number1 = QStringView{s1}.mid(3).toInt();
33
int
number2 = QStringView{s2}.mid(3).toInt();
34
return
number1 < number2;
35
}
else
{
36
return
s1.compare(s2, Qt::CaseInsensitive) < 0;
37
}
38
}
else
{
39
return
isNumber2;
40
}
41
}
ServicesProxyModel
Definition
servicesproxymodel.h:10
ServicesProxyModel::headerData
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
\reimp
Definition
servicesproxymodel.cpp:13
ServicesProxyModel::lessThan
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override
Returns true if the value of the item referred to by the given index source_left is less than the val...
Definition
servicesproxymodel.cpp:22
qttools
src
qdbus
qdbusviewer
servicesproxymodel.cpp
Generated on
for Qt by
1.18.0