QbsProjectManager: Do not offer to add and remove files during a build.

The build graph is locked then. Disabling the action in the first place
is nicer than letting the respective qbs API call fail.

Change-Id: Icfb89b454a240253c9ddc7681b452d06ff0393dd
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
This commit is contained in:
Christian Kandeler
2014-07-24 12:18:29 +02:00
parent fc24fe726e
commit cf9d12ed41
3 changed files with 19 additions and 6 deletions

View File

@@ -324,6 +324,17 @@ bool QbsBaseProjectNode::renameFile(const QString &filePath, const QString &newF
return false;
}
static QList<ProjectExplorer::ProjectAction> supportedNodeActions(ProjectExplorer::Node *node)
{
QList<ProjectExplorer::ProjectAction> actions;
if (parentQbsProjectNode(node)->project()->isProjectEditable()) {
actions << ProjectExplorer::AddNewFile << ProjectExplorer::AddExistingFile
<< ProjectExplorer::RemoveFile;
}
return actions;
}
// --------------------------------------------------------------------
// QbsGroupNode:
// --------------------------------------------------------------------
@@ -355,9 +366,7 @@ bool QbsGroupNode::isEnabled() const
QList<ProjectExplorer::ProjectAction> QbsGroupNode::supportedActions(ProjectExplorer::Node *node) const
{
Q_UNUSED(node);
return QList<ProjectExplorer::ProjectAction>() << ProjectExplorer::AddNewFile << ProjectExplorer::AddExistingFile
<< ProjectExplorer::RemoveFile;
return supportedNodeActions(node);
}
bool QbsGroupNode::addFiles(const QStringList &filePaths, QStringList *notAdded)
@@ -563,9 +572,7 @@ bool QbsProductNode::showInSimpleTree() const
QList<ProjectExplorer::ProjectAction> QbsProductNode::supportedActions(ProjectExplorer::Node *node) const
{
Q_UNUSED(node);
return QList<ProjectExplorer::ProjectAction>() << ProjectExplorer::AddNewFile << ProjectExplorer::AddExistingFile
<< ProjectExplorer::RemoveFile;
return supportedNodeActions(node);
}
bool QbsProductNode::addFiles(const QStringList &filePaths, QStringList *notAdded)

View File

@@ -189,6 +189,11 @@ QStringList QbsProject::files(Project::FilesMode fileMode) const
return result.toList();
}
bool QbsProject::isProjectEditable() const
{
return m_qbsProject.isValid() && !isParsing() && !ProjectExplorer::BuildManager::isBuilding();
}
class ChangeExpector
{
public:

View File

@@ -70,6 +70,7 @@ public:
QStringList files(FilesMode fileMode) const;
bool isProjectEditable() const;
bool addFilesToProduct(QbsBaseProjectNode *node, const QStringList &filePaths,
const qbs::ProductData &productData, const qbs::GroupData &groupData,
QStringList *notAdded);