2013-05-07 14:02:08 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2013-05-07 14:02:08 +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-05-07 14:02:08 +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-05-07 14:02:08 +02:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2013-05-07 14:02:08 +02:00
|
|
|
|
|
|
|
|
#include <coreplugin/editormanager/ieditor.h>
|
|
|
|
|
#include <coreplugin/idocument.h>
|
2016-10-20 16:22:46 +02:00
|
|
|
#include <utils/guard.h>
|
2013-05-07 14:02:08 +02:00
|
|
|
|
2013-05-23 13:36:27 +02:00
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
class QComboBox;
|
2015-01-30 16:59:25 +01:00
|
|
|
class QSpinBox;
|
2014-02-13 16:43:28 +01:00
|
|
|
class QToolBar;
|
|
|
|
|
class QStackedWidget;
|
2013-05-23 13:36:27 +02:00
|
|
|
QT_END_NAMESPACE
|
2013-05-07 14:02:08 +02:00
|
|
|
|
2014-09-26 11:37:54 +02:00
|
|
|
namespace TextEditor { class TextEditorWidget; }
|
2014-01-30 17:04:54 +01:00
|
|
|
|
2013-05-07 14:02:08 +02:00
|
|
|
namespace DiffEditor {
|
|
|
|
|
|
2015-01-30 14:33:39 +01:00
|
|
|
namespace Internal {
|
|
|
|
|
class DescriptionEditorWidget;
|
2014-02-11 13:00:35 +01:00
|
|
|
class DiffEditorDocument;
|
2015-01-30 16:10:04 +01:00
|
|
|
class IDiffView;
|
2017-05-09 12:19:11 +02:00
|
|
|
class UnifiedView;
|
|
|
|
|
class SideBySideView;
|
2013-05-07 14:02:08 +02:00
|
|
|
|
2015-01-30 14:59:41 +01:00
|
|
|
class DiffEditor : public Core::IEditor
|
2013-05-07 14:02:08 +02:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
2014-08-21 21:12:04 +02:00
|
|
|
|
2013-05-07 14:02:08 +02:00
|
|
|
public:
|
2015-03-11 15:22:40 +01:00
|
|
|
DiffEditor(DiffEditorDocument *doc);
|
2015-06-01 17:55:31 +02:00
|
|
|
~DiffEditor() override;
|
2013-05-07 14:02:08 +02:00
|
|
|
|
2015-06-01 17:55:31 +02:00
|
|
|
Core::IEditor *duplicate() override;
|
2018-09-25 20:47:14 +03:00
|
|
|
Core::IDocument *document() const override;
|
2015-06-01 17:55:31 +02:00
|
|
|
QWidget *toolBar() override;
|
2017-05-09 12:19:11 +02:00
|
|
|
TextEditor::TextEditorWidget *descriptionWidget() const;
|
|
|
|
|
TextEditor::TextEditorWidget *unifiedEditorWidget() const;
|
|
|
|
|
TextEditor::TextEditorWidget *leftEditorWidget() const;
|
|
|
|
|
TextEditor::TextEditorWidget *rightEditorWidget() const;
|
2013-05-07 14:02:08 +02:00
|
|
|
|
2015-10-31 23:17:25 +02:00
|
|
|
private:
|
|
|
|
|
DiffEditor();
|
|
|
|
|
void setDocument(QSharedPointer<DiffEditorDocument> doc);
|
|
|
|
|
|
2015-01-30 16:59:25 +01:00
|
|
|
void documentHasChanged();
|
|
|
|
|
void toggleDescription();
|
|
|
|
|
void updateDescription();
|
|
|
|
|
void contextLineCountHasChanged(int lines);
|
2015-03-10 12:50:43 +01:00
|
|
|
void ignoreWhitespaceHasChanged();
|
2015-01-30 16:59:25 +01:00
|
|
|
void prepareForReload();
|
|
|
|
|
void reloadHasFinished(bool success);
|
|
|
|
|
void setCurrentDiffFileIndex(int index);
|
|
|
|
|
void documentStateChanged();
|
|
|
|
|
|
|
|
|
|
void toggleSync();
|
2013-05-07 14:02:08 +02:00
|
|
|
|
2015-03-11 15:22:40 +01:00
|
|
|
IDiffView *loadSettings();
|
2015-01-30 16:59:25 +01:00
|
|
|
void saveSetting(const QString &key, const QVariant &value) const;
|
2013-05-23 13:36:27 +02:00
|
|
|
void updateEntryToolTip();
|
2015-01-30 16:59:25 +01:00
|
|
|
void showDiffView(IDiffView *view);
|
2014-02-13 16:43:28 +01:00
|
|
|
void updateDiffEditorSwitcher();
|
2015-01-30 16:10:04 +01:00
|
|
|
void addView(IDiffView *view);
|
|
|
|
|
IDiffView *currentView() const;
|
|
|
|
|
void setCurrentView(IDiffView *view);
|
|
|
|
|
IDiffView *nextView();
|
2015-01-30 16:59:25 +01:00
|
|
|
void setupView(IDiffView *view);
|
2013-05-23 13:36:27 +02:00
|
|
|
|
2015-01-30 14:59:41 +01:00
|
|
|
QSharedPointer<DiffEditorDocument> m_document;
|
2017-12-06 21:30:57 +01:00
|
|
|
DescriptionEditorWidget *m_descriptionWidget = nullptr;
|
|
|
|
|
UnifiedView *m_unifiedView = nullptr;
|
|
|
|
|
SideBySideView *m_sideBySideView = nullptr;
|
|
|
|
|
QStackedWidget *m_stackedWidget = nullptr;
|
2015-01-30 16:10:04 +01:00
|
|
|
QVector<IDiffView *> m_views;
|
2017-12-06 21:30:57 +01:00
|
|
|
QToolBar *m_toolBar = nullptr;
|
|
|
|
|
QComboBox *m_entriesComboBox = nullptr;
|
|
|
|
|
QSpinBox *m_contextSpinBox = nullptr;
|
2016-11-24 11:49:02 +01:00
|
|
|
QAction *m_contextSpinBoxAction = nullptr;
|
2015-01-30 16:59:25 +01:00
|
|
|
QAction *m_toggleSyncAction;
|
2014-10-24 14:11:12 +02:00
|
|
|
QAction *m_whitespaceButtonAction;
|
2014-01-30 17:04:54 +01:00
|
|
|
QAction *m_toggleDescriptionAction;
|
2014-07-04 13:55:51 +02:00
|
|
|
QAction *m_reloadAction;
|
2016-11-24 11:49:02 +01:00
|
|
|
QAction *m_contextLabelAction = nullptr;
|
2015-03-10 12:50:43 +01:00
|
|
|
QAction *m_viewSwitcherAction;
|
2015-01-30 16:59:25 +01:00
|
|
|
QPair<QString, QString> m_currentFileChunk;
|
2017-12-06 21:30:57 +01:00
|
|
|
int m_currentViewIndex = -1;
|
|
|
|
|
int m_currentDiffFileIndex = -1;
|
2016-10-20 16:22:46 +02:00
|
|
|
Utils::Guard m_ignoreChanges;
|
2017-12-06 21:30:57 +01:00
|
|
|
bool m_sync = false;
|
|
|
|
|
bool m_showDescription = true;
|
2013-05-07 14:02:08 +02:00
|
|
|
};
|
|
|
|
|
|
2015-01-30 14:59:41 +01:00
|
|
|
} // namespace Internal
|
2013-05-07 14:02:08 +02:00
|
|
|
} // namespace DiffEditor
|