35 #include <QModelIndex>
36 #include <QtXml/QDomElement>
55 return QString::fromUtf8 (str.c_str ());
118 const QString& locale,
119 const QString& prefix =
"leechcraft",
120 const QString& appname =
"leechcraft");
141 const QString& prefix =
"leechcraft",
142 const QString& appname =
"leechcraft");
189 UTIL_API QPixmap
DrawOverlayText (QPixmap px,
const QString& text, QFont font,
const QPen& pen,
const QBrush& brush);
234 template<
typename TagGetter,
typename TagSetter>
237 QDomDocument& document,
238 const QString& elementName,
244 qWarning () << Q_FUNC_INFO
247 return node.toElement ();
250 QDomNodeList elements = node.childNodes ();
251 for (
int i = 0; i < elements.size (); ++i)
253 QDomElement elem = elements.at (i).toElement ();
254 if (tagGetter (elem) == tags.at (0))
256 if (tags.size () > 1)
258 QStringList childTags = tags;
259 childTags.removeAt (0);
261 document, elementName,
262 tagGetter, tagSetter);
269 QDomElement result = document.createElement (elementName);
270 tagSetter (result, tags.at (0));
271 node.appendChild (result);
272 if (tags.size () > 1)
274 QStringList childTags = tags;
275 childTags.removeAt (0);
277 document, elementName,
278 tagGetter, tagSetter);
284 template<
typename K,
typename V>
285 QMap<K, V>
MakeMap (std::initializer_list<QPair<K, V>> l)
288 for (
const auto& pair : l)
289 result [pair.first] = pair.second;
UTIL_API QString MakePrettySize(qint64 sourceSize)
Makes a formatted size from number.
UTIL_API QTranslator * LoadTranslator(const QString &base, const QString &locale, const QString &prefix="leechcraft", const QString &appname="leechcraft")
bool operator()(typename T::value_type i)
UTIL_API uintptr_t Handle2Num(Qt::HANDLE handle)
Converts the handle to an integer.
UTIL_API QString GetLocaleName()
Returns the current locale name, like en_US.
UTIL_API QString MakeTimeFromLong(ulong time)
Makes a formatted time from number.
UTIL_API QString GetLanguage()
Returns the current language name.
UTIL_API QString GetInternetLocaleName(const QLocale &)
UTIL_API QTranslator * InstallTranslator(const QString &base, const QString &prefix="leechcraft", const QString &appname="leechcraft")
Loads and installs a translator.
UTIL_API QAction * CreateSeparator(QObject *parent)
Returns the action that is set to act as a separator.
UTIL_API QString GetUserText(const Entity &entity)
Return the user-readable representation of the entity.
UTIL_API QPixmap DrawOverlayText(QPixmap px, const QString &text, QFont font, const QPen &pen, const QBrush &brush)
ValueFinder(data_type data)
UTIL_API QString GetAsBase64Src(const QImage &image)
Returns the given image in a Base64-encoded form.
UTIL_API QModelIndexList GetSummarySelectedRows(QObject *sender)
Describes parameters of an entity.
QMap< K, V > MakeMap(std::initializer_list< QPair< K, V >> l)
QDomElement GetElementForTags(const QStringList &tags, QDomNode &node, QDomDocument &document, const QString &elementName, TagGetter tagGetter, TagSetter tagSetter)
Returns an element for a given tags list.
QString FromStdString(const std::string &str)
An utility function that creates a QString from UTF8-encoded std::string.