Commit fdd85b7f authored by Kai Koehne's avatar Kai Koehne

QmlProjectManager refactoring

Putting every class in it's own files + avoid "using namespace"
parent 45efd5b5
......@@ -62,7 +62,7 @@
#include <projectexplorer/project.h>
#include <projectexplorer/target.h>
#include <qmlprojectmanager/qmlproject.h>
#include <qmlprojectmanager/qmlprojectrunconfiguration.h>
#include <QtCore/QStringList>
#include <QtCore/QtPlugin>
......@@ -186,8 +186,8 @@ void QmlInspectorMode::connectToViewer()
return;
}
QmlProjectManager::QmlRunConfiguration* config =
qobject_cast<QmlProjectManager::QmlRunConfiguration*>(project->activeTarget()->activeRunConfiguration());
QmlProjectManager::QmlProjectRunConfiguration* config =
qobject_cast<QmlProjectManager::QmlProjectRunConfiguration*>(project->activeTarget()->activeRunConfiguration());
if (!config) {
emit statusMessage(tr("Cannot find project run configuration, debugging canceled."));
return;
......
......@@ -37,11 +37,8 @@
#include <QtCore/QTextStream>
#include <QtCore/QCoreApplication>
using namespace QmlProjectManager::Internal;
//////////////////////////////////////////////////////////////////////////////
// QmlNewProjectWizardDialog
//////////////////////////////////////////////////////////////////////////////
namespace QmlProjectManager {
namespace Internal {
QmlNewProjectWizardDialog::QmlNewProjectWizardDialog(QWidget *parent) :
ProjectExplorer::BaseProjectWizardDialog(parent)
......@@ -168,3 +165,6 @@ bool QmlNewProjectWizard::postGenerateFiles(const Core::GeneratedFiles &l, QStri
return true;
}
} // namespace Internal
} // namespace QmlProjectManager
......@@ -31,113 +31,30 @@
#define QMLPROJECT_H
#include "qmlprojectmanager.h"
#include "qmlprojectnodes.h"
#include "qmlprojectmanager_global.h"
#include "qmltarget.h"
#include "fileformat/qmlprojectitem.h"
#include "qmlprojectnodes.h"
#include "qmlprojecttarget.h"
#include <projectexplorer/project.h>
#include <projectexplorer/projectnodes.h>
#include <projectexplorer/buildstep.h>
#include <projectexplorer/applicationrunconfiguration.h>
#include <projectexplorer/filewatcher.h>
#include <coreplugin/ifile.h>
#include <QtCore/QDir>
#include <QtDeclarative/QmlEngine>
namespace QmlJSEditor {
class ModelManagerInterface;
}
namespace QmlProjectManager {
class QmlProject;
class QmlRunConfiguration;
namespace Internal {
class QmlProjectFile : public Core::IFile
{
Q_OBJECT
public:
QmlProjectFile(QmlProject *parent, QString fileName);
virtual ~QmlProjectFile();
virtual bool save(const QString &fileName = QString());
virtual QString fileName() const;
virtual QString defaultPath() const;
virtual QString suggestedFileName() const;
virtual QString mimeType() const;
virtual bool isModified() const;
virtual bool isReadOnly() const;
virtual bool isSaveAsAllowed() const;
virtual void modified(ReloadBehavior *behavior);
private:
QmlProject *m_project;
QString m_fileName;
};
class QmlRunConfigurationFactory : public ProjectExplorer::IRunConfigurationFactory
{
Q_OBJECT
public:
explicit QmlRunConfigurationFactory(QObject *parent = 0);
~QmlRunConfigurationFactory();
QStringList availableCreationIds(ProjectExplorer::Target *parent) const;
QString displayNameForId(const QString &id) const;
bool canCreate(ProjectExplorer::Target *parent, const QString &id) const;
ProjectExplorer::RunConfiguration *create(ProjectExplorer::Target *parent, const QString &id);
bool canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const;
ProjectExplorer::RunConfiguration *restore(ProjectExplorer::Target *parent, const QVariantMap &map);
bool canClone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *source) const;
ProjectExplorer::RunConfiguration *clone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *source);
};
class QmlRunControl : public ProjectExplorer::RunControl {
Q_OBJECT
public:
explicit QmlRunControl(QmlRunConfiguration *runConfiguration, bool debugMode);
virtual ~QmlRunControl ();
// RunControl
virtual void start();
virtual void stop();
virtual bool isRunning() const;
namespace ProjectExplorer {
class FileWatcher;
}
private slots:
void processExited(int exitCode);
void slotBringApplicationToForeground(qint64 pid);
void slotAddToOutputWindow(const QString &line);
void slotError(const QString & error);
namespace QmlProjectManager {
private:
ProjectExplorer::ApplicationLauncher m_applicationLauncher;
class QmlProjectItem;
QString m_executable;
QStringList m_commandLineArguments;
bool m_debugMode;
};
namespace Internal {
class QmlRunControlFactory : public ProjectExplorer::IRunControlFactory {
Q_OBJECT
public:
explicit QmlRunControlFactory(QObject *parent = 0);
virtual ~QmlRunControlFactory();
// IRunControlFactory
virtual bool canRun(ProjectExplorer::RunConfiguration *runConfiguration, const QString &mode) const;
virtual ProjectExplorer::RunControl *create(ProjectExplorer::RunConfiguration *runConfiguration, const QString &mode);
virtual QString displayName() const;
virtual QWidget *configurationWidget(ProjectExplorer::RunConfiguration *runConfiguration);
};
class QmlProjectFile;
class QmlProjectNode;
} // namespace Internal
......@@ -155,8 +72,8 @@ public:
QString id() const;
Core::IFile *file() const;
Internal::Manager *projectManager() const;
Internal::QmlTargetFactory *targetFactory() const;
Internal::QmlTarget *activeTarget() const;
Internal::QmlProjectTargetFactory *targetFactory() const;
Internal::QmlProjectTarget *activeTarget() const;
QList<ProjectExplorer::Project *> dependsOn();
......@@ -209,49 +126,7 @@ private:
ProjectExplorer::FileWatcher *m_fileWatcher;
Internal::QmlProjectNode *m_rootNode;
Internal::QmlTargetFactory *m_targetFactory;
};
class QMLPROJECTMANAGER_EXPORT QmlRunConfiguration : public ProjectExplorer::RunConfiguration
{
Q_OBJECT
friend class Internal::QmlRunConfigurationFactory;
public:
QmlRunConfiguration(Internal::QmlTarget *parent);
virtual ~QmlRunConfiguration();
Internal::QmlTarget *qmlTarget() const;
QString viewerPath() const;
QStringList viewerArguments() const;
QString workingDirectory() const;
uint debugServerPort() const;
// RunConfiguration
virtual QWidget *configurationWidget();
QVariantMap toMap() const;
private slots:
QString mainScript() const;
void setMainScript(const QString &scriptFile);
void onQmlViewerChanged();
void onQmlViewerArgsChanged();
void onDebugServerPortChanged();
protected:
QmlRunConfiguration(Internal::QmlTarget *parent, QmlRunConfiguration *source);
virtual bool fromMap(const QVariantMap &map);
private:
void ctor();
QString m_scriptFile;
QString m_qmlViewerCustomPath;
QString m_qmlViewerDefaultPath;
QString m_qmlViewerArgs;
uint m_debugServerPort;
Internal::QmlProjectTargetFactory *m_targetFactory;
};
} // namespace QmlProjectManager
......
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** 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.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#include "qmlprojectfile.h"
#include "qmlproject.h"
#include "qmlprojectconstants.h"
namespace QmlProjectManager {
namespace Internal {
QmlProjectFile::QmlProjectFile(QmlProject *parent, QString fileName)
: Core::IFile(parent),
m_project(parent),
m_fileName(fileName)
{ }
QmlProjectFile::~QmlProjectFile()
{ }
bool QmlProjectFile::save(const QString &)
{
return false;
}
QString QmlProjectFile::fileName() const
{
return m_fileName;
}
QString QmlProjectFile::defaultPath() const
{
return QString();
}
QString QmlProjectFile::suggestedFileName() const
{
return QString();
}
QString QmlProjectFile::mimeType() const
{
return Constants::QMLMIMETYPE;
}
bool QmlProjectFile::isModified() const
{
return false;
}
bool QmlProjectFile::isReadOnly() const
{
return true;
}
bool QmlProjectFile::isSaveAsAllowed() const
{
return false;
}
void QmlProjectFile::modified(ReloadBehavior *)
{
}
} // namespace Internal
} // namespace QmlProjectManager
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** 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.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#ifndef QMLPROJECTFILE_H
#define QMLPROJECTFILE_H
#include <coreplugin/ifile.h>
namespace QmlProjectManager {
class QmlProject;
namespace Internal {
class QmlProjectFile : public Core::IFile
{
Q_OBJECT
public:
QmlProjectFile(QmlProject *parent, QString fileName);
virtual ~QmlProjectFile();
virtual bool save(const QString &fileName = QString());
virtual QString fileName() const;
virtual QString defaultPath() const;
virtual QString suggestedFileName() const;
virtual QString mimeType() const;
virtual bool isModified() const;
virtual bool isReadOnly() const;
virtual bool isSaveAsAllowed() const;
virtual void modified(ReloadBehavior *behavior);
private:
QmlProject *m_project;
QString m_fileName;
};
} // namespace Internal
} // namespace QmlProjectManager
#endif // QMLPROJECTFILE_H
......@@ -32,6 +32,7 @@
#include "qmlproject.h"
#include <coreplugin/icore.h>
#include <coreplugin/ifile.h>
#include <coreplugin/uniqueidmanager.h>
#include <coreplugin/messagemanager.h>
#include <projectexplorer/projectexplorerconstants.h>
......@@ -40,8 +41,8 @@
#include <QtDebug>
using namespace QmlProjectManager;
using namespace QmlProjectManager::Internal;
namespace QmlProjectManager {
namespace Internal {
Manager::Manager()
{
......@@ -101,3 +102,6 @@ void Manager::notifyChanged(const QString &fileName)
}
}
}
} // namespace Internal
} // namespace QmlProjectManager
......@@ -14,18 +14,27 @@ HEADERS += qmlproject.h \
qmlprojectconstants.h \
qmlprojectnodes.h \
qmlprojectwizard.h \
qmlprojectfile.h \
qmlprojectruncontrol.h \
qmlprojectrunconfiguration.h \
qmlprojectrunconfigurationfactory.h \
qmlnewprojectwizard.h \
qmltaskmanager.h \
qmlprojectmanager_global.h \
qmltarget.h
qmlprojectmanagerconstants.h \
qmlprojecttarget.h
SOURCES += qmlproject.cpp \
qmlprojectplugin.cpp \
qmlprojectmanager.cpp \
qmlprojectnodes.cpp \
qmlprojectwizard.cpp \
qmlprojectfile.cpp \
qmlprojectruncontrol.cpp \
qmlprojectrunconfiguration.cpp \
qmlprojectrunconfigurationfactory.cpp \
qmlnewprojectwizard.cpp \
qmltaskmanager.cpp \
qmltarget.cpp
qmlprojecttarget.cpp
RESOURCES += qmlproject.qrc
OTHER_FILES += QmlProjectManager.pluginspec
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** 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.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#include <qglobal.h>
namespace QmlProjectManager {
namespace Constants {
const char * const QML_RC_ID("QmlProjectManager.QmlRunConfiguration");
const char * const QML_RC_DISPLAY_NAME(QT_TRANSLATE_NOOP("QmlProjectManager::Internal::QmlRunConfiguration", "QML Viewer"));
const char * const QML_VIEWER_KEY("QmlProjectManager.QmlRunConfiguration.QmlViewer");
const char * const QML_VIEWER_ARGUMENTS_KEY("QmlProjectManager.QmlRunConfiguration.QmlViewerArguments");
const char * const QML_VIEWER_TARGET_ID("QmlProjectManager.QmlTarget");
const char * const QML_VIEWER_TARGET_DISPLAY_NAME("QML Viewer");
const char * const QML_MAINSCRIPT_KEY("QmlProjectManager.QmlRunConfiguration.MainScript");
const char * const QML_DEBUG_SERVER_PORT_KEY("QmlProjectManager.QmlRunConfiguration.DebugServerPort");
const int QML_DEFAULT_DEBUG_SERVER_PORT(3768);
} // namespace Constants
} // namespace QmlProjectManager
......@@ -36,9 +36,10 @@
#include <QFileInfo>
#include <QDir>
#include <QTextStream>
using namespace QmlProjectManager;
using namespace QmlProjectManager::Internal;
namespace QmlProjectManager {
namespace Internal {
QmlProjectNode::QmlProjectNode(QmlProject *project, Core::IFile *projectFile)
: ProjectExplorer::ProjectNode(QFileInfo(projectFile->fileName()).absoluteFilePath()),
......@@ -235,3 +236,6 @@ bool QmlProjectNode::renameFile(const ProjectExplorer::FileType fileType,
Q_UNUSED(newFilePath)
return false;
}
} // namespace Internal
} // namespace QmlProjectManager
......@@ -27,8 +27,8 @@
**
**************************************************************************/
#ifndef QMLPROJECTNODE_H
#define QMLPROJECTNODE_H
#ifndef QMLPROJECTNODES_H
#define QMLPROJECTNODES_H
#include <projectexplorer/projectnodes.h>
......@@ -89,4 +89,4 @@ private:
} // namespace Internal
} // namespace QmlProjectManager
#endif // QMLPROJECTNODE_H
#endif // QMLPROJECTNODES_H
......@@ -33,6 +33,8 @@
#include "qmlnewprojectwizard.h"
#include "qmlprojectconstants.h"
#include "qmlproject.h"
#include "qmlprojectrunconfigurationfactory.h"
#include "qmlprojectruncontrol.h"
#include "qmltaskmanager.h"
#include <extensionsystem/pluginmanager.h>
......@@ -47,8 +49,8 @@
#include <QtCore/QtPlugin>
using namespace QmlProjectManager;
using namespace QmlProjectManager::Internal;
namespace QmlProjectManager {
namespace Internal {
QmlProjectPlugin::QmlProjectPlugin() :
m_qmlTaskManager(0)
......@@ -75,8 +77,8 @@ bool QmlProjectPlugin::initialize(const QStringList &, QString *errorMessage)
m_qmlTaskManager = new QmlTaskManager(this);
addAutoReleasedObject(manager);
addAutoReleasedObject(new QmlRunConfigurationFactory);
addAutoReleasedObject(new QmlRunControlFactory);
addAutoReleasedObject(new Internal::QmlProjectRunConfigurationFactory);
addAutoReleasedObject(new Internal::QmlRunControlFactory);
addAutoReleasedObject(new QmlNewProjectWizard);
addAutoReleasedObject(new QmlProjectWizard);
return true;
......@@ -94,4 +96,7 @@ void QmlProjectPlugin::extensionsInitialized()
m_qmlTaskManager, SLOT(documentUpdated(QmlJS::Document::Ptr)));
}
Q_EXPORT_PLUGIN(QmlProjectPlugin)
} // namespace Internal
} // namespace QmlProjectManager
Q_EXPORT_PLUGIN(QmlProjectManager::Internal::QmlProjectPlugin)
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** 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.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#include "qmlproject.h"
#include "qmlprojectmanagerconstants.h"
#include "qmlprojectrunconfiguration.h"
#include "qmlprojecttarget.h"
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/editormanager/ieditor.h>
#include <coreplugin/icore.h>
#include <coreplugin/ifile.h>
#include <utils/synchronousprocess.h>
#include <utils/pathchooser.h>
#include <QFormLayout>
#include <QComboBox>
#include <QCoreApplication>
#include <QLineEdit>
#include <QSpinBox>
namespace QmlProjectManager {
QmlProjectRunConfiguration::QmlProjectRunConfiguration(Internal::QmlProjectTarget *parent) :
ProjectExplorer::RunConfiguration(parent, QLatin1String(Constants::QML_RC_ID)),
m_debugServerPort(Constants::QML_DEFAULT_DEBUG_SERVER_PORT)
{
ctor();
}
QmlProjectRunConfiguration::QmlProjectRunConfiguration(Internal::QmlProjectTarget *parent, QmlProjectRunConfiguration *source) :
ProjectExplorer::RunConfiguration(parent, source),
m_scriptFile(source->m_scriptFile),
m_qmlViewerCustomPath(source->m_qmlViewerCustomPath),
m_qmlViewerArgs(source->m_qmlViewerArgs),
m_debugServerPort(source->m_debugServerPort)
{
ctor();
}
void QmlProjectRunConfiguration::ctor()
{
setDisplayName(tr("QML Viewer", "QMLRunConfiguration display name."));
// prepend creator/bin dir to search path (only useful for special creator-qml package)
const QString searchPath = QCoreApplication::applicationDirPath()
+ Utils::SynchronousProcess::pathSeparator()
+ QString(qgetenv("PATH"));
m_qmlViewerDefaultPath = Utils::SynchronousProcess::locateBinary(searchPath, QLatin1String("qmlviewer"));
}
QmlProjectRunConfiguration::~QmlProjectRunConfiguration()
{
}
Internal::QmlProjectTarget *QmlProjectRunConfiguration::qmlTarget() const
{
return static_cast<Internal::QmlProjectTarget *>(target());
}
QString QmlProjectRunConfiguration::viewerPath() const
{
if (!m_qmlViewerCustomPath.isEmpty())
return m_qmlViewerCustomPath;
return m_qmlViewerDefaultPath;
}
QStringList QmlProjectRunConfiguration::viewerArguments() const
{
QStringList args;
// arguments in .user file
if (!m_qmlViewerArgs.isEmpty())