LeechCraft 0.6.70-17335-ge406ffdcaf
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
notificationactionhandler.cpp
Go to the documentation of this file.
1/**********************************************************************
2 * LeechCraft - modular cross-platform feature rich internet client.
3 * Copyright (C) 2006-2014 Georg Rudoy
4 *
5 * Distributed under the Boost Software License, Version 1.0.
6 * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7 **********************************************************************/
8
10#include <QStringList>
11
12namespace LC::Util
13{
15 : Entity_ (e)
16 {
17 Entity_.Additional_ [QStringLiteral ("HandlingObject")] = QVariant::fromValue (QObject_ptr (this));
18 }
19
20 void NotificationActionHandler::AddFunction (const QString& name, Callback_t callback)
21 {
22 ActionName2Callback_ << qMakePair (name, callback);
23 static const auto notificationAction = QStringLiteral ("NotificationActions");
24 const QStringList& sl = Entity_.Additional_ [notificationAction].toStringList ();
25 Entity_.Additional_ [notificationAction] = sl + QStringList (name);
26 }
27
29 {
30 DependentObjects_ << QPointer<QObject> (obj);
31 }
32
34 {
35 if (std::any_of (DependentObjects_.begin (), DependentObjects_.end (),
36 [] (const auto& obj) { return obj.isNull (); }))
37 return;
38
39 ActionName2Callback_.at (idx).second ();
40 }
41}
UTIL_XPC_API NotificationActionHandler(Entity &entity, QObject *=nullptr)
Creates the handler on the given entity.
UTIL_XPC_API void AddDependentObject(QObject *object)
Adds an object as a dependent object.
UTIL_XPC_API void AddFunction(const QString &name, Callback_t action)
Adds an action with the given name.
std::function< void()> Callback_t
Type of functions used as actions in the handler.
A message used for inter-plugin communication.
Definition structures.h:96
std::shared_ptr< QObject > QObject_ptr
Definition structures.h:222