| 1 |
// Copyright (C) 2019 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 "pythonwritedeclaration.h" |
| 5 |
#include <cppwriteinitialization.h> |
| 6 |
#include <language.h> |
| 7 |
#include <driver.h> |
| 8 |
#include <ui4.h> |
| 9 |
#include <uic.h> |
| 10 |
|
| 11 |
#include <QtCore/qtextstream.h> |
| 12 |
#include <QtCore/qdebug.h> |
| 13 |
|
| 14 |
QT_BEGIN_NAMESPACE |
| 15 |
|
| 16 |
using namespace Qt::StringLiterals; |
| 17 |
|
| 18 |
namespace Python { |
| 19 |
|
| 20 |
WriteDeclaration::WriteDeclaration(Uic *uic) : |
| 21 |
m_uic(uic), |
| 22 |
m_driver(uic->driver()), |
| 23 |
m_output(uic->output()), |
| 24 |
m_option(uic->option()) |
| 25 |
{ |
| 26 |
} |
| 27 |
|
| 28 |
void WriteDeclaration::acceptUI(DomUI *node) |
| 29 |
{ |
| 30 |
// remove any left-over C++ namespaces |
| 31 |
const QString qualifiedClassName = "Ui_"_L1 + node->elementClass() |
| 32 |
+ m_option.postfix; |
| 33 |
m_output << "class " << language::fixClassName(qualifiedClassName) << "(object):\n"; |
| 34 |
|
| 35 |
TreeWalker::acceptWidget(node->elementWidget()); |
| 36 |
if (const DomButtonGroups *domButtonGroups = node->elementButtonGroups()) |
| 37 |
acceptButtonGroups(domButtonGroups); |
| 38 |
CPP::WriteInitialization(m_uic).acceptUI(node); |
| 39 |
} |
| 40 |
|
| 41 |
// Register button groups to prevent the on-the-fly creation legacy |
| 42 |
// feature from triggering |
| 43 |
void WriteDeclaration::acceptButtonGroup(const DomButtonGroup *buttonGroup) |
| 44 |
{ |
| 45 |
m_driver->findOrInsertButtonGroup(buttonGroup); |
| 46 |
} |
| 47 |
|
| 48 |
} // namespace Python |
| 49 |
|
| 50 |
QT_END_NAMESPACE |