BibleTime
Functions
util::tool Namespace Reference

Functions

QString fixSwordBcp47 (QString input)
 
QIcon const & getIconForModule (const CSwordModuleInfo *const module)
 
bool inHTMLTag (const int pos, const QString &text)
 
void initExplanationLabel (QLabel *label, const QString &heading, const QString &text)
 Initializes a QLabel to explain difficult things of dialogs. More...
 
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. More...
 
bool savePlainFile (const QString &filename, void(&writer)(QTextStream &, void *), void *userPtr)
 
bool savePlainFile (QString const &filename, QString const &text)
 

Function Documentation

◆ fixSwordBcp47()

QString util::tool::fixSwordBcp47 ( QString  input)
Parameters
[in]inputThe potentially invalid BCP 47 string from Sword to fix.
Returns
a string (hopefully) more conformant to BCP 47

Definition at line 158 of file tool.cpp.

Referenced by CDisplaySettingsPage::initSwordLocaleCombo(), and CDisplaySettingsPage::resetLanguage().

◆ getIconForModule()

QIcon const & util::tool::getIconForModule ( const CSwordModuleInfo module)

◆ inHTMLTag()

bool util::tool::inHTMLTag ( int  pos,
const QString &  text 
)
Returns
whether the character at position "pos" of text is inside an HTML tag.

Definition at line 137 of file tool.cpp.

◆ initExplanationLabel()

void util::tool::initExplanationLabel ( QLabel *  label,
const QString &  heading,
const QString &  text 
)

Initializes a QLabel to explain difficult things of dialogs.

The label should be used to explain difficult things of the GUI, e.g. in the options dialog pages.

Parameters
[in]labelThe label to initialize
[in]headingThe heading for the label.
[in]textThe text for the label.

Definition at line 116 of file tool.cpp.

Referenced by BtSearchModuleChooserDialog::retranslateUi(), BtStandardWorksTab::retranslateUi(), and BtTextFiltersTab::retranslateUi().

◆ mWidth()

int util::tool::mWidth ( QWidget const &  widget,
int const  mCount 
)

Calculates a maximum rendered text width for a widget and a string with the a given length.

This function can be used for setting the size for a widget. It may be better to roughly calculate the size based on some text width rather than use a hard- coded value.

Parameters
[in]widgetthe widget whose font metrics to use.
[in]mCountthe length of the string of 'M' characters to use for calculating the width.
Returns
the width in pixels.

Definition at line 155 of file tool.cpp.

Referenced by BtIndexDialog::BtIndexDialog(), Search::BtSearchResultArea::BtSearchResultArea(), Search::BtSearchOptionsArea::initView(), Search::CModuleResultView::initView(), and CBookmarkIndex::paintEvent().

◆ savePlainFile() [1/2]

bool util::tool::savePlainFile ( QString const &  filename,
void(&)(QTextStream &, void *)  writer,
void *  userPtr 
)

Creates the file filename and writes to it using a callback..

Parameters
[in]filenamethe filename to save to.
[in]writerthe writer callback.
[in]userPtrarbitrary data passed on to the callback.
[in]fileCodecthe codec to use to save the given string data.
Warning
if a file with the given name already exists, it is first removed.
Returns
whether the file was properly saved.

Definition at line 35 of file tool.cpp.

References BT_ASSERT.

Referenced by BtBookmarksModel::save(), BtModelViewReadDisplay::save(), Search::CSearchAnalysisScene::saveAsHTML(), CExportManager::saveKey(), CExportManager::saveKeyList(), and savePlainFile().

◆ savePlainFile() [2/2]

bool util::tool::savePlainFile ( QString const &  filename,
QString const &  text 
)

Creates the file filename and put text into the file.

Creates the file filename and save the given text into the file.

Parameters
[in]filenamethe filename to save to.
[in]textthe string data to save.
[in]fileCodecthe codec to use to save the given string data.
Warning
if a file with the given name already exists, it is first removed.
Returns
whether the file was properly saved.

Definition at line 71 of file tool.cpp.

References savePlainFile().