Albert
Loading...
Searching...
No Matches
albert::StandardItem Class Reference

#include <albert/standarditem.h>

Description

General purpose Item implementation.

Inheritance diagram for albert::StandardItem:
[legend]

Public Member Functions

template<typename T_ID = QString, typename T_TEXT = QString, typename T_SUBTEXT = QString, typename T_ICON_FACTORY = std::function<std::unique_ptr<Icon>()>, typename T_ACTIONS = std::vector<Action>, typename T_INPUTACTION = QString>
requires (std::same_as<std::remove_cvref_t<T_ID>, QString> && std::same_as<std::remove_cvref_t<T_TEXT>, QString> && std::same_as<std::remove_cvref_t<T_SUBTEXT>, QString> && std::convertible_to<std::remove_cvref_t<T_ICON_FACTORY>, std::function<std::unique_ptr<Icon>()>> && std::same_as<std::remove_cvref_t<T_ACTIONS>, std::vector<Action>> && std::same_as<std::remove_cvref_t<T_INPUTACTION>, QString>)
 StandardItem (T_ID &&id, T_TEXT &&text, T_SUBTEXT &&subtext, T_ICON_FACTORY &&icon_factory, T_ACTIONS &&actions=std::vector< Action >{}, T_INPUTACTION &&input_action_text=QString{}) noexcept
 Constructs a StandardItem with the contents initialized with the data passed.
 
 StandardItem (StandardItem &&other) noexcept=default
 Constructs a StandardItem with the contents of other using move semantics.
 
StandardItemoperator= (StandardItem &&other) noexcept=default
 Replaces the contents with those of other using move semantics.
 
 ~StandardItem ()
 Destructs the StandardItem.
 
void setId (QString id)
 Sets the item identifier to id.
 
void setText (QString text)
 Sets the item text to text.
 
void setSubtext (QString text)
 Sets the item subtext to text.
 
void setIconFactory (std::function< std::unique_ptr< Icon >()> icon_factory)
 Sets the item factory to icon_factory.
 
std::function< std::unique_ptr< Icon >()> iconFactory ()
 Returns the item icon factory.
 
void setActions (std::vector< Action > actions)
 Sets the item actions to actions.
 
void setInputActionText (QString text)
 Sets the item input action text to text.
 
QString id () const override
 Returns the item identifier.
 
QString text () const override
 Returns the item text.
 
QString subtext () const override
 Returns the item subtext.
 
QString inputActionText () const override
 Returns the item input action text.
 
std::unique_ptr< Iconicon () const override
 Returns the item icon.
 
std::vector< Actionactions () const override
 Returns the item actions.
 
- Public Member Functions inherited from albert::Item
virtual ~Item ()
 Destructs the item.
 
virtual void addObserver (Observer *observer)
 Starts notifying observer about any changes.
 
virtual void removeObserver (Observer *observer)
 Stops notifying observer about any changes.
 

Static Public Member Functions

template<typename T_ID = QString, typename T_TEXT = QString, typename T_SUBTEXT = QString, typename T_ICON_FACTORY = std::function<std::unique_ptr<Icon>()>, typename T_ACTIONS = std::vector<Action>, typename T_INPUTACTION = QString>
requires (std::same_as<std::decay_t<T_ID>, QString> && std::same_as<std::decay_t<T_TEXT>, QString> && std::same_as<std::decay_t<T_SUBTEXT>, QString> && std::convertible_to<std::decay_t<T_ICON_FACTORY>, std::function<std::unique_ptr<Icon>()>> && std::same_as<std::decay_t<T_ACTIONS>, std::vector<Action>> && std::same_as<std::decay_t<T_INPUTACTION>, QString>)
static std::shared_ptr< StandardItemmake (T_ID &&id, T_TEXT &&text, T_SUBTEXT &&subtext, T_ICON_FACTORY &&icon_factory, T_ACTIONS &&actions=std::vector< Action >{}, T_INPUTACTION &&input_action_text=QString{}) noexcept
 Constructs a shared_ptr holding a StandardItem with the contents initialized with the data passed.
 

Member Function Documentation

◆ actions()

std::vector< Action > albert::StandardItem::actions ( ) const
overridevirtual

Returns the item actions.

These are the actions a users can choose to activate. The base implementation returns an empty vector.

Reimplemented from albert::Item.

◆ icon()

std::unique_ptr< Icon > albert::StandardItem::icon ( ) const
overridevirtual

Returns the item icon.

Do not clone a stored icon in this function. Icons can be a heavy resource. Instead return a new instance every time this function is called. The view will cache the icon instance.

Implements albert::Item.

◆ id()

QString albert::StandardItem::id ( ) const
overridevirtual

Returns the item identifier.

Has to be unique per extension. This function is involved in several time critical operartion such as indexing and sorting. It is therefore recommended to return a string that is as short as possible as fast as possible.

Implements albert::Item.

◆ inputActionText()

QString albert::StandardItem::inputActionText ( ) const
overridevirtual

Returns the item input action text.

Used as input text replacement (usually by pressing Tab).

The base implementation returns text().

Reimplemented from albert::Item.

◆ make()

template<typename T_ID = QString, typename T_TEXT = QString, typename T_SUBTEXT = QString, typename T_ICON_FACTORY = std::function<std::unique_ptr<Icon>()>, typename T_ACTIONS = std::vector<Action>, typename T_INPUTACTION = QString>
requires (std::same_as<std::decay_t<T_ID>, QString> && std::same_as<std::decay_t<T_TEXT>, QString> && std::same_as<std::decay_t<T_SUBTEXT>, QString> && std::convertible_to<std::decay_t<T_ICON_FACTORY>, std::function<std::unique_ptr<Icon>()>> && std::same_as<std::decay_t<T_ACTIONS>, std::vector<Action>> && std::same_as<std::decay_t<T_INPUTACTION>, QString>)
static std::shared_ptr< StandardItem > albert::StandardItem::make ( T_ID &&  id,
T_TEXT &&  text,
T_SUBTEXT &&  subtext,
T_ICON_FACTORY &&  icon_factory,
T_ACTIONS &&  actions = std::vector<Action>{},
T_INPUTACTION &&  input_action_text = QString{} 
)
inlinestaticnoexcept

Constructs a shared_ptr holding a StandardItem with the contents initialized with the data passed.

Convenience function for readability. See the StandardItem::StandardItem for details.

◆ subtext()

QString albert::StandardItem::subtext ( ) const
overridevirtual

Returns the item subtext.

Secondary descriptive text displayed in a list item.x

Implements albert::Item.

◆ text()

QString albert::StandardItem::text ( ) const
overridevirtual

Returns the item text.

Primary text displayed emphasized in a list item. The string must not be empty, since the text length is used as divisor for scoring. Return as fast as possible. No checks are performed. If empty you get undefined behavior.

Implements albert::Item.


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