blob: 5334f06baf55d4a02d3eebc9876540284598852c (
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
51
52
53
54
55
56
|
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "databaseinfo.h"
#include "driver.h"
#include "ui4.h"
#include "utils.h"
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
DatabaseInfo::DatabaseInfo() = default;
void DatabaseInfo::acceptUI(DomUI *node)
{
m_connections.clear();
m_cursors.clear();
m_fields.clear();
TreeWalker::acceptUI(node);
m_connections.removeDuplicates();
}
void DatabaseInfo::acceptWidget(DomWidget *node)
{
QHash<QString, DomProperty*> properties = propertyMap(node->elementProperty());
DomProperty *frameworkCode = properties.value("frameworkCode"_L1);
if (frameworkCode && toBool(frameworkCode->elementBool()) == false)
return;
DomProperty *db = properties.value("database"_L1);
if (db && db->elementStringList()) {
QStringList info = db->elementStringList()->elementString();
if (info.isEmpty() || info.constFirst().isEmpty())
return;
const QString &connection = info.constFirst();
m_connections.append(connection);
QString table = info.size() > 1 ? info.at(1) : QString();
if (table.isEmpty())
return;
m_cursors[connection].append(table);
QString field = info.size() > 2 ? info.at(2) : QString();
if (field.isEmpty())
return;
m_fields[connection].append(field);
}
TreeWalker::acceptWidget(node);
}
QT_END_NAMESPACE
|