2013-02-15 12:49:50 +01:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2014-01-07 13:27:11 +01:00
|
|
|
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
2013-02-15 12:49:50 +01:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
|
|
|
|
**
|
|
|
|
|
** 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
|
|
|
|
|
** 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.
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
** 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
|
|
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2014-01-30 14:27:50 +01:00
|
|
|
#ifndef SIDEBYSIDEDIFFEDITORWIDGET_H
|
|
|
|
|
#define SIDEBYSIDEDIFFEDITORWIDGET_H
|
2013-02-15 12:49:50 +01:00
|
|
|
|
|
|
|
|
#include "diffeditor_global.h"
|
|
|
|
|
#include "differ.h"
|
2013-12-16 16:19:40 +01:00
|
|
|
#include "diffeditorcontroller.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
|
|
|
|
|
class QSplitter;
|
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
|
|
|
|
|
2013-02-21 17:03:00 +01:00
|
|
|
namespace DiffEditor {
|
2014-02-24 11:10:17 +01:00
|
|
|
class DiffEditorGuiController;
|
2014-01-30 14:27:50 +01:00
|
|
|
class SideDiffEditorWidget;
|
2014-02-28 10:40:20 +01:00
|
|
|
|
|
|
|
|
namespace Internal {
|
2014-01-17 11:17:46 +01:00
|
|
|
class ChunkData;
|
|
|
|
|
class FileData;
|
2014-02-28 10:40:20 +01:00
|
|
|
}
|
2013-02-15 12:49:50 +01:00
|
|
|
|
2014-01-30 14:27:50 +01:00
|
|
|
class DIFFEDITOR_EXPORT SideBySideDiffEditorWidget : public QWidget
|
2013-02-15 12:49:50 +01:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
2014-01-30 14:27:50 +01:00
|
|
|
SideBySideDiffEditorWidget(QWidget *parent = 0);
|
|
|
|
|
~SideBySideDiffEditorWidget();
|
2013-02-15 12:49:50 +01:00
|
|
|
|
2014-02-24 11:10:17 +01:00
|
|
|
void setDiffEditorGuiController(DiffEditorGuiController *controller);
|
|
|
|
|
DiffEditorGuiController *diffEditorGuiController() const;
|
2013-12-16 16:19:40 +01:00
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
|
void clear(const QString &message = QString());
|
|
|
|
|
void setDiff(const QList<DiffEditorController::DiffFilesContents> &diffFileList, const QString &workingDirectory);
|
|
|
|
|
|
2013-02-15 12:49:50 +01:00
|
|
|
void setContextLinesNumber(int lines);
|
|
|
|
|
void setIgnoreWhitespaces(bool ignore);
|
2013-12-16 16:19:40 +01:00
|
|
|
void setCurrentDiffFileIndex(int diffFileIndex);
|
2013-02-15 12:49:50 +01:00
|
|
|
|
2013-06-05 15:25:42 +02:00
|
|
|
void setFontSettings(const TextEditor::FontSettings &fontSettings);
|
2013-07-01 13:15:27 +02:00
|
|
|
void slotLeftJumpToOriginalFileRequested(int diffFileIndex, int lineNumber, int columnNumber);
|
|
|
|
|
void slotRightJumpToOriginalFileRequested(int diffFileIndex, int lineNumber, int columnNumber);
|
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-04-10 13:51:04 +02:00
|
|
|
void leftDocumentSizeChanged();
|
|
|
|
|
void rightDocumentSizeChanged();
|
2013-02-15 12:49:50 +01:00
|
|
|
|
|
|
|
|
private:
|
2013-12-16 16:19:40 +01:00
|
|
|
class DiffList {
|
|
|
|
|
public:
|
|
|
|
|
DiffEditorController::DiffFileInfo leftFileInfo;
|
|
|
|
|
DiffEditorController::DiffFileInfo rightFileInfo;
|
2013-04-25 17:37:20 +02:00
|
|
|
QList<Diff> diffList;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void setDiff(const QList<DiffList> &diffList);
|
2014-01-17 15:59:31 +01:00
|
|
|
void handleWhitespaces(const QList<Diff> &input,
|
|
|
|
|
QList<Diff> *leftOutput,
|
|
|
|
|
QList<Diff> *rightOutput) const;
|
2014-02-28 10:40:20 +01:00
|
|
|
void colorDiff(const QList<Internal::FileData> &fileDataList);
|
2013-02-15 12:49:50 +01:00
|
|
|
void showDiff();
|
2014-01-30 14:27:50 +01:00
|
|
|
void synchronizeFoldings(SideDiffEditorWidget *source, SideDiffEditorWidget *destination);
|
2013-07-01 13:15:27 +02:00
|
|
|
void jumpToOriginalFile(const QString &fileName, int lineNumber, int columnNumber);
|
2013-02-15 12:49:50 +01:00
|
|
|
|
2014-02-24 11:10:17 +01:00
|
|
|
DiffEditorGuiController *m_guiController;
|
2013-12-16 16:19:40 +01:00
|
|
|
DiffEditorController *m_controller;
|
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;
|
|
|
|
|
|
2013-04-25 17:37:20 +02:00
|
|
|
QList<DiffList> m_diffList; // list of original outputs from differ
|
2014-02-28 10:40:20 +01:00
|
|
|
QList<Internal::ChunkData> m_originalChunkData; // one big chunk for every file, ignoreWhitespace taken into account
|
|
|
|
|
QList<Internal::FileData> m_contextFileData; // ultimate data to be shown, contextLinesNumber taken into account
|
2013-02-15 12:49:50 +01:00
|
|
|
|
2013-04-10 13:51:04 +02:00
|
|
|
bool m_foldingBlocker;
|
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
|
|
|
};
|
|
|
|
|
|
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
|