LeechCraft  %{LEECHCRAFT_VERSION}
Modular cross-platform feature rich live environment.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
LeechCraft::Util Namespace Reference

Namespaces

 CacheStrat
 
 SvcAuth
 
 SysInfo
 
 XDG
 

Classes

class  AddressesModelManager
 
class  AssocCache
 
class  AutoResizeMixin
 Automatically moves a widget to fit a rectangle on resize. More...
 
class  BackendSelector
 A common dialog to select storage backend. More...
 
class  BaseHookInterconnector
 Base class for signal-slot relays in plugin APIs. More...
 
class  CategorySelector
 The CategorySelector widget provides a way to select amongst a group of items. More...
 
class  ClearLineEditAddon
 Provides a "clear text" action for line edits. More...
 
class  ColorButton
 A button for choosing a color. More...
 
class  ColorThemeProxy
 Proxy for QML files to use colors from current color theme. More...
 
class  CustomCookieJar
 A customized cookie jar with additional features. More...
 
class  CustomNetworkReply
 A network reply with customizable content and reply headers. More...
 
class  DBLock
 Provides database transaction lock. More...
 
class  DefaultHookProxy
 Standard implementation of IHookProxy. More...
 
class  DelayedExecutor
 
class  DeleteLaterPolicy
 
class  ExtensionsData
 
class  ExtensionsDataImpl
 
class  FileRemoveGuard
 QFile removing itself from file system on destruction. More...
 
class  FindNotification
 A horizontal bar with typical widgets for text search. More...
 
class  FindNotificationWk
 A helper class to aid connecting FindNotification with Qt WebKit. More...
 
class  FlattenFilterModel
 Proxy model flattening a hierarchical model. More...
 
class  FlatToFoldersProxyModel
 
class  FlowLayout
 A simple flow layout implementation. More...
 
class  IDPool
 A simple pool of identificators of the given type. More...
 
class  LineEditButtonManager
 Manages additional overlay buttons in a QLineEdit. More...
 
class  MergeModel
 
class  MimeDetector
 
class  MimeDetectorImpl
 
class  ModelItem
 
class  ModelIterator
 
class  NetworkDiskCache
 A thread-safe garbage-collected network disk cache. More...
 
class  NoDeletePolicy
 
class  NotificationActionHandler
 Aids in adding actions to notifications. More...
 
class  PageNotification
 A horizontal widget embedding into the parent layout of the passed parent widget. More...
 
class  PlotItem
 
class  QueueManager
 A simple scheduling manager for a queue of functors. More...
 
class  RegExp
 
struct  RegExpImpl
 
class  ResourceLoader
 Utility class for loading a file from a set of locations. More...
 
class  SelectableBrowser
 A "browser" that shows HTML either via QTextBrowser or a browser plugin. More...
 
class  SettableIconProvider
 
class  ShortcutManager
 Aids in providing configurable shortcuts. More...
 
class  SlotClosure
 
class  SlotClosureBase
 
class  StandardNAMFactory
 
class  StdDataFilterMenuCreator
 
class  StlAssocIteratorAdaptor
 
struct  StlAssocRange
 
class  TagsCompleter
 Completer suitable for tag completion. More...
 
class  TagsCompletionModel
 A QStringListModel providing additional methods for tags. More...
 
class  TagsFilterModel
 Provides filter model with additional tags filter mode. More...
 
class  TagsLineEdit
 A line edit class suitable for use with TagsCompleter. More...
 
class  ThemeImageProvider
 Provides icons from the current theme by their FDO name. More...
 
class  ToolTipItem
 ToolTip for Qml objects. More...
 
class  TreeItem
 
class  UnhideListModel
 
class  UnhideListViewBase
 
class  UnhoverDeleteMixin
 Allows to hide a widget or popup after mouse leave. More...
 
struct  ValueFinder
 
class  WidthIconProvider
 Provides scalable icons to QML. More...
 
class  XWrapper
 

Typedefs

typedef std::shared_ptr
< XmlSettingsDialog > 
XmlSettingsDialog_ptr
 
typedef std::shared_ptr
< ModelItem
ModelItem_ptr
 
typedef std::weak_ptr< ModelItemModelItem_wtr
 
typedef QVector< ModelItem_ptrModelItemsList_t
 
typedef std::shared_ptr< const
ModelItem
ModelItem_cptr
 
typedef QList< QPair< QString,
QString > > 
AddrList_t
 
using OneTimeRunner = SlotClosure< DeleteLaterPolicy >
 
typedef std::shared_ptr
< QIODevice > 
QIODevice_ptr
 
typedef std::shared_ptr
< DefaultHookProxy
DefaultHookProxy_ptr
 

Enumerations

enum  FitFlag {
  NoFlags,
  NoOverlap = 0x01
}
 
enum  QueuePriority {
  QueuePriority::Normal,
  QueuePriority::High
}
 
enum  SysPath {
  SysPath::QML,
  SysPath::Share
}
 Describes various root paths recognized by GetSysPath(). More...
 
enum  UserDir {
  UserDir::Cache,
  UserDir::LC
}
 Describes various user-specific paths. More...
 
enum  WinStateFlag {
  NoState = 0,
  Modal = 1 << 0,
  Sticky = 1 << 1,
  MaximizedVert = 1 << 2,
  MaximizedHorz = 1 << 3,
  Shaded = 1 << 4,
  SkipTaskbar = 1 << 5,
  SkipPager = 1 << 6,
  Hidden = 1 << 7,
  Fullscreen = 1 << 8,
  OnTop = 1 << 9,
  OnBottom = 1 << 10,
  Attention = 1 << 11
}
 
enum  AllowedActionFlag {
  NoAction = 0,
  Move = 1 << 0,
  Resize = 1 << 1,
  Minimize = 1 << 2,
  Shade = 1 << 3,
  Stick = 1 << 4,
  MaximizeHorz = 1 << 5,
  MaximizeVert = 1 << 6,
  ShowFullscreen = 1 << 7,
  ChangeDesktop = 1 << 8,
  Close = 1 << 9,
  MoveToTop = 1 << 10,
  MoveToBottom = 1 << 11
}
 

Functions

QPoint FitRectScreen (QPoint pos, const QSize &size, FitFlags flags=NoFlags, const QPoint &shiftAdd=QPoint(0, 0))
 Tries to fit a rectangle (like a dialog or popup) into screen. More...
 
QPoint FitRect (QPoint pos, const QSize &size, const QRect &geometry, FitFlags flags=NoFlags, const QPoint &shiftAdd=QPoint(0, 0))
 Tries to fit a rectangle (like a dialog or popup) into geometry. More...
 
QLabel * ShowPixmapLabel (const QPixmap &pixmap, const QPoint &pos=QPoint())
 Shows a pixmap at the given pos. More...
 
 Q_DECLARE_FLAGS (FitFlags, FitFlag)
 
AddrList_t GetLocalAddresses (int port=0)
 Returns all local addresses. More...
 
QList< QHostAddress > GetAllAddresses ()
 Returns all addresses likely accessible "from the outside". More...
 
QString GetSocketErrorString (QAbstractSocket::SocketError error)
 Returns an error string for the given socket error. More...
 
template<typename T1 , typename T2 , template< typename U > class Container, typename F >
auto ZipWith (const Container< T1 > &c1, const Container< T2 > &c2, F f) -> Container< typename std::result_of< F(T1, T2)>::type >
 
template<typename T1 , typename T2 , template< typename U > class Container, template< typename U1, typename U2 > class Pair = QPair>
auto Zip (const Container< T1 > &c1, const Container< T2 > &c2) -> Container< Pair< T1, T2 >>
 
template<typename T , template< typename U > class Container, typename F >
auto Map (const Container< T > &c, F f) -> Container< decltype(f(T()))>
 
template<template< typename K, typename V > class PairType = std::pair, typename Assoc >
StlAssocRange< typename
Assoc::const_iterator, Assoc,
PairType > 
Stlize (const Assoc &assoc)
 
QStringList GetPathCandidates (SysPath path, QString subfolder)
 Returns possible full paths for the path and subfolder. More...
 
QString GetSysPath (SysPath path, const QString &subfolder, const QString &filename)
 Returns path to the file in the given root path and subfolder. More...
 
QUrl GetSysPathUrl (SysPath path, const QString &subfolder, const QString &filename)
 Returns path to the file in the given root path and subfolder. More...
 
QStringList GetSystemPaths ()
 Returns the components of the system PATH variable. More...
 
QString FindInSystemPath (const QString &name, const QStringList &paths, const std::function< bool(QFileInfo)> &filter=std::function< bool(QFileInfo)>())
 Searches for a file in system paths according to a filter. More...
 
QDir GetUserDir (UserDir dir, const QString &subpath)
 
QDir CreateIfNotExists (QString path)
 Creates a path if it doesn't exist. More...
 
QString GetTemporaryName (const QString &pattern=QString("lc_temp.XXXXXX"))
 Returns a temporary filename. More...
 
QString FromStdString (const std::string &str)
 An utility function that creates a QString from UTF8-encoded std::string. More...
 
UTIL_API QString GetAsBase64Src (const QImage &image)
 Returns the given image in a Base64-encoded form. More...
 
UTIL_API QString GetUserText (const Entity &entity)
 Return the user-readable representation of the entity. More...
 
UTIL_API QString MakePrettySize (qint64 sourceSize)
 Makes a formatted size from number. More...
 
UTIL_API QString MakeTimeFromLong (ulong time)
 Makes a formatted time from number. More...
 
