2013-05-07 14:02:08 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
|
|
|
|
** Contact: http://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
|
2015-01-14 18:07:15 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms and
|
|
|
|
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
2014-10-01 13:21:18 +02:00
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
2013-05-07 14:02:08 +02:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-10-01 13:21:18 +02:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2013-05-07 14:02:08 +02:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
|
|
|
|
** rights. These rights are described in The Qt Company LGPL Exception
|
2013-05-07 14:02:08 +02:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2013-05-30 12:15:22 +02:00
|
|
|
#include "diffeditor.h"
|
2013-05-07 14:02:08 +02:00
|
|
|
#include "diffeditorconstants.h"
|
2014-01-30 14:27:50 +01:00
|
|
|
#include "diffeditordocument.h"
|
2015-01-30 16:10:04 +01:00
|
|
|
#include "diffview.h"
|
2013-05-07 14:02:08 +02:00
|
|
|
|
|
|
|
|
#include <coreplugin/icore.h>
|
2013-06-03 12:32:07 +02:00
|
|
|
#include <coreplugin/coreconstants.h>
|
2014-01-30 17:04:54 +01:00
|
|
|
#include <coreplugin/minisplitter.h>
|
|
|
|
|
|
2014-09-26 09:14:03 +02:00
|
|
|
#include <texteditor/texteditor.h>
|
2014-01-30 17:04:54 +01:00
|
|
|
#include <texteditor/texteditorsettings.h>
|
|
|
|
|
#include <texteditor/displaysettings.h>
|
2014-09-24 12:40:28 +02:00
|
|
|
#include <texteditor/marginsettings.h>
|
2013-06-03 12:32:07 +02:00
|
|
|
|
2015-01-30 16:10:04 +01:00
|
|
|
#include <utils/algorithm.h>
|
2015-01-10 23:40:32 +02:00
|
|
|
#include <utils/fileutils.h>
|
2015-01-30 11:35:31 +01:00
|
|
|
#include <utils/qtcassert.h>
|
2015-01-10 23:40:32 +02:00
|
|
|
|
2015-02-26 13:38:54 +01:00
|
|
|
#include <QAction>
|
2014-02-13 16:43:28 +01:00
|
|
|
#include <QStackedWidget>
|
2013-05-07 14:02:08 +02:00
|
|
|
#include <QToolButton>
|
|
|
|
|
#include <QSpinBox>
|
|
|
|
|
#include <QStyle>
|
|
|
|
|
#include <QLabel>
|
2013-05-21 13:51:26 +02:00
|
|
|
#include <QHBoxLayout>
|
2013-05-23 13:36:27 +02:00
|
|
|
#include <QToolBar>
|
|
|
|
|
#include <QComboBox>
|
2015-02-26 13:22:35 +01:00
|
|
|
#include <QAction>
|
2014-06-30 15:04:36 +02:00
|
|
|
#include <QDir>
|
2014-02-13 16:43:28 +01:00
|
|
|
#include <QTextCodec>
|
2014-06-24 10:53:03 +03:00
|
|
|
#include <QTextBlock>
|
2014-02-13 16:43:28 +01:00
|
|
|
|
|
|
|
|
static const char settingsGroupC[] = "DiffEditor";
|
2015-01-30 16:59:25 +01:00
|
|
|
static const char descriptionVisibleKeyC[] = "DescriptionVisible";
|
|
|
|
|
static const char horizontalScrollBarSynchronizationKeyC[] =
|
|
|
|
|
"HorizontalScrollBarSynchronization";
|
|
|
|
|
static const char contextLineCountKeyC[] = "ContextLineNumbers";
|
|
|
|
|
static const char ignoreWhitespaceKeyC[] = "IgnoreWhitespace";
|
|
|
|
|
|
|
|
|
|
static const char diffViewKeyC[] = "DiffEditorType";
|
2014-02-13 16:43:28 +01:00
|
|
|
|
|
|
|
|
static const char legacySettingsGroupC[] = "Git";
|
|
|
|
|
static const char useDiffEditorKeyC[] = "UseDiffEditor";
|
2013-05-07 14:02:08 +02:00
|
|
|
|
2014-01-30 17:04:54 +01:00
|
|
|
using namespace TextEditor;
|
|
|
|
|
|
2013-05-07 14:02:08 +02:00
|
|
|
namespace DiffEditor {
|
2014-01-30 17:04:54 +01:00
|
|
|
namespace Internal {
|
|
|
|
|
|
2014-09-26 11:37:54 +02:00
|
|
|
class DescriptionEditorWidget : public TextEditorWidget
|
2014-01-30 17:04:54 +01:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
|
|
|
|
DescriptionEditorWidget(QWidget *parent = 0);
|
|
|
|
|
virtual QSize sizeHint() const;
|
|
|
|
|
|
2014-06-24 10:53:03 +03:00
|
|
|
signals:
|
2015-01-28 13:45:02 +01:00
|
|
|
void requestBranchList();
|
2014-06-24 10:53:03 +03:00
|
|
|
|
2014-01-30 17:04:54 +01:00
|
|
|
protected:
|
2014-06-24 10:53:03 +03:00
|
|
|
void mouseMoveEvent(QMouseEvent *e);
|
|
|
|
|
void mouseReleaseEvent(QMouseEvent *e);
|
|
|
|
|
|
2014-09-24 12:40:28 +02:00
|
|
|
void setDisplaySettings(const DisplaySettings &ds);
|
|
|
|
|
void setMarginSettings(const MarginSettings &ms);
|
|
|
|
|
|
2014-06-24 10:53:03 +03:00
|
|
|
bool findContentsUnderCursor(const QTextCursor &cursor);
|
|
|
|
|
void highlightCurrentContents();
|
|
|
|
|
void handleCurrentContents();
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
QTextCursor m_currentCursor;
|
2014-01-30 17:04:54 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
DescriptionEditorWidget::DescriptionEditorWidget(QWidget *parent)
|
2014-09-26 11:37:54 +02:00
|
|
|
: TextEditorWidget(parent)
|
2014-01-30 17:04:54 +01:00
|
|
|
{
|
2014-08-28 18:46:39 +02:00
|
|
|
setupFallBackEditor("DiffEditor.DescriptionEditor");
|
|
|
|
|
|
2014-01-30 17:04:54 +01:00
|
|
|
DisplaySettings settings = displaySettings();
|
|
|
|
|
settings.m_textWrapping = false;
|
|
|
|
|
settings.m_displayLineNumbers = false;
|
|
|
|
|
settings.m_highlightCurrentLine = false;
|
|
|
|
|
settings.m_displayFoldingMarkers = false;
|
|
|
|
|
settings.m_markTextChanges = false;
|
|
|
|
|
settings.m_highlightBlocks = false;
|
2014-09-26 11:37:54 +02:00
|
|
|
TextEditorWidget::setDisplaySettings(settings);
|
2014-01-30 17:04:54 +01:00
|
|
|
|
|
|
|
|
setCodeFoldingSupported(true);
|
|
|
|
|
setFrameStyle(QFrame::NoFrame);
|
|
|
|
|
|
|
|
|
|
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QSize DescriptionEditorWidget::sizeHint() const
|
|
|
|
|
{
|
2014-09-26 11:37:54 +02:00
|
|
|
QSize size = TextEditorWidget::sizeHint();
|
2014-01-30 17:04:54 +01:00
|
|
|
size.setHeight(size.height() / 5);
|
|
|
|
|
return size;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DescriptionEditorWidget::setDisplaySettings(const DisplaySettings &ds)
|
|
|
|
|
{
|
|
|
|
|
DisplaySettings settings = displaySettings();
|
|
|
|
|
settings.m_visualizeWhitespace = ds.m_visualizeWhitespace;
|
2014-09-26 11:37:54 +02:00
|
|
|
TextEditorWidget::setDisplaySettings(settings);
|
2014-01-30 17:04:54 +01:00
|
|
|
}
|
|
|
|
|
|
2014-09-24 12:40:28 +02:00
|
|
|
void DescriptionEditorWidget::setMarginSettings(const MarginSettings &ms)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(ms);
|
2014-09-26 11:37:54 +02:00
|
|
|
TextEditorWidget::setMarginSettings(MarginSettings());
|
2014-09-24 12:40:28 +02:00
|
|
|
}
|
|
|
|
|
|
2014-06-24 10:53:03 +03:00
|
|
|
void DescriptionEditorWidget::mouseMoveEvent(QMouseEvent *e)
|
|
|
|
|
{
|
|
|
|
|
if (e->buttons()) {
|
2014-09-26 11:37:54 +02:00
|
|
|
TextEditorWidget::mouseMoveEvent(e);
|
2014-06-24 10:53:03 +03:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Qt::CursorShape cursorShape;
|
|
|
|
|
|
|
|
|
|
const QTextCursor cursor = cursorForPosition(e->pos());
|
|
|
|
|
if (findContentsUnderCursor(cursor)) {
|
|
|
|
|
highlightCurrentContents();
|
|
|
|
|
cursorShape = Qt::PointingHandCursor;
|
|
|
|
|
} else {
|
|
|
|
|
setExtraSelections(OtherSelection, QList<QTextEdit::ExtraSelection>());
|
|
|
|
|
cursorShape = Qt::IBeamCursor;
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-26 11:37:54 +02:00
|
|
|
TextEditorWidget::mouseMoveEvent(e);
|
2014-06-24 10:53:03 +03:00
|
|
|
viewport()->setCursor(cursorShape);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DescriptionEditorWidget::mouseReleaseEvent(QMouseEvent *e)
|
|
|
|
|
{
|
|
|
|
|
if (e->button() == Qt::LeftButton && !(e->modifiers() & Qt::ShiftModifier)) {
|
|
|
|
|
const QTextCursor cursor = cursorForPosition(e->pos());
|
|
|
|
|
if (findContentsUnderCursor(cursor)) {
|
|
|
|
|
handleCurrentContents();
|
|
|
|
|
e->accept();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-26 11:37:54 +02:00
|
|
|
TextEditorWidget::mouseReleaseEvent(e);
|
2014-06-24 10:53:03 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool DescriptionEditorWidget::findContentsUnderCursor(const QTextCursor &cursor)
|
|
|
|
|
{
|
|
|
|
|
m_currentCursor = cursor;
|
|
|
|
|
return cursor.block().text() == QLatin1String(Constants::EXPAND_BRANCHES);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DescriptionEditorWidget::highlightCurrentContents()
|
|
|
|
|
{
|
|
|
|
|
QTextEdit::ExtraSelection sel;
|
|
|
|
|
sel.cursor = m_currentCursor;
|
|
|
|
|
sel.cursor.select(QTextCursor::LineUnderCursor);
|
|
|
|
|
sel.format.setFontUnderline(true);
|
2014-09-26 11:37:54 +02:00
|
|
|
setExtraSelections(TextEditorWidget::OtherSelection,
|
2014-06-24 10:53:03 +03:00
|
|
|
QList<QTextEdit::ExtraSelection>() << sel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DescriptionEditorWidget::handleCurrentContents()
|
|
|
|
|
{
|
|
|
|
|
m_currentCursor.select(QTextCursor::LineUnderCursor);
|
|
|
|
|
m_currentCursor.removeSelectedText();
|
|
|
|
|
m_currentCursor.insertText(QLatin1String("Branches: Expanding..."));
|
2015-01-28 13:45:02 +01:00
|
|
|
emit requestBranchList();
|
2014-06-24 10:53:03 +03:00
|
|
|
}
|
|
|
|
|
|
2013-05-30 12:15:22 +02:00
|
|
|
///////////////////////////////// DiffEditor //////////////////////////////////
|
2013-05-07 14:02:08 +02:00
|
|
|
|
2014-08-21 21:12:04 +02:00
|
|
|
DiffEditor::DiffEditor(const QSharedPointer<DiffEditorDocument> &doc)
|
|
|
|
|
: m_document(doc)
|
2014-01-31 09:01:49 +01:00
|
|
|
, m_descriptionWidget(0)
|
2014-02-13 16:43:28 +01:00
|
|
|
, m_stackedWidget(0)
|
2014-01-31 09:01:49 +01:00
|
|
|
, m_toolBar(0)
|
2013-12-16 16:19:40 +01:00
|
|
|
, m_entriesComboBox(0)
|
2015-01-30 16:59:25 +01:00
|
|
|
, m_toggleSyncAction(0)
|
|
|
|
|
, m_whitespaceButtonAction(0)
|
|
|
|
|
, m_contextLabelAction(0)
|
|
|
|
|
, m_contextSpinBoxAction(0)
|
2014-01-30 17:04:54 +01:00
|
|
|
, m_toggleDescriptionAction(0)
|
2014-07-04 13:55:51 +02:00
|
|
|
, m_reloadAction(0)
|
2014-02-13 16:43:28 +01:00
|
|
|
, m_diffEditorSwitcher(0)
|
2015-01-30 16:59:25 +01:00
|
|
|
, m_currentViewIndex(-1)
|
|
|
|
|
, m_currentDiffFileIndex(-1)
|
|
|
|
|
, m_sync(false)
|
|
|
|
|
, m_showDescription(true)
|
|
|
|
|
, m_ignoreChanges(true)
|
2013-05-07 14:02:08 +02:00
|
|
|
{
|
2015-01-30 11:35:31 +01:00
|
|
|
QTC_ASSERT(m_document, return);
|
2015-01-30 16:59:25 +01:00
|
|
|
setDuplicateSupported(true);
|
2015-01-30 11:35:31 +01:00
|
|
|
|
2014-01-30 17:04:54 +01:00
|
|
|
QSplitter *splitter = new Core::MiniSplitter(Qt::Vertical);
|
2014-01-31 09:01:49 +01:00
|
|
|
|
2015-01-30 14:33:39 +01:00
|
|
|
m_descriptionWidget = new DescriptionEditorWidget(splitter);
|
2014-01-30 17:04:54 +01:00
|
|
|
m_descriptionWidget->setReadOnly(true);
|
|
|
|
|
splitter->addWidget(m_descriptionWidget);
|
2014-01-31 09:01:49 +01:00
|
|
|
|
2014-02-13 16:43:28 +01:00
|
|
|
m_stackedWidget = new QStackedWidget(splitter);
|
|
|
|
|
splitter->addWidget(m_stackedWidget);
|
|
|
|
|
|
2015-01-30 16:10:04 +01:00
|
|
|
addView(new SideBySideView);
|
|
|
|
|
addView(new UnifiedView);
|
2014-01-31 09:01:49 +01:00
|
|
|
|
2014-01-30 17:04:54 +01:00
|
|
|
setWidget(splitter);
|
|
|
|
|
|
2015-01-30 14:33:39 +01:00
|
|
|
connect(m_descriptionWidget, &DescriptionEditorWidget::requestBranchList,
|
2015-01-30 16:59:25 +01:00
|
|
|
m_document.data(), &DiffEditorDocument::requestMoreInformation);
|
|
|
|
|
connect(m_document.data(), &DiffEditorDocument::documentChanged,
|
|
|
|
|
this, &DiffEditor::documentHasChanged);
|
|
|
|
|
connect(m_document.data(), &DiffEditorDocument::descriptionChanged,
|
|
|
|
|
this, &DiffEditor::updateDescription);
|
|
|
|
|
connect(m_document.data(), &DiffEditorDocument::aboutToReload,
|
|
|
|
|
this, &DiffEditor::prepareForReload);
|
|
|
|
|
connect(m_document.data(), &DiffEditorDocument::reloadFinished,
|
|
|
|
|
this, &DiffEditor::reloadHasFinished);
|
2014-02-13 16:43:28 +01:00
|
|
|
|
|
|
|
|
toolBar();
|
2015-01-30 16:59:25 +01:00
|
|
|
|
|
|
|
|
loadSettings();
|
|
|
|
|
updateDescription();
|
|
|
|
|
|
|
|
|
|
m_ignoreChanges = false;
|
2013-05-07 14:02:08 +02:00
|
|
|
}
|
|
|
|
|
|
2013-05-30 12:15:22 +02:00
|
|
|
DiffEditor::~DiffEditor()
|
2013-05-07 14:02:08 +02:00
|
|
|
{
|
2014-01-31 09:01:49 +01:00
|
|
|
delete m_toolBar;
|
2015-01-30 11:18:08 +01:00
|
|
|
delete m_widget;
|
2013-05-07 14:02:08 +02:00
|
|
|
}
|
|
|
|
|
|
2014-01-31 09:01:49 +01:00
|
|
|
Core::IEditor *DiffEditor::duplicate()
|
|
|
|
|
{
|
2014-08-21 21:12:04 +02:00
|
|
|
return new DiffEditor(m_document);
|
2014-01-31 09:01:49 +01:00
|
|
|
}
|
|
|
|
|
|
2014-02-13 16:43:28 +01:00
|
|
|
bool DiffEditor::open(QString *errorString,
|
|
|
|
|
const QString &fileName,
|
|
|
|
|
const QString &realFileName)
|
2013-05-07 14:02:08 +02:00
|
|
|
{
|
|
|
|
|
Q_UNUSED(realFileName)
|
2014-10-23 16:47:20 +02:00
|
|
|
return m_document->open(errorString, fileName);
|
2013-05-07 14:02:08 +02:00
|
|
|
}
|
|
|
|
|
|
2013-05-30 12:15:22 +02:00
|
|
|
Core::IDocument *DiffEditor::document()
|
2013-05-07 14:02:08 +02:00
|
|
|
{
|
2014-01-31 09:01:49 +01:00
|
|
|
return m_document.data();
|
2013-05-07 14:02:08 +02:00
|
|
|
}
|
|
|
|
|
|
2015-01-30 16:10:04 +01:00
|
|
|
static QToolBar *createToolBar(IDiffView *someView)
|
2013-05-07 14:02:08 +02:00
|
|
|
{
|
|
|
|
|
// Create
|
|
|
|
|
QToolBar *toolBar = new QToolBar;
|
2013-08-29 13:08:34 +02:00
|
|
|
toolBar->setToolButtonStyle(Qt::ToolButtonIconOnly);
|
2015-01-30 16:10:04 +01:00
|
|
|
const int size = someView->widget()->style()->pixelMetric(QStyle::PM_SmallIconSize);
|
2013-05-07 14:02:08 +02:00
|
|
|
toolBar->setIconSize(QSize(size, size));
|
|
|
|
|
|
|
|
|
|
return toolBar;
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-30 12:15:22 +02:00
|
|
|
QWidget *DiffEditor::toolBar()
|
2013-05-07 14:02:08 +02:00
|
|
|
{
|
2015-01-30 16:10:04 +01:00
|
|
|
QTC_ASSERT(!m_views.isEmpty(), return 0);
|
|
|
|
|
|
2014-01-31 09:01:49 +01:00
|
|
|
if (m_toolBar)
|
|
|
|
|
return m_toolBar;
|
2013-05-07 14:02:08 +02:00
|
|
|
|
|
|
|
|
// Create
|
2015-01-30 16:10:04 +01:00
|
|
|
m_toolBar = createToolBar(m_views.at(0));
|
2013-05-21 13:51:26 +02:00
|
|
|
|
2013-05-23 13:36:27 +02:00
|
|
|
m_entriesComboBox = new QComboBox;
|
|
|
|
|
m_entriesComboBox->setMinimumContentsLength(20);
|
|
|
|
|
// Make the combo box prefer to expand
|
|
|
|
|
QSizePolicy policy = m_entriesComboBox->sizePolicy();
|
|
|
|
|
policy.setHorizontalPolicy(QSizePolicy::Expanding);
|
|
|
|
|
m_entriesComboBox->setSizePolicy(policy);
|
2015-01-30 16:59:25 +01:00
|
|
|
connect(m_entriesComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
|
|
|
|
this, &DiffEditor::setCurrentDiffFileIndex);
|
2014-01-31 09:01:49 +01:00
|
|
|
m_toolBar->addWidget(m_entriesComboBox);
|
2013-05-07 14:02:08 +02:00
|
|
|
|
2015-01-30 16:59:25 +01:00
|
|
|
m_whitespaceButton = new QToolButton(m_toolBar);
|
|
|
|
|
m_whitespaceButton->setText(tr("Ignore Whitespace"));
|
|
|
|
|
m_whitespaceButton->setCheckable(true);
|
|
|
|
|
m_whitespaceButton->setChecked(m_document->ignoreWhitespace());
|
|
|
|
|
m_whitespaceButtonAction = m_toolBar->addWidget(m_whitespaceButton);
|
2013-05-07 14:02:08 +02:00
|
|
|
|
2014-01-31 09:01:49 +01:00
|
|
|
QLabel *contextLabel = new QLabel(m_toolBar);
|
2013-05-30 12:01:07 +02:00
|
|
|
contextLabel->setText(tr("Context Lines:"));
|
2013-06-04 10:53:03 +02:00
|
|
|
contextLabel->setContentsMargins(6, 0, 6, 0);
|
2014-10-24 14:11:12 +02:00
|
|
|
m_contextLabelAction = m_toolBar->addWidget(contextLabel);
|
2013-05-07 14:02:08 +02:00
|
|
|
|
2015-01-30 16:59:25 +01:00
|
|
|
m_contextSpinBox = new QSpinBox(m_toolBar);
|
|
|
|
|
m_contextSpinBox->setRange(1, 100);
|
|
|
|
|
m_contextSpinBox->setValue(m_document->contextLineCount());
|
|
|
|
|
m_contextSpinBox->setFrame(false);
|
|
|
|
|
m_contextSpinBox->setSizePolicy(QSizePolicy::Minimum,
|
|
|
|
|
QSizePolicy::Expanding); // Mac Qt5
|
|
|
|
|
m_contextSpinBoxAction = m_toolBar->addWidget(m_contextSpinBox);
|
2013-05-07 14:02:08 +02:00
|
|
|
|
2014-01-31 09:01:49 +01:00
|
|
|
QToolButton *toggleDescription = new QToolButton(m_toolBar);
|
2015-01-30 16:10:04 +01:00
|
|
|
toggleDescription->setIcon(QIcon(QLatin1String(Constants::ICON_TOP_BAR)));
|
2014-01-30 17:04:54 +01:00
|
|
|
toggleDescription->setCheckable(true);
|
2015-01-30 16:59:25 +01:00
|
|
|
toggleDescription->setChecked(m_showDescription);
|
2014-01-31 09:01:49 +01:00
|
|
|
m_toggleDescriptionAction = m_toolBar->addWidget(toggleDescription);
|
2015-01-30 16:59:25 +01:00
|
|
|
updateDescription();
|
2014-01-30 17:04:54 +01:00
|
|
|
|
2014-02-13 16:43:28 +01:00
|
|
|
QToolButton *reloadButton = new QToolButton(m_toolBar);
|
2014-06-12 17:54:46 +02:00
|
|
|
reloadButton->setIcon(QIcon(QLatin1String(Core::Constants::ICON_RELOAD_GRAY)));
|
2014-02-13 16:43:28 +01:00
|
|
|
reloadButton->setToolTip(tr("Reload Editor"));
|
2014-07-04 13:55:51 +02:00
|
|
|
m_reloadAction = m_toolBar->addWidget(reloadButton);
|
2015-01-30 16:59:25 +01:00
|
|
|
documentStateChanged();
|
2014-07-04 13:55:51 +02:00
|
|
|
|
|
|
|
|
QToolButton *toggleSync = new QToolButton(m_toolBar);
|
|
|
|
|
toggleSync->setIcon(QIcon(QLatin1String(Core::Constants::ICON_LINK)));
|
|
|
|
|
toggleSync->setCheckable(true);
|
2015-01-30 16:59:25 +01:00
|
|
|
m_toggleSyncAction = m_toolBar->addWidget(toggleSync);
|
2014-02-13 16:43:28 +01:00
|
|
|
|
|
|
|
|
m_diffEditorSwitcher = new QToolButton(m_toolBar);
|
|
|
|
|
m_toolBar->addWidget(m_diffEditorSwitcher);
|
|
|
|
|
updateDiffEditorSwitcher();
|
|
|
|
|
|
2015-01-30 16:59:25 +01:00
|
|
|
connect(m_whitespaceButton, &QToolButton::clicked,
|
|
|
|
|
this, &DiffEditor::ignoreWhitespaceHasChanged);
|
|
|
|
|
connect(m_contextSpinBox, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
|
|
|
|
|
this, &DiffEditor::contextLineCountHasChanged);
|
|
|
|
|
connect(toggleSync, &QAbstractButton::clicked, this, &DiffEditor::toggleSync);
|
2015-01-28 13:45:02 +01:00
|
|
|
connect(toggleDescription, &QAbstractButton::clicked,
|
2015-01-30 16:59:25 +01:00
|
|
|
this, &DiffEditor::toggleDescription);
|
2015-01-28 13:45:02 +01:00
|
|
|
connect(m_diffEditorSwitcher, &QAbstractButton::clicked,
|
2015-01-30 16:10:04 +01:00
|
|
|
this, [this]() { showDiffView(nextView()); });
|
2013-12-16 16:19:40 +01:00
|
|
|
|
2015-01-30 16:59:25 +01:00
|
|
|
connect(reloadButton, &QAbstractButton::clicked, this, [this]() { m_document->reload(); });
|
|
|
|
|
connect(m_document.data(), &DiffEditorDocument::temporaryStateChanged,
|
|
|
|
|
this, &DiffEditor::documentStateChanged);
|
2014-02-11 13:00:35 +01:00
|
|
|
|
2015-01-30 16:59:25 +01:00
|
|
|
return m_toolBar;
|
2014-02-11 13:00:35 +01:00
|
|
|
}
|
|
|
|
|
|
2015-01-30 16:59:25 +01:00
|
|
|
void DiffEditor::documentHasChanged()
|
2014-02-11 13:00:35 +01:00
|
|
|
{
|
2015-01-30 16:59:25 +01:00
|
|
|
m_ignoreChanges = true;
|
|
|
|
|
const QList<FileData> diffFileList = m_document->diffFiles();
|
2014-02-11 13:00:35 +01:00
|
|
|
|
2015-01-30 16:59:25 +01:00
|
|
|
currentView()->setDiff(diffFileList, m_document->baseDirectory());
|
2014-02-11 13:00:35 +01:00
|
|
|
|
2013-05-23 13:36:27 +02:00
|
|
|
m_entriesComboBox->clear();
|
2015-01-30 16:59:25 +01:00
|
|
|
int index = 0;
|
2013-05-23 13:36:27 +02:00
|
|
|
const int count = diffFileList.count();
|
|
|
|
|
for (int i = 0; i < count; i++) {
|
2014-02-13 16:43:28 +01:00
|
|
|
const DiffFileInfo leftEntry = diffFileList.at(i).leftFileInfo;
|
|
|
|
|
const DiffFileInfo rightEntry = diffFileList.at(i).rightFileInfo;
|
2015-01-10 23:40:32 +02:00
|
|
|
const QString leftShortFileName = Utils::FileName::fromString(leftEntry.fileName).fileName();
|
|
|
|
|
const QString rightShortFileName = Utils::FileName::fromString(rightEntry.fileName).fileName();
|
2013-05-23 13:36:27 +02:00
|
|
|
QString itemText;
|
|
|
|
|
QString itemToolTip;
|
|
|
|
|
if (leftEntry.fileName == rightEntry.fileName) {
|
|
|
|
|
itemText = leftShortFileName;
|
|
|
|
|
|
|
|
|
|
if (leftEntry.typeInfo.isEmpty() && rightEntry.typeInfo.isEmpty()) {
|
|
|
|
|
itemToolTip = leftEntry.fileName;
|
|
|
|
|
} else {
|
|
|
|
|
itemToolTip = tr("[%1] vs. [%2] %3")
|
2014-02-13 16:43:28 +01:00
|
|
|
.arg(leftEntry.typeInfo,
|
|
|
|
|
rightEntry.typeInfo,
|
|
|
|
|
leftEntry.fileName);
|
2013-05-23 13:36:27 +02:00
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (leftShortFileName == rightShortFileName) {
|
|
|
|
|
itemText = leftShortFileName;
|
|
|
|
|
} else {
|
|
|
|
|
itemText = tr("%1 vs. %2")
|
2014-02-13 16:43:28 +01:00
|
|
|
.arg(leftShortFileName,
|
|
|
|
|
rightShortFileName);
|
2013-05-23 13:36:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (leftEntry.typeInfo.isEmpty() && rightEntry.typeInfo.isEmpty()) {
|
|
|
|
|
itemToolTip = tr("%1 vs. %2")
|
2014-02-13 16:43:28 +01:00
|
|
|
.arg(leftEntry.fileName,
|
|
|
|
|
rightEntry.fileName);
|
2013-05-23 13:36:27 +02:00
|
|
|
} else {
|
|
|
|
|
itemToolTip = tr("[%1] %2 vs. [%3] %4")
|
2014-02-13 16:43:28 +01:00
|
|
|
.arg(leftEntry.typeInfo,
|
|
|
|
|
leftEntry.fileName,
|
|
|
|
|
rightEntry.typeInfo,
|
|
|
|
|
rightEntry.fileName);
|
2013-05-23 13:36:27 +02:00
|
|
|
}
|
|
|
|
|
}
|
2015-01-30 16:59:25 +01:00
|
|
|
if (m_currentFileChunk.first == leftEntry.fileName
|
|
|
|
|
&& m_currentFileChunk.second == rightEntry.fileName)
|
|
|
|
|
index = i;
|
2013-05-23 13:36:27 +02:00
|
|
|
m_entriesComboBox->addItem(itemText);
|
2015-01-30 16:59:25 +01:00
|
|
|
m_entriesComboBox->setItemData(m_entriesComboBox->count() - 1,
|
|
|
|
|
leftEntry.fileName, Qt::UserRole);
|
|
|
|
|
m_entriesComboBox->setItemData(m_entriesComboBox->count() - 1,
|
|
|
|
|
rightEntry.fileName, Qt::UserRole + 1);
|
2014-02-13 16:43:28 +01:00
|
|
|
m_entriesComboBox->setItemData(m_entriesComboBox->count() - 1,
|
|
|
|
|
itemToolTip, Qt::ToolTipRole);
|
2013-05-23 13:36:27 +02:00
|
|
|
}
|
2015-01-30 16:59:25 +01:00
|
|
|
|
|
|
|
|
m_ignoreChanges = false;
|
|
|
|
|
|
|
|
|
|
setCurrentDiffFileIndex(m_entriesComboBox->count() > 0 ? index : -1);
|
2013-05-23 13:36:27 +02:00
|
|
|
}
|
|
|
|
|
|
2015-01-30 16:59:25 +01:00
|
|
|
void DiffEditor::toggleDescription()
|
2013-05-23 13:36:27 +02:00
|
|
|
{
|
2015-01-30 16:59:25 +01:00
|
|
|
m_showDescription = !m_showDescription;
|
|
|
|
|
saveSetting(QLatin1String(descriptionVisibleKeyC), m_showDescription);
|
|
|
|
|
updateDescription();
|
2013-05-23 13:36:27 +02:00
|
|
|
}
|
|
|
|
|
|
2015-01-30 16:59:25 +01:00
|
|
|
void DiffEditor::updateDescription()
|
2014-01-30 17:04:54 +01:00
|
|
|
{
|
2015-01-30 16:59:25 +01:00
|
|
|
QString description = m_document->description();
|
2014-01-30 17:04:54 +01:00
|
|
|
m_descriptionWidget->setPlainText(description);
|
2015-01-30 16:59:25 +01:00
|
|
|
m_descriptionWidget->setVisible(m_showDescription && !description.isEmpty());
|
|
|
|
|
|
|
|
|
|
QTC_ASSERT(m_toolBar, return);
|
|
|
|
|
QTC_ASSERT(m_toggleDescriptionAction, return);
|
|
|
|
|
|
|
|
|
|
QWidget *toggle = m_toolBar->widgetForAction(m_toggleDescriptionAction);
|
|
|
|
|
toggle->setToolTip(m_showDescription ? tr("Hide Change Description")
|
|
|
|
|
: tr("Show Change Description"));
|
|
|
|
|
m_toggleDescriptionAction->setVisible(!description.isEmpty());
|
2014-01-30 17:04:54 +01:00
|
|
|
}
|
|
|
|
|
|
2015-01-30 16:59:25 +01:00
|
|
|
void DiffEditor::contextLineCountHasChanged(int lines)
|
2014-01-30 17:04:54 +01:00
|
|
|
{
|
2015-01-30 16:59:25 +01:00
|
|
|
QTC_ASSERT(!m_document->isContextLineCountForced(), return);
|
|
|
|
|
if (m_ignoreChanges || lines == m_document->contextLineCount())
|
|
|
|
|
return;
|
2014-01-30 17:04:54 +01:00
|
|
|
|
2015-01-30 16:59:25 +01:00
|
|
|
m_document->setContextLineCount(lines);
|
|
|
|
|
saveSetting(QLatin1String(contextLineCountKeyC), lines);
|
|
|
|
|
|
|
|
|
|
m_document->reload();
|
|
|
|
|
}
|
2014-01-30 17:04:54 +01:00
|
|
|
|
2015-01-30 16:59:25 +01:00
|
|
|
void DiffEditor::ignoreWhitespaceHasChanged(bool ignore)
|
|
|
|
|
{
|
|
|
|
|
if (m_ignoreChanges || ignore == m_document->ignoreWhitespace())
|
2014-01-30 17:04:54 +01:00
|
|
|
return;
|
|
|
|
|
|
2015-01-30 16:59:25 +01:00
|
|
|
m_document->setIgnoreWhitespace(ignore);
|
|
|
|
|
saveSetting(QLatin1String(ignoreWhitespaceKeyC), ignore);
|
|
|
|
|
m_document->reload();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DiffEditor::prepareForReload()
|
|
|
|
|
{
|
|
|
|
|
documentStateChanged(); // To update actions...
|
|
|
|
|
|
|
|
|
|
QTC_ASSERT(currentView(), return);
|
|
|
|
|
|
|
|
|
|
if (m_entriesComboBox->count() > 0) {
|
|
|
|
|
m_currentFileChunk
|
|
|
|
|
= qMakePair(m_entriesComboBox->itemData(m_currentDiffFileIndex, Qt::UserRole).toString(),
|
|
|
|
|
m_entriesComboBox->itemData(m_currentDiffFileIndex, Qt::UserRole + 1).toString());
|
|
|
|
|
} else {
|
|
|
|
|
m_currentFileChunk = qMakePair(QString(), QString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_ignoreChanges = true;
|
|
|
|
|
m_contextSpinBox->setValue(m_document->contextLineCount());
|
|
|
|
|
m_whitespaceButton->setChecked(m_document->ignoreWhitespace());
|
|
|
|
|
m_ignoreChanges = false;
|
|
|
|
|
currentView()->beginOperation();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DiffEditor::reloadHasFinished(bool success)
|
|
|
|
|
{
|
|
|
|
|
if (!currentView())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
m_currentFileChunk = qMakePair(QString(), QString());
|
|
|
|
|
|
|
|
|
|
currentView()->endOperation(success);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DiffEditor::updateEntryToolTip()
|
|
|
|
|
{
|
|
|
|
|
const QString &toolTip = m_entriesComboBox->itemData(
|
|
|
|
|
m_entriesComboBox->currentIndex(), Qt::ToolTipRole).toString();
|
|
|
|
|
m_entriesComboBox->setToolTip(toolTip);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DiffEditor::setCurrentDiffFileIndex(int index)
|
|
|
|
|
{
|
|
|
|
|
if (m_ignoreChanges)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
QTC_ASSERT((index < 0) != (m_entriesComboBox->count() > 0), return);
|
|
|
|
|
|
|
|
|
|
m_ignoreChanges = true;
|
|
|
|
|
|
|
|
|
|
m_currentDiffFileIndex = index;
|
|
|
|
|
currentView()->setCurrentDiffFileIndex(index);
|
|
|
|
|
|
|
|
|
|
m_entriesComboBox->setCurrentIndex(m_entriesComboBox->count() > 0 ? qMax(0, index) : -1);
|
|
|
|
|
updateEntryToolTip();
|
2014-01-30 17:04:54 +01:00
|
|
|
|
2015-01-30 16:59:25 +01:00
|
|
|
m_ignoreChanges = false;
|
2014-02-13 16:43:28 +01:00
|
|
|
}
|
|
|
|
|
|
2015-01-30 16:59:25 +01:00
|
|
|
void DiffEditor::documentStateChanged()
|
2014-07-04 13:55:51 +02:00
|
|
|
{
|
2015-01-30 16:59:25 +01:00
|
|
|
const bool canReload = m_document->isTemporary();
|
|
|
|
|
const bool contextVisible = !m_document->isContextLineCountForced();
|
2014-11-06 13:23:40 +01:00
|
|
|
|
2015-01-30 16:59:25 +01:00
|
|
|
m_whitespaceButtonAction->setVisible(canReload);
|
|
|
|
|
m_contextLabelAction->setVisible(canReload && contextVisible);
|
|
|
|
|
m_contextSpinBoxAction->setVisible(canReload && contextVisible);
|
|
|
|
|
m_reloadAction->setVisible(canReload);
|
2014-07-04 13:55:51 +02:00
|
|
|
}
|
|
|
|
|
|
2015-01-30 16:10:04 +01:00
|
|
|
void DiffEditor::updateDiffEditorSwitcher()
|
2014-02-13 16:43:28 +01:00
|
|
|
{
|
2015-01-30 16:10:04 +01:00
|
|
|
if (!m_diffEditorSwitcher)
|
|
|
|
|
return;
|
2015-01-30 16:59:25 +01:00
|
|
|
IDiffView *next = nextView();
|
|
|
|
|
m_diffEditorSwitcher->setIcon(next->icon());
|
|
|
|
|
m_diffEditorSwitcher->setToolTip(next->toolTip());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DiffEditor::toggleSync()
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(currentView(), return);
|
|
|
|
|
m_sync = !m_sync;
|
|
|
|
|
saveSetting(QLatin1String(horizontalScrollBarSynchronizationKeyC), m_sync);
|
|
|
|
|
currentView()->setSync(m_sync);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DiffEditor::loadSettings()
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(currentView(), return);
|
|
|
|
|
QSettings *s = Core::ICore::settings();
|
2014-02-13 16:43:28 +01:00
|
|
|
|
2015-01-30 16:59:25 +01:00
|
|
|
// TODO: Remove in 3.6: Read legacy settings first:
|
|
|
|
|
s->beginGroup(QLatin1String(legacySettingsGroupC));
|
|
|
|
|
const bool legacyExists = s->contains(QLatin1String(useDiffEditorKeyC));
|
|
|
|
|
const bool legacyEditor = s->value(
|
|
|
|
|
QLatin1String(useDiffEditorKeyC), true).toBool();
|
|
|
|
|
s->remove(QLatin1String(useDiffEditorKeyC));
|
|
|
|
|
s->endGroup();
|
|
|
|
|
|
|
|
|
|
// Save legacy settings to current settings:
|
|
|
|
|
if (legacyExists) {
|
|
|
|
|
saveSetting(QLatin1String(diffViewKeyC), legacyEditor ? m_views.at(0)->id().toSetting() :
|
|
|
|
|
m_views.at(1)->id().toSetting());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Read current settings:
|
|
|
|
|
s->beginGroup(QLatin1String(settingsGroupC));
|
|
|
|
|
m_showDescription = s->value(QLatin1String(descriptionVisibleKeyC),
|
|
|
|
|
true).toBool();
|
|
|
|
|
m_sync = s->value(QLatin1String(horizontalScrollBarSynchronizationKeyC),
|
|
|
|
|
true).toBool();
|
|
|
|
|
m_document->setIgnoreWhitespace(s->value(QLatin1String(ignoreWhitespaceKeyC), false).toBool());
|
|
|
|
|
m_document->setContextLineCount(s->value(QLatin1String(contextLineCountKeyC), 3).toInt());
|
|
|
|
|
Core::Id id = Core::Id::fromSetting(s->value(QLatin1String(diffViewKeyC)));
|
|
|
|
|
s->endGroup();
|
|
|
|
|
|
|
|
|
|
IDiffView *view = Utils::findOr(m_views, m_views.at(0), [id](IDiffView *v) { return v->id() == id; });
|
|
|
|
|
QTC_ASSERT(view, return);
|
|
|
|
|
|
|
|
|
|
setupView(view);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DiffEditor::saveSetting(const QString &key, const QVariant &value) const
|
|
|
|
|
{
|
|
|
|
|
QSettings *s = Core::ICore::settings();
|
|
|
|
|
s->beginGroup(QLatin1String(settingsGroupC));
|
|
|
|
|
s->setValue(key, value);
|
|
|
|
|
s->endGroup();
|
2014-02-13 16:43:28 +01:00
|
|
|
}
|
|
|
|
|
|
2015-01-30 16:10:04 +01:00
|
|
|
void DiffEditor::addView(IDiffView *view)
|
2014-02-13 16:43:28 +01:00
|
|
|
{
|
2015-01-30 16:10:04 +01:00
|
|
|
QTC_ASSERT(!m_views.contains(view), return);
|
|
|
|
|
m_views.append(view);
|
|
|
|
|
m_stackedWidget->addWidget(view->widget());
|
2015-01-30 16:59:25 +01:00
|
|
|
if (m_views.count() == 1)
|
|
|
|
|
setCurrentView(view);
|
|
|
|
|
|
|
|
|
|
connect(view, &IDiffView::currentDiffFileIndexChanged, this, &DiffEditor::setCurrentDiffFileIndex);
|
2015-01-30 16:10:04 +01:00
|
|
|
}
|
2014-02-13 16:43:28 +01:00
|
|
|
|
2015-01-30 16:10:04 +01:00
|
|
|
IDiffView *DiffEditor::currentView() const
|
|
|
|
|
{
|
2015-02-23 15:52:08 +01:00
|
|
|
if (m_currentViewIndex < 0)
|
|
|
|
|
return 0;
|
2015-01-30 16:10:04 +01:00
|
|
|
return m_views.at(m_currentViewIndex);
|
|
|
|
|
}
|
2014-01-30 17:04:54 +01:00
|
|
|
|
2015-01-30 16:10:04 +01:00
|
|
|
void DiffEditor::setCurrentView(IDiffView *view)
|
|
|
|
|
{
|
|
|
|
|
const int pos = Utils::indexOf(m_views, [view](IDiffView *v) { return v == view; });
|
|
|
|
|
QTC_ASSERT(pos >= 0 && pos < m_views.count(), return);
|
|
|
|
|
m_currentViewIndex = pos;
|
2014-02-13 16:43:28 +01:00
|
|
|
}
|
|
|
|
|
|
2015-01-30 16:10:04 +01:00
|
|
|
IDiffView *DiffEditor::nextView()
|
2014-02-13 16:43:28 +01:00
|
|
|
{
|
2015-02-23 15:52:08 +01:00
|
|
|
int pos = m_currentViewIndex + 1;
|
|
|
|
|
if (pos >= m_views.count())
|
|
|
|
|
pos = 0;
|
2014-02-13 16:43:28 +01:00
|
|
|
|
2015-02-23 15:52:08 +01:00
|
|
|
return m_views.at(pos);
|
2015-01-30 16:10:04 +01:00
|
|
|
}
|
2014-02-13 16:43:28 +01:00
|
|
|
|
2015-01-30 16:59:25 +01:00
|
|
|
void DiffEditor::setupView(IDiffView *view)
|
2015-01-30 16:10:04 +01:00
|
|
|
{
|
2015-01-30 16:59:25 +01:00
|
|
|
QTC_ASSERT(view, return);
|
|
|
|
|
setCurrentView(view);
|
2015-01-30 16:10:04 +01:00
|
|
|
|
2015-01-30 16:59:25 +01:00
|
|
|
saveSetting(QLatin1String(diffViewKeyC), currentView()->id().toSetting());
|
2014-02-13 16:43:28 +01:00
|
|
|
|
2015-01-30 16:59:25 +01:00
|
|
|
m_toggleSyncAction->setVisible(currentView()->supportsSync());
|
|
|
|
|
m_toggleSyncAction->setToolTip(currentView()->syncToolTip());
|
|
|
|
|
m_toggleSyncAction->setChecked(m_sync);
|
2014-02-13 16:43:28 +01:00
|
|
|
|
2015-01-30 16:59:25 +01:00
|
|
|
view->setDocument(m_document.data());
|
|
|
|
|
view->setSync(m_sync);
|
2014-02-13 16:43:28 +01:00
|
|
|
|
2015-01-30 16:59:25 +01:00
|
|
|
view->beginOperation();
|
|
|
|
|
view->setDiff(m_document->diffFiles(), m_document->baseDirectory());
|
|
|
|
|
view->endOperation(true);
|
|
|
|
|
view->setCurrentDiffFileIndex(m_currentDiffFileIndex);
|
2015-01-30 16:10:04 +01:00
|
|
|
|
2015-01-30 16:59:25 +01:00
|
|
|
m_stackedWidget->setCurrentWidget(view->widget());
|
2014-02-13 16:43:28 +01:00
|
|
|
|
2015-01-30 16:59:25 +01:00
|
|
|
updateDiffEditorSwitcher();
|
|
|
|
|
if (widget())
|
|
|
|
|
widget()->setFocusProxy(view->widget());
|
2014-02-13 16:43:28 +01:00
|
|
|
}
|
|
|
|
|
|
2015-01-30 16:59:25 +01:00
|
|
|
void DiffEditor::showDiffView(IDiffView *view)
|
2014-02-13 16:43:28 +01:00
|
|
|
{
|
2015-01-30 16:59:25 +01:00
|
|
|
if (currentView() == view)
|
|
|
|
|
return;
|
2014-02-13 16:43:28 +01:00
|
|
|
|
2015-01-30 16:59:25 +01:00
|
|
|
if (currentView()) // during initialization
|
|
|
|
|
currentView()->setDocument(0);
|
2014-02-13 16:43:28 +01:00
|
|
|
|
2015-01-30 16:59:25 +01:00
|
|
|
QTC_ASSERT(view, return);
|
|
|
|
|
setupView(view);
|
2014-01-30 17:04:54 +01:00
|
|
|
}
|
|
|
|
|
|
2015-01-30 14:59:41 +01:00
|
|
|
} // namespace Internal
|
2013-05-07 14:02:08 +02:00
|
|
|
} // namespace DiffEditor
|
2014-01-30 17:04:54 +01:00
|
|
|
|
|
|
|
|
#include "diffeditor.moc"
|