BibleTime
src
frontend
searchdialog
analysis
csearchanalysislegenditem.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 "
csearchanalysislegenditem.h
"
14
15
#include <QBrush>
16
#include <QFont>
17
#include <QPainter>
18
#include <QPoint>
19
#include <QRect>
20
#include <QRectF>
21
#include "../../../backend/cswordmodulesearch.h"
22
#include "../../../backend/drivers/cswordmoduleinfo.h"
23
#include "
csearchanalysisscene.h
"
24
25
26
namespace
Search
{
27
28
const
int
ITEM_TEXT_SIZE
= 8;
29
30
const
int
LEGEND_INNER_BORDER
= 5;
31
const
int
LEGEND_DELTAY
= 4;
32
33
34
void
CSearchAnalysisLegendItem::paint
(QPainter* painter,
const
QStyleOptionGraphicsItem*,
QWidget
*) {
35
painter->save();
36
37
//the outer rectangle
38
#define S(...) static_cast<int>(__VA_ARGS__)
39
QPoint p1(
S
(rect().x()),
S
(rect().y()));
40
QPoint p2(
S
(rect().x() + rect().width()),
S
(rect().y() + rect().height()));
41
QRect
r
(p1, p2);
42
r
=
r
.normalized();
43
painter->drawRect(
r
);
44
45
QFont f = painter->font();
46
f.setPointSize(
ITEM_TEXT_SIZE
);
47
painter->setFont(f);
48
49
// for (unsigned int index=0; index < m_moduleList->count(); index++){
50
int
moduleIndex = 0;
51
for
(
auto
const
& result : *
m_results
) {
52
auto
const
*
const
m = result.module;
53
// the module color indicators
54
QPoint p1(
S
(rect().x()) +
LEGEND_INNER_BORDER
,
S
(rect().y()) +
LEGEND_INNER_BORDER
+ moduleIndex*(
LEGEND_DELTAY
+
ITEM_TEXT_SIZE
));
55
#undef S
56
QPoint p2(p1.x() +
ITEM_TEXT_SIZE
, p1.y() +
ITEM_TEXT_SIZE
);
57
QRect
r
(p1, p2);
58
painter->fillRect(
r
, QBrush(
CSearchAnalysisScene::getColor
(moduleIndex)) );
59
r
=
r
.normalized();
60
painter->drawRect(
r
);
61
62
QPoint p3( p2.x() +
LEGEND_INNER_BORDER
, p2.y() );
63
painter->drawText(p3, m->name() );
64
65
++moduleIndex;
66
}
67
painter->restore();
68
}
69
70
71
}
QWidget
Search::CSearchAnalysisLegendItem::paint
void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) override
Definition
csearchanalysislegenditem.cpp:34
Search::CSearchAnalysisLegendItem::m_results
CSwordModuleSearch::Results const *const m_results
Definition
csearchanalysislegenditem.h:36
Search::CSearchAnalysisScene::getColor
static QColor getColor(int index)
Definition
csearchanalysisscene.cpp:175
S
#define S(...)
csearchanalysislegenditem.h
csearchanalysisscene.h
r
QStringList r(content.left(bodyIndex))
Search
Definition
bibletime.h:29
Search::LEGEND_DELTAY
const int LEGEND_DELTAY
Definition
csearchanalysislegenditem.cpp:31
Search::ITEM_TEXT_SIZE
const int ITEM_TEXT_SIZE
Definition
csearchanalysisitem.cpp:27
Search::LEGEND_INNER_BORDER
const int LEGEND_INNER_BORDER
Definition
csearchanalysislegenditem.cpp:30
Generated by
1.9.8