UTIL_API QTranslator * LoadTranslator (const QString &base, const QString &locale, const QString &prefix="leechcraft", const QString &appname="leechcraft")
 
UTIL_API QTranslator * InstallTranslator (const QString &base, const QString &prefix="leechcraft", const QString &appname="leechcraft")
 Loads and installs a translator. More...
 
UTIL_API QString GetLocaleName ()
 Returns the current locale name, like en_US. More...
 
UTIL_API QString GetInternetLocaleName (const QLocale &)
 
UTIL_API QString GetLanguage ()
 Returns the current language name. More...
 
UTIL_API QModelIndexList GetSummarySelectedRows (QObject *sender)
 
UTIL_API QAction * CreateSeparator (QObject *parent)
 Returns the action that is set to act as a separator. More...
 
UTIL_API QPixmap DrawOverlayText (QPixmap px, const QString &text, QFont font, const QPen &pen, const QBrush &brush)
 
UTIL_API uintptr_t Handle2Num (Qt::HANDLE handle)
 Converts the handle to an integer. More...
 
template<typename TagGetter , typename TagSetter >
QDomElement GetElementForTags (const QStringList &tags, QDomNode &node, QDomDocument &document, const QString &elementName, TagGetter tagGetter, TagSetter tagSetter)
 Returns an element for a given tags list. More...
 
template<typename K , typename V >
QMap< K, V > MakeMap (std::initializer_list< QPair< K, V >> l)
 
QString GetPassword (const QString &keyName, const QString &dialogText, QObject *emitter, bool useStore=true)
 Returns password for the key, possibly asking the user. More...
 
void SavePassword (const QString &password, const QString &keyName, QObject *emitter)
 Saves the password to be retrieved later via GetPassword(). More...
 
QList< ANFieldDataGetStdANFields (const QString &type)
 
Entity MakeAN (const QString &header, const QString &text, Priority priority, const QString &senderID, const QString &cat, const QString &type, const QString &id, const QStringList &visualPath, int delta=1, int count=0, const QString &fullText=QString(), const QString &extendedText=QString())
 Creates an Advanced Notifications-enabled notify entity. More...
 
Entity MakeANRule (const QString &title, const QString &senderID, const QString &cat, const QStringList &types, AN::NotifyFlags flags, bool openConfiguration, const QList< QPair< QString, ANFieldValue >> &fields)
 
QList< QObject * > GetDataFilters (const QVariant &data, IEntityManager *manager)
 Returns the data filter plugins that can handle data. More...
 
Entity MakeEntity (const QVariant &entity, const QString &location, TaskParameters tp, const QString &mime)
 
Entity MakeNotification (const QString &header, const QString &text, Priority priority)
 An utility function to make a Entity with notification. More...
 
Entity MakeANCancel (const Entity &event)
 Makes an event for canceling another Advanced Notifications event. More...
 
Entity MakeANCancel (const QString &senderId, const QString &eventId)
 Makes an event for canceling another Advanced Notifications event. More...
 
QVariantList GetPersistentData (const QList< QVariant > &keys, QObject *object)
 
UTIL_XPC_API Entity MakeEntity (const QVariant &entity, const QString &location, LeechCraft::TaskParameters tp, const QString &mime=QString())
 An utility function to make a Entity. More...
 
XmlSettingsDialog * OpenXSD (const QString &title, const QString &filename, Util::BaseSettingsManager *bsm)
 

Variables

const int SourcePager = 2
 
const int StateRemove = 0
 
const int StateAdd = 1
 

Typedef Documentation

typedef QList<QPair<QString, QString> > LeechCraft::Util::AddrList_t

Definition at line 44 of file addresses.h.

Definition at line 117 of file defaulthookproxy.h.

typedef std::shared_ptr<const ModelItem> LeechCraft::Util::ModelItem_cptr

Definition at line 46 of file modelitem.h.

typedef std::shared_ptr<ModelItem> LeechCraft::Util::ModelItem_ptr

Definition at line 41 of file modelitem.h.

Definition at line 44 of file modelitem.h.

Definition at line 45 of file modelitem.h.

Definition at line 38 of file onetimerunner.h.

typedef std::shared_ptr<QIODevice> LeechCraft::Util::QIODevice_ptr

Definition at line 50 of file resourceloader.h.

typedef std::shared_ptr<XmlSettingsDialog> LeechCraft::Util::XmlSettingsDialog_ptr

Definition at line 39 of file ihavesettings.h.

Enumeration Type Documentation

Enumerator
NoAction 
Move 
Resize 
Minimize 
Shade 
Stick 
MaximizeHorz 
MaximizeVert 
ShowFullscreen 
ChangeDesktop 
Close 
MoveToTop 
MoveToBottom 

Definition at line 57 of file winflags.h.

