Commit 3bcaf23b authored by Tobias Hunger's avatar Tobias Hunger

Qbs: Simplify build methods

Use m_editorProject and m_editorNode where possible instead of going through
the current editor, its document and the nodes.

Change-Id: I252cedccf71a3c9884d0202aae394c42a5e96014
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
parent 6063d313
......@@ -374,17 +374,10 @@ void QbsProjectManagerPlugin::buildFileContextMenu()
void QbsProjectManagerPlugin::buildFile()
{
QString file;
QbsProject *project = 0;
if (Core::IDocument *currentDocument= Core::EditorManager::currentDocument()) {
file = currentDocument->filePath();
project = qobject_cast<QbsProject *>(SessionManager::projectForFile(file));
}
if (!project || file.isEmpty())
if (!m_editorProject || !m_editorNode)
return;
buildSingleFile(project, file);
buildSingleFile(m_editorProject, m_editorNode->path());
}
void QbsProjectManagerPlugin::buildProductContextMenu()
......@@ -397,19 +390,15 @@ void QbsProjectManagerPlugin::buildProductContextMenu()
void QbsProjectManagerPlugin::buildProduct()
{
QbsProject *project = 0;
QbsProductNode *product = 0;
if (Core::IDocument *currentDocument= Core::EditorManager::currentDocument()) {
const QString file = currentDocument->filePath();
if (!m_editorProject || !m_editorNode)
return;
project = qobject_cast<QbsProject *>(SessionManager::projectForFile(file));
product = qobject_cast<QbsProductNode *>(SessionManager::nodeForFile(file)->projectNode());
}
QbsProductNode *product = qobject_cast<QbsProductNode *>(m_editorNode->projectNode());
if (!project || !product)
if (!product)
return;
buildProducts(project, QStringList(product->displayName()));
buildProducts(m_editorProject, QStringList(product->displayName()));
}
void QbsProjectManagerPlugin::buildSubprojectContextMenu()
......@@ -429,31 +418,28 @@ void QbsProjectManagerPlugin::buildSubprojectContextMenu()
void QbsProjectManagerPlugin::buildSubproject()
{
QbsProject *project = 0;
if (!m_editorNode || !m_editorProject)
return;
QbsProjectNode *subproject = 0;
if (Core::IDocument *currentDocument= Core::EditorManager::currentDocument()) {
const QString file = currentDocument->filePath();
project = qobject_cast<QbsProject *>(SessionManager::projectForFile(file));
QbsBaseProjectNode *start = qobject_cast<QbsBaseProjectNode *>(SessionManager::nodeForFile(file)->projectNode());
while (start && start != project->rootProjectNode()) {
QbsProjectNode *tmp = qobject_cast<QbsProjectNode *>(start);
if (tmp) {
subproject = tmp;
break;
}
start = qobject_cast<QbsProjectNode *>(start->parentFolderNode());
QbsBaseProjectNode *start = qobject_cast<QbsBaseProjectNode *>(m_editorNode->projectNode());
while (start && start != m_editorProject->rootProjectNode()) {
QbsProjectNode *tmp = qobject_cast<QbsProjectNode *>(start);
if (tmp) {
subproject = tmp;
break;
}
start = qobject_cast<QbsProjectNode *>(start->parentFolderNode());
}
if (!project || !subproject)
if (!subproject)
return;
QStringList toBuild;
foreach (const qbs::ProductData &data, subproject->qbsProjectData().allProducts())
toBuild << data.name();
buildProducts(project, toBuild);
buildProducts(m_editorProject, toBuild);
}
void QbsProjectManagerPlugin::buildFiles(QbsProject *project, const QStringList &files,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment