[QBS] Just a few questions
Thomas Epting
thomas.epting.stryker at gmail.com
Wed May 28 07:33:41 CEST 2014
Hi Kevin,
Regarding Qbs integration in QtCreator 3.1 we see the same issues. I know
there is QBS-17 and some more, but nobody seems to be working on these. So
some time ago I did a quick hack which at least allows us to add files to
Qbs projects in a convenient way. It's probably not the best solution at
all, but it's working for us. I've added the patch against 3.1 sources to
this posting.
Regards,
Thomas
2014-05-27 19:12 GMT+02:00 Kevin Chaves <kmchaves at live.com>:
> Thank you again. I didn't think it would be this easy to transfer
> everything over. Considering I started working on this Friday as a weekend
> project just to see how far i could get over the long weekend. I'm finding
> that the integration with Qt Creator is a much bigger limiting factor. For
> instance adding/removing files doesn't seem to work in the context menu,
> and hand editing them in I've had to close and reopen the project in Qt
> creator (3.1).
>
> I'll see if i can get your suggestion working, that way we have a working
> qbs build as an option.
>
> Thanks again
>
> Kevin
>
> _______________________________________________
> QBS mailing list
> QBS at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/qbs
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qbs/attachments/20140528/5961dac3/attachment.html>
-------------- next part --------------
diff --git a/src/plugins/qbsprojectmanager/qbsnodes.cpp b/src/plugins/qbsprojectmanager/qbsnodes.cpp
index 213fd4a..6f6aad8 100644
--- a/src/plugins/qbsprojectmanager/qbsnodes.cpp
+++ b/src/plugins/qbsprojectmanager/qbsnodes.cpp
@@ -88,6 +88,26 @@ QIcon QbsGroupNode::m_groupIcon;
QIcon QbsProjectNode::m_projectIcon;
QIcon QbsProductNode::m_productIcon;
+static QbsProjectNode *parentQbsProjectNode(ProjectExplorer::Node *node)
+{
+ for (ProjectExplorer::FolderNode *pn = node->projectNode(); pn; pn = pn->parentFolderNode()) {
+ QbsProjectNode *prjNode = qobject_cast<QbsProjectNode *>(pn);
+ if (prjNode)
+ return prjNode;
+ }
+ return 0;
+}
+
+static QbsProductNode *parentQbsProductNode(ProjectExplorer::Node *node)
+{
+ for (; node; node = node->parentFolderNode()) {
+ QbsProductNode *prdNode = qobject_cast<QbsProductNode *>(node);
+ if (prdNode)
+ return prdNode;
+ }
+ return 0;
+}
+
class FileTreeNode {
public:
explicit FileTreeNode(const QString &n = QString(), FileTreeNode *p = 0, bool f = false) :
@@ -341,6 +361,37 @@ bool QbsGroupNode::isEnabled() const
&& m_qbsGroupData->isEnabled();
}
+QList<ProjectExplorer::ProjectAction> QbsGroupNode::supportedActions(ProjectExplorer::Node* node) const
+{
+ Q_UNUSED(node);
+ return QList<ProjectExplorer::ProjectAction>() << ProjectExplorer::AddNewFile << ProjectExplorer::AddExistingFile;
+}
+
+bool QbsGroupNode::addFiles(const QStringList& filePaths, QStringList* notAdded)
+{
+ Q_UNUSED(notAdded);
+
+ QbsProjectNode *prjNode = parentQbsProjectNode(this);
+ if (!prjNode || !prjNode->qbsProject().isValid()) {
+ return false;
+ }
+
+ QbsProductNode *prdNode = parentQbsProductNode(this);
+ if (!prdNode || !prdNode->qbsProductData().isValid()) {
+ return false;
+ }
+
+ qbs::Project prj = prjNode->qbsProject();
+ qbs::ErrorInfo err = prj.addFiles(prdNode->qbsProductData(), *m_qbsGroupData, filePaths);
+
+ if (!err.hasError()) {
+ QbsGroupNode::setupFiles(this, m_qbsGroupData->allFilePaths() + filePaths, m_productPath, true);
+ return true;
+ }
+
+ return false;
+}
+
void QbsGroupNode::updateQbsGroupData(const qbs::GroupData *grp, const QString &productPath,
bool productWasEnabled, bool productIsEnabled)
{
@@ -498,6 +549,35 @@ bool QbsProductNode::showInSimpleTree() const
return true;
}
+QList<ProjectExplorer::ProjectAction> QbsProductNode::supportedActions(ProjectExplorer::Node* node) const
+{
+ return QList<ProjectExplorer::ProjectAction>() << ProjectExplorer::AddNewFile << ProjectExplorer::AddExistingFile;
+}
+
+bool QbsProductNode::addFiles(const QStringList& filePaths, QStringList* notAdded)
+{
+ Q_UNUSED(notAdded);
+
+ QbsProjectNode *prjNode = parentQbsProjectNode(this);
+ if (!prjNode || !prjNode->qbsProject().isValid()) {
+ return false;
+ }
+
+ foreach (const qbs::GroupData &grp, m_qbsProductData.groups()) {
+ if (grp.name() == m_qbsProductData.name() && grp.location() == m_qbsProductData.location()) {
+ qbs::Project prj = prjNode->qbsProject();
+ qbs::ErrorInfo err = prj.addFiles(m_qbsProductData, grp, filePaths);
+ if (!err.hasError()) {
+ const QString &productPath = QFileInfo(m_qbsProductData.location().fileName()).absolutePath();
+ QbsGroupNode::setupFiles(this, grp.allFilePaths() + filePaths, productPath, true);
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
void QbsProductNode::setQbsProductData(const qbs::ProductData prd)
{
if (m_qbsProductData == prd)
@@ -602,6 +682,12 @@ QbsProjectNode::~QbsProjectNode()
// do not delete m_project
}
+bool QbsProjectNode::addFiles(const QStringList& filePaths, QStringList* notAdded)
+{
+ QbsProductNode *prd = findProductNode(displayName());
+ return prd ? prd->addFiles(filePaths, notAdded) : false;
+}
+
void QbsProjectNode::update(const qbs::Project &prj)
{
update(prj.isValid() ? prj.projectData() : qbs::ProjectData());
diff --git a/src/plugins/qbsprojectmanager/qbsnodes.h b/src/plugins/qbsprojectmanager/qbsnodes.h
index fe4315b..4d7a338 100644
--- a/src/plugins/qbsprojectmanager/qbsnodes.h
+++ b/src/plugins/qbsprojectmanager/qbsnodes.h
@@ -107,6 +107,8 @@ public:
QbsGroupNode(const qbs::GroupData *grp, const QString &productPath);
bool isEnabled() const;
+ QList<ProjectExplorer::ProjectAction> supportedActions(Node *node) const;
+ bool addFiles(const QStringList &filePaths, QStringList *notAdded = 0);
void updateQbsGroupData(const qbs::GroupData *grp, const QString &productPath,
bool productWasEnabled, bool productIsEnabled);
@@ -139,6 +141,8 @@ public:
bool isEnabled() const;
bool showInSimpleTree() const;
+ QList<ProjectExplorer::ProjectAction> supportedActions(Node *node) const;
+ bool addFiles(const QStringList &filePaths, QStringList *notAdded = 0);
void setQbsProductData(const qbs::ProductData prd);
const qbs::ProductData qbsProductData() const { return m_qbsProductData; }
@@ -165,6 +169,8 @@ public:
explicit QbsProjectNode(const QString &path);
~QbsProjectNode();
+ bool addFiles(const QStringList &filePaths, QStringList *notAdded = 0);
+
void update(const qbs::Project &prj);
void update(const qbs::ProjectData &prjData);
More information about the Qbs
mailing list