2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2014-01-07 13:27:11 +01:00
|
|
|
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2008-12-02 16:19:05 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "plaintexteditorfactory.h"
|
2014-07-30 13:13:24 +02:00
|
|
|
#include "basetexteditor.h"
|
2011-05-20 11:27:07 +02:00
|
|
|
#include "basetextdocument.h"
|
2014-07-30 10:41:06 +02:00
|
|
|
#include "normalindenter.h"
|
2013-12-10 15:54:20 +01:00
|
|
|
#include "texteditoractionhandler.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "texteditorconstants.h"
|
|
|
|
|
#include "texteditorplugin.h"
|
2013-12-10 15:54:20 +01:00
|
|
|
#include "texteditorsettings.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
#include <coreplugin/coreconstants.h>
|
2011-05-06 12:48:44 +02:00
|
|
|
#include <coreplugin/infobar.h>
|
2014-08-22 19:14:48 +02:00
|
|
|
#include <utils/qtcassert.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-05-06 12:30:23 +04:00
|
|
|
#include <QCoreApplication>
|
2010-05-28 14:37:25 +02:00
|
|
|
|
2014-08-22 19:14:48 +02:00
|
|
|
namespace TextEditor {
|
2014-08-27 11:19:04 +02:00
|
|
|
|
|
|
|
|
static PlainTextEditorFactory *m_instance = 0;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2014-08-22 19:14:48 +02:00
|
|
|
class PlainTextEditorWidget : public BaseTextEditorWidget
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
PlainTextEditorWidget() {}
|
|
|
|
|
void finalizeInitialization() { setupAsPlainEditor(); }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
PlainTextEditorFactory::PlainTextEditorFactory()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2014-08-27 11:19:04 +02:00
|
|
|
QTC_CHECK(!m_instance);
|
|
|
|
|
m_instance = this;
|
2013-05-31 19:35:37 +02:00
|
|
|
setId(Core::Constants::K_DEFAULT_TEXT_EDITOR_ID);
|
|
|
|
|
setDisplayName(qApp->translate("OpenWith::Editors", Core::Constants::K_DEFAULT_TEXT_EDITOR_DISPLAY_NAME));
|
|
|
|
|
addMimeType(QLatin1String(TextEditor::Constants::C_TEXTEDITOR_MIMETYPE_TEXT));
|
|
|
|
|
|
2014-08-22 19:14:48 +02:00
|
|
|
setDocumentCreator([]() { return new BaseTextDocument(Core::Constants::K_DEFAULT_TEXT_EDITOR_ID); });
|
|
|
|
|
setEditorWidgetCreator([]() { return new PlainTextEditorWidget; });
|
|
|
|
|
setIndenterCreator([]() { return new NormalIndenter; });
|
|
|
|
|
|
2014-09-02 12:25:20 +02:00
|
|
|
setEditorActionHandlers(TextEditorActionHandler::Format |
|
2010-06-18 16:30:56 +02:00
|
|
|
TextEditorActionHandler::UnCommentSelection |
|
|
|
|
|
TextEditorActionHandler::UnCollapseAll);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2014-08-27 11:19:04 +02:00
|
|
|
PlainTextEditorFactory *PlainTextEditorFactory::instance()
|
|
|
|
|
{
|
|
|
|
|
return m_instance;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BaseTextEditor *PlainTextEditorFactory::createPlainTextEditor()
|
|
|
|
|
{
|
|
|
|
|
return qobject_cast<BaseTextEditor *>(m_instance->createEditor());
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-22 19:14:48 +02:00
|
|
|
} // namespace TextEditor
|