|
Albert
|
#include <albert/standarditem.h>
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 | |
| StandardItem & | operator= (const StandardItem &)=delete |
| StandardItem (StandardItem &&other) noexcept=default | |
| Constructs a StandardItem with the contents of other using move semantics. | |
| StandardItem & | operator= (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< Icon > | icon () const override |
| Returns the item icon. | |
| std::vector< Action > | actions () 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< 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{}) 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< Action > | actions_ |
| QString | input_action_text_ |
|
inlinenoexcept |
Constructs a StandardItem with the contents initialized with the data passed.
|
delete |
|
defaultnoexcept |
Constructs a StandardItem with the contents of other using move semantics.
| albert::util::StandardItem::~StandardItem | ( | ) |
Destructs the StandardItem.
|
overridevirtual |
Returns item actions.
These are the actions a users can run. The base implementation returns an empty vector.
Reimplemented from albert::Item.
|
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.
| std::function< std::unique_ptr< Icon >()> albert::util::StandardItem::iconFactory | ( | ) |
Returns the item icon factory.
|
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.
|
overridevirtual |
Returns the input action text.
Used as input text replacement (usually by pressing Tab). The base implementation returns text().
Reimplemented from albert::Item.
|
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.
|
delete |
|
defaultnoexcept |
Replaces the contents with those of other using move semantics.
| void albert::util::StandardItem::setActions | ( | std::vector< Action > | actions | ) |
Sets the item actions to actions.
| void albert::util::StandardItem::setIconFactory | ( | std::function< std::unique_ptr< Icon >()> | icon_factory | ) |
Sets the item factory to icon_factory.
| void albert::util::StandardItem::setId | ( | QString | id | ) |
Sets the item identifier to id.
| void albert::util::StandardItem::setInputActionText | ( | QString | text | ) |
Sets the item input action text to text.
| void albert::util::StandardItem::setSubtext | ( | QString | text | ) |
Sets the item subtext to text.
| void albert::util::StandardItem::setText | ( | QString | text | ) |
Sets the item text to text.
|
overridevirtual |
Returns the item subtext.
Secondary descriptive text displayed in a list item.
Implements albert::Item.
|
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.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |