35 #include <QModelIndex>
36 #include <QtXml/QDomElement>
56 return QString::fromUtf8 (str.c_str ());
102 const QString& locale,
103 const QString& prefix =
"leechcraft",
104 const QString& appname =
"leechcraft");
125 const QString& prefix =
"leechcraft",
126 const QString& appname =
"leechcraft");
173 UTIL_API QPixmap
DrawOverlayText (QPixmap px,
const QString& text, QFont font,
const QPen& pen,
const QBrush& brush);
218 template<
typename TagGetter,
typename TagSetter>
221 QDomDocument& document,
222 const QString& elementName,
228 qWarning () << Q_FUNC_INFO
231 return node.toElement ();
234 QDomNodeList elements = node.childNodes ();
235 for (
int i = 0; i < elements.size (); ++i)
237 QDomElement elem = elements.at (i).toElement ();
238 if (tagGetter (elem) == tags.at (0))
240 if (tags.size () > 1)
242 QStringList childTags = tags;
243 childTags.removeAt (0);
245 document, elementName,
246 tagGetter, tagSetter);
253 QDomElement result = document.createElement (elementName);
254 tagSetter (result, tags.at (0));
255 node.appendChild (result);
256 if (tags.size () > 1)
258 QStringList childTags = tags;
259 childTags.removeAt (0);
261 document, elementName,
262 tagGetter, tagSetter);
268 template<
typename K,
typename V>
271 #if QT_VERSION >= 0x050000
275 for (
const auto& pair : l)
276 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")
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 &)
QMap< K, V > MakeMap(std::initializer_list< std::pair< K, V >> l)
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)
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.
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.