summaryrefslogtreecommitdiff
path: root/src/plugins/vcsbase
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@theqtcompany.com>2015-01-19 15:42:22 +0100
committerTobias Hunger <tobias.hunger@theqtcompany.com>2015-01-21 10:16:56 +0100
commitdb215dcf6949387b2e4e5fea289b2e69ee7c65b0 (patch)
tree6e634f68877500c7b4bca30fc32454f80bae50fc /src/plugins/vcsbase
parent0efe82475f08331f726e24a8d72262ead9e495db (diff)
downloadqt-creator-db215dcf6949387b2e4e5fea289b2e69ee7c65b0.tar.gz
VcsBase: Add Js Extension for querying VCS configuration state
This enables JSON wizards to check for that. Change-Id: If6bfc580b37f712168b707ac51412df8f1cbbf25 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Diffstat (limited to 'src/plugins/vcsbase')
-rw-r--r--src/plugins/vcsbase/vcsbase.pro2
-rw-r--r--src/plugins/vcsbase/vcsbase.qbs2
-rw-r--r--src/plugins/vcsbase/vcsplugin.cpp4
-rw-r--r--src/plugins/vcsbase/wizard/vcsjsextension.cpp54
-rw-r--r--src/plugins/vcsbase/wizard/vcsjsextension.h51
5 files changed, 113 insertions, 0 deletions
diff --git a/src/plugins/vcsbase/vcsbase.pro b/src/plugins/vcsbase/vcsbase.pro
index 6524523abf..91b4e11013 100644
--- a/src/plugins/vcsbase/vcsbase.pro
+++ b/src/plugins/vcsbase/vcsbase.pro
@@ -3,6 +3,7 @@ include(../../qtcreatorplugin.pri)
HEADERS += vcsbase_global.h \
vcsbaseconstants.h \
wizard/vcsconfigurationpage.h \
+ wizard/vcsjsextension.h \
vcsplugin.h \
corelistener.h \
vcsbaseplugin.h \
@@ -34,6 +35,7 @@ HEADERS += vcsbase_global.h \
SOURCES += vcsplugin.cpp \
vcsbaseplugin.cpp \
wizard/vcsconfigurationpage.cpp \
+ wizard/vcsjsextension.cpp \
corelistener.cpp \
baseannotationhighlighter.cpp \
diffhighlighter.cpp \
diff --git a/src/plugins/vcsbase/vcsbase.qbs b/src/plugins/vcsbase/vcsbase.qbs
index 44e379de04..36072b9e25 100644
--- a/src/plugins/vcsbase/vcsbase.qbs
+++ b/src/plugins/vcsbase/vcsbase.qbs
@@ -81,5 +81,7 @@ QtcPlugin {
"images/submit.png",
"wizard/vcsconfigurationpage.cpp",
"wizard/vcsconfigurationpage.h",
+ "wizard/vcsjsextension.cpp",
+ "wizard/vcsjsextension.h",
]
}
diff --git a/src/plugins/vcsbase/vcsplugin.cpp b/src/plugins/vcsbase/vcsplugin.cpp
index 1432f77b9c..17bb728cba 100644
--- a/src/plugins/vcsbase/vcsplugin.cpp
+++ b/src/plugins/vcsbase/vcsplugin.cpp
@@ -37,8 +37,10 @@
#include "vcsoutputwindow.h"
#include "corelistener.h"
#include "wizard/vcsconfigurationpage.h"
+#include "wizard/vcsjsextension.h"
#include <coreplugin/iversioncontrol.h>
+#include <coreplugin/jsexpander.h>
#include <coreplugin/mimedatabase.h>
#include <coreplugin/vcsmanager.h>
@@ -93,6 +95,8 @@ bool VcsPlugin::initialize(const QStringList &arguments, QString *errorMessage)
JsonWizardFactory::registerPageFactory(new Internal::VcsConfigurationPageFactory);
+ JsExpander::registerQObjectForJs(QLatin1String("Vcs"), new VcsJsExtension);
+
Utils::MacroExpander *expander = Utils::globalMacroExpander();
expander->registerVariable(Constants::VAR_VCS_NAME,
tr("Name of the version control system in use by the current project."),
diff --git a/src/plugins/vcsbase/wizard/vcsjsextension.cpp b/src/plugins/vcsbase/wizard/vcsjsextension.cpp
new file mode 100644
index 0000000000..ba39411312
--- /dev/null
+++ b/src/plugins/vcsbase/wizard/vcsjsextension.cpp
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://www.qt.io/licensing. For further information
+** use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "vcsjsextension.h"
+
+#include <coreplugin/iversioncontrol.h>
+#include <coreplugin/vcsmanager.h>
+
+using namespace Core;
+
+namespace VcsBase {
+namespace Internal {
+
+bool VcsJsExtension::isConfigured(const QString &vcsId) const
+{
+ IVersionControl *vc = VcsManager::versionControl(Id::fromString(vcsId));
+ return vc && vc->isConfigured();
+}
+
+QString VcsJsExtension::displayName(const QString &vcsId) const
+{
+ IVersionControl *vc = VcsManager::versionControl(Id::fromString(vcsId));
+ return vc ? vc->displayName() : QString();
+}
+
+} // namespace Internal
+} // namespace VcsBase
diff --git a/src/plugins/vcsbase/wizard/vcsjsextension.h b/src/plugins/vcsbase/wizard/vcsjsextension.h
new file mode 100644
index 0000000000..289f9186c8
--- /dev/null
+++ b/src/plugins/vcsbase/wizard/vcsjsextension.h
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://www.qt.io/licensing. For further information
+** use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef VCSJSEXTENSION_H
+#define VCSJSEXTENSION_H
+
+#include <QObject>
+
+namespace VcsBase {
+namespace Internal {
+
+class VcsJsExtension : public QObject
+{
+ Q_OBJECT
+
+public:
+ Q_INVOKABLE bool isConfigured(const QString &vcsId) const;
+ Q_INVOKABLE QString displayName(const QString &vcsId) const;
+};
+
+} // namespace Internal
+} // namespace VcsBase
+
+#endif // VCSJSEXTENSION_H