Albert
Loading...
Searching...
No Matches
query.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 <QAbstractListModel>
6#include <QObject>
7#include <QString>
8#include <albert/export.h>
9#include <memory>
10#include <vector>
11
12namespace albert
13{
14class Item;
15
19class ALBERT_EXPORT Query : public QObject
20{
21 Q_OBJECT
22
23public:
24
26 Q_INVOKABLE virtual QString synopsis() const = 0;
27
29 Q_INVOKABLE virtual QString trigger() const = 0;
30
32 Q_INVOKABLE virtual QString string() const = 0;
33
35 Q_INVOKABLE virtual bool isFinished() const = 0;
36
38 Q_INVOKABLE virtual const bool &isValid() const = 0;
39
41 Q_INVOKABLE virtual bool isTriggered() const = 0;
42
44 Q_INVOKABLE virtual QAbstractListModel *matches() = 0;
45
47 Q_INVOKABLE virtual QAbstractListModel *fallbacks() = 0;
48
50 Q_INVOKABLE virtual void activateMatch(uint item, uint action = 0) = 0;
51
53 Q_INVOKABLE virtual void activateFallback(uint item, uint action = 0) = 0;
54
58 virtual void add(const std::shared_ptr<Item> &item) = 0;
59
63 virtual void add(std::shared_ptr<Item> &&item) = 0;
64
66 virtual void add(const std::vector<std::shared_ptr<Item>> &items) = 0;
67
69 virtual void add(std::vector<std::shared_ptr<Item>> &&items) = 0;
70
74 inline operator QString() const { return string(); }
75
76protected:
77
78 ~Query() override;
79
80signals:
81
83 void finished();
84};
85
86}
Common query object.
Definition query.h:20
virtual Q_INVOKABLE QString synopsis() const =0
The synopsis of this query.
virtual void add(std::vector< std::shared_ptr< Item > > &&items)=0
Move add multiple items.
virtual Q_INVOKABLE void activateMatch(uint item, uint action=0)=0
Executes match a match action.
virtual void add(std::shared_ptr< Item > &&item)=0
Move add single item.
virtual Q_INVOKABLE QAbstractListModel * fallbacks()=0
Returns the fallbacks.
virtual void add(const std::vector< std::shared_ptr< Item > > &items)=0
Copy add multiple items.
virtual Q_INVOKABLE bool isFinished() const =0
True if the query thread stopped.
virtual Q_INVOKABLE QAbstractListModel * matches()=0
Returns the matches.
~Query() override
virtual Q_INVOKABLE QString trigger() const =0
The trigger of this query.
virtual Q_INVOKABLE bool isTriggered() const =0
True if this query has a trigger.
void finished()
Emitted when the query finished processing.
virtual Q_INVOKABLE void activateFallback(uint item, uint action=0)=0
Executes match a fallback action.
virtual void add(const std::shared_ptr< Item > &item)=0
Copy add single item.
virtual Q_INVOKABLE const bool & isValid() const =0
True if query has not been cancelled.
virtual Q_INVOKABLE QString string() const =0
Query string excluding the trigger.
Definition action.h:10