35 #include <QModelIndex>
36 #include <QtXml/QDomElement>
55 return QString::fromUtf8 (str.c_str ());
136 const QString& prefix =
"leechcraft",
137 const QString& appname =
"leechcraft");
225 const QString& location,
226 LeechCraft::TaskParameters tp,
227 const QString& mime = QString ());
299 UTIL_API QPixmap
DrawOverlayText (QPixmap px,
const QString& text, QFont font,
const QPen& pen,
const QBrush& brush);
333 template<
typename TagGetter,
typename TagSetter>
336 QDomDocument& document,
337 const QString& elementName,
343 qWarning () << Q_FUNC_INFO
346 return node.toElement ();
349 QDomNodeList elements = node.childNodes ();
350 for (
int i = 0; i < elements.size (); ++i)
352 QDomElement elem = elements.at (i).toElement ();
353 if (tagGetter (elem) == tags.at (0))
355 if (tags.size () > 1)
357 QStringList childTags = tags;
358 childTags.removeAt (0);
360 document, elementName,
361 tagGetter, tagSetter);
368 QDomElement result = document.createElement (elementName);
369 tagSetter (result, tags.at (0));
370 node.appendChild (result);
371 if (tags.size () > 1)
373 QStringList childTags = tags;
374 childTags.removeAt (0);
376 document, elementName,
377 tagGetter, tagSetter);
383 template<
typename K,
typename V>
384 QMap<K, V>
MakeMap (std::initializer_list<QPair<K, V>> l)
387 for (
const auto& pair : l)
388 result [pair.first] = pair.second;
UTIL_API QVariantList GetPersistentData(const QList< QVariant > &keys, QObject *object)
bool operator()(typename T::value_type i)
UTIL_API QDir GetUserDir(const QString &path)
Returns the path relative to user directory.
UTIL_API QString GetLocaleName()
Returns the current locale name, like en_US.
UTIL_API QString GetTemporaryName(const QString &pattern=QString("lc_temp.XXXXXX"))
Returns a temporary filename.
UTIL_API QString MakePrettySize(qint64)
Makes a formatted size from number.
UTIL_API QDir CreateIfNotExists(const QString &path)
Creates a path if it doesn't exist.
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 QString MakeTimeFromLong(ulong)
Makes a formatted time from number.
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)
UTIL_API Entity MakeANCancel(const Entity &event)
Makes an event for canceling another Advanced Notifications event.
UTIL_API Entity MakeEntity(const QVariant &entity, const QString &location, LeechCraft::TaskParameters tp, const QString &mime=QString())
An utility function to make a Entity.
UTIL_API Entity MakeNotification(const QString &header, const QString &text, Priority priority)
An utility function to make a Entity with notification.
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.