Additional fitting options used by FitRect() and FitRectScreen().

Enumerator
NoFlags 

Default fitting options.

NoOverlap 

The fitted rectangle should never overlap with the original top left position.

This option may be useful if a menu or tooltip is fitted, since it's generally undesirable to cover the corresponding UI element with the menu or tooltip.

Definition at line 46 of file util.h.

Enumerator
Normal 
High 

Definition at line 46 of file queuemanager.h.

Describes various root paths recognized by GetSysPath().

See also
GetPathCandidates(), GetSysPath()
Enumerator
QML 

Root path for QML files.

Plugins are expected to install their files into a subdirectory of this directory.

Share 

Directory with shared data files.

Corresponds to /usr/[local/]share/leechcraft on Linux, for example.

Definition at line 48 of file paths.h.

Describes various user-specific paths.

Enumerator
Cache 

Cache for volatile data.

LC 

Root LeechCraft directory (something like ~/.leechcraft).

Definition at line 170 of file paths.h.

Enumerator
NoState 
Modal 
Sticky 
MaximizedVert 
MaximizedHorz 
Shaded 
SkipTaskbar 
SkipPager 
Hidden 
Fullscreen 
OnTop 
OnBottom 
Attention 

Definition at line 38 of file winflags.h.

Function Documentation

UTIL_SYS_API QDir LeechCraft::Util::CreateIfNotExists ( QString  path)

Creates a path if it doesn't exist.

Creates a relative path ~/.leechcraft/path and throws an exception if this could not be done or if such path already exists and it is not readable.

Parameters
[in]pathThe path to create.
Returns
The newly created dir.
Exceptions
std::runtime_errorThrows if the path could not be created.

Definition at line 148 of file paths.cpp.

QAction * LeechCraft::Util::CreateSeparator ( QObject *  parent)

Returns the action that is set to act as a separator.

That is the action with setSeparator(true);

Parameters
[in]parentThe parent of the action.
Returns
The separator action.

Definition at line 278 of file util.cpp.

QPixmap LeechCraft::Util::DrawOverlayText ( QPixmap  px,
const QString &  text,
QFont  font,
const QPen &  pen,
const QBrush &  brush 
)

Definition at line 285 of file util.cpp.

UTIL_SYS_API QString LeechCraft::Util::FindInSystemPath ( const QString &  name,
const QStringList &  paths,
const std::function< bool(QFileInfo)> &  filter = std::function< bool(QFileInfo)>() 
)

Searches for a file in system paths according to a filter.

This function searches for a file named name in system paths passed in paths and returns the full path for the first file that matches filter, or an empty string if nothing is found.

paths are most possibly obtained via GetSystemPaths(), but an arbitrary set of paths is fine too.

Parameters
[in]nameThe name of the file to search for.
[in]pathsThe paths to search in.
[in]filterThe filter function for the candidates.
Returns
The full path to the first found file or an empty string.

Definition at line 101 of file paths.cpp.

QString LeechCraft::Util::FromStdString ( const std::string &  str)
inline

An utility function that creates a QString from UTF8-encoded std::string.

Parameters
[in]strThe UTF-8 encoded std::string.
Returns
The QString containing the same string.

Definition at line 53 of file util.h.

QString LeechCraft::Util::GetAsBase64Src ( const QImage &  image)

Returns the given image in a Base64-encoded form.

The return result is suitable for inserting into <img>'s src attribute as is.

Parameters
[in]imageThe image to represent as Base64-encoded form.
Returns
The source string.

Definition at line 51 of file util.cpp.

UTIL_XPC_API QList< QObject * > LeechCraft::Util::GetDataFilters ( const QVariant &  data,
IEntityManager manager 
)

Returns the data filter plugins that can handle data.

This function queries all available data filters plugins if they can handle data and returns the list of object instances that can handle it. The object instances are guaranteed to implement the IDataFilter interface as well as IEntityHandler interface.

The manager is used to obtain the list of plugins. It can be obtained from the ICoreProxy_ptr object that is passed to your plugin's Init() function.

Parameters
[in]dataThe data to query.
[in]managerThe manager used to get the plugins.
Returns
The list of data filters that can handle data.

Definition at line 90 of file util.cpp.

References IEntityManager::GetPossibleHandlers(), and MakeEntity().

+ Here is the call graph for this function:

template<typename TagGetter , typename TagSetter >
QDomElement LeechCraft::Util::GetElementForTags ( const QStringList &  tags,
QDomNode &  node,
QDomDocument &  document,
const QString &  elementName,
TagGetter  tagGetter,
TagSetter  tagSetter 
)

Returns an element for a given tags list.

This function tries to implement projection from tags to a hierarchical structure in form of XML. It traverses the tags list and creates child nodes from the document, appending the hierarchical structure's tree root to the node. It returns the parent element to which the item should be appended.

