summaryrefslogtreecommitdiff
path: root/src/plugins/python/pythonutils.cpp
diff options
context:
space:
mode:
authorDavid Schulz <david.schulz@qt.io>2022-03-23 07:40:20 +0100
committerDavid Schulz <david.schulz@qt.io>2022-03-28 09:29:15 +0000
commit64170a788ad76d36fc081fa68601cf9a3fe2f5fd (patch)
tree9cb16559c4780a90b55fb79c24ee16917ad9cb30 /src/plugins/python/pythonutils.cpp
parentff686f567900ac45860556253c397425edc05cfc (diff)
downloadqt-creator-64170a788ad76d36fc081fa68601cf9a3fe2f5fd.tar.gz
Python: extract pythonProjectForFile function to utils
Change-Id: I4055527302cab09f55cd4b06bfd3896accb4832a Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'src/plugins/python/pythonutils.cpp')
-rw-r--r--src/plugins/python/pythonutils.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/plugins/python/pythonutils.cpp b/src/plugins/python/pythonutils.cpp
index 5b37cdbf6b..1ddad5cfcf 100644
--- a/src/plugins/python/pythonutils.cpp
+++ b/src/plugins/python/pythonutils.cpp
@@ -146,5 +146,16 @@ QString pythonName(const FilePath &pythonPath)
return name;
}
+PythonProject *pythonProjectForFile(const FilePath &pythonFile)
+{
+ for (ProjectExplorer::Project *project : ProjectExplorer::SessionManager::projects()) {
+ if (auto pythonProject = qobject_cast<PythonProject *>(project)) {
+ if (pythonProject->isKnownFile(pythonFile))
+ return pythonProject;
+ }
+ }
+ return nullptr;
+}
+
} // namespace Internal
} // namespace Python