15 #include <QApplication>
18 #include <QFileDevice>
19 #include <QFontMetrics>
23 #include <QMessageBox>
25 #include <QTextStream>
27 #include "../backend/drivers/cswordmoduleinfo.h"
36 void (&writer)(QTextStream &,
void *),
41 QFile saveFile(filename);
43 if (saveFile.exists())
46 if (saveFile.open(QIODevice::ReadWrite)) {
47 QTextStream textstream(&saveFile);
48 writer(textstream, userPtr);
51 if (saveFile.error() == QFile::NoError)
54 QMessageBox::critical(
nullptr, QObject::tr(
"Error"),
55 QStringLiteral(
"<qt>%1<br/><b>%2</b></qt>")
56 .arg(QObject::tr(
"Error while writing to file."))
57 .arg(QObject::tr(
"Please check that enough disk space is available.")));
60 QMessageBox::critical(
nullptr, QObject::tr(
"Error"),
61 QStringLiteral(
"<qt>%1<br/><b>%2</b></qt>")
62 .arg(QObject::tr(
"The file couldn't be opened for saving."))
63 .arg(QObject::tr(
"Please check permissions etc.")));
73 struct UserData { QString
const & text; } userData{text};
74 static auto const writer =
75 +[](QTextStream & out,
void * textPtr)
76 { out << static_cast<const UserData *>(textPtr)->text; };
82 return CResMgr::modules::book::icon_locked();
85 return CResMgr::modules::icon_cult();
87 switch (module->
type()) {
90 return CResMgr::modules::bible::icon_locked();
91 return CResMgr::modules::bible::icon_unlocked();
95 return CResMgr::modules::lexicon::icon_locked();
96 return CResMgr::modules::lexicon::icon_unlocked();
100 return CResMgr::modules::commentary::icon_locked();
101 return CResMgr::modules::commentary::icon_unlocked();
105 return CResMgr::modules::book::icon_locked();
106 return CResMgr::modules::book::icon_unlocked();
111 return CResMgr::modules::book::icon_locked();
112 return CResMgr::modules::book::icon_unlocked();
117 const QString & heading,
118 const QString & text)
121 if (!heading.isEmpty())
122 labelText += QStringLiteral(
"<b>%1</b>").arg(heading);
124 if (!heading.isEmpty() && !text.isEmpty())
126 QStringLiteral(
"<span style=\"white-space:pre\"> - </span>");
129 labelText += QStringLiteral(
"<small>%1</small>").arg(text);
131 label->setText(labelText);
132 label->setWordWrap(
true);
134 label->setFrameStyle(QFrame::Box | QFrame::Sunken);
138 int i1 = text.lastIndexOf(
'<', pos);
139 int i2 = text.lastIndexOf(
'>', pos);
140 int i3 = text.indexOf(
'>', pos);
141 int i4 = text.indexOf(
'<', pos);
147 if ((i3 > 0) && (i4 == -1))
152 return (i1 > i2) && (i3 < i4);
156 {
return widget.fontMetrics().horizontalAdvance(QString(mCount,
'M')); }
159 input.replace(
'_',
'-');
CSwordModuleInfo::Category category() const