LeechCraft  0.6.70-10870-g558588d6ec
Modular cross-platform feature rich live environment.
LeechCraft::Util::XDG::ItemsFinder Class Reference

Finds and parses XDG .desktop files. More...

#include "itemsfinder.h"

+ Inheritance diagram for LeechCraft::Util::XDG::ItemsFinder:
+ Collaboration diagram for LeechCraft::Util::XDG::ItemsFinder:

Public Slots

void update ()
 Updates the list of items. More...
 

Signals

void itemsListChanged ()
 Notifies when the list of items changes in any way. More...
 

Public Member Functions

 ItemsFinder (ICoreProxy_ptr, const QList< Type > &types, QObject *parent=nullptr)
 Constructs the items finder for the given types. More...
 
bool IsReady () const
 Checks whether this items finder is ready. More...
 
Cat2Items_t GetItems () const
 Returns the categorized list of XDG items. More...
 
Item_ptr FindItem (const QString &permanentID) const
 Finds an XDG item for the given permanent ID. More...
 

Detailed Description

Finds and parses XDG .desktop files.

The .desktop files are found in the directories matching the types passed to the object's constructor.

Parsing is done asynchronously in a separate thread, and the itemsListChanged() signal is emitted each time the list of files changes.

This class does not watch for changes in the said paths. Use the ItemsDatabase instead if that functionality is required.

See also
ItemsDatabase

Definition at line 65 of file itemsfinder.h.

Constructor & Destructor Documentation

◆ ItemsFinder()

LeechCraft::Util::XDG::ItemsFinder::ItemsFinder ( ICoreProxy_ptr  proxy,
const QList< Type > &  types,
QObject *  parent = nullptr 
)

Constructs the items finder for the given types.

ToPaths() is used to get the list of directories for each of the types.

The ItemsFinder will asynchronously update itself automatically a few moments after creation and emit itemsListChanged() when the update finishes.

Parameters
[in]proxyThe proxy to use to get the icons of the items that were found.
[in]typesThe item types to watch for.
[in]parentThe parent object of this finder.

Definition at line 47 of file itemsfinder.cpp.

Member Function Documentation

◆ FindItem()

Item_ptr LeechCraft::Util::XDG::ItemsFinder::FindItem ( const QString &  permanentID) const

Finds an XDG item for the given permanent ID.

Parameters
[in]permanentIDThe permanent ID of the item as returned by Item::GetPermanentID().
Returns
The item matching the permanentID or a null pointer if there is no such item.

Definition at line 66 of file itemsfinder.cpp.

◆ GetItems()

Cat2Items_t LeechCraft::Util::XDG::ItemsFinder::GetItems ( ) const

Returns the categorized list of XDG items.

The returned hash contains the mapping from XDG category ID to the list of items in that category. A single item can appear in multiple categories at the same time.

If the finder is not ready (IsReady() returns false), this function returns an empty hash.

Returns
The categorized list of items.

Definition at line 61 of file itemsfinder.cpp.

◆ IsReady()

bool LeechCraft::Util::XDG::ItemsFinder::IsReady ( ) const

Checks whether this items finder is ready.

An items finder is ready if it has finished at least one search process. In other words, IsReady() returns true iff itemsListChanged() has been emitted at least once.

Returns
Whether the items finder has finished at least one items search.

Definition at line 56 of file itemsfinder.cpp.

◆ itemsListChanged

void LeechCraft::Util::XDG::ItemsFinder::itemsListChanged ( )
signal

Notifies when the list of items changes in any way.

Referenced by update().

+ Here is the caller graph for this function:

◆ update

void LeechCraft::Util::XDG::ItemsFinder::update ( )
slot

Updates the list of items.

If IsReady() returns false, and thus no items are known to the finder yet, this function blocks and emits itemsListChanged() before returning.

Otherwise, this function spawns an asynchronous update process.

Definition at line 240 of file itemsfinder.cpp.

References itemsListChanged().


The documentation for this class was generated from the following files: