LeechCraft
0.6.70-18450-gabe19ee3b0
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
flatitemsmodel.h
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
#pragma once
10
11
#include "
flatitemsmodeltypedbase.h
"
12
13
namespace
LC::Util
14
{
15
namespace
detail
16
{
17
template
<
typename
T,
typename
... Ts>
18
QVariant
GetFieldImpl
(
int
idx, T& head, Ts&... tail)
19
{
20
if
(!idx)
21
return
head;
22
23
if
constexpr
(
sizeof
... (Ts))
24
return
GetFieldImpl
(idx - 1, tail...);
25
else
26
throw
std::runtime_error {
"out of bounds tuple-like access"
};
27
}
28
29
template
<
typename
T>
30
QVariant
GetField
(
const
T& item,
int
idx)
31
{
32
auto
&& [...elems] = item;
33
return
GetFieldImpl
(idx, elems...);
34
}
35
}
36
37
template
<
typename
T>
38
class
FlatItemsModel
:
public
FlatItemsModelTypedBase
<T>
39
{
40
public
:
41
using
FlatItemsModelTypedBase
<T>
::FlatItemsModelTypedBase
;
42
protected
:
43
QVariant
GetData
(
int
row,
int
col,
int
role)
const override
44
{
45
if
(role == this->
DataRole
)
46
return
QVariant::fromValue (this->
Items_
.at (row));
47
48
if
(role != Qt::DisplayRole)
49
return
{};
50
51
return
detail::GetField
(this->
Items_
.at (row), col);
52
}
53
};
54
}
LC::Util::FlatItemsModelBase::DataRole
static constexpr auto DataRole
Definition
flatitemsmodelbase.h:22
LC::Util::FlatItemsModel
Definition
flatitemsmodel.h:39
LC::Util::FlatItemsModel::GetData
QVariant GetData(int row, int col, int role) const override
Definition
flatitemsmodel.h:43
LC::Util::FlatItemsModelTypedBase
Definition
flatitemsmodeltypedbase.h:17
LC::Util::FlatItemsModelTypedBase::Items_
QList< T > Items_
Definition
flatitemsmodeltypedbase.h:19
flatitemsmodeltypedbase.h
LC::Util::detail
Definition
fancytrayiconfreedesktop.cpp:24
LC::Util::detail::GetFieldImpl
QVariant GetFieldImpl(int idx, T &head, Ts &... tail)
Definition
flatitemsmodel.h:18
LC::Util::detail::GetField
QVariant GetField(const T &item, int idx)
Definition
flatitemsmodel.h:30
LC::Util
Definition
icoreproxy.h:34
src
util
models
flatitemsmodel.h
Generated by
1.16.1