Files
qt-creator/src/plugins/qmljseditor/qmljseditorfactory.cpp

102 lines
3.0 KiB
C++
Raw Normal View History

2009-04-22 15:21:04 +02:00
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
2009-04-22 15:21:04 +02:00
**
** Contact: Nokia Corporation (qt-info@nokia.com)
2009-04-22 15:21:04 +02:00
**
**
** GNU Lesser General Public License Usage
**
2011-04-13 08:42:33 +02:00
** 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.
2009-04-22 15:21:04 +02:00
**
2010-12-17 16:01:08 +01:00
** In addition, as a special exception, Nokia gives you certain additional
2011-04-13 08:42:33 +02:00
** rights. These rights are described in the Nokia Qt LGPL Exception
2010-12-17 16:01:08 +01:00
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
2011-04-13 08:42:33 +02:00
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
2010-12-17 16:01:08 +01:00
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
2009-04-22 15:21:04 +02:00
**
**************************************************************************/
#include "qmljseditorfactory.h"
#include "qmljseditoreditable.h"
#include "qmljseditor.h"
#include "qmljseditoractionhandler.h"
#include "qmljseditorconstants.h"
#include "qmljseditorplugin.h"
2009-04-22 15:21:04 +02:00
#include <qmljstools/qmljstoolsconstants.h>
#include <extensionsystem/pluginmanager.h>
#include <extensionsystem/pluginspec.h>
#include <coreplugin/icore.h>
#include <coreplugin/infobar.h>
2009-04-22 15:21:04 +02:00
#include <coreplugin/editormanager/editormanager.h>
#include <QtCore/QFileInfo>
#include <QtCore/QDebug>
#include <QtCore/QSettings>
#include <QtGui/QMessageBox>
#include <QtGui/QPushButton>
#include <QtGui/QMainWindow>
using namespace QmlJSEditor;
using namespace QmlJSEditor::Internal;
using namespace QmlJSEditor::Constants;
2009-04-22 15:21:04 +02:00
QmlJSEditorFactory::QmlJSEditorFactory(QObject *parent)
: Core::IEditorFactory(parent)
2009-04-22 15:21:04 +02:00
{
m_mimeTypes
<< QLatin1String(QmlJSTools::Constants::QML_MIMETYPE)
<< QLatin1String(QmlJSTools::Constants::JS_MIMETYPE)
<< QLatin1String(QmlJSTools::Constants::JSON_MIMETYPE)
;
2009-04-22 15:21:04 +02:00
}
Core::Id QmlJSEditorFactory::id() const
2009-04-22 15:21:04 +02:00
{
return C_QMLJSEDITOR_ID;
2009-04-22 15:21:04 +02:00
}
QString QmlJSEditorFactory::displayName() const
{
return tr(C_QMLJSEDITOR_DISPLAY_NAME);
}
Core::IFile *QmlJSEditorFactory::open(const QString &fileName)
2009-04-22 15:21:04 +02:00
{
Core::IEditor *iface = Core::EditorManager::instance()->openEditor(fileName, id());
2009-04-22 15:21:04 +02:00
if (!iface) {
2009-09-30 17:43:21 +02:00
qWarning() << "QmlEditorFactory::open: openEditor failed for " << fileName;
2009-04-22 15:21:04 +02:00
return 0;
}
return iface->file();
}
Core::IEditor *QmlJSEditorFactory::createEditor(QWidget *parent)
2009-04-22 15:21:04 +02:00
{
QmlJSEditor::QmlJSTextEditorWidget *rc = new QmlJSEditor::QmlJSTextEditorWidget(parent);
QmlJSEditorPlugin::instance()->initializeEditor(rc);
return rc->editor();
2009-04-22 15:21:04 +02:00
}
QStringList QmlJSEditorFactory::mimeTypes() const
2009-04-22 15:21:04 +02:00
{
return m_mimeTypes;
}