blob: da6d12131b1d1747e17c9c2273136a07ce5511ea (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
#include "widgetpluginmanager.h"
#include <QObject>
#include <QDir>
#include <QDebug>
#include <QStandardItemModel>
enum { debug = 0 };
namespace QmlDesigner {
namespace Internal {
WidgetPluginManager::WidgetPluginManager() = default;
WidgetPluginManager::IWidgetPluginList WidgetPluginManager::instances()
{
IWidgetPluginList rc;
const auto end = m_paths.end();
for (auto it = m_paths.begin(); it != end; ++it)
it->getInstances(&rc);
if (debug)
qDebug() << '<' << Q_FUNC_INFO << rc.size();
return rc;
}
bool WidgetPluginManager::addPath(const QString &path)
{
const QDir dir(path);
if (!dir.exists())
return false;
m_paths.push_back(WidgetPluginPath(dir));
return true;
}
QAbstractItemModel *WidgetPluginManager::createModel(QObject *parent)
{
auto model = new QStandardItemModel(parent);
const auto end = m_paths.end();
for (auto it = m_paths.begin(); it != end; ++it)
model->appendRow(it->createModelItem());
return model;
}
} // namespace Internal
} // namespace QmlDesigner
|