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

#include <albert/standarditem.h>

Inheritance diagram for albert::util::StandardItem:
[legend]

Detailed Description

General purpose Item implementation.

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 (const StandardItem &)=delete
 
StandardItemoperator= (const StandardItem &)=delete
 
 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 input action text.
 
std::unique_ptr< Iconicon () const override
 Returns the item icon.
 
std::vector< Actionactions () const override
 Returns item actions.
 
- Public Member Functions inherited from albert::Item
virtual ~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.
 

Protected Attributes

QString id_
 
QString text_
 
QString subtext_
 
std::function< std::unique_ptr< Icon >()> icon_factory_
 
std::vector< Actionactions_
 
QString input_action_text_
 

Constructor & Destructor Documentation

◆ StandardItem() [1/3]

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>)
albert::util::StandardItem::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{} 
)
inlinenoexcept

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

◆ StandardItem() [2/3]

albert::util::StandardItem::StandardItem ( const StandardItem )
delete

◆ StandardItem() [3/3]

albert::util::StandardItem::StandardItem ( StandardItem &&  other)
defaultnoexcept

Constructs a StandardItem with the contents of other using move semantics.

◆ ~StandardItem()

albert::util::StandardItem::~StandardItem ( )

Destructs the StandardItem.

Member Function Documentation

◆ actions()

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

Returns item actions.

These are the actions a users can run. The base implementation returns an empty vector.

Reimplemented from albert::Item.

◆ icon()

std::unique_ptr< Icon > albert::util::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. See iconutil.h for the built-in icon factories. See albert::Icon if you want to create your own icon engine.

Implements albert::Item.

◆ iconFactory()

std::function< std::unique_ptr< Icon >()> albert::util::StandardItem::iconFactory ( )

Returns the item icon factory.

◆ id()

QString albert::util::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::util::StandardItem::inputActionText ( ) const
overridevirtual

Returns the 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::util::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.

◆ operator=() [1/2]

StandardItem & albert::util::StandardItem::operator= ( const StandardItem )
delete

◆ operator=() [2/2]

StandardItem & albert::util::StandardItem::operator= ( StandardItem &&  other)
defaultnoexcept

Replaces the contents with those of other using move semantics.

◆ setActions()

void albert::util::StandardItem::setActions ( std::vector< Action actions)

Sets the item actions to actions.

◆ setIconFactory()

void albert::util::StandardItem::setIconFactory ( std::function< std::unique_ptr< Icon >()>  icon_factory)

Sets the item factory to icon_factory.

◆ setId()

void albert::util::StandardItem::setId ( QString  id)

Sets the item identifier to id.

◆ setInputActionText()

void albert::util::StandardItem::setInputActionText ( QString  text)

Sets the item input action text to text.

◆ setSubtext()

void albert::util::StandardItem::setSubtext ( QString  text)

Sets the item subtext to text.

◆ setText()

void albert::util::StandardItem::setText ( QString  text)

Sets the item text to text.

◆ subtext()

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

Returns the item subtext.

Secondary descriptive text displayed in a list item.

Implements albert::Item.

◆ text()

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

Returns the item text.

Primary text displayed emphasized in a list item. This string is used in scoring. It is therefore recommended to return as fast as possible. The text length is used as divisor for scoring, hence the string must not be empty, otherwise you get undefined behavior. For performance reasons text length is not checked.

Implements albert::Item.

Member Data Documentation

◆ actions_

std::vector<Action> albert::util::StandardItem::actions_
protected

◆ icon_factory_

std::function<std::unique_ptr<Icon>()> albert::util::StandardItem::icon_factory_
protected

◆ id_

QString albert::util::StandardItem::id_
protected

◆ input_action_text_

QString albert::util::StandardItem::input_action_text_
protected

◆ subtext_

QString albert::util::StandardItem::subtext_
protected

◆ text_

QString albert::util::StandardItem::text_
protected

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