1/****************************************************************************
2**
3** Copyright (C) 2015 The Qt Company Ltd.
4** Contact: http://www.qt.io/licensing/
5**
6** This file is part of the QtContacts module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL21$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see http://www.qt.io/terms-conditions. For further
15** information use the contact form at http://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 2.1 or version 3 as published by the Free
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the
22** following information to ensure the GNU Lesser General Public License
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25**
26** As a special exception, The Qt Company gives you certain additional
27** rights. These rights are described in The Qt Company LGPL Exception
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29**
30** $QT_END_LICENSE$
31**
32****************************************************************************/
33
34#include "qcontactactionfactory.h"
35
36#include "qcontact.h"
37#include "qcontactactiondescriptor_p.h"
38
39QT_BEGIN_NAMESPACE_CONTACTS
40
41/*!
42 \class QContactActionFactory
43 \brief The QContactActionFactory class provides an interface for clients
44 to retrieve instances of action implementations
45 \inmodule QtContacts
46 \ingroup contacts-actions
47 */
48
49/*!
50 \fn QContactActionFactory::QContactActionFactory(QObject* parent)
51 Default constructor for this interface. Passes \a parent to the QObject constructor.
52*/
53
54/*!
55 \fn QContactActionFactory::~QContactActionFactory()
56
57 Clears any memory in use by this factory
58 */
59
60QContactActionFactory::~QContactActionFactory()
61{
62}
63
64
65/*!
66 \fn QContactActionFactory::actionDescriptors() const
67
68 Return a list of action descriptors for the actions that this factory supports.
69*/
70
71/*!
72 \fn QContactActionFactory::contactFilter(const QContactActionDescriptor& which) const
73
74 Returns a filter to select contacts that are supported by the action specified by \a which.
75*/
76
77/*!
78 \fn QContactActionFactory::supportedTargets(const QContact& contact, const QContactActionDescriptor& which) const
79
80 Returns the targets which are supported by the action described by \a which that may be instantiated by this factory
81 for the given \a contact. If there are no supported targets for the \a contact, then that
82 contact is not supported by the action.
83
84 \sa supportsContact()
85 */
86
87/*!
88 \fn QContactActionFactory::supportsContact(const QContact& contact, const QContactActionDescriptor& which) const
89
90 Returns true if there are any targets for the given \a contact supported by the action described by \a which.
91 */
92
93/*!
94 \fn QContactActionFactory::create(const QContactActionDescriptor& which) const
95
96 Returns a new \l QContactAction instance for the supplied action descriptor \a which.
97
98 The caller will own this object.
99*/
100
101/*!
102 \fn QContactActionFactory::metaData(const QString& key, const QList<QContactActionTarget>& targets, const QVariantMap& parameters = QVariantMap(), const QContactActionDescriptor& which) const
103
104 Returns the meta-data associated with the action described by \a which for the given \a key (such as icon, label or sound cues).
105 The meta-data may vary depending on the \a targets of the action and any \a parameters to invocation which the client may specify.
106 */
107
108/*!
109 \fn QContactActionFactory::InterfaceName()
110 The name of the interface that action plugins should implement.
111 */
112
113bool QContactActionFactory::supportsContact(const QContact& contact, const QContactActionDescriptor& which) const
114{
115 // default implementation is naive.
116 return !supportedTargets(contact, which).isEmpty();
117}
118
119/*!
120 Creates an action descriptor based on the supplied action name \a actionName, service name \a serviceName, action identifier \a actionIdentifier, and version \a implementationVersion.
121*/
122QContactActionDescriptor QContactActionFactory::createDescriptor(const QString& actionName, const QString& serviceName, const QString& actionIdentifier, int implementationVersion) const
123{
124 QContactActionDescriptor retn;
125 retn.d->m_actionName = actionName;
126 retn.d->m_serviceName = serviceName;
127 retn.d->m_identifier = actionIdentifier;
128 retn.d->m_implementationVersion = implementationVersion;
129 retn.d->m_factory = this;
130 return retn;
131}
132
133#include "moc_qcontactactionfactory.cpp"
134
135QT_END_NAMESPACE_CONTACTS
136

source code of qtpim/src/contacts/qcontactactionfactory.cpp