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 T1 = QString, typename T2 = QString, typename T3 = QString, typename T4 = QStringList, typename T5 = std::vector<Action>, typename T6 = QString>
requires (std::same_as<std::remove_cvref_t<T1>, QString> && std::same_as<std::remove_cvref_t<T2>, QString> && std::same_as<std::remove_cvref_t<T3>, QString> && std::same_as<std::remove_cvref_t<T4>, QStringList> && std::same_as<std::remove_cvref_t<T5>, std::vector<Action>> && std::same_as<std::remove_cvref_t<T6>, QString>)
 StandardItem (T1 &&id, T2 &&text, T3 &&subtext, T4 &&icon_urls, T5 &&actions=std::vector< Action >{}, T6 &&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.
 
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 setIconUrls (QStringList urls)
 Sets the item icon urls to urls.
 
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.
 
QStringList iconUrls () const override
 Returns the items icon urls.
 
std::vector< Actionactions () const override
 Returns the item actions.
 
- Public Member Functions inherited from albert::Item
virtual ~Item ()
 
virtual void addObserver (Observer *observer)
 Start notifying observer about any changes.
 
virtual void removeObserver (Observer *observer)
 Stop notifying observer about any changes.
 

Static Public Member Functions

template<typename T1 = QString, typename T2 = QString, typename T3 = QString, typename T4 = QStringList, typename T5 = std::vector<Action>, typename T6 = QString>
requires (std::same_as<std::decay_t<T1>, QString> && std::same_as<std::decay_t<T2>, QString> && std::same_as<std::decay_t<T3>, QString> && std::same_as<std::decay_t<T4>, QStringList> && std::same_as<std::decay_t<T5>, std::vector<Action>> && std::same_as<std::decay_t<T6>, QString>)
static std::shared_ptr< StandardItemmake (T1 &&id, T2 &&text, T3 &&subtext, T4 &&icon_urls, T5 &&actions=std::vector< Action >{}, T6 &&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_
 
QStringList icon_urls_
 
std::vector< Actionactions_
 
QString input_action_text_
 

Constructor & Destructor Documentation

◆ StandardItem() [1/3]

template<typename T1 = QString, typename T2 = QString, typename T3 = QString, typename T4 = QStringList, typename T5 = std::vector<Action>, typename T6 = QString>
requires (std::same_as<std::remove_cvref_t<T1>, QString> && std::same_as<std::remove_cvref_t<T2>, QString> && std::same_as<std::remove_cvref_t<T3>, QString> && std::same_as<std::remove_cvref_t<T4>, QStringList> && std::same_as<std::remove_cvref_t<T5>, std::vector<Action>> && std::same_as<std::remove_cvref_t<T6>, QString>)
albert::util::StandardItem::StandardItem ( T1 &&  id,
T2 &&  text,
T3 &&  subtext,
T4 &&  icon_urls,
T5 &&  actions = std::vector<Action>{},
T6 &&  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.

Member Function Documentation

◆ actions()

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

Returns the item actions.

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

Reimplemented from albert::Item.

◆ iconUrls()

QStringList albert::util::StandardItem::iconUrls ( ) const
overridevirtual

Returns the items icon urls.

Used to get the item icon using the icon provider functions.

Implements albert::Item.

◆ 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 T1 = QString, typename T2 = QString, typename T3 = QString, typename T4 = QStringList, typename T5 = std::vector<Action>, typename T6 = QString>
requires (std::same_as<std::decay_t<T1>, QString> && std::same_as<std::decay_t<T2>, QString> && std::same_as<std::decay_t<T3>, QString> && std::same_as<std::decay_t<T4>, QStringList> && std::same_as<std::decay_t<T5>, std::vector<Action>> && std::same_as<std::decay_t<T6>, QString>)
static std::shared_ptr< StandardItem > albert::util::StandardItem::make ( T1 &&  id,
T2 &&  text,
T3 &&  subtext,
T4 &&  icon_urls,
T5 &&  actions = std::vector<Action>{},
T6 &&  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.

◆ setIconUrls()

void albert::util::StandardItem::setIconUrls ( QStringList  urls)

Sets the item icon urls to urls.

◆ 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_urls_

QStringList albert::util::StandardItem::icon_urls_
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: