Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qgenericpluginfactory.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5
7#include "private/qfactoryloader_p.h"
9#include "qdebug.h"
10
12
13using namespace Qt::StringLiterals;
14
15Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, gpLoader,
16 (QGenericPluginFactoryInterface_iid, "/generic"_L1, Qt::CaseInsensitive))
17
18/*!
19 \class QGenericPluginFactory
20 \ingroup plugins
21 \inmodule QtGui
22
23 \brief The QGenericPluginFactory class creates plugin drivers.
24
25 \sa QGenericPlugin
26*/
27
28/*!
29 Creates the driver specified by \a key, using the given \a specification.
30
31 Note that the keys are case-insensitive.
32
33 \sa keys()
34*/
35QObject *QGenericPluginFactory::create(const QString& key, const QString &specification)
36{
37 return qLoadPlugin<QObject, QGenericPlugin>(gpLoader(), key.toLower(), specification);
38}
39
40/*!
41 Returns the list of valid keys, i.e. the available mouse drivers.
42
43 \sa create()
44*/
45QStringList QGenericPluginFactory::keys()
46{
47 QStringList list;
48
49 typedef QMultiMap<int, QString> PluginKeyMap;
50 typedef PluginKeyMap::const_iterator PluginKeyMapConstIterator;
51
52 const PluginKeyMap keyMap = gpLoader()->keyMap();
53 const PluginKeyMapConstIterator cend = keyMap.constEnd();
54 for (PluginKeyMapConstIterator it = keyMap.constBegin(); it != cend; ++it)
55 if (!list.contains(it.value()))
56 list += it.value();
57 return list;
58}
59
60QT_END_NAMESPACE
Combined button and popup list for selecting options.
#define QGenericPluginFactoryInterface_iid