Skip to content

Commit 7bbec73

Browse files
Move Action into item.h. Apply perfect forwarding in ctor.
1 parent 84982fe commit 7bbec73

File tree

4 files changed

+38
-54
lines changed

4 files changed

+38
-54
lines changed

CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ set(TARGET_LIB lib${PROJECT_NAME})
5454
set(LIB_PUBLIC_HEADER
5555
${PROJECT_BINARY_DIR}/include/albert/config.h # generated
5656
${PROJECT_BINARY_DIR}/include/albert/export.h # generated
57-
include/albert/action.h
5857
include/albert/albert.h
5958
include/albert/extension.h
6059
include/albert/extensionplugin.h
@@ -118,7 +117,6 @@ set(LIB_SRC
118117
src/app/triggersqueryhandler.h
119118
src/app/urlhandler.cpp
120119

121-
src/common/action.cpp
122120
src/common/extension.cpp
123121
src/common/item.cpp
124122
src/common/rankitem.cpp

include/albert/action.h

Lines changed: 0 additions & 39 deletions
This file was deleted.

include/albert/item.h

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,50 @@
33

44
#pragma once
55
#include <QStringList>
6-
#include <albert/action.h>
76
#include <albert/export.h>
7+
#include <functional>
88
#include <vector>
99

1010
namespace albert
1111
{
1212

13+
/// Action used by result items (\ref Item).
14+
class ALBERT_EXPORT Action final
15+
{
16+
public:
17+
18+
/// Constructs an \ref Action with the contents initialized with the data passed.
19+
/// \param id \copybrief id
20+
/// \param text \copybrief text
21+
/// \param function \copybrief function
22+
/// \param hideOnActivation \copybrief hide_on_activation
23+
template<typename T1 = QString,
24+
typename T2 = QString,
25+
typename T3 = std::function<void()>>
26+
Action(T1 &&id_,
27+
T2 &&text_,
28+
T3 &&function_,
29+
bool hide_on_activation_ = true) noexcept :
30+
id(std::forward<T1>(id_)),
31+
text(std::forward<T2>(text_)),
32+
function(std::forward<T3>(function_)),
33+
hide_on_activation(hide_on_activation_)
34+
{}
35+
36+
/// The identifier.
37+
QString id;
38+
39+
/// The description.
40+
QString text;
41+
42+
/// The function executed on activation.
43+
std::function<void()> function;
44+
45+
/// The activation behavior.
46+
bool hide_on_activation;
47+
};
48+
49+
1350
///
1451
/// Result items displayed in the query results list
1552
///

src/common/action.cpp

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)