Coverage Report

Created: 2026-07-25 07:03

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/qtbase/src/gui/kernel/qgenericpluginfactory.cpp
Line
Count
Source
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
// Qt-Security score:significant reason:default
4
5
#include "qgenericpluginfactory.h"
6
7
#include "qguiapplication.h"
8
#include "private/qfactoryloader_p.h"
9
#include "qgenericplugin.h"
10
#include "qdebug.h"
11
12
QT_BEGIN_NAMESPACE
13
14
using namespace Qt::StringLiterals;
15
16
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, gpLoader,
17
    (QGenericPluginFactoryInterface_iid, "/generic"_L1, Qt::CaseInsensitive))
18
19
/*!
20
    \class QGenericPluginFactory
21
    \ingroup plugins
22
    \inmodule QtGui
23
24
    \brief The QGenericPluginFactory class creates plugin drivers.
25
26
    \sa QGenericPlugin
27
*/
28
29
/*!
30
    Creates the driver specified by \a key, using the given \a specification.
31
32
    Note that the keys are case-insensitive.
33
34
    \sa keys()
35
*/
36
QObject *QGenericPluginFactory::create(const QString& key, const QString &specification)
37
0
{
38
0
    return qLoadPlugin<QObject, QGenericPlugin>(gpLoader(), key.toLower(), specification);
39
0
}
40
41
/*!
42
    Returns the list of valid keys, i.e. the available mouse drivers.
43
44
    \sa create()
45
*/
46
QStringList QGenericPluginFactory::keys()
47
0
{
48
0
    QStringList list;
49
50
0
    typedef QMultiMap<int, QString> PluginKeyMap;
51
0
    typedef PluginKeyMap::const_iterator PluginKeyMapConstIterator;
52
53
0
    const PluginKeyMap keyMap = gpLoader()->keyMap();
54
0
    const PluginKeyMapConstIterator cend = keyMap.constEnd();
55
0
    for (PluginKeyMapConstIterator it = keyMap.constBegin(); it != cend; ++it)
56
0
        if (!list.contains(it.value()))
57
0
            list += it.value();
58
0
    return list;
59
0
}
60
61
QT_END_NAMESPACE