1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4#include "databaseinfo.h"
5#include "driver.h"
6#include "ui4.h"
7#include "utils.h"
8
9QT_BEGIN_NAMESPACE
10
11using namespace Qt::StringLiterals;
12
13DatabaseInfo::DatabaseInfo() = default;
14
15void DatabaseInfo::acceptUI(DomUI *node)
16{
17 m_connections.clear();
18 m_cursors.clear();
19 m_fields.clear();
20
21 TreeWalker::acceptUI(ui: node);
22
23 m_connections.removeDuplicates();
24}
25
26void DatabaseInfo::acceptWidget(DomWidget *node)
27{
28 QHash<QString, DomProperty*> properties = propertyMap(properties: node->elementProperty());
29
30 DomProperty *frameworkCode = properties.value(key: "frameworkCode"_L1);
31 if (frameworkCode && toBool(str: frameworkCode->elementBool()) == false)
32 return;
33
34 DomProperty *db = properties.value(key: "database"_L1);
35 if (db && db->elementStringList()) {
36 QStringList info = db->elementStringList()->elementString();
37 if (info.isEmpty() || info.constFirst().isEmpty())
38 return;
39 const QString &connection = info.constFirst();
40 m_connections.append(t: connection);
41
42 QString table = info.size() > 1 ? info.at(i: 1) : QString();
43 if (table.isEmpty())
44 return;
45 m_cursors[connection].append(t: table);
46
47 QString field = info.size() > 2 ? info.at(i: 2) : QString();
48 if (field.isEmpty())
49 return;
50 m_fields[connection].append(t: field);
51 }
52
53 TreeWalker::acceptWidget(widget: node);
54}
55
56QT_END_NAMESPACE
57

source code of qtbase/src/tools/uic/databaseinfo.cpp