For empty tags list it just returns node converted to the QDomElement.

tagSetter is a function or functor that should be able to take two parameters, a QDomElement and a QString, and set tags for it.

tagGetter is a function or functor that should be able to take one parameter, a QDomElement, and return a QString for it with tags previously set with tagSetter.

Parameters
[in]tagsList of tags.
[in]nodeThe parent-most node to which all other nodes are appended.
[in]documentThe document containing all these nodes.
[in]elementNameThe name of the XML element that carries info about the tags.
[in]tagSetterSetter function for the tags for the given element.
[in]tagGetterGetter function for the tags for the given element.
Returns
Parent element of the item with tags.

Definition at line 235 of file util.h.

QString LeechCraft::Util::GetInternetLocaleName ( const QLocale &  locale)

Definition at line 243 of file util.cpp.

QString LeechCraft::Util::GetLanguage ( )

Returns the current language name.

This function works as GetLocaleName() except it doesn't return (and doesn't query for) country name.

Returns
Current language name.
See also
GetLocaleName()

Definition at line 255 of file util.cpp.

References GetLocaleName().

+ Here is the call graph for this function:

QString LeechCraft::Util::GetLocaleName ( )

Returns the current locale name, like en_US.

First, this function checks the locale value stored in "Language" key of settings object with organizationName() and applicationName(). If it's equal to "system", this function queries the LANG environment variable, and if it is empty or in invalid format (not like en_US), it takes the value of QLocale::system().name().

Then, if the resulting name the name of the language only, GetLocaleName() tries to find any countries for that language. If any countries are found, the code of the first found country is appended, else "_00" is appended.

Returns
Current locale name.
See also
GetLanguage()

Definition at line 216 of file util.cpp.

Referenced by GetLanguage(), and InstallTranslator().

+ Here is the caller graph for this function:

UTIL_XPC_API QString LeechCraft::Util::GetPassword ( const QString &  keyName,
const QString &  dialogText,
QObject *  emitter,
bool  useStore = true 
)

Returns password for the key, possibly asking the user.

This function returns password for the given keyName and using the given emitter object. The password is typically stored in a storage plugin like SecMan.

If the password isn't found in any password stores (or there are no password stores) or useStore is set to false, this function asks the user for the password instead using the dialogText for the dialog and returns the user input instead. If user has canceled the dialog it returns an null string. Otherwise, if the user has entered some text this function automatically stores the password under the keyName.

The emitter object is used to send the corresponding internal Entity objects around, so it should have its gotEntity() and delegateEntity() signals both relayed to the corresponding plugin instance object.

Note
Despite the name this function can be used to retrieve arbitrary string data saved via SavePassword().
Parameters
[in]keyNameThe name of the key uniquely identifying the password.
[in]dialogTextThe text of the dialog to present to the user if the password isn't found or useStore is false.
[in]emitterThe object used to emit the gotEntity() and delegateEntity() signals.
[in]useStoreWhether stored password should be used at all. Calling code may explicitly set this to false if the saved password is known to be invalid, for instance.
Returns
The password or a null string.
See also
SavePassword()

Definition at line 74 of file passutils.cpp.

References SavePassword().

+ Here is the call graph for this function:

UTIL_SYS_API QStringList LeechCraft::Util::GetPathCandidates ( SysPath  path,
QString  subfolder 
)

Returns possible full paths for the path and subfolder.

This function returns a list of paths formed as the given root path identified by path plus the subfolder in it. The paths in the returned list aren't checked for existence.

For example, on Linux

const auto& paths = GetPathCandidates (SysPath::Share, "flags");

will return { "/usr/share/leechcraft/flags", "/usr/local/share/leechcraft/flags" }.

The subfolder can actually be a relative path, like flags/countries, not just a single subfolder name.

This function hardly needs to be called from user code, consider using GetSysPath() instead.

Parameters
[in]pathThe root path.
[in]subfolderThe subfolder inside the root path.
Returns
The list of possible paths to the subfolder in the root path identified by path.
See also
GetSysPath()

Definition at line 47 of file paths.cpp.

References QML, and Share.

Referenced by GetSysPath(), and LeechCraft::Util::UnhideListViewBase::UnhideListViewBase().

+ Here is the caller graph for this function:

UTIL_XPC_API QVariantList LeechCraft::Util::GetPersistentData ( const QList< QVariant > &  keys,
QObject *  object 
)

Definition at line 144 of file util.cpp.

References LeechCraft::Entity::Additional_, LeechCraft::Internal, and MakeEntity().

+ Here is the call graph for this function:

QModelIndexList LeechCraft::Util::GetSummarySelectedRows ( QObject *  sender)

Definition at line 260 of file util.cpp.

UTIL_SYS_API QString LeechCraft::Util::GetSysPath ( SysPath  path,
const QString &  subfolder,
const QString &  filename 
)

