Albert
Loading...
Searching...
No Matches
standarditem.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2024 Manuel Schneider
2// SPDX-License-Identifier: MIT
3
4#pragma once
5#include <albert/item.h>
6#include <vector>
7
8namespace albert
9{
10
12class ALBERT_EXPORT StandardItem : public Item
13{
14public:
22 explicit StandardItem(QString id,
23 QString text = {},
24 QString subtext = {},
25 QString input_action_text = {},
26 QStringList icon_urls = {},
27 std::vector<Action> actions = {}) noexcept;
28
29 StandardItem(const StandardItem &) = delete;
31
33 StandardItem(StandardItem &&other) noexcept = default;
34
36 StandardItem &operator=(StandardItem &&other) noexcept = default;
37
39 void setId(QString id);
40
42 void setText(QString text);
43
45 void setSubtext(QString text);
46
48 void setInputActionText(QString text);
49
51 void setIconUrls(QStringList urls);
52
54 void setActions(std::vector<Action> actions);
55
57 static std::shared_ptr<StandardItem> make(
58 QString id = {},
59 QString text = {},
60 QString subtext = {},
61 QString input_action_text = {},
62 QStringList icon_urls = {},
63 std::vector<Action> actions = {});
64
66 static std::shared_ptr<StandardItem> make(
67 QString id = {},
68 QString text = {},
69 QString subtext = {},
70 QStringList icon_urls = {},
71 std::vector<Action> actions = {});
72
73 // albert::Item interface
74 QString id() const override;
75 QString text() const override;
76 QString subtext() const override;
77 QString inputActionText() const override;
78 QStringList iconUrls() const override;
79 std::vector<Action> actions() const override;
80
81protected:
82 QString id_;
83 QString text_;
84 QString subtext_;
86 QStringList icon_urls_;
87 std::vector<Action> actions_;
88};
89
90}
Result items displayed in the query results list.
Definition item.h:17
General purpose value type Item implememtation.
Definition standarditem.h:13
static std::shared_ptr< StandardItem > make(QString id={}, QString text={}, QString subtext={}, QStringList icon_urls={}, std::vector< Action > actions={})
Convenience shared pointer factory for standard items w/o inputAction.
QStringList iconUrls() const override
Getter for the items iconUrls.
QString subtext() const override
Getter for the item subtext.
QString text_
Definition standarditem.h:83
std::vector< Action > actions() const override
Getter for item actions.
void setId(QString id)
Sets the item identifier to id.
QStringList icon_urls_
Definition standarditem.h:86
StandardItem(const StandardItem &)=delete
QString id_
Definition standarditem.h:82
StandardItem(QString id, QString text={}, QString subtext={}, QString input_action_text={}, QStringList icon_urls={}, std::vector< Action > actions={}) noexcept
Constructs a StandardItem with the contents initialized with the data passed.
static std::shared_ptr< StandardItem > make(QString id={}, QString text={}, QString subtext={}, QString input_action_text={}, QStringList icon_urls={}, std::vector< Action > actions={})
Convenience shared pointer factory for standard items.
void setInputActionText(QString text)
Sets the item input action text to text.
QString subtext_
Definition standarditem.h:84
StandardItem(StandardItem &&other) noexcept=default
Constructs a StandardItem with the contents of other using move semantics.
QString inputActionText() const override
Getter for the 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
Getter for the item identifier.
StandardItem & operator=(const StandardItem &)=delete
std::vector< Action > actions_
Definition standarditem.h:87
QString input_action_text_
Definition standarditem.h:85
void setIconUrls(QStringList urls)
Sets the item icon urls to urls.
QString text() const override
Getter for the item text.
void setActions(std::vector< Action > actions)
Sets the item actions to actions.
Definition action.h:10