5#include <albert/item.h>
8namespace albert{
class Icon; }
25 template<
typename T_ID = QString,
26 typename T_TEXT = QString,
27 typename T_SUBTEXT = QString,
28 typename T_ICON_FACTORY = std::function<std::unique_ptr<Icon>()>,
29 typename T_ACTIONS = std::vector<Action>,
30 typename T_INPUTACTION = QString>
31 requires(std::same_as<std::remove_cvref_t<T_ID>, QString>
32 && std::same_as<std::remove_cvref_t<T_TEXT>, QString>
33 && std::same_as<std::remove_cvref_t<T_SUBTEXT>, QString>
34 && std::convertible_to<std::remove_cvref_t<T_ICON_FACTORY>, std::function<std::unique_ptr<Icon>()>>
35 && std::same_as<std::remove_cvref_t<T_ACTIONS>, std::vector<Action>>
36 && std::same_as<std::remove_cvref_t<T_INPUTACTION>, QString>)
40 T_ICON_FACTORY &&icon_factory,
41 T_ACTIONS &&actions = std::vector<Action>{},
42 T_INPUTACTION &&input_action_text = QString{})
noexcept :
43 id_(std::forward<T_ID>(id)),
44 text_(std::forward<T_TEXT>(text)),
45 subtext_(std::forward<T_SUBTEXT>(subtext)),
46 icon_factory_(std::forward<T_ICON_FACTORY>(icon_factory)),
47 actions_(std::forward<T_ACTIONS>(actions)),
48 input_action_text_(std::forward<T_INPUTACTION>(input_action_text))
58 template<
typename T_ID = QString,
59 typename T_TEXT = QString,
60 typename T_SUBTEXT = QString,
61 typename T_ICON_FACTORY = std::function<std::unique_ptr<Icon>()>,
62 typename T_ACTIONS = std::vector<Action>,
63 typename T_INPUTACTION = QString>
64 requires(std::same_as<std::decay_t<T_ID>, QString>
65 && std::same_as<std::decay_t<T_TEXT>, QString>
66 && std::same_as<std::decay_t<T_SUBTEXT>, QString>
67 && std::convertible_to<std::decay_t<T_ICON_FACTORY>, std::function<std::unique_ptr<Icon>()>>
68 && std::same_as<std::decay_t<T_ACTIONS>, std::vector<Action>>
69 && std::same_as<std::decay_t<T_INPUTACTION>, QString>)
70 static std::shared_ptr<StandardItem>
make(T_ID &&
id,
73 T_ICON_FACTORY &&icon_factory,
74 T_ACTIONS &&actions = std::vector<Action>{},
75 T_INPUTACTION &&input_action_text = QString{})
noexcept
77 return std::make_shared<StandardItem>(std::forward<T_ID>(
id),
78 std::forward<T_TEXT>(text),
79 std::forward<T_SUBTEXT>(subtext),
80 std::forward<T_ICON_FACTORY>(icon_factory),
81 std::forward<T_ACTIONS>(actions),
82 std::forward<T_INPUTACTION>(input_action_text));
85 StandardItem(
const StandardItem &) =
delete;
86 StandardItem& operator=(
const StandardItem&) =
delete;
118 QString
id()
const override;
122 std::unique_ptr<Icon>
icon()
const override;
129 std::function<std::unique_ptr<Icon>()> icon_factory_;
130 std::vector<Action> actions_;
131 QString input_action_text_;
Result items displayed in the query results list.
Definition item.h:71
General purpose Item implementation.
Definition standarditem.h:19
void setIconFactory(std::function< std::unique_ptr< Icon >()> icon_factory)
Sets the item factory to icon_factory.
std::unique_ptr< Icon > icon() const override
Returns the item icon.
QString subtext() const override
Returns the item subtext.
std::vector< Action > actions() const override
Returns the item actions.
void setId(QString id)
Sets the item identifier to id.
std::function< std::unique_ptr< Icon >()> iconFactory()
Returns the item icon factory.
void setInputActionText(QString text)
Sets the item input action text to text.
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.
Definition standarditem.h:70
StandardItem(StandardItem &&other) noexcept=default
Constructs a StandardItem with the contents of other using move semantics.
~StandardItem()
Destructs the StandardItem.
QString inputActionText() const override
Returns the item input action text.
void setSubtext(QString text)
Sets the item subtext to text.
void setText(QString text)
Sets the item text to text.
StandardItem & operator=(StandardItem &&other) noexcept=default
Replaces the contents with those of other using move semantics.
QString id() const override
Returns the item identifier.
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.
Definition standarditem.h:37
QString text() const override
Returns the item text.
void setActions(std::vector< Action > actions)
Sets the item actions to actions.
The Albert namespace.
Definition app.h:55