Returns path to the file in the given root path and subfolder.

This function returns path to a file named filename and located in the path specified by path + subfolder. It actually checks whether the file exists and if it doesn't, returns a null string instead.

If LeechCraft is running on a system where multiple paths correspond to a single path, they are checked from more user-accessible to less user-accessible. For example, SysPath::Share corresponds to /usr/local/share/leechcraft and then /usr/share/leechcraft.

The subfolder can actually be a relative path, like flags/countries, not just a single subfolder name.

Refer to GetPathCandidates() for more information.

Parameters
[in]pathThe identifier of the root path.
[in]subfolderThe subfolder inside the path.
[in]filenameThe filename inside the path + subfolder.
Returns
Path to the filename located in path + subfolder, or an empty string if there is no such file.
See also
GetPathCandidates()
GetSysPathUrl()

Definition at line 78 of file paths.cpp.

References GetPathCandidates().

Referenced by GetSysPathUrl(), and LeechCraft::Util::UnhideListViewBase::UnhideListViewBase().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

UTIL_SYS_API QUrl LeechCraft::Util::GetSysPathUrl ( SysPath  path,
const QString &  subfolder,
const QString &  filename 
)

Returns path to the file in the given root path and subfolder.

This function behaves exactly like GetSysPath(), but it returns the path as QUrl via the QUrl::fromLocalFile, so it is suitable, for example, for QML views.

Parameters
[in]pathThe identifier of the root path.
[in]subfolderThe subfolder inside the path.
[in]filenameThe filename inside the path + subfolder.
Returns
Path to the filename located in path + subfolder, or an empty URL if there is no such file.
See also
GetSysPath()

Definition at line 91 of file paths.cpp.

References GetSysPath().

+ Here is the call graph for this function:

UTIL_SYS_API QStringList LeechCraft::Util::GetSystemPaths ( )

Returns the components of the system PATH variable.

This function gets the PATH variable from the environment, parses it and returns the list of the components to the caller.

Returns
System PATH components.
See also
FindInSystemPath()

Definition at line 96 of file paths.cpp.

UTIL_SYS_API QString LeechCraft::Util::GetTemporaryName ( const QString &  pattern = QString("lc_temp.XXXXXX"))

Returns a temporary filename.

This function returns a name of a temporary file that could be created, not creating the file itself.

Parameters
[in]patternPattern of the filename.
Returns
The filename.

Definition at line 165 of file paths.cpp.

UTIL_SYS_API QDir LeechCraft::Util::GetUserDir ( UserDir  dir,
const QString &  subpath 
)

Definition at line 119 of file paths.cpp.

References Cache, and LC.

Referenced by LeechCraft::Util::NetworkDiskCache::NetworkDiskCache().

+ Here is the caller graph for this function:

QString LeechCraft::Util::GetUserText ( const Entity &  entity)

Return the user-readable representation of the entity.

Parameters
[in]entityThe Entity from which to make the user-readable representation.
Returns
The user-readable string describing the entity.

Definition at line 60 of file util.cpp.

References LeechCraft::Entity::Additional_, LeechCraft::Entity::Entity_, and LeechCraft::Entity::Mime_.

uintptr_t LeechCraft::Util::Handle2Num ( Qt::HANDLE  handle)

Converts the handle to an integer.

Different handles are mapped to different integers. This way a handle can be used, for example, as a part of a DB connection ID string.

Parameters
[in]handleThe handle to convert.
Returns
The integer representation of the handle.

Definition at line 341 of file util.cpp.

QTranslator * LeechCraft::Util::InstallTranslator ( const QString &  base,
const QString &  prefix = "leechcraft",
const QString &  appname = "leechcraft" 
)

Loads and installs a translator.

Attempts to load and install a translator for the current locale. The name is formed like this: 'prefix_' + base + '_' + locale If base is an empty string, the second _ isn't appended.

First resources are searched (:/), then APPDIR/translations on Windows and /usr/[local/]share/appname/translations on Unix.

Parameters
[in]baseBase name of the translation file.
[in]prefixThe optional prefix of the translation (useful if it's not LC's one).
[in]appnameBase name of the application.
Returns
The translator object if loading is successful, NULL otherwise.

Definition at line 196 of file util.cpp.

References GetLocaleName(), and LoadTranslator().

+ Here is the call graph for this function:

QTranslator * LeechCraft::Util::LoadTranslator ( const QString &  base,
const QString &  locale,
const QString &  prefix = "leechcraft",
const QString &  appname = "leechcraft" 
)

Definition at line 154 of file util.cpp.

Referenced by InstallTranslator().

+ Here is the caller graph for this function:

UTIL_XPC_API Entity LeechCraft::Util::MakeAN ( const QString &  header,
const QString &  text,
Priority  priority,
const QString &  senderID,
const QString &  cat,
const QString &  type,
const QString &  id,
const QStringList &  visualPath,
int  delta = 1,
int  count = 0,
const QString &  fullText = QString(),
const QString &  extendedText = QString() 
)

Creates an Advanced Notifications-enabled notify entity.

Returns an entity with the given header, text and a bunch of other parameters that can be handled by Advanced Notifications.

The returned entity will also be handled by a visual notifications plugin if AN is not present. To avoid this set the MIME type of the result to x-leechcraft/notification+advanced.

Refer to the hand-written documentation for more information about using Advanced Notifications.

Parameters
[in]headerThe header of the notification. This field will also be used if AN is not present.
[in]textThe text of the notification. This field will also be used if AN is not present.
[in]priorityThe priority of this notification.
[in]senderIDThe ID of the plugin sending this notification.
[in]catThe category of this notification (one of Cat constants in interfaces/an/constants.h).
[in]typeThe type of this notification (one of Type constants in interfaces/an/constants.h).
[in]idThe ID of this notification, used to group consecutive notifications about similar events like incoming message from the same IM contact.
[in]visualPathThe list of names for a menu-like structure wishing to show this notification.
[in]deltaThe change of count of events with this id, or 0 to use count.
[in]countThe total count of events with this id, used if delta is 0.
[in]fullTextThe full text of this notification. If null, the text parameter is used.
[in]extendedTextThe extended text of this notification. If null, the text parameter is used.
See also
MakeANCancel()

Definition at line 42 of file util.cpp.

References LeechCraft::AN::EF::Count, LeechCraft::AN::EF::DeltaCount, LeechCraft::AN::EF::EventCategory, LeechCraft::AN::EF::EventID, LeechCraft::AN::EF::EventType, LeechCraft::AN::EF::ExtendedText, LeechCraft::AN::EF::FullText, MakeNotification(), LeechCraft::AN::EF::SenderID, and LeechCraft::AN::EF::VisualPath.

+ Here is the call graph for this function:

UTIL_XPC_API Entity LeechCraft::Util::MakeANCancel ( const Entity &  event)

Makes an event for canceling another Advanced Notifications event.

Creates an Entity that cancels a previously generated Advanced Notifications event. The returned entity can be then emitted to notify plugins that the given event has been canceled.

Parameters
[in]eventThe event to cancel.
Returns
The Entity canceling the given event.

Definition at line 126 of file util.cpp.

References LeechCraft::Entity::Additional_, LeechCraft::AN::CatEventCancel, LeechCraft::Entity::Entity_, LeechCraft::AN::EF::EventCategory, LeechCraft::AN::EF::EventID, MakeNotification(), LeechCraft::PInfo_, and LeechCraft::AN::EF::SenderID.

+ Here is the call graph for this function:

UTIL_XPC_API Entity LeechCraft::Util::MakeANCancel ( const QString &  senderId,
const QString &  eventId 
)

Makes an event for canceling another Advanced Notifications event.

Creates an Entity that cancels a previously generated Advanced Notifications event. The returned entity can be then emitted to notify plugins that the given event has been canceled.

This function doesn't take a previously created entity as the other overload does. Instead, it plainly creates the required entity from the given senderId and eventId. They should match those of the event in question.

Parameters
[in]senderIdThe ID of the sender of the event that is to be canceled.
[in]eventIdThe ID of the event that is to be canceled.
Returns
The Entity canceling the given event.

Definition at line 135 of file util.cpp.

References LeechCraft::Entity::Additional_, LeechCraft::AN::CatEventCancel, LeechCraft::AN::EF::EventCategory, LeechCraft::AN::EF::EventID, MakeNotification(), LeechCraft::PInfo_, and LeechCraft::AN::EF::SenderID.

+ Here is the call graph for this function:

UTIL_XPC_API Entity LeechCraft::Util::MakeANRule ( const QString &  title,
const QString &  senderID,
const QString &  cat,
const QStringList &  types,
AN::NotifyFlags  flags,
bool  openConfiguration,
const QList< QPair< QString, ANFieldValue >> &  fields 
)
Entity LeechCraft::Util::MakeEntity ( const QVariant &  entity,
const QString &  location,
TaskParameters  tp,
const QString &  mime 
)
UTIL_XPC_API Entity LeechCraft::Util::MakeEntity ( const QVariant &  entity,
const QString &  location,
LeechCraft::TaskParameters  tp,
const QString &  mime = QString() 
)

An utility function to make a Entity.

Creates a Entity that wraps the given entity from given location with parameterrs identified by tp and given mime type (which is null by default).

This function is provided for convenience and is equivalent to manually filling the Entity.

Parameters
[in]entityThe Entity_ field of the Entity.
[in]locationThe Location_ field of the Entity.
[in]tpThe Params_ field of the Entity.
[in]mimeThe Mime_ field of the Entity.
Returns
The resulting Entity.
See also
Entity, MakeNotification()
template<typename K , typename V >
QMap<K, V> LeechCraft::Util::MakeMap ( std::initializer_list< QPair< K, V >>  l)

Definition at line 285 of file util.h.

UTIL_XPC_API Entity LeechCraft::Util::MakeNotification ( const QString &  header,
const QString &  text,
Priority  priority 
)

An utility function to make a Entity with notification.

Creates a Entity that holds information about user-visible notification. These notifications have "x-leechcraft/notification" MIME.

You can further customize the returned Entity to suit your exact needs. See the documentation for Entity about such entities.

Parameters
[in]headerThe header of the notification.
[in]textThe text of the notification.
[in]priorityThe priority level of the notification.
Returns
The Entity containing the corresponding notification.
See also
Entity, MakeEntity()

Definition at line 114 of file util.cpp.

References LeechCraft::Entity::Additional_, LeechCraft::AutoAccept, MakeEntity(), and LeechCraft::OnlyHandle.

Referenced by MakeAN(), MakeANCancel(), and MakeANRule().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

QString LeechCraft::Util::MakePrettySize ( qint64  sourceSize)

Makes a formatted size from number.

Converts, for example, 1048576 to 1.0 MB.

Parameters
[in]sourceSizeSize in bytes.
Returns
Formatted string.
See also
SetStrings
MakeTimeFromLong

Definition at line 96 of file util.cpp.

QString LeechCraft::Util::MakeTimeFromLong ( ulong  time)

Makes a formatted time from number.

Converts, for example 256 to 00:04:16.

Parameters
[in]timeTime interval in seconds.
Returns
DateTime object.
See also
MakePrettySize

Definition at line 143 of file util.cpp.

template<typename T , template< typename U > class Container, typename F >
auto LeechCraft::Util::Map ( const Container< T > &  c,
f 
) -> Container<decltype (f (T ()))>

Definition at line 62 of file prelude.h.

UTIL_XSD_API XmlSettingsDialog * LeechCraft::Util::OpenXSD ( const QString &  title,
const QString &  filename,
Util::BaseSettingsManager *  bsm 
)

Definition at line 40 of file util.cpp.

LeechCraft::Util::Q_DECLARE_FLAGS ( FitFlags  ,
FitFlag   
)
UTIL_XPC_API void LeechCraft::Util::SavePassword ( const QString &  password,
const QString &  keyName,
QObject *  emitter 
)

Saves the password to be retrieved later via GetPassword().

This function stores the password under the given keyName and using the given emitter object. The password is typically stored in a storage plugin like SecMan.

If there are no storage plugins, this function does nothing.

The emitter object is used to send the corresponding internal Entity objects around, so it should have its gotEntity() and delegateEntity() signals both relayed to the corresponding plugin instance object.

Note
Despite the name this function can be used to save arbitrary string data in secure storages like SecMan.
Parameters
[in]passwordThe password string to save.
[in]keyNameThe name of the key uniquely identifying the password.
[in]emitterThe object used to emit the gotEntity() and delegateEntity() signals.
See also
GetPassword()

Definition at line 93 of file passutils.cpp.

References LeechCraft::Entity::Additional_, LeechCraft::Internal, and MakeEntity().

Referenced by GetPassword().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<template< typename K, typename V > class PairType = std::pair, typename Assoc >
StlAssocRange<typename Assoc::const_iterator, Assoc, PairType> LeechCraft::Util::Stlize ( const Assoc &  assoc)

Definition at line 81 of file qtutil.h.

template<typename T1 , typename T2 , template< typename U > class Container, template< typename U1, typename U2 > class Pair = QPair>
auto LeechCraft::Util::Zip ( const Container< T1 > &  c1,
const Container< T2 > &  c2 
) -> Container<Pair<T1, T2>>

Definition at line 54 of file prelude.h.

References ZipWith().

+ Here is the call graph for this function:

template<typename T1 , typename T2 , template< typename U > class Container, typename F >
auto LeechCraft::Util::ZipWith ( const Container< T1 > &  c1,
const Container< T2 > &  c2,
f 
) -> Container<typename std::result_of<F (T1, T2)>::type>

Definition at line 40 of file prelude.h.

Referenced by Zip().

+ Here is the caller graph for this function:

Variable Documentation

const int LeechCraft::Util::SourcePager = 2

Definition at line 50 of file xwrapper.cpp.

const int LeechCraft::Util::StateAdd = 1

Definition at line 53 of file xwrapper.cpp.

const int LeechCraft::Util::StateRemove = 0

Definition at line 52 of file xwrapper.cpp.

Referenced by LeechCraft::Util::XWrapper::MoveWindowTo().