13#include <QtCore/qdir.h>
14#include <QtCore/qfileinfo.h>
15#include <QtCore/qtextstream.h>
63 auto usedIt =
c->find(module);
64 if (usedIt ==
c->end())
66 else if (!usedIt.value().contains(
className))
73 std::sort(classList.begin(), classList.end());
80 str << (
i % 4 == 0 ?
",\n " :
", ");
81 str << classList.at(
i);
88 bool useStarImports =
false,
92 str <<
"from " << modulePrefix <<
it.key() <<
" import ";
94 str <<
"* # type: ignore";
120 if (!m_customWidgets.
isEmpty() || !m_plainCustomWidgets.isEmpty()) {
123 for (
const auto &
w : m_plainCustomWidgets)
124 output <<
"import " <<
w <<
'\n';
128 const auto includes = resources->elementInclude();
129 for (
auto include : includes) {
130 if (include->hasAttributeLocation())
131 writeResourceImport(include->attributeLocation());
143 if (!options.inputFile.isEmpty() && !options.pythonRoot.isEmpty()) {
145 if (resource.
size() > options.pythonRoot.size())
146 resource.
remove(0, options.pythonRoot.size() + 1);
155void WriteImports::writeResourceImport(
const QString &module)
166 if (options.rcPrefix)
167 resource.
insert(basePos, u
"rc_");
171 switch (options.pythonResourceImport) {
179 str <<
"import " << resourceAbsolutePath(resource) <<
'\n';
194 if (dcw !=
nullptr) {
210 const bool result = moduleIt != m_classToModule.
cend();
231 modulePath.
replace(u
'/', u
'.');
241 switch (node->
kind()) {
255void WriteImports::addEnumBaseClass(
const QString &
v)
258 const auto colonPos =
v.indexOf(u
"::");
QString elementEnum() const
QString elementSet() const
DomResources * elementResources() const
void acceptUI(DomUI *node) override
void acceptProperty(DomProperty *node) override
void doAdd(const QString &className, const DomCustomWidget *dcw=nullptr) override
static QByteArray number(int, int base=10)
Returns a byte-array representing the whole number n as text.
static QString cleanPath(const QString &path)
Returns path with directory separators normalized (that is, platform-native separators converted to "...
\inmodule QtCore \reentrant
QString canonicalPath() const
Returns the file's path canonical path (excluding the file name), i.e.
const_iterator constFind(const Key &key) const noexcept
const_iterator cend() const noexcept
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
const_iterator cbegin() const noexcept
\macro QT_RESTRICTED_CAST_FROM_ASCII
qsizetype lastIndexOf(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
QString & replace(qsizetype i, qsizetype len, QChar after)
void chop(qsizetype n)
Removes n characters from the end of the string.
qsizetype size() const
Returns the number of characters in this string.
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
QString & insert(qsizetype i, QChar c)
QString sliced(qsizetype pos) const
QString & append(QChar c)
QString left(qsizetype n) const
Returns a substring that contains the n leftmost characters of the string.
QString & remove(qsizetype i, qsizetype len)
Removes n characters from the string, starting at the given position index, and returns a reference t...
const CustomWidgetsInfo * customWidgetsInfo() const
const Option & option() const
void add(const QString &className, const DomCustomWidget *dcw=nullptr)
void acceptUI(DomUI *node) override
void acceptProperty(DomProperty *node) override
QSet< QString >::iterator it
static void formatImportClasses(QTextStream &str, QStringList classList)
static void insertClass(const QString &module, const QString &className, WriteImports::ClassesPerModule *c)
static void formatClasses(QTextStream &str, const WriteImports::ClassesPerModule &c, bool useStarImports=false, const QByteArray &modulePrefix={})
static WriteImports::ClassesPerModule defaultClasses()
Combined button and popup list for selecting options.
#define QByteArrayLiteral(str)
GLsizei const GLfloat * v
[13]
GLfloat GLfloat GLfloat w
[0]
GLenum GLuint GLintptr GLsizeiptr size
[1]
#define qPrintable(string)
#define QStringLiteral(str)
QT_BEGIN_NAMESPACE typedef uchar * output
const char className[16]
[1]
unsigned int useStarImports
ClassInfoEntries classInfoEntries()