forked from qt-creator/qt-creator
Qnx: Momentics Cascades project importer
Change-Id: I232d97cd1570b37f694540337b1075800e330e97 Reviewed-by: Nicolas Arnaud-Cormos <nicolas@kdab.com>
This commit is contained in:
committed by
Fanda Vacek
parent
9a97c42412
commit
a97242e332
@@ -187,15 +187,18 @@ BaseFileWizard::~BaseFileWizard()
|
||||
{
|
||||
}
|
||||
|
||||
BaseFileWizard::ExtensionList BaseFileWizard::selectExtensions()
|
||||
{
|
||||
return ExtensionSystem::PluginManager::getObjects<IFileWizardExtension>();
|
||||
}
|
||||
|
||||
void BaseFileWizard::runWizard(const QString &path, QWidget *parent, const QString &platform, const QVariantMap &extraValues)
|
||||
{
|
||||
QTC_ASSERT(!path.isEmpty(), return);
|
||||
|
||||
typedef QList<IFileWizardExtension*> ExtensionList;
|
||||
|
||||
QString errorMessage;
|
||||
// Compile extension pages, purge out unused ones
|
||||
ExtensionList extensions = ExtensionSystem::PluginManager::getObjects<IFileWizardExtension>();
|
||||
ExtensionList extensions = selectExtensions();
|
||||
WizardPageList allExtensionPages;
|
||||
for (ExtensionList::iterator it = extensions.begin(); it != extensions.end(); ) {
|
||||
const WizardPageList extensionPages = (*it)->extensionPages(this);
|
||||
|
||||
@@ -52,6 +52,8 @@ namespace Utils { class Wizard; }
|
||||
|
||||
namespace Core {
|
||||
|
||||
class IFileWizardExtension;
|
||||
|
||||
class CORE_EXPORT WizardDialogParameters
|
||||
{
|
||||
public:
|
||||
@@ -117,9 +119,12 @@ public:
|
||||
|
||||
protected:
|
||||
typedef QList<QWizardPage *> WizardPageList;
|
||||
typedef QList<Core::IFileWizardExtension*> ExtensionList;
|
||||
|
||||
explicit BaseFileWizard(QObject *parent = 0);
|
||||
|
||||
virtual ExtensionList selectExtensions();
|
||||
|
||||
virtual QWizard *createWizardDialog(QWidget *parent,
|
||||
const WizardDialogParameters &wizardDialogParameters) const = 0;
|
||||
|
||||
|
||||
248
src/plugins/qnx/cascadesimport/bardescriptorconverter.cpp
Normal file
248
src/plugins/qnx/cascadesimport/bardescriptorconverter.cpp
Normal file
@@ -0,0 +1,248 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
|
||||
** Contact: BlackBerry Limited (blackberry-qt@qnx.com)
|
||||
**
|
||||
** 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://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: 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 "bardescriptorconverter.h"
|
||||
|
||||
#include <coreplugin/generatedfile.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QDomDocument>
|
||||
|
||||
namespace Qnx {
|
||||
namespace Internal {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// BarDescriptorConverter
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
static const char S_ASSET[] = "asset";
|
||||
static const char S_PATH[] = "path";
|
||||
static const char S_SRC_DIR[] = "%SRC_DIR%/";
|
||||
|
||||
BarDescriptorConverter::BarDescriptorConverter(ConvertedProjectContext &ctx)
|
||||
: FileConverter(ctx)
|
||||
{
|
||||
}
|
||||
|
||||
QString BarDescriptorConverter::projectName() const
|
||||
{
|
||||
return convertedProjectContext().projectName();
|
||||
}
|
||||
|
||||
QString BarDescriptorConverter::applicationBinaryName() const
|
||||
{
|
||||
return projectName();
|
||||
}
|
||||
|
||||
QString BarDescriptorConverter::applicationBinaryPath() const
|
||||
{
|
||||
return projectName();
|
||||
}
|
||||
|
||||
QDomElement BarDescriptorConverter::findElement(QDomDocument &doc, const QString &tagName,
|
||||
const QString &attributeName, const QString &attributeValue)
|
||||
{
|
||||
QDomElement ret;
|
||||
QTC_ASSERT(!tagName.isEmpty(), return ret);
|
||||
QDomElement rootElement = doc.documentElement();
|
||||
static const QLatin1String elementTextFakeAttributeNameString("S_ELEMENT_TEXT_FAKE_ATTRIBUTE_NAME");
|
||||
bool isFindText = (attributeName == elementTextFakeAttributeNameString);
|
||||
QRegExp rxAttrValue;
|
||||
if (!isFindText && !attributeValue.isEmpty())
|
||||
rxAttrValue = QRegExp(attributeValue, Qt::CaseSensitive, QRegExp::Wildcard);
|
||||
for (QDomElement el = rootElement.firstChildElement(tagName);
|
||||
!el.isNull(); el = el.nextSiblingElement(tagName)) {
|
||||
if (attributeName.isEmpty()) {
|
||||
// take first matching tag name
|
||||
ret = el;
|
||||
break;
|
||||
} else if (isFindText) {
|
||||
QString s = el.text();
|
||||
if (s == attributeValue) {
|
||||
ret = el;
|
||||
break;
|
||||
}
|
||||
} else if (el.hasAttribute(attributeName)) {
|
||||
if (attributeValue.isEmpty() || rxAttrValue.exactMatch(el.attribute(attributeName))) {
|
||||
ret = el;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
QDomElement BarDescriptorConverter::ensureElement(QDomDocument &doc, const QString &tagName,
|
||||
const QString &attributeName, const QString &attributeValue)
|
||||
{
|
||||
QDomElement ret = findElement(doc, tagName, attributeName, attributeValue);
|
||||
if (ret.isNull()) {
|
||||
QDomElement rootElement = doc.documentElement();
|
||||
ret = rootElement.appendChild(doc.createElement(tagName)).toElement();
|
||||
QTC_ASSERT(!ret.isNull(), return ret);
|
||||
}
|
||||
if (!attributeName.isEmpty()) {
|
||||
ret.setAttribute(attributeName, attributeValue);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
QDomElement BarDescriptorConverter::removeElement(QDomDocument &doc, const QString &tagName,
|
||||
const QString &attributeName, const QString &attributeValue)
|
||||
{
|
||||
QDomElement ret = findElement(doc, tagName, attributeName, attributeValue);
|
||||
if (!ret.isNull()) {
|
||||
QDomNode nd = ret.parentNode();
|
||||
QTC_ASSERT(!nd.isNull(), return ret);
|
||||
nd.removeChild(ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void BarDescriptorConverter::setEnv(QDomDocument &doc, const QString &name, const QString &value)
|
||||
{
|
||||
QDomElement el = ensureElement(doc, QLatin1String("env"), QLatin1String("var"), name);
|
||||
QTC_ASSERT(!el.isNull(), return);
|
||||
el.setAttribute(QString::fromLatin1("value"), value);
|
||||
}
|
||||
|
||||
void BarDescriptorConverter::setAsset(QDomDocument &doc, const QString &srcPath,
|
||||
const QString &destPath, const QString &type, bool isEntry)
|
||||
{
|
||||
ImportLog &log = convertedProjectContext().importLog();
|
||||
log.logInfo(tr("Setting asset path: %1 to %2 type: %3 entry point: %4")
|
||||
.arg(srcPath).arg(destPath).arg(type).arg(isEntry));
|
||||
QDomElement assetElement = ensureElement(doc, QLatin1String(S_ASSET), QLatin1String(S_PATH), srcPath);
|
||||
QTC_ASSERT(!assetElement.isNull(), return);
|
||||
while (assetElement.hasChildNodes()) {
|
||||
QDomNode nd = assetElement.firstChild();
|
||||
assetElement.removeChild(nd);
|
||||
}
|
||||
assetElement.appendChild(doc.createTextNode(destPath));
|
||||
|
||||
const QString typeString = QLatin1String("type");
|
||||
QString s = assetElement.attribute(typeString);
|
||||
if (s != type)
|
||||
assetElement.setAttribute(typeString, type);
|
||||
|
||||
const QString entryString = QLatin1String("entry");
|
||||
s = assetElement.attribute(entryString);
|
||||
bool b = (s.compare(QLatin1String("true"), Qt::CaseInsensitive) == 0)
|
||||
|| (s.compare(QLatin1String("1")) == 0);
|
||||
if (b != isEntry)
|
||||
assetElement.setAttribute(entryString, QVariant(isEntry).toString());
|
||||
}
|
||||
|
||||
void BarDescriptorConverter::removeAsset(QDomDocument &doc, const QString &srcPath)
|
||||
{
|
||||
ImportLog &log = convertedProjectContext().importLog();
|
||||
log.logInfo(tr("Removing asset path: %1").arg(srcPath));
|
||||
removeElement(doc, QLatin1String(S_ASSET), QLatin1String(S_PATH), srcPath);
|
||||
}
|
||||
|
||||
void BarDescriptorConverter::replaceAssetSourcePath(QDomDocument &doc, const QString &oldSrcPath,
|
||||
const QString &newSrcPath)
|
||||
{
|
||||
ImportLog &log = convertedProjectContext().importLog();
|
||||
QDomElement el = ensureElement(doc, QLatin1String(S_ASSET), QLatin1String(S_PATH), oldSrcPath);
|
||||
if (!el.isNull()) {
|
||||
log.logInfo(tr("Replacing asset source path: %1 -> %2").arg(oldSrcPath).arg(newSrcPath));
|
||||
el.setAttribute(QLatin1String(S_PATH), newSrcPath);
|
||||
}
|
||||
}
|
||||
|
||||
void BarDescriptorConverter::fixImageAsset(QDomDocument &doc, const QString &definitionElementName)
|
||||
{
|
||||
ImportLog &log = convertedProjectContext().importLog();
|
||||
QString target;
|
||||
QDomElement el = findElement(doc, definitionElementName, QString(), QString());
|
||||
if (!el.isNull()) {
|
||||
const QString imageString = QLatin1String("image");
|
||||
for (QDomElement imageElement = el.firstChildElement(imageString); !imageElement.isNull();
|
||||
imageElement = imageElement.nextSiblingElement(imageString)) {
|
||||
target = imageElement.text();
|
||||
if (!target.isEmpty())
|
||||
replaceAssetSourcePath(doc, target, QLatin1String(S_SRC_DIR) % target);
|
||||
}
|
||||
} else {
|
||||
log.logWarning(tr("Cannot find image asset definition: <%1>").arg(definitionElementName));
|
||||
}
|
||||
}
|
||||
|
||||
void BarDescriptorConverter::fixIconAsset(QDomDocument &doc)
|
||||
{
|
||||
const QString iconString = QString::fromLatin1("icon");
|
||||
fixImageAsset(doc, iconString);
|
||||
}
|
||||
|
||||
void BarDescriptorConverter::fixSplashScreensAsset(QDomDocument &doc)
|
||||
{
|
||||
const QString splashScreensString = QString::fromLatin1("splashScreens");
|
||||
fixImageAsset(doc, splashScreensString);
|
||||
}
|
||||
|
||||
bool BarDescriptorConverter::convertFile(Core::GeneratedFile &file, QString &errorMessage)
|
||||
{
|
||||
FileConverter::convertFile(file, errorMessage);
|
||||
if (errorMessage.isEmpty()) {
|
||||
QDomDocument doc;
|
||||
if (!doc.setContent(file.binaryContents(), &errorMessage)) {
|
||||
errorMessage = tr("Error parsing XML file '%1': %2").arg(file.path()).arg(errorMessage);
|
||||
return false;
|
||||
}
|
||||
|
||||
// remove <configuration> elements, since they are Momentics specific
|
||||
QDomElement rootElement = doc.documentElement();
|
||||
const QString configurationString = QLatin1String("configuration");
|
||||
while (true) {
|
||||
QDomElement el = rootElement.firstChildElement(configurationString);
|
||||
if (el.isNull())
|
||||
break;
|
||||
rootElement.removeChild(el);
|
||||
}
|
||||
|
||||
// remove obsolete assets
|
||||
removeAsset(doc, QLatin1String("translations"));
|
||||
removeAsset(doc, QLatin1String("translations/*"));
|
||||
// assets
|
||||
setAsset(doc, applicationBinaryPath(), applicationBinaryName(),
|
||||
QLatin1String("Qnx/Elf"), true);
|
||||
const QString assetsString = QLatin1String("assets");
|
||||
replaceAssetSourcePath(doc, assetsString, QLatin1String(S_SRC_DIR) % assetsString);
|
||||
fixIconAsset(doc);
|
||||
fixSplashScreensAsset(doc);
|
||||
|
||||
file.setBinaryContents(doc.toByteArray(4));
|
||||
}
|
||||
return errorMessage.isEmpty();
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Qnx
|
||||
76
src/plugins/qnx/cascadesimport/bardescriptorconverter.h
Normal file
76
src/plugins/qnx/cascadesimport/bardescriptorconverter.h
Normal file
@@ -0,0 +1,76 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
|
||||
** Contact: BlackBerry Limited (blackberry-qt@qnx.com)
|
||||
**
|
||||
** 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://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: 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 QNX_BLACKBERRY_CASCADESPROJECTIMPORT_BARDESCRIPTORCONVERTER_H
|
||||
#define QNX_BLACKBERRY_CASCADESPROJECTIMPORT_BARDESCRIPTORCONVERTER_H
|
||||
|
||||
#include "fileconverter.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
|
||||
class QDomElement;
|
||||
class QDomDocument;
|
||||
|
||||
namespace Qnx {
|
||||
namespace Internal {
|
||||
|
||||
class BarDescriptorConverter : public FileConverter
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(BarDescriptorConverter);
|
||||
public:
|
||||
BarDescriptorConverter(ConvertedProjectContext &ctx);
|
||||
virtual ~BarDescriptorConverter() {}
|
||||
|
||||
bool convertFile(Core::GeneratedFile &file, QString &errorMessage);
|
||||
private:
|
||||
QString projectName() const;
|
||||
QString applicationBinaryName() const;
|
||||
QString applicationBinaryPath() const;
|
||||
|
||||
QDomElement findElement(QDomDocument &doc, const QString &tagName,
|
||||
const QString &attributeName, const QString &attributeValue);
|
||||
QDomElement ensureElement(QDomDocument &doc, const QString &tagName,
|
||||
const QString &attributeName, const QString &attributeValue);
|
||||
QDomElement removeElement(QDomDocument &doc, const QString &tagName,
|
||||
const QString &attributeName, const QString &attributeValue);
|
||||
|
||||
void fixImageAsset(QDomDocument &doc, const QString &definitionElementName);
|
||||
void fixIconAsset(QDomDocument &doc);
|
||||
void fixSplashScreensAsset(QDomDocument &doc);
|
||||
|
||||
void setEnv(QDomDocument &doc, const QString &name, const QString &value);
|
||||
void setAsset(QDomDocument &doc, const QString &srcPath, const QString &destPath, const QString &type = QString(), bool isEntry = false);
|
||||
void removeAsset(QDomDocument &doc, const QString &srcPath);
|
||||
void replaceAssetSourcePath(QDomDocument &doc, const QString &oldSrcPath, const QString &newSrcPath);
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Qnx
|
||||
|
||||
#endif // QNX_BLACKBERRY_CASCADESPROJECTIMPORT_BARDESCRIPTORCONVERTER_H
|
||||
23
src/plugins/qnx/cascadesimport/cascadesimport.pri
Normal file
23
src/plugins/qnx/cascadesimport/cascadesimport.pri
Normal file
@@ -0,0 +1,23 @@
|
||||
SOURCES += \
|
||||
$$PWD/cascadesimportwizard.cpp \
|
||||
$$PWD/srcprojectwizardpage.cpp \
|
||||
$$PWD/fileconverter.cpp \
|
||||
$$PWD/bardescriptorconverter.cpp \
|
||||
$$PWD/projectfileconverter.cpp \
|
||||
$$PWD/importlogconverter.cpp \
|
||||
$$PWD/importlog.cpp \
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/cascadesimportwizard.h \
|
||||
$$PWD/srcprojectwizardpage.h \
|
||||
$$PWD/fileconverter.h \
|
||||
$$PWD/bardescriptorconverter.h \
|
||||
$$PWD/projectfileconverter.h \
|
||||
$$PWD/importlogconverter.h \
|
||||
$$PWD/importlog.h \
|
||||
|
||||
FORMS += \
|
||||
$$PWD/srcprojectwizardpage.ui \
|
||||
|
||||
RESOURCES += \
|
||||
$$PWD/cascadesimport.qrc \
|
||||
5
src/plugins/qnx/cascadesimport/cascadesimport.qrc
Normal file
5
src/plugins/qnx/cascadesimport/cascadesimport.qrc
Normal file
@@ -0,0 +1,5 @@
|
||||
<RCC>
|
||||
<qresource prefix="/qnx/cascadesimport">
|
||||
<file>resources/templates/project.pro</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
300
src/plugins/qnx/cascadesimport/cascadesimportwizard.cpp
Normal file
300
src/plugins/qnx/cascadesimport/cascadesimportwizard.cpp
Normal file
@@ -0,0 +1,300 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
|
||||
** Contact: BlackBerry Limited (blackberry-qt@qnx.com)
|
||||
**
|
||||
** 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://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: 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 "cascadesimportwizard.h"
|
||||
#include "srcprojectwizardpage.h"
|
||||
#include "bardescriptorconverter.h"
|
||||
#include "importlogconverter.h"
|
||||
#include "projectfileconverter.h"
|
||||
|
||||
#include <qnxconstants.h>
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/customwizard/customwizard.h>
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/documentmanager.h>
|
||||
|
||||
#include <utils/projectintropage.h>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <QPainter>
|
||||
#include <QPixmap>
|
||||
#include <QIcon>
|
||||
#include <QStringBuilder>
|
||||
#include <QDirIterator>
|
||||
|
||||
namespace Qnx {
|
||||
namespace Internal {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CascadesImportWizardDialog
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CascadesImportWizardDialog::CascadesImportWizardDialog(QWidget *parent)
|
||||
: Utils::Wizard(parent)
|
||||
{
|
||||
setWindowTitle(tr("Import Existing Momentics Cascades Project"));
|
||||
|
||||
m_srcProjectPage = new SrcProjectWizardPage(this);
|
||||
m_srcProjectPage->setTitle(tr("Momentics Cascades Project Name and Location"));
|
||||
|
||||
m_destProjectPage = new Utils::ProjectIntroPage(this);
|
||||
m_destProjectPage->setTitle(tr("Project Name and Location"));
|
||||
m_destProjectPage->setPath(Core::DocumentManager::projectsDirectory());
|
||||
|
||||
const int srcProjectPageId = addPage(m_srcProjectPage);
|
||||
wizardProgress()->item(srcProjectPageId)->setTitle(tr("Momentics"));
|
||||
|
||||
const int destProjectPageId = addPage(m_destProjectPage);
|
||||
wizardProgress()->item(destProjectPageId)->setTitle(tr("QtCreator"));
|
||||
|
||||
connect(m_srcProjectPage, SIGNAL(validPathChanged(QString)), this, SLOT(onSrcProjectPathChanged(QString)));
|
||||
}
|
||||
|
||||
QString CascadesImportWizardDialog::srcProjectPath() const
|
||||
{
|
||||
return m_srcProjectPage->path();
|
||||
}
|
||||
|
||||
QString CascadesImportWizardDialog::destProjectPath() const
|
||||
{
|
||||
return m_destProjectPage->path() % QLatin1Char('/') % projectName();
|
||||
}
|
||||
|
||||
QString CascadesImportWizardDialog::projectName() const
|
||||
{
|
||||
return m_destProjectPage->projectName();
|
||||
}
|
||||
|
||||
void CascadesImportWizardDialog::onSrcProjectPathChanged(const QString &path)
|
||||
{
|
||||
Q_UNUSED(path);
|
||||
m_destProjectPage->setProjectName(m_srcProjectPage->projectName());
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Wizard
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
static const char IMPORT_LOG_FILE_NAME[] = "import.log";
|
||||
|
||||
CascadesImportWizard::CascadesImportWizard(QObject *parent)
|
||||
: Core::BaseFileWizard(parent)
|
||||
{
|
||||
setWizardKind(ProjectWizard);
|
||||
setIcon(QPixmap(QLatin1String(Qnx::Constants::QNX_BB_CATEGORY_ICON)));
|
||||
setDisplayName(tr("Momentics Cascades Project"));
|
||||
setId(QLatin1String("Q.QnxBlackBerryCascadesApp"));
|
||||
setRequiredFeatures(Core::FeatureSet(Constants::QNX_BB_FEATURE));
|
||||
setDescription(tr("Imports existing Cascades projects created within QNX Momentics IDE. "
|
||||
"This allows you to use the project in QtCreator."));
|
||||
setCategory(QLatin1String(ProjectExplorer::Constants::IMPORT_WIZARD_CATEGORY));
|
||||
setDisplayCategory(QLatin1String(ProjectExplorer::Constants::IMPORT_WIZARD_CATEGORY_DISPLAY));
|
||||
}
|
||||
|
||||
CascadesImportWizard::~CascadesImportWizard()
|
||||
{
|
||||
}
|
||||
|
||||
Core::FeatureSet CascadesImportWizard::requiredFeatures() const
|
||||
{
|
||||
return Core::FeatureSet(Constants::QNX_BB_FEATURE);
|
||||
}
|
||||
|
||||
Core::BaseFileWizard::ExtensionList CascadesImportWizard::selectExtensions()
|
||||
{
|
||||
return Core::BaseFileWizard::ExtensionList();
|
||||
}
|
||||
|
||||
QWizard *CascadesImportWizard::createWizardDialog(QWidget *parent,
|
||||
const Core::WizardDialogParameters &wizardDialogParameters) const
|
||||
{
|
||||
CascadesImportWizardDialog *wizard = new CascadesImportWizardDialog(parent);
|
||||
setupWizard(wizard);
|
||||
|
||||
foreach (QWizardPage *p, wizardDialogParameters.extensionPages())
|
||||
BaseFileWizard::applyExtensionPageShortTitle(wizard, wizard->addPage(p));
|
||||
|
||||
return wizard;
|
||||
}
|
||||
|
||||
bool CascadesImportWizard::convertFile(Core::GeneratedFile &file,
|
||||
ConvertedProjectContext &projectContext, QString &errorMessage) const
|
||||
{
|
||||
bool ret = false;
|
||||
if (convertFileContent(file, projectContext, errorMessage))
|
||||
if (convertFilePath(file, projectContext, errorMessage))
|
||||
ret = true;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool CascadesImportWizard::convertFileContent(Core::GeneratedFile &file,
|
||||
ConvertedProjectContext &projectContext, QString &errorMessage) const
|
||||
{
|
||||
QString filePath = file.path();
|
||||
QString fileName = filePath.section(QLatin1Char('/'), -1);
|
||||
bool isRootFile = (fileName == filePath);
|
||||
QString fileExtension = fileName.section(QLatin1Char('.'), -1).toLower();
|
||||
bool useFileConverter = true;
|
||||
if (isRootFile) {
|
||||
if (fileName == QLatin1String("bar-descriptor.xml")) {
|
||||
BarDescriptorConverter conv(projectContext);
|
||||
conv.convertFile(file, errorMessage);
|
||||
useFileConverter = false;
|
||||
} else if (fileName == QLatin1String(IMPORT_LOG_FILE_NAME)) {
|
||||
ImportLogConverter conv(projectContext);
|
||||
conv.convertFile(file, errorMessage);
|
||||
useFileConverter = false;
|
||||
} else if (fileExtension == QLatin1String("pro")) {
|
||||
ProjectFileConverter conv(projectContext);
|
||||
conv.convertFile(file, errorMessage);
|
||||
useFileConverter = false;
|
||||
}
|
||||
}
|
||||
if (useFileConverter) {
|
||||
FileConverter conv(projectContext);
|
||||
conv.convertFile(file, errorMessage);
|
||||
}
|
||||
return errorMessage.isEmpty();
|
||||
}
|
||||
|
||||
bool CascadesImportWizard::convertFilePath(Core::GeneratedFile &file,
|
||||
ConvertedProjectContext &projectContext, QString &errorMessage) const
|
||||
{
|
||||
Q_UNUSED(errorMessage);
|
||||
const QString destProjectPath = projectContext.destProjectPath();
|
||||
file.setPath(destProjectPath % QLatin1Char('/') % file.path());
|
||||
return true;
|
||||
}
|
||||
|
||||
void CascadesImportWizard::collectFiles_helper(QStringList &filePaths,
|
||||
ConvertedProjectContext &projectContext, const QString &rootPath,
|
||||
const QList< QRegExp > &blackList) const
|
||||
{
|
||||
const QString srcProjectPath = projectContext.srcProjectPath();
|
||||
bool isProjectRoot = (rootPath.length() == srcProjectPath.length());
|
||||
QDirIterator it(rootPath, QDir::NoDotAndDotDot | QDir::Files | QDir::Dirs);
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
bool isBlacklisted = false;
|
||||
QString fileName = it.fileName();
|
||||
foreach (const QRegExp &rx, blackList) {
|
||||
QString pattern = rx.pattern();
|
||||
if (pattern.at(0) == QLatin1Char('/')) {
|
||||
if (isProjectRoot) {
|
||||
QString fn = QLatin1Char('/') % fileName;
|
||||
if (rx.exactMatch(fn)) {
|
||||
isBlacklisted = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (rx.exactMatch(fileName)) {
|
||||
isBlacklisted = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isBlacklisted) {
|
||||
QFileInfo fi = it.fileInfo();
|
||||
if (fi.isFile())
|
||||
filePaths << it.filePath().mid(srcProjectPath.length() + 1);
|
||||
else if (fi.isDir())
|
||||
collectFiles_helper(filePaths, projectContext, it.filePath(), blackList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CascadesImportWizard::collectFiles(ConvertedProjectContext &projectContext, QString &errorMessage) const
|
||||
{
|
||||
static QList<QRegExp> blackList;
|
||||
if (blackList.isEmpty()) {
|
||||
blackList << QRegExp(QLatin1String("/arm"), Qt::CaseInsensitive, QRegExp::Wildcard)
|
||||
<< QRegExp(QLatin1String("/x86"), Qt::CaseInsensitive, QRegExp::Wildcard)
|
||||
<< QRegExp(QLatin1String("/translations"), Qt::CaseInsensitive, QRegExp::Wildcard)
|
||||
<< QRegExp(QLatin1String("Makefile"), Qt::CaseInsensitive, QRegExp::Wildcard)
|
||||
<< QRegExp(QLatin1String("Makefile.*"), Qt::CaseInsensitive, QRegExp::Wildcard)
|
||||
<< QRegExp(QLatin1String("/config.pri"), Qt::CaseInsensitive, QRegExp::Wildcard)
|
||||
<< QRegExp(QLatin1String("/precompiled.h"), Qt::CaseInsensitive, QRegExp::Wildcard);
|
||||
}
|
||||
QStringList filePaths;
|
||||
collectFiles_helper(filePaths, projectContext, projectContext.srcProjectPath(), blackList);
|
||||
filePaths << QLatin1String(IMPORT_LOG_FILE_NAME);
|
||||
projectContext.setCollectedFiles(filePaths);
|
||||
return errorMessage.isEmpty();
|
||||
}
|
||||
|
||||
Core::GeneratedFiles CascadesImportWizard::generateFiles(const QWizard *w, QString *pErrorMessage) const
|
||||
{
|
||||
Core::GeneratedFiles files;
|
||||
QString errorMessage;
|
||||
|
||||
const CascadesImportWizardDialog *wizardDialog = qobject_cast<const CascadesImportWizardDialog *>(w);
|
||||
if (wizardDialog) {
|
||||
ConvertedProjectContext projectContext;
|
||||
projectContext.setSrcProjectPath(wizardDialog->srcProjectPath());
|
||||
projectContext.setDestProjectPath(wizardDialog->destProjectPath());
|
||||
|
||||
if (collectFiles(projectContext, errorMessage)) {
|
||||
foreach (const QString &filePath, projectContext.collectedFiles()) {
|
||||
Core::GeneratedFile file(filePath);
|
||||
if (convertFile(file, projectContext, errorMessage)) {
|
||||
if (!file.path().isEmpty())
|
||||
files << file;
|
||||
}
|
||||
if (!errorMessage.isEmpty()) {
|
||||
errorMessage = tr("Error generating file '%1': %2").arg(filePath).arg(errorMessage);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!errorMessage.isEmpty())
|
||||
if (pErrorMessage)
|
||||
*pErrorMessage = errorMessage;
|
||||
return files;
|
||||
}
|
||||
|
||||
bool CascadesImportWizard::postGenerateFiles(const QWizard *w, const Core::GeneratedFiles &l, QString *errorMessage)
|
||||
{
|
||||
Q_UNUSED(w);
|
||||
return ProjectExplorer::CustomProjectWizard::postGenerateOpen(l, errorMessage);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Qnx
|
||||
93
src/plugins/qnx/cascadesimport/cascadesimportwizard.h
Normal file
93
src/plugins/qnx/cascadesimport/cascadesimportwizard.h
Normal file
@@ -0,0 +1,93 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
|
||||
** Contact: BlackBerry Limited (blackberry-qt@qnx.com)
|
||||
**
|
||||
** 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://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: 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 QNX_BLACKBERRY_CASCADESIMPORT_WIZARD_H
|
||||
#define QNX_BLACKBERRY_CASCADESIMPORT_WIZARD_H
|
||||
|
||||
#include "fileconverter.h"
|
||||
|
||||
#include <coreplugin/basefilewizard.h>
|
||||
#include <utils/wizard.h>
|
||||
|
||||
namespace Utils {
|
||||
class ProjectIntroPage;
|
||||
}
|
||||
|
||||
namespace Qnx {
|
||||
namespace Internal {
|
||||
|
||||
class SrcProjectWizardPage;
|
||||
|
||||
class CascadesImportWizardDialog : public Utils::Wizard
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CascadesImportWizardDialog(QWidget *parent = 0);
|
||||
|
||||
QString srcProjectPath() const;
|
||||
QString destProjectPath() const;
|
||||
|
||||
QString projectName() const;
|
||||
private slots:
|
||||
void onSrcProjectPathChanged(const QString &path);
|
||||
private:
|
||||
SrcProjectWizardPage *m_srcProjectPage;
|
||||
Utils::ProjectIntroPage *m_destProjectPage;
|
||||
};
|
||||
|
||||
class CascadesImportWizard : public Core::BaseFileWizard
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CascadesImportWizard(QObject *parent = 0);
|
||||
virtual ~CascadesImportWizard();
|
||||
|
||||
Core::FeatureSet requiredFeatures() const;
|
||||
protected:
|
||||
ExtensionList selectExtensions();
|
||||
QWizard* createWizardDialog(QWidget *parent,
|
||||
const Core::WizardDialogParameters &wizardDialogParameters) const;
|
||||
Core::GeneratedFiles generateFiles(const QWizard *w, QString *errorMessage) const;
|
||||
bool postGenerateFiles(const QWizard *w, const Core::GeneratedFiles &l, QString *errorMessage);
|
||||
private:
|
||||
bool collectFiles(ConvertedProjectContext &projectContext, QString &errorMessage) const;
|
||||
void collectFiles_helper(QStringList &file_paths, ConvertedProjectContext &projectContext,
|
||||
const QString &rootPath, const QList< QRegExp > &blackList) const;
|
||||
bool convertFile(Core::GeneratedFile &file, ConvertedProjectContext &projectContext,
|
||||
QString &errorMessage) const;
|
||||
bool convertFilePath(Core::GeneratedFile &file, ConvertedProjectContext &projectContext,
|
||||
QString &errorMessage) const;
|
||||
bool convertFileContent(Core::GeneratedFile &file, ConvertedProjectContext &projectContext,
|
||||
QString &errorMessage) const;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Qnx
|
||||
|
||||
#endif // QNX_BLACKBERRY_CASCADESIMPORT_WIZARD_H
|
||||
99
src/plugins/qnx/cascadesimport/fileconverter.cpp
Normal file
99
src/plugins/qnx/cascadesimport/fileconverter.cpp
Normal file
@@ -0,0 +1,99 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
|
||||
** Contact: BlackBerry Limited (blackberry-qt@qnx.com)
|
||||
**
|
||||
** 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://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: 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 "fileconverter.h"
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
#include <coreplugin/generatedfile.h>
|
||||
|
||||
namespace Qnx {
|
||||
namespace Internal {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// ConvertedProjectContext
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
QString ConvertedProjectContext::projectName() const
|
||||
{
|
||||
return destProjectPath().section(QLatin1Char('/'), -1);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FileConverter
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
bool FileConverter::convertFile(Core::GeneratedFile &file, QString &errorMessage)
|
||||
{
|
||||
ImportLog &log = convertedProjectContext().importLog();
|
||||
log.logInfo(tr("===== Converting file: %1").arg(file.path()));
|
||||
loadFileContent(file, errorMessage);
|
||||
if (!errorMessage.isEmpty())
|
||||
logError(errorMessage);
|
||||
return errorMessage.isEmpty();
|
||||
}
|
||||
|
||||
QByteArray FileConverter::loadFileContent(const QString &filePath, QString &errorMessage)
|
||||
{
|
||||
QByteArray ret;
|
||||
Utils::FileReader fr;
|
||||
QString absFilePath = filePath;
|
||||
if (!filePath.startsWith(QLatin1String(":/"))) {
|
||||
const QString srcProjectPath = convertedProjectContext().srcProjectPath();
|
||||
absFilePath = srcProjectPath % QLatin1Char('/') % filePath;
|
||||
}
|
||||
fr.fetch(absFilePath);
|
||||
if (!fr.errorString().isEmpty())
|
||||
errorMessage = fr.errorString();
|
||||
else
|
||||
ret = fr.data();
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool FileConverter::loadFileContent(Core::GeneratedFile &file, QString &errorMessage)
|
||||
{
|
||||
if (file.binaryContents().isEmpty()) {
|
||||
// virtual files have some content set already
|
||||
QString filePath = file.path();
|
||||
QByteArray ba = loadFileContent(filePath, errorMessage);
|
||||
file.setBinaryContents(ba);
|
||||
}
|
||||
return errorMessage.isEmpty();
|
||||
}
|
||||
|
||||
void FileConverter::logError(const QString &errorMessage)
|
||||
{
|
||||
if (!errorMessage.isEmpty())
|
||||
convertedProjectContext().importLog().logError(errorMessage);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Qnx
|
||||
|
||||
85
src/plugins/qnx/cascadesimport/fileconverter.h
Normal file
85
src/plugins/qnx/cascadesimport/fileconverter.h
Normal file
@@ -0,0 +1,85 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
|
||||
** Contact: BlackBerry Limited (blackberry-qt@qnx.com)
|
||||
**
|
||||
** 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://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: 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 QNX_BLACKBERRY_CASCADESPROJECTIMPORT_FILECONVERTER_H
|
||||
#define QNX_BLACKBERRY_CASCADESPROJECTIMPORT_FILECONVERTER_H
|
||||
|
||||
#include "importlog.h"
|
||||
|
||||
#include <QStringList>
|
||||
#include <QCoreApplication>
|
||||
|
||||
namespace Core {
|
||||
class GeneratedFile;
|
||||
}
|
||||
|
||||
namespace Qnx {
|
||||
namespace Internal {
|
||||
|
||||
class ConvertedProjectContext
|
||||
{
|
||||
public:
|
||||
void setSrcProjectPath(const QString &p) {m_srcProjectPath = p;}
|
||||
QString srcProjectPath() const {return m_srcProjectPath;}
|
||||
void setDestProjectPath(const QString &p) {m_destProjectPath = p;}
|
||||
QString destProjectPath() const {return m_destProjectPath;}
|
||||
|
||||
QString projectName() const;
|
||||
const QStringList& collectedFiles() const {return m_collectedFiles;}
|
||||
void setCollectedFiles(const QStringList &files) {m_collectedFiles = files;}
|
||||
ImportLog& importLog() {return m_importLog;}
|
||||
private:
|
||||
QString m_srcProjectPath;
|
||||
QString m_destProjectPath;
|
||||
ImportLog m_importLog;
|
||||
QStringList m_collectedFiles;
|
||||
};
|
||||
|
||||
class FileConverter
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(FileConverter);
|
||||
public:
|
||||
FileConverter(ConvertedProjectContext &ctx) : m_convertedProjectContext(ctx) {}
|
||||
virtual ~FileConverter() {}
|
||||
|
||||
virtual bool convertFile(Core::GeneratedFile &file, QString &errorMessage);
|
||||
protected:
|
||||
ConvertedProjectContext& convertedProjectContext() const {return m_convertedProjectContext;}
|
||||
|
||||
bool loadFileContent(Core::GeneratedFile &file, QString &errorMessage);
|
||||
QByteArray loadFileContent(const QString &filePath, QString &errorMessage);
|
||||
void logError(const QString &errorMessage);
|
||||
|
||||
ConvertedProjectContext &m_convertedProjectContext;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Qnx
|
||||
|
||||
#endif // QNX_BLACKBERRY_CASCADESPROJECTIMPORT_FILECONVERTER_H
|
||||
152
src/plugins/qnx/cascadesimport/importlog.cpp
Normal file
152
src/plugins/qnx/cascadesimport/importlog.cpp
Normal file
@@ -0,0 +1,152 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
|
||||
** Contact: BlackBerry Limited (blackberry-qt@qnx.com)
|
||||
**
|
||||
** 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://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: 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 "importlog.h"
|
||||
|
||||
namespace Qnx {
|
||||
namespace Internal {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// ImportLogEntry
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
static const char S_ERROR[] = "error";
|
||||
static const char S_WARNING[] = "warning";
|
||||
static const char S_INFO[] = "info";
|
||||
static const char S_DEBUG[] = "debug";
|
||||
static const char S_UNDEFINED[] = "undefined";
|
||||
|
||||
ImportLogEntry::ImportLogEntry(int sev, const QString &msg, const QString &context)
|
||||
: QVariantList()
|
||||
{
|
||||
reserve(UnusedIx);
|
||||
append(sev);
|
||||
append(msg);
|
||||
append(context);
|
||||
}
|
||||
|
||||
static const char* severityEnumToStr(ImportLogEntry::Severity sev)
|
||||
{
|
||||
switch (sev) {
|
||||
case ImportLogEntry::Error:
|
||||
return S_ERROR;
|
||||
case ImportLogEntry::Warning:
|
||||
return S_WARNING;
|
||||
case ImportLogEntry::Info:
|
||||
return S_INFO;
|
||||
case ImportLogEntry::Debug:
|
||||
return S_DEBUG;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return S_UNDEFINED;
|
||||
}
|
||||
|
||||
ImportLogEntry::Severity ImportLogEntry::severity() const
|
||||
{
|
||||
if (isValid())
|
||||
return (Severity)(at(SeverityIx).toInt());
|
||||
return Undefined;
|
||||
}
|
||||
|
||||
QString ImportLogEntry::severityStr() const
|
||||
{
|
||||
return QLatin1String(severityEnumToStr(severity()));
|
||||
}
|
||||
|
||||
QChar ImportLogEntry::severityAbbr() const
|
||||
{
|
||||
return severityStr().at(0).toUpper();
|
||||
}
|
||||
|
||||
QString ImportLogEntry::message() const
|
||||
{
|
||||
if (isValid())
|
||||
return at(MessageIx).toString();
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString ImportLogEntry::context() const
|
||||
{
|
||||
if (isValid())
|
||||
return at(ContextIx).toString();
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString ImportLogEntry::toString() const
|
||||
{
|
||||
QString ret;
|
||||
if (severity() == Undefined)
|
||||
ret = message();
|
||||
else
|
||||
ret = QString::fromLatin1("[%1]%2 %3").arg(severityAbbr()).arg(context()).arg(message());
|
||||
return ret;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// ImportLog
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
QString ImportLog::toString() const
|
||||
{
|
||||
QString ret;
|
||||
foreach (const ImportLogEntry &sle, *this)
|
||||
ret += sle.toString() % QLatin1Char('\n');
|
||||
return ret;
|
||||
}
|
||||
|
||||
ImportLog& ImportLog::logError(const QString &msg, const QString &context)
|
||||
{
|
||||
append(ImportLogEntry(ImportLogEntry::Error, msg, context));
|
||||
return *this;
|
||||
}
|
||||
|
||||
ImportLog& ImportLog::logWarning(const QString &msg, const QString &context)
|
||||
{
|
||||
append(ImportLogEntry(ImportLogEntry::Warning, msg, context));
|
||||
return *this;
|
||||
}
|
||||
|
||||
ImportLog& ImportLog::logInfo(const QString &msg, const QString &context)
|
||||
{
|
||||
append(ImportLogEntry(ImportLogEntry::Info, msg, context));
|
||||
return *this;
|
||||
}
|
||||
|
||||
ImportLog& ImportLog::logDebug(const QString &msg, const QString &context)
|
||||
{
|
||||
append(ImportLogEntry(ImportLogEntry::Debug, msg, context));
|
||||
return *this;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Qnx
|
||||
|
||||
72
src/plugins/qnx/cascadesimport/importlog.h
Normal file
72
src/plugins/qnx/cascadesimport/importlog.h
Normal file
@@ -0,0 +1,72 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
|
||||
** Contact: BlackBerry Limited (blackberry-qt@qnx.com)
|
||||
**
|
||||
** 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://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: 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 QNX_BLACKBERRY_CASCADESPROJECTIMPORT_IMPORTLOG_H
|
||||
#define QNX_BLACKBERRY_CASCADESPROJECTIMPORT_IMPORTLOG_H
|
||||
|
||||
#include <QVariantList>
|
||||
|
||||
namespace Qnx {
|
||||
namespace Internal {
|
||||
|
||||
class ImportLogEntry : public QVariantList
|
||||
{
|
||||
public:
|
||||
enum Severity {Undefined = 0, Debug, Info, Warning, Error};
|
||||
|
||||
ImportLogEntry() : QVariantList() {}
|
||||
ImportLogEntry(int sev, const QString &msg, const QString &context = QString());
|
||||
ImportLogEntry(const QVariantList &l) : QVariantList(l) {}
|
||||
|
||||
bool isValid() const {return (count() >= UnusedIx);}
|
||||
Severity severity() const;
|
||||
QString severityStr() const;
|
||||
QChar severityAbbr() const;
|
||||
QString message() const;
|
||||
QString context() const;
|
||||
QString toString() const;
|
||||
private:
|
||||
enum FieldIndexes {SeverityIx = 0, MessageIx, ContextIx, UnusedIx};
|
||||
};
|
||||
|
||||
class ImportLog : public QList<ImportLogEntry> ///< error list
|
||||
{
|
||||
public:
|
||||
QString toString() const;
|
||||
|
||||
ImportLog& logError(const QString &msg, const QString &context = QString());
|
||||
ImportLog& logWarning(const QString &msg, const QString &context = QString());
|
||||
ImportLog& logInfo(const QString &msg, const QString &context = QString());
|
||||
ImportLog& logDebug(const QString &msg, const QString &context = QString());
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Qnx
|
||||
|
||||
#endif // QNX_BLACKBERRY_CASCADESPROJECTIMPORT_IMPORTLOG_H
|
||||
68
src/plugins/qnx/cascadesimport/importlogconverter.cpp
Normal file
68
src/plugins/qnx/cascadesimport/importlogconverter.cpp
Normal file
@@ -0,0 +1,68 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
|
||||
** Contact: BlackBerry Limited (blackberry-qt@qnx.com)
|
||||
**
|
||||
** 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://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: 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 "importlogconverter.h"
|
||||
|
||||
#include <qnxconstants.h>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
#include <coreplugin/generatedfile.h>
|
||||
|
||||
#include <QDateTime>
|
||||
|
||||
namespace Qnx {
|
||||
namespace Internal {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// ImportLogConverter
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
ImportLogConverter::ImportLogConverter(ConvertedProjectContext &ctx)
|
||||
: FileConverter(ctx)
|
||||
{
|
||||
}
|
||||
|
||||
bool ImportLogConverter::convertFile(Core::GeneratedFile &file, QString &errorMessage)
|
||||
{
|
||||
Q_UNUSED(errorMessage);
|
||||
QString content;
|
||||
content += QLatin1String("========================================================\n");
|
||||
content += tr("Generated by cascades importer ver: %1, %2\n")
|
||||
.arg(QLatin1String(Qnx::Constants::QNX_BLACKBERRY_CASCADESIMPORTER_VERSION))
|
||||
.arg(QDateTime::currentDateTime().toString(Qt::ISODate));
|
||||
content += QLatin1String("========================================================\n\n");
|
||||
content += convertedProjectContext().importLog().toString();
|
||||
file.setContents(content);
|
||||
file.setAttributes(file.attributes() | Core::GeneratedFile::OpenEditorAttribute);
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Qnx
|
||||
51
src/plugins/qnx/cascadesimport/importlogconverter.h
Normal file
51
src/plugins/qnx/cascadesimport/importlogconverter.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
|
||||
** Contact: BlackBerry Limited (blackberry-qt@qnx.com)
|
||||
**
|
||||
** 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://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: 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 QNX_BLACKBERRY_CASCADESPROJECTIMPORT_IMPORTLOGCONVERTER_H
|
||||
#define QNX_BLACKBERRY_CASCADESPROJECTIMPORT_IMPORTLOGCONVERTER_H
|
||||
|
||||
#include "fileconverter.h"
|
||||
|
||||
namespace Qnx {
|
||||
namespace Internal {
|
||||
|
||||
class ImportLogConverter : public FileConverter
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(ImportLogConverter);
|
||||
public:
|
||||
ImportLogConverter(ConvertedProjectContext &ctx);
|
||||
virtual ~ImportLogConverter() {}
|
||||
|
||||
bool convertFile(Core::GeneratedFile &file, QString &errorMessage);
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Qnx
|
||||
|
||||
#endif // QNX_BLACKBERRY_CASCADESPROJECTIMPORT_IMPORTLOGCONVERTER_H
|
||||
195
src/plugins/qnx/cascadesimport/projectfileconverter.cpp
Normal file
195
src/plugins/qnx/cascadesimport/projectfileconverter.cpp
Normal file
@@ -0,0 +1,195 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
|
||||
** Contact: BlackBerry Limited (blackberry-qt@qnx.com)
|
||||
**
|
||||
** 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://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: 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 "projectfileconverter.h"
|
||||
|
||||
#include <qnxconstants.h>
|
||||
|
||||
#include <coreplugin/generatedfile.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QSet>
|
||||
|
||||
namespace Qnx {
|
||||
namespace Internal {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// ProjectFileConverter
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
ProjectFileConverter::ProjectFileConverter(ConvertedProjectContext &ctx)
|
||||
: FileConverter(ctx)
|
||||
{
|
||||
}
|
||||
|
||||
static QMap<QString, QString> scanForDefinedVariables(const Core::GeneratedFile &file)
|
||||
{
|
||||
QMap<QString, QString> ret;
|
||||
QString origContent = file.contents();
|
||||
QStringList lines = origContent.split(QLatin1Char('\n'), QString::KeepEmptyParts);
|
||||
QString line;
|
||||
foreach (QString ln, lines) {
|
||||
ln = ln.trimmed();
|
||||
if (ln.length() && (ln.at(0) == QLatin1Char('#')))
|
||||
continue;
|
||||
if ((line.length() > 0) && (line.at(line.length() - 1) == QLatin1Char('\\'))) {
|
||||
line = line.mid(line.length() - 1);
|
||||
line += ln;
|
||||
} else {
|
||||
line = ln;
|
||||
}
|
||||
if ((line.length() > 0) && (line.at(line.length() - 1) != QLatin1Char('\\'))) {
|
||||
int ix1 = line.indexOf(QLatin1Char('='));
|
||||
if (ix1 > 0) {
|
||||
int ix2 = (line.at(ix1 - 1) == QLatin1Char('+'))? ix1 - 1: ix1;
|
||||
QString k = line.mid(0, ix2).trimmed().toUpper();
|
||||
QString v = line.mid(ix1 + 1).trimmed();
|
||||
if (ix1 != ix2)
|
||||
v = ret.value(k) % QLatin1Char(' ') % v;
|
||||
ret[k] = v;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static QSet<QString> parseVariable(const QString &varStr)
|
||||
{
|
||||
QStringList sl = varStr.split(QLatin1Char(' '), QString::SkipEmptyParts);
|
||||
QSet<QString> ret = QSet<QString>::fromList(sl);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static QString updateVariable(const QString &varStr, const QString &varsToAdd,
|
||||
const QString &varsToRemove)
|
||||
{
|
||||
QSet<QString> var = parseVariable(varStr);
|
||||
|
||||
QSet<QString> ss = parseVariable(varsToAdd);
|
||||
foreach (QString s, ss)
|
||||
var << s;
|
||||
|
||||
ss = parseVariable(varsToRemove);
|
||||
foreach (QString s, ss)
|
||||
var.remove(s);
|
||||
|
||||
QStringList sl = QStringList::fromSet(var);
|
||||
return sl.join(QLatin1Char(' '));
|
||||
}
|
||||
|
||||
bool ProjectFileConverter::convertFile(Core::GeneratedFile &file, QString &errorMessage)
|
||||
{
|
||||
if (!FileConverter::convertFile(file, errorMessage))
|
||||
return false;
|
||||
|
||||
ImportLog &log = convertedProjectContext().importLog();
|
||||
QMap<QString, QString> origProjectVariables = scanForDefinedVariables(file);
|
||||
QString fileContent;
|
||||
|
||||
QLatin1String path( ":/qnx/cascadesimport/resources/templates/project.pro");
|
||||
QByteArray ba = loadFileContent(path, errorMessage);
|
||||
if (!errorMessage.isEmpty())
|
||||
return false;
|
||||
fileContent = QString::fromUtf8(ba);
|
||||
|
||||
QStringList headers;
|
||||
QStringList sources;
|
||||
QStringList resources;
|
||||
QStringList otherFiles;
|
||||
|
||||
QSet<QString> entries;
|
||||
foreach (const QString &filePath, convertedProjectContext().collectedFiles()) {
|
||||
QString ext = filePath.section(QLatin1Char('.'), -1);
|
||||
if (ext.compare(QLatin1String("c"), Qt::CaseInsensitive) == 0)
|
||||
sources << filePath;
|
||||
else if (ext.compare(QLatin1String("cc"), Qt::CaseInsensitive) == 0)
|
||||
sources << filePath;
|
||||
else if (ext.compare(QLatin1String("cpp"), Qt::CaseInsensitive) == 0)
|
||||
sources << filePath;
|
||||
else if (ext.compare(QLatin1String("h"), Qt::CaseInsensitive) == 0)
|
||||
headers << filePath;
|
||||
else if (ext.compare(QLatin1String("hh"), Qt::CaseInsensitive) == 0)
|
||||
headers << filePath;
|
||||
else if (ext.compare(QLatin1String("hpp"), Qt::CaseInsensitive) == 0)
|
||||
headers << filePath;
|
||||
else if (ext.compare(QLatin1String("qrc"), Qt::CaseInsensitive) == 0)
|
||||
resources << filePath;
|
||||
else if (ext.compare(QLatin1String("qml"), Qt::CaseInsensitive) == 0)
|
||||
otherFiles << filePath;
|
||||
else if (ext.compare(QLatin1String("js"), Qt::CaseInsensitive) == 0)
|
||||
otherFiles << filePath;
|
||||
else if (ext.compare(QLatin1String("ts"), Qt::CaseInsensitive) == 0)
|
||||
otherFiles << filePath;
|
||||
else if (ext.compare(QLatin1String("pro"), Qt::CaseInsensitive) == 0)
|
||||
otherFiles << filePath;
|
||||
else if (filePath.compare(QLatin1String("bar-descriptor.xml"), Qt::CaseInsensitive) == 0)
|
||||
otherFiles << filePath;
|
||||
else if (filePath.startsWith(QLatin1String("assets/"), Qt::CaseInsensitive))
|
||||
// include all the content of the assets directory
|
||||
otherFiles << filePath;
|
||||
else if (filePath.startsWith(QLatin1String("src/"), Qt::CaseInsensitive))
|
||||
// include all the content of the src directory
|
||||
otherFiles << filePath;
|
||||
else if (ext.compare(QLatin1String("log"), Qt::CaseInsensitive) != 0)
|
||||
log.logWarning(tr("File '%1' not listed in '%2' file, should it be?")
|
||||
.arg(filePath).arg(file.path()));
|
||||
}
|
||||
|
||||
fileContent.replace(QLatin1String("%HEADERS%"), headers.join(QLatin1String(" \\\n ")));
|
||||
fileContent.replace(QLatin1String("%SOURCES%"), sources.join(QLatin1String(" \\\n ")));
|
||||
fileContent.replace(QLatin1String("%RESOURCES%"), resources.join(QLatin1String(" \\\n ")));
|
||||
fileContent.replace(QLatin1String("%OTHER_FILES%"), otherFiles.join(QLatin1String(" \\\n ")));
|
||||
fileContent.replace(QLatin1String("%PROJECT_NAME%"), convertedProjectContext().projectName());
|
||||
fileContent.replace(QLatin1String("%TARGET%"), origProjectVariables.value(QLatin1String("TARGET"),
|
||||
convertedProjectContext().projectName()));
|
||||
fileContent.replace(QLatin1String("%EXTRA_LIBS%"), origProjectVariables.value(QLatin1String("LIBS")));
|
||||
fileContent.replace(QLatin1String("%IMPORTER_VERSION%"),
|
||||
QLatin1String(Qnx::Constants::QNX_BLACKBERRY_CASCADESIMPORTER_VERSION));
|
||||
fileContent.replace(QLatin1String("%DATE_TIME%"),
|
||||
QDateTime::currentDateTime().toString(Qt::ISODate));
|
||||
fileContent.replace(QLatin1String("%QT%"),
|
||||
updateVariable(origProjectVariables.value(QLatin1String("QT")),
|
||||
QLatin1String("declarative script svg sql network xml xmlpatterns"),
|
||||
QString()
|
||||
));
|
||||
fileContent.replace(QLatin1String("%CONFIG%"),
|
||||
updateVariable(origProjectVariables.value(QLatin1String("CONFIG")),
|
||||
QLatin1String("qt warn_on"),
|
||||
QLatin1String("debug release debug_and_release cascades cascades10")
|
||||
));
|
||||
fileContent.replace(QLatin1String("%MOBILITY%"), origProjectVariables.value(QLatin1String("MOBILITY")));
|
||||
file.setContents(fileContent);
|
||||
file.setAttributes(file.attributes() | Core::GeneratedFile::OpenProjectAttribute);
|
||||
return errorMessage.isEmpty();
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Qnx
|
||||
58
src/plugins/qnx/cascadesimport/projectfileconverter.h
Normal file
58
src/plugins/qnx/cascadesimport/projectfileconverter.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
|
||||
** Contact: BlackBerry Limited (blackberry-qt@qnx.com)
|
||||
**
|
||||
** 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://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: 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 QNX_BLACKBERRY_CASCADESPROJECTIMPORT_PROJECTFILECONVERTER_H
|
||||
#define QNX_BLACKBERRY_CASCADESPROJECTIMPORT_PROJECTFILECONVERTER_H
|
||||
|
||||
#include "fileconverter.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
|
||||
#include <QMap>
|
||||
#include <QString>
|
||||
|
||||
namespace Qnx {
|
||||
namespace Internal {
|
||||
|
||||
class ProjectFileConverter : public FileConverter
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(ProjectFileConverter);
|
||||
public:
|
||||
ProjectFileConverter(ConvertedProjectContext &ctx);
|
||||
virtual ~ProjectFileConverter() {}
|
||||
|
||||
bool convertFile(Core::GeneratedFile &file, QString &errorMessage);
|
||||
private:
|
||||
QMap<QString, QString> definedVariables(const Core::GeneratedFile &file);
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Qnx
|
||||
|
||||
#endif // QNX_BLACKBERRY_CASCADESPROJECTIMPORT_PROJECTFILECONVERTER_H
|
||||
@@ -0,0 +1,46 @@
|
||||
#========================================================================================
|
||||
# generated by CascadesProjectImporter ver. %IMPORTER_VERSION% - %DATE_TIME%
|
||||
#========================================================================================
|
||||
|
||||
TEMPLATE = app
|
||||
TARGET = %TARGET%
|
||||
|
||||
CONFIG += %CONFIG%
|
||||
|
||||
# For cascades integration, some additional libraries are needed
|
||||
# and the library path needs to be set
|
||||
LIBS += -lbb -lbbcascades
|
||||
LIBS += %EXTRA_LIBS%
|
||||
|
||||
QT -= gui
|
||||
QT += %QT%
|
||||
|
||||
MOBILITY += %MOBILITY%
|
||||
|
||||
QMAKE_CFLAGS += -Wno-psabi
|
||||
QMAKE_CXXFLAGS += -Wno-psabi
|
||||
|
||||
CONFIG(release, debug|release) {
|
||||
zygotize {
|
||||
TEMPLATE = lib
|
||||
QMAKE_CFLAGS += -fstack-protector-strong -fvisibility=hidden -mthumb -Os
|
||||
QMAKE_CXXFLAGS += -fstack-protector-strong -fvisibility=hidden -mthumb -Os
|
||||
QMAKE_LFLAGS += -Wl,-z,relro
|
||||
DEFINES += _FORTIFY_SOURCE=2
|
||||
}
|
||||
}
|
||||
|
||||
INCLUDEPATH += src
|
||||
|
||||
HEADERS += \
|
||||
%HEADERS%
|
||||
|
||||
SOURCES += \
|
||||
%SOURCES%
|
||||
|
||||
RESOURCES += \
|
||||
%RESOURCES%
|
||||
|
||||
OTHER_FILES += \
|
||||
bar-descriptor.xml \
|
||||
%OTHER_FILES%
|
||||
85
src/plugins/qnx/cascadesimport/srcprojectwizardpage.cpp
Normal file
85
src/plugins/qnx/cascadesimport/srcprojectwizardpage.cpp
Normal file
@@ -0,0 +1,85 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
|
||||
** Contact: BlackBerry Limited (blackberry-qt@qnx.com)
|
||||
**
|
||||
** 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://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: 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 "srcprojectwizardpage.h"
|
||||
#include "ui_srcprojectwizardpage.h"
|
||||
|
||||
#include <QDir>
|
||||
|
||||
namespace Qnx {
|
||||
namespace Internal {
|
||||
|
||||
SrcProjectWizardPage::SrcProjectWizardPage(QWidget *parent)
|
||||
: QWizardPage(parent), m_complete(false)
|
||||
{
|
||||
ui = new Ui::SrcProjectWizardPage;
|
||||
ui->setupUi(this);
|
||||
|
||||
connect(ui->pathChooser, SIGNAL(pathChanged(QString)), this, SLOT(onPathChooserPathChanged(QString)));
|
||||
|
||||
setPath(QDir::homePath());
|
||||
}
|
||||
|
||||
SrcProjectWizardPage::~SrcProjectWizardPage()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void SrcProjectWizardPage::onPathChooserPathChanged(const QString &newPath)
|
||||
{
|
||||
bool newComplete = ui->pathChooser->isValid();
|
||||
if (newComplete != m_complete) {
|
||||
m_complete = newComplete;
|
||||
emit completeChanged();
|
||||
}
|
||||
if (newComplete) emit validPathChanged(newPath);
|
||||
}
|
||||
|
||||
QString SrcProjectWizardPage::projectName() const
|
||||
{
|
||||
return path().section(QLatin1Char('/'), -1);
|
||||
}
|
||||
|
||||
QString SrcProjectWizardPage::path() const
|
||||
{
|
||||
return Utils::FileName::fromUserInput(ui->pathChooser->path()).toString();
|
||||
}
|
||||
|
||||
void SrcProjectWizardPage::setPath(const QString &path)
|
||||
{
|
||||
ui->pathChooser->setPath(path);
|
||||
}
|
||||
|
||||
bool SrcProjectWizardPage::isComplete() const
|
||||
{
|
||||
return m_complete;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Qnx
|
||||
64
src/plugins/qnx/cascadesimport/srcprojectwizardpage.h
Normal file
64
src/plugins/qnx/cascadesimport/srcprojectwizardpage.h
Normal file
@@ -0,0 +1,64 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
|
||||
** Contact: BlackBerry Limited (blackberry-qt@qnx.com)
|
||||
**
|
||||
** 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://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/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 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: 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 QNX_BLACKBERRY_CASCADESPROJECTIMPORT_SRCPROJECTWIZARDPAGE_H
|
||||
#define QNX_BLACKBERRY_CASCADESPROJECTIMPORT_SRCPROJECTWIZARDPAGE_H
|
||||
|
||||
#include <QWizardPage>
|
||||
|
||||
namespace Qnx {
|
||||
namespace Internal {
|
||||
|
||||
namespace Ui { class SrcProjectWizardPage; }
|
||||
|
||||
class SrcProjectWizardPage : public QWizardPage
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SrcProjectWizardPage(QWidget *parent = 0);
|
||||
virtual ~SrcProjectWizardPage();
|
||||
|
||||
QString projectName() const;
|
||||
QString path() const;
|
||||
void setPath(const QString &path);
|
||||
|
||||
bool isComplete() const;
|
||||
signals:
|
||||
void validPathChanged(const QString &path);
|
||||
private slots:
|
||||
void onPathChooserPathChanged(const QString &newPath);
|
||||
private:
|
||||
Ui::SrcProjectWizardPage *ui;
|
||||
bool m_complete;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Qnx
|
||||
|
||||
#endif // QNX_BLACKBERRY_CASCADESPROJECTIMPORT_SRCPROJECTWIZARDPAGE_H
|
||||
42
src/plugins/qnx/cascadesimport/srcprojectwizardpage.ui
Normal file
42
src/plugins/qnx/cascadesimport/srcprojectwizardpage.ui
Normal file
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Qnx::Internal::SrcProjectWizardPage</class>
|
||||
<widget class="QWizardPage" name="Qnx::Internal::SrcProjectWizardPage">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>520</width>
|
||||
<height>147</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Choose the Location</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::ExpandingFieldsGrow</enum>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="pathLabel">
|
||||
<property name="text">
|
||||
<string>Project path:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="Utils::PathChooser" name="pathChooser" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Utils::PathChooser</class>
|
||||
<extends>QWidget</extends>
|
||||
<header location="global">utils/pathchooser.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -226,6 +226,7 @@ FORMS += \
|
||||
blackberryinstallwizardprocesspage.ui
|
||||
|
||||
include(../../private_headers.pri)
|
||||
include(./cascadesimport/cascadesimport.pri)
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4) {
|
||||
QT += gui-private
|
||||
|
||||
@@ -239,4 +239,31 @@ QtcPlugin {
|
||||
"images/target-small.png",
|
||||
"images/target.png",
|
||||
]
|
||||
|
||||
Group {
|
||||
name: "CascadesImport"
|
||||
prefix: "cascadesimport/"
|
||||
files: [
|
||||
"cascadesimport.qrc",
|
||||
|
||||
"srcprojectwizardpage.ui",
|
||||
|
||||
"cascadesimportwizard.cpp",
|
||||
"srcprojectwizardpage.cpp",
|
||||
"fileconverter.cpp",
|
||||
"bardescriptorconverter.cpp",
|
||||
"projectfileconverter.cpp",
|
||||
"importlogconverter.cpp",
|
||||
"importlog.cpp",
|
||||
|
||||
"cascadesimportwizard.h",
|
||||
"srcprojectwizardpage.h",
|
||||
"fileconverter.h",
|
||||
"bardescriptorconverter.h",
|
||||
"projectfileconverter.h",
|
||||
"importlogconverter.h",
|
||||
"importlog.h",
|
||||
]
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -108,6 +108,8 @@ const char QNX_KEY_ACTIVE[] = "active";
|
||||
|
||||
const char QNX_BLACKBERRY_DEPLOY_CMD[] = "blackberry-deploy";
|
||||
|
||||
const char QNX_BLACKBERRY_CASCADESIMPORTER_VERSION[] = "0.0.1";
|
||||
|
||||
} // namespace Constants
|
||||
} // namespace Qnx
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@
|
||||
#include "blackberrycheckdevmodestepfactory.h"
|
||||
#include "blackberrydeviceconnectionmanager.h"
|
||||
#include "blackberryconfigurationmanager.h"
|
||||
#include "cascadesimport/cascadesimportwizard.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/mimedatabase.h>
|
||||
@@ -89,6 +90,7 @@ bool QNXPlugin::initialize(const QStringList &arguments, QString *errorString)
|
||||
addAutoReleasedObject(new BlackBerryNDKSettingsPage);
|
||||
addAutoReleasedObject(new BlackBerryKeysPage);
|
||||
addAutoReleasedObject(new BlackBerryCheckDevModeStepFactory);
|
||||
addAutoReleasedObject(new CascadesImportWizard);
|
||||
BlackBerryDeviceConnectionManager::instance()->initialize();
|
||||
|
||||
// Handles QNX
|
||||
|
||||
Reference in New Issue
Block a user