2013-06-17 13:55:31 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2013-06-17 13:55:31 +02:00
|
|
|
**
|
|
|
|
|
** 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
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2013-06-17 13:55:31 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2013-06-17 13:55:31 +02:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "diffeditor.h"
|
|
|
|
|
#include "diffeditorconstants.h"
|
2014-08-21 21:12:04 +02:00
|
|
|
#include "diffeditordocument.h"
|
2014-01-30 14:27:50 +01:00
|
|
|
#include "diffeditorfactory.h"
|
|
|
|
|
#include "sidebysidediffeditorwidget.h"
|
2013-06-17 13:55:31 +02:00
|
|
|
|
2017-05-09 12:19:11 +02:00
|
|
|
#include "texteditor/texteditoractionhandler.h"
|
|
|
|
|
|
2013-06-17 13:55:31 +02:00
|
|
|
#include <QCoreApplication>
|
|
|
|
|
|
|
|
|
|
namespace DiffEditor {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
DiffEditorFactory::DiffEditorFactory(QObject *parent)
|
2013-08-12 11:21:58 +02:00
|
|
|
: IEditorFactory(parent)
|
2013-06-17 13:55:31 +02:00
|
|
|
{
|
2013-08-12 11:21:58 +02:00
|
|
|
setId(Constants::DIFF_EDITOR_ID);
|
2017-04-24 17:01:10 +02:00
|
|
|
setDisplayName(QCoreApplication::translate("DiffEditorFactory", Constants::DIFF_EDITOR_DISPLAY_NAME));
|
2014-02-13 16:43:28 +01:00
|
|
|
addMimeType(Constants::DIFF_EDITOR_MIMETYPE);
|
2017-05-09 12:19:11 +02:00
|
|
|
auto descriptionHandler = new TextEditor::TextEditorActionHandler(
|
|
|
|
|
this, id(), Constants::C_DIFF_EDITOR_DESCRIPTION);
|
|
|
|
|
descriptionHandler->setTextEditorWidgetResolver([](Core::IEditor *e) {
|
|
|
|
|
return static_cast<DiffEditor *>(e)->descriptionWidget();
|
|
|
|
|
});
|
|
|
|
|
auto unifiedHandler = new TextEditor::TextEditorActionHandler(
|
|
|
|
|
this, id(), Constants::UNIFIED_VIEW_ID);
|
|
|
|
|
unifiedHandler->setTextEditorWidgetResolver([](Core::IEditor *e) {
|
|
|
|
|
return static_cast<DiffEditor *>(e)->unifiedEditorWidget();
|
|
|
|
|
});
|
|
|
|
|
auto leftHandler = new TextEditor::TextEditorActionHandler(
|
|
|
|
|
this, id(), Core::Id(Constants::SIDE_BY_SIDE_VIEW_ID).withSuffix(1));
|
|
|
|
|
leftHandler->setTextEditorWidgetResolver([](Core::IEditor *e) {
|
|
|
|
|
return static_cast<DiffEditor *>(e)->leftEditorWidget();
|
|
|
|
|
});
|
|
|
|
|
auto rightHandler = new TextEditor::TextEditorActionHandler(
|
|
|
|
|
this, id(), Core::Id(Constants::SIDE_BY_SIDE_VIEW_ID).withSuffix(2));
|
|
|
|
|
rightHandler->setTextEditorWidgetResolver([](Core::IEditor *e) {
|
|
|
|
|
return static_cast<DiffEditor *>(e)->rightEditorWidget();
|
|
|
|
|
});
|
2013-06-17 13:55:31 +02:00
|
|
|
}
|
|
|
|
|
|
2014-01-07 14:41:57 +01:00
|
|
|
Core::IEditor *DiffEditorFactory::createEditor()
|
2013-06-17 13:55:31 +02:00
|
|
|
{
|
2015-03-11 15:22:40 +01:00
|
|
|
return new DiffEditor(new DiffEditorDocument);
|
2013-06-17 13:55:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace DiffEditor
|