BibleTime
src
util
tool.h
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-2021 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
#pragma once
14
15
#include <QString>
16
17
18
class
CSwordModuleInfo
;
19
class
QIcon;
20
class
QLabel;
21
class
QTextStream;
22
class
QWidget
;
23
24
namespace
util
{
25
namespace
tool {
26
27
/**
28
Creates the file filename and writes to it using a callback..
29
30
\param[in] filename the filename to save to.
31
\param[in] writer the writer callback.
32
\param[in] userPtr arbitrary data passed on to the callback.
33
\param[in] fileCodec the codec to use to save the given string data.
34
\warning if a file with the given name already exists, it is first removed.
35
\returns whether the file was properly saved.
36
*/
37
bool
savePlainFile
(QString
const
& filename,
38
void
(&writer)(QTextStream &,
void
*),
39
void
* userPtr);
40
41
/**
42
Creates the file filename and save the given text into the file.
43
44
\param[in] filename the filename to save to.
45
\param[in] text the string data to save.
46
\param[in] fileCodec the codec to use to save the given string data.
47
\warning if a file with the given name already exists, it is first removed.
48
\returns whether the file was properly saved.
49
*/
50
bool
savePlainFile
(QString
const
& filename, QString
const
& text);
51
52
/**
53
\param[in] module the module whose icon to return.
54
\returns the icon used for the a module.
55
*/
56
QIcon
const
&
getIconForModule
(
const
CSwordModuleInfo
* module);
57
58
/**
59
\brief Initializes a QLabel to explain difficult things of dialogs.
60
61
The label should be used to explain difficult things of the GUI, e.g. in the
62
options dialog pages.
63
64
\param[in] label The label to initialize
65
\param[in] heading The heading for the label.
66
\param[in] text The text for the label.
67
*/
68
void
initExplanationLabel
(QLabel * label,
69
const
QString & heading,
70
const
QString & text);
71
72
/**
73
\returns whether the character at position "pos" of text is inside an HTML tag.
74
*/
75
bool
inHTMLTag
(
int
pos,
const
QString & text);
76
77
/**
78
\brief Calculates a maximum rendered text width for a widget and a string with
79
the a given length.
80
81
This function can be used for setting the size for a widget. It may be better
82
to roughly calculate the size based on some text width rather than use a hard-
83
coded value.
84
85
\param[in] widget the widget whose font metrics to use.
86
\param[in] mCount the length of the string of 'M' characters to use for
87
calculating the width.
88
89
\returns the width in pixels.
90
*/
91
int
mWidth
(
QWidget
const
& widget,
int
const
mCount);
92
93
/**
94
\param[in] input The potentially invalid BCP 47 string from Sword to fix.
95
\returns a string (hopefully) more conformant to BCP 47
96
*/
97
QString
fixSwordBcp47
(QString input);
98
99
}
/* namespace tool { */
100
}
/* namespace util { */
CSwordModuleInfo
Definition:
cswordmoduleinfo.h:49
QWidget
util::tool::fixSwordBcp47
QString fixSwordBcp47(QString input)
Definition:
tool.cpp:158
util::tool::initExplanationLabel
void initExplanationLabel(QLabel *const label, const QString &heading, const QString &text)
Initializes a QLabel to explain difficult things of dialogs.
Definition:
tool.cpp:116
util::tool::mWidth
int mWidth(QWidget const &widget, int const mCount)
Calculates a maximum rendered text width for a widget and a string with the a given length.
Definition:
tool.cpp:155
util::tool::savePlainFile
bool savePlainFile(const QString &filename, void(&writer)(QTextStream &, void *), void *userPtr)
Definition:
tool.cpp:35
util::tool::inHTMLTag
bool inHTMLTag(const int pos, const QString &text)
Definition:
tool.cpp:137
util::tool::getIconForModule
QIcon const & getIconForModule(const CSwordModuleInfo *const module)
Definition:
tool.cpp:80
util
Definition:
cp1252.cpp:24
Generated by
1.9.1