forked from qt-creator/qt-creator
Make resources of Python projects accessible from Qt Designer
Set node types for the various file types. Fixes: QTCREATORBUG-23248 Change-Id: I0ce01f70103cf79fd6f8d07119cda7922367595c Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
This commit is contained in:
@@ -168,6 +168,21 @@ PythonProject::PythonProject(const FilePath &fileName)
|
|||||||
connect(this, &PythonProject::projectFileIsDirty, this, [this]() { refresh(); });
|
connect(this, &PythonProject::projectFileIsDirty, this, [this]() { refresh(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static FileType getFileType(const QString &f)
|
||||||
|
{
|
||||||
|
const auto cs = HostOsInfo::isWindowsHost()
|
||||||
|
? Qt::CaseInsensitive : Qt::CaseSensitive;
|
||||||
|
if (f.endsWith(".pyproject", cs) || f.endsWith(".pyqtc", cs))
|
||||||
|
return FileType::Project;
|
||||||
|
if (f.endsWith(".qrc", cs))
|
||||||
|
return FileType::Resource;
|
||||||
|
if (f.endsWith(".ui", cs))
|
||||||
|
return FileType::Form;
|
||||||
|
if (f.endsWith(".qml", cs) || f.endsWith(".js", cs))
|
||||||
|
return FileType::QML;
|
||||||
|
return FileType::Source;
|
||||||
|
}
|
||||||
|
|
||||||
void PythonProject::refresh(Target *target)
|
void PythonProject::refresh(Target *target)
|
||||||
{
|
{
|
||||||
ParseGuard guard = guardParsingRun();
|
ParseGuard guard = guardParsingRun();
|
||||||
@@ -178,8 +193,7 @@ void PythonProject::refresh(Target *target)
|
|||||||
auto newRoot = std::make_unique<PythonProjectNode>(this);
|
auto newRoot = std::make_unique<PythonProjectNode>(this);
|
||||||
for (const QString &f : qAsConst(m_files)) {
|
for (const QString &f : qAsConst(m_files)) {
|
||||||
const QString displayName = baseDir.relativeFilePath(f);
|
const QString displayName = baseDir.relativeFilePath(f);
|
||||||
const FileType fileType = f.endsWith(".pyproject") || f.endsWith(".pyqtc") ? FileType::Project
|
const FileType fileType = getFileType(f);
|
||||||
: FileType::Source;
|
|
||||||
newRoot->addNestedNode(std::make_unique<PythonFileNode>(FilePath::fromString(f),
|
newRoot->addNestedNode(std::make_unique<PythonFileNode>(FilePath::fromString(f),
|
||||||
displayName, fileType));
|
displayName, fileType));
|
||||||
if (fileType == FileType::Source) {
|
if (fileType == FileType::Source) {
|
||||||
|
Reference in New Issue
Block a user