diffeditor.h 3.33 KB
Newer Older
1 2
/****************************************************************************
**
3 4
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
5 6 7 8 9 10 11
**
** 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
12 13 14
** 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.
15
**
16 17 18 19 20 21 22
** 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.
23 24 25
**
****************************************************************************/

hjk's avatar
hjk committed
26
#pragma once
27

jkobus's avatar
jkobus committed
28
#include "diffeditorcontroller.h"
29 30 31 32

#include <coreplugin/editormanager/ieditor.h>
#include <coreplugin/idocument.h>

jkobus's avatar
jkobus committed
33 34
QT_BEGIN_NAMESPACE
class QComboBox;
Tobias Hunger's avatar
Tobias Hunger committed
35
class QLabel;
36
class QSpinBox;
jkobus's avatar
jkobus committed
37
class QToolBar;
Jarek Kobus's avatar
Jarek Kobus committed
38
class QToolButton;
jkobus's avatar
jkobus committed
39
class QStackedWidget;
jkobus's avatar
jkobus committed
40
QT_END_NAMESPACE
41

42
namespace TextEditor { class TextEditorWidget; }
Jarek Kobus's avatar
Jarek Kobus committed
43

44 45
namespace DiffEditor {

46 47
namespace Internal {
class DescriptionEditorWidget;
jkobus's avatar
jkobus committed
48
class DiffEditorDocument;
49
class IDiffView;
50

51
class DiffEditor : public Core::IEditor
52 53
{
    Q_OBJECT
54

55
public:
56
    DiffEditor(DiffEditorDocument *doc);
57
    ~DiffEditor() override;
58

59 60 61
    Core::IEditor *duplicate() override;
    Core::IDocument *document() override;
    QWidget *toolBar() override;
62

Orgad Shaneh's avatar
Orgad Shaneh committed
63 64 65 66
private:
    DiffEditor();
    void setDocument(QSharedPointer<DiffEditorDocument> doc);

67 68 69 70
    void documentHasChanged();
    void toggleDescription();
    void updateDescription();
    void contextLineCountHasChanged(int lines);
Tobias Hunger's avatar
Tobias Hunger committed
71
    void ignoreWhitespaceHasChanged();
72 73 74 75 76 77
    void prepareForReload();
    void reloadHasFinished(bool success);
    void setCurrentDiffFileIndex(int index);
    void documentStateChanged();

    void toggleSync();
78

79
    IDiffView *loadSettings();
80
    void saveSetting(const QString &key, const QVariant &value) const;
jkobus's avatar
jkobus committed
81
    void updateEntryToolTip();
82
    void showDiffView(IDiffView *view);
jkobus's avatar
jkobus committed
83
    void updateDiffEditorSwitcher();
84 85 86 87
    void addView(IDiffView *view);
    IDiffView *currentView() const;
    void setCurrentView(IDiffView *view);
    IDiffView *nextView();
88
    void setupView(IDiffView *view);
jkobus's avatar
jkobus committed
89

90 91
    QSharedPointer<DiffEditorDocument> m_document;
    DescriptionEditorWidget *m_descriptionWidget;
jkobus's avatar
jkobus committed
92
    QStackedWidget *m_stackedWidget;
93
    QVector<IDiffView *> m_views;
94
    QToolBar *m_toolBar;
jkobus's avatar
jkobus committed
95
    QComboBox *m_entriesComboBox;
96 97
    QSpinBox *m_contextSpinBox;
    QAction *m_toggleSyncAction;
98
    QAction *m_whitespaceButtonAction;
Jarek Kobus's avatar
Jarek Kobus committed
99
    QAction *m_toggleDescriptionAction;
100
    QAction *m_reloadAction;
Tobias Hunger's avatar
Tobias Hunger committed
101 102
    QLabel *m_contextLabel;
    QAction *m_viewSwitcherAction;
103 104 105
    QPair<QString, QString> m_currentFileChunk;
    int m_currentViewIndex;
    int m_currentDiffFileIndex;
Tobias Hunger's avatar
Tobias Hunger committed
106
    int m_ignoreChanges;
107 108
    bool m_sync;
    bool m_showDescription;
109 110
};

111
} // namespace Internal
112
} // namespace DiffEditor