BibleTime
Toggle main menu visibility
Main Page
Related Pages
Namespaces
Namespace List
Namespace Members
All
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
Functions
a
b
c
d
e
f
g
h
i
l
m
n
p
q
r
s
t
v
Variables
a
b
c
d
g
h
i
k
l
m
p
r
s
u
Typedefs
Enumerations
Enumerator
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
~
Functions
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
~
Variables
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
Typedefs
Enumerations
Enumerator
a
b
c
d
e
f
g
h
i
l
m
n
p
r
s
t
u
w
Properties
Related Symbols
Files
File List
File Members
All
a
b
c
e
f
h
i
j
k
l
m
o
p
r
s
t
u
w
Functions
b
c
f
i
j
l
m
o
p
r
t
Variables
Typedefs
Enumerations
Enumerator
Macros
a
b
c
i
l
m
r
s
t
u
w
src
frontend
btbookshelfgroupingmenu.cpp
Go to the documentation of this file.
1
/*********
2
*
3
* In the name of the Father, and of the Son, and of the Holy Spirit.
4
*
5
* This file is part of BibleTime's source code, https://bibletime.info/
6
*
7
* Copyright 1999-2025 by the BibleTime developers.
8
* The BibleTime source code is licensed under the GNU General Public License
9
* version 2.0.
10
*
11
**********/
12
13
#include "
btbookshelfgroupingmenu.h
"
14
15
#include <QAction>
16
#include <QActionGroup>
17
#include <QVariant>
18
#include "../backend/bookshelfmodel/btbookshelftreemodel.h"
19
#include "../util/btconnect.h"
20
#include "../util/cresmgr.h"
21
22
23
namespace
{
24
25
inline
void
setActionRef
(
QAction
*a,
const
BtBookshelfTreeModel::Grouping
&g) {
26
a->setProperty(
"groupingPointer"
,
27
QVariant::fromValue(
28
const_cast<
void
*
>
(
static_cast<
void
const
*
>
(&g))));
29
}
25
inline
void
setActionRef
(
QAction
*a,
const
BtBookshelfTreeModel::Grouping
&g) {
…
}
30
31
inline
const
BtBookshelfTreeModel::Grouping
&
getActionRef
(
const
QAction
*a) {
32
return
*
static_cast<
BtBookshelfTreeModel::Grouping
const
*
>
(
33
a->property(
"groupingPointer"
).value<
void
*>());
34
}
31
inline
const
BtBookshelfTreeModel::Grouping
&
getActionRef
(
const
QAction
*a) {
…
}
35
36
}
// anonymous namespace
23
namespace
{
…
}
37
38
39
void
BtBookshelfGroupingMenu::setGrouping
(
40
BtBookshelfTreeModel::Grouping
const
& grouping)
41
{
42
using
G =
BtBookshelfTreeModel::Grouping
;
43
if
(grouping == G::CAT_LANG) {
44
m_groupingCatLangAction
->setChecked(
true
);
45
}
else
if
(grouping == G::CAT) {
46
m_groupingCatAction
->setChecked(
true
);
47
}
else
if
(grouping == G::LANG_CAT) {
48
m_groupingLangCatAction
->setChecked(
true
);
49
}
else
if
(grouping == G::LANG) {
50
m_groupingLangAction
->setChecked(
true
);
51
}
else
{
52
BT_ASSERT
(grouping == G::NONE);
53
if
(
m_groupingNoneAction
)
54
m_groupingNoneAction
->setChecked(
true
);
55
}
56
}
39
void
BtBookshelfGroupingMenu::setGrouping
( {
…
}
57
58
void
BtBookshelfGroupingMenu::initMenu
(
bool
showNoGrouping) {
59
setIcon(CResMgr::mainIndex::grouping::icon());
60
61
m_groupingActionGroup
=
new
QActionGroup(
this
);
62
m_groupingActionGroup
->setExclusive(
true
);
63
BT_CONNECT
(
m_groupingActionGroup
, &QActionGroup::triggered,
64
[
this
](
QAction
*
const
action)
65
{ Q_EMIT
signalGroupingOrderChanged
(getActionRef(action)); });
66
67
using
G =
BtBookshelfTreeModel::Grouping
;
68
69
m_groupingCatLangAction
=
new
QAction
(
this
);
70
m_groupingCatLangAction
->setCheckable(
true
);
71
setActionRef(
m_groupingCatLangAction
, G::CAT_LANG);
72
m_groupingActionGroup
->addAction(
m_groupingCatLangAction
);
73
addAction(
m_groupingCatLangAction
);
74
75
m_groupingCatAction
=
new
QAction
(
this
);
76
m_groupingCatAction
->setCheckable(
true
);
77
setActionRef(
m_groupingCatAction
, G::CAT);
78
m_groupingActionGroup
->addAction(
m_groupingCatAction
);
79
addAction(
m_groupingCatAction
);
80
81
m_groupingLangCatAction
=
new
QAction
(
this
);
82
m_groupingLangCatAction
->setCheckable(
true
);
83
setActionRef(
m_groupingLangCatAction
, G::LANG_CAT);
84
m_groupingActionGroup
->addAction(
m_groupingLangCatAction
);
85
addAction(
m_groupingLangCatAction
);
86
87
m_groupingLangAction
=
new
QAction
(
this
);
88
m_groupingLangAction
->setCheckable(
true
);
89
setActionRef(
m_groupingLangAction
, G::LANG);
90
m_groupingActionGroup
->addAction(
m_groupingLangAction
);
91
addAction(
m_groupingLangAction
);
92
93
if
(showNoGrouping) {
94
m_groupingNoneAction
=
new
QAction
(
this
);
95
m_groupingNoneAction
->setCheckable(
true
);
96
setActionRef(
m_groupingNoneAction
, G::NONE);
97
m_groupingActionGroup
->addAction(
m_groupingNoneAction
);
98
addAction(
m_groupingNoneAction
);
99
}
else
{
100
m_groupingNoneAction
=
nullptr
;
101
}
102
103
retranslateUi
();
104
}
58
void
BtBookshelfGroupingMenu::initMenu
(
bool
showNoGrouping) {
…
}
105
106
void
BtBookshelfGroupingMenu::retranslateUi
() {
107
m_groupingCatLangAction
->setText(tr(
"Category/Language"
));
108
m_groupingCatAction
->setText(tr(
"Category"
));
109
m_groupingLangCatAction
->setText(tr(
"Language/Category"
));
110
m_groupingLangAction
->setText(tr(
"Language"
));
111
112
if
(
m_groupingNoneAction
!=
nullptr
) {
113
m_groupingNoneAction
->setText(tr(
"No grouping"
));
114
}
115
}
106
void
BtBookshelfGroupingMenu::retranslateUi
() {
…
}
BT_ASSERT
#define BT_ASSERT(...)
Definition
btassert.h:17
btbookshelfgroupingmenu.h
BT_CONNECT
#define BT_CONNECT(...)
Definition
btconnect.h:20
BtBookshelfGroupingMenu::setGrouping
void setGrouping(BtBookshelfTreeModel::Grouping const &grouping)
Definition
btbookshelfgroupingmenu.cpp:39
BtBookshelfGroupingMenu::signalGroupingOrderChanged
void signalGroupingOrderChanged(const BtBookshelfTreeModel::Grouping &)
BtBookshelfGroupingMenu::m_groupingLangAction
QAction * m_groupingLangAction
Definition
btbookshelfgroupingmenu.h:52
BtBookshelfGroupingMenu::retranslateUi
void retranslateUi()
Definition
btbookshelfgroupingmenu.cpp:106
BtBookshelfGroupingMenu::m_groupingLangCatAction
QAction * m_groupingLangCatAction
Definition
btbookshelfgroupingmenu.h:51
BtBookshelfGroupingMenu::m_groupingCatAction
QAction * m_groupingCatAction
Definition
btbookshelfgroupingmenu.h:50
BtBookshelfGroupingMenu::initMenu
void initMenu(bool showNoGrouping)
Definition
btbookshelfgroupingmenu.cpp:58
BtBookshelfGroupingMenu::m_groupingCatLangAction
QAction * m_groupingCatLangAction
Definition
btbookshelfgroupingmenu.h:49
BtBookshelfGroupingMenu::m_groupingNoneAction
QAction * m_groupingNoneAction
Definition
btbookshelfgroupingmenu.h:53
BtBookshelfGroupingMenu::m_groupingActionGroup
QActionGroup * m_groupingActionGroup
Definition
btbookshelfgroupingmenu.h:48
BtBookshelfTreeModel::Grouping
Definition
btbookshelftreemodel.h:67
QAction
anonymous_namespace{btbookshelfgroupingmenu.cpp}::getActionRef
const BtBookshelfTreeModel::Grouping & getActionRef(const QAction *a)
Definition
btbookshelfgroupingmenu.cpp:31
anonymous_namespace{btbookshelfgroupingmenu.cpp}::setActionRef
void setActionRef(QAction *a, const BtBookshelfTreeModel::Grouping &g)
Definition
btbookshelfgroupingmenu.cpp:25
Generated by
1.9.8