2013-02-15 12:49:50 +01:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2013-02-15 12:49:50 +01: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-02-15 12:49:50 +01: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-02-15 12:49:50 +01:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2014-01-30 14:27:50 +01:00
|
|
|
#ifndef SIDEBYSIDEDIFFEDITORWIDGET_H
|
|
|
|
|
#define SIDEBYSIDEDIFFEDITORWIDGET_H
|
2013-02-15 12:49:50 +01:00
|
|
|
|
2015-03-10 14:19:38 +01:00
|
|
|
#include "diffutils.h"
|
|
|
|
|
|
2014-03-10 12:57:48 +01:00
|
|
|
#include <QWidget>
|
|
|
|
|
#include <QTextCharFormat>
|
2013-02-15 12:49:50 +01:00
|
|
|
|
2014-02-11 13:00:35 +01:00
|
|
|
namespace TextEditor { class FontSettings; }
|
2013-02-15 12:49:50 +01:00
|
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
2014-02-13 16:43:28 +01:00
|
|
|
class QMenu;
|
2015-03-10 14:19:38 +01:00
|
|
|
class QSplitter;
|
2013-02-15 12:49:50 +01:00
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
2013-02-21 17:03:00 +01:00
|
|
|
namespace DiffEditor {
|
2015-01-30 14:46:20 +01:00
|
|
|
|
2015-03-10 14:19:38 +01:00
|
|
|
class DiffEditorController;
|
2013-02-15 12:49:50 +01:00
|
|
|
|
2015-01-30 14:55:56 +01:00
|
|
|
namespace Internal {
|
|
|
|
|
|
2015-03-10 14:19:38 +01:00
|
|
|
class DiffEditorDocument;
|
2015-01-30 14:55:56 +01:00
|
|
|
class SideDiffEditorWidget;
|
|
|
|
|
|
|
|
|
|
class SideBySideDiffEditorWidget : public QWidget
|
2013-02-15 12:49:50 +01:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
2015-01-30 11:18:08 +01:00
|
|
|
explicit SideBySideDiffEditorWidget(QWidget *parent = 0);
|
2013-02-15 12:49:50 +01:00
|
|
|
|
2015-01-30 16:59:25 +01:00
|
|
|
void setDocument(DiffEditorDocument *document);
|
2013-12-16 16:19:40 +01:00
|
|
|
|
2014-02-13 16:43:28 +01:00
|
|
|
void setDiff(const QList<FileData> &diffFileList,
|
|
|
|
|
const QString &workingDirectory);
|
2013-12-16 16:19:40 +01:00
|
|
|
void setCurrentDiffFileIndex(int diffFileIndex);
|
2013-02-15 12:49:50 +01:00
|
|
|
|
2015-01-30 16:59:25 +01:00
|
|
|
void setHorizontalSync(bool sync);
|
|
|
|
|
|
|
|
|
|
void saveState();
|
|
|
|
|
void restoreState();
|
|
|
|
|
|
|
|
|
|
void clear(const QString &message = QString());
|
|
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
void currentDiffFileIndexChanged(int index);
|
|
|
|
|
|
|
|
|
|
private slots:
|
2013-06-05 15:25:42 +02:00
|
|
|
void setFontSettings(const TextEditor::FontSettings &fontSettings);
|
2014-02-13 16:43:28 +01:00
|
|
|
void slotLeftJumpToOriginalFileRequested(int diffFileIndex,
|
|
|
|
|
int lineNumber, int columnNumber);
|
|
|
|
|
void slotRightJumpToOriginalFileRequested(int diffFileIndex,
|
|
|
|
|
int lineNumber, int columnNumber);
|
|
|
|
|
void slotLeftContextMenuRequested(QMenu *menu, int diffFileIndex,
|
|
|
|
|
int chunkIndex);
|
|
|
|
|
void slotRightContextMenuRequested(QMenu *menu, int diffFileIndex,
|
|
|
|
|
int chunkIndex);
|
|
|
|
|
void slotSendChunkToCodePaster();
|
|
|
|
|
void slotApplyChunk();
|
|
|
|
|
void slotRevertChunk();
|
2013-05-22 16:33:44 +02:00
|
|
|
void leftVSliderChanged();
|
|
|
|
|
void rightVSliderChanged();
|
|
|
|
|
void leftHSliderChanged();
|
|
|
|
|
void rightHSliderChanged();
|
2013-05-23 13:36:27 +02:00
|
|
|
void leftCursorPositionChanged();
|
|
|
|
|
void rightCursorPositionChanged();
|
2013-02-15 12:49:50 +01:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void showDiff();
|
2014-02-13 16:43:28 +01:00
|
|
|
void jumpToOriginalFile(const QString &fileName,
|
|
|
|
|
int lineNumber, int columnNumber);
|
2014-07-28 23:25:49 +03:00
|
|
|
void patch(bool revert);
|
2013-02-15 12:49:50 +01:00
|
|
|
|
2015-01-30 16:59:25 +01:00
|
|
|
DiffEditorDocument *m_document;
|
2014-01-30 14:27:50 +01:00
|
|
|
SideDiffEditorWidget *m_leftEditor;
|
|
|
|
|
SideDiffEditorWidget *m_rightEditor;
|
2013-02-15 12:49:50 +01:00
|
|
|
QSplitter *m_splitter;
|
|
|
|
|
|
2015-01-30 16:59:25 +01:00
|
|
|
QList<FileData> m_contextFileData; // ultimate data to be shown, contextLineCount taken into account
|
2013-02-15 12:49:50 +01:00
|
|
|
|
2014-02-13 16:43:28 +01:00
|
|
|
bool m_ignoreCurrentIndexChange;
|
2013-04-10 13:51:04 +02:00
|
|
|
bool m_foldingBlocker;
|
2015-01-30 16:59:25 +01:00
|
|
|
bool m_horizontalSync;
|
2014-02-13 16:43:28 +01:00
|
|
|
int m_contextMenuFileIndex;
|
|
|
|
|
int m_contextMenuChunkIndex;
|
2013-06-05 15:25:42 +02:00
|
|
|
|
2014-02-13 16:43:28 +01:00
|
|
|
QTextCharFormat m_spanLineFormat;
|
2013-06-05 15:25:42 +02:00
|
|
|
QTextCharFormat m_fileLineFormat;
|
|
|
|
|
QTextCharFormat m_chunkLineFormat;
|
|
|
|
|
QTextCharFormat m_leftLineFormat;
|
|
|
|
|
QTextCharFormat m_leftCharFormat;
|
|
|
|
|
QTextCharFormat m_rightLineFormat;
|
|
|
|
|
QTextCharFormat m_rightCharFormat;
|
2013-02-15 12:49:50 +01:00
|
|
|
};
|
|
|
|
|
|
2015-01-30 14:55:56 +01:00
|
|
|
} // namespace Internal
|
2013-02-21 17:03:00 +01:00
|
|
|
} // namespace DiffEditor
|
2013-02-15 12:49:50 +01:00
|
|
|
|
2014-01-30 14:27:50 +01:00
|
|
|
#endif // SIDEBYSIDEDIFFEDITORWIDGET_H
|