forked from qt-creator/qt-creator
DiffEditor: Modernize
* Use member init * Use nullptr * Use range-for * omit QLatin1{String|Char} where possible Change-Id: Ib231b747cdd9073b3d4fc6779b8e0afb2b404a31 Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: André Hartmann <aha_1980@gmx.de>
This commit is contained in:
committed by
André Hartmann
parent
53a151074a
commit
aae3056b33
@@ -191,7 +191,7 @@ void DescriptionEditorWidget::mouseReleaseEvent(QMouseEvent *e)
|
||||
bool DescriptionEditorWidget::findContentsUnderCursor(const QTextCursor &cursor)
|
||||
{
|
||||
m_currentCursor = cursor;
|
||||
return cursor.block().text() == QLatin1String(Constants::EXPAND_BRANCHES);
|
||||
return cursor.block().text() == Constants::EXPAND_BRANCHES;
|
||||
}
|
||||
|
||||
void DescriptionEditorWidget::highlightCurrentContents()
|
||||
@@ -210,28 +210,13 @@ void DescriptionEditorWidget::handleCurrentContents()
|
||||
{
|
||||
m_currentCursor.select(QTextCursor::LineUnderCursor);
|
||||
m_currentCursor.removeSelectedText();
|
||||
m_currentCursor.insertText(QLatin1String("Branches: Expanding..."));
|
||||
m_currentCursor.insertText("Branches: Expanding...");
|
||||
emit requestBranchList();
|
||||
}
|
||||
|
||||
///////////////////////////////// DiffEditor //////////////////////////////////
|
||||
|
||||
DiffEditor::DiffEditor()
|
||||
: m_document(0)
|
||||
, m_descriptionWidget(0)
|
||||
, m_stackedWidget(0)
|
||||
, m_toolBar(0)
|
||||
, m_entriesComboBox(0)
|
||||
, m_contextSpinBox(0)
|
||||
, m_toggleSyncAction(0)
|
||||
, m_whitespaceButtonAction(0)
|
||||
, m_toggleDescriptionAction(0)
|
||||
, m_reloadAction(0)
|
||||
, m_viewSwitcherAction(0)
|
||||
, m_currentViewIndex(-1)
|
||||
, m_currentDiffFileIndex(-1)
|
||||
, m_sync(false)
|
||||
, m_showDescription(true)
|
||||
{
|
||||
// Editor:
|
||||
setDuplicateSupported(true);
|
||||
@@ -458,7 +443,7 @@ void DiffEditor::toggleDescription()
|
||||
return;
|
||||
|
||||
m_showDescription = !m_showDescription;
|
||||
saveSetting(QLatin1String(descriptionVisibleKeyC), m_showDescription);
|
||||
saveSetting(descriptionVisibleKeyC, m_showDescription);
|
||||
updateDescription();
|
||||
}
|
||||
|
||||
@@ -486,7 +471,7 @@ void DiffEditor::contextLineCountHasChanged(int lines)
|
||||
return;
|
||||
|
||||
m_document->setContextLineCount(lines);
|
||||
saveSetting(QLatin1String(contextLineCountKeyC), lines);
|
||||
saveSetting(contextLineCountKeyC, lines);
|
||||
|
||||
m_document->reload();
|
||||
}
|
||||
@@ -498,7 +483,7 @@ void DiffEditor::ignoreWhitespaceHasChanged()
|
||||
if (m_ignoreChanges.isLocked() || ignore == m_document->ignoreWhitespace())
|
||||
return;
|
||||
m_document->setIgnoreWhitespace(ignore);
|
||||
saveSetting(QLatin1String(ignoreWhitespaceKeyC), ignore);
|
||||
saveSetting(ignoreWhitespaceKeyC, ignore);
|
||||
|
||||
m_document->reload();
|
||||
}
|
||||
@@ -605,7 +590,7 @@ void DiffEditor::toggleSync()
|
||||
|
||||
QTC_ASSERT(currentView(), return);
|
||||
m_sync = !m_sync;
|
||||
saveSetting(QLatin1String(horizontalScrollBarSynchronizationKeyC), m_sync);
|
||||
saveSetting(horizontalScrollBarSynchronizationKeyC, m_sync);
|
||||
currentView()->setSync(m_sync);
|
||||
}
|
||||
|
||||
@@ -615,12 +600,12 @@ IDiffView *DiffEditor::loadSettings()
|
||||
QSettings *s = Core::ICore::settings();
|
||||
|
||||
// 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->beginGroup(settingsGroupC);
|
||||
m_showDescription = s->value(descriptionVisibleKeyC, true).toBool();
|
||||
m_sync = s->value(horizontalScrollBarSynchronizationKeyC, true).toBool();
|
||||
m_document->setIgnoreWhitespace(s->value(ignoreWhitespaceKeyC, false).toBool());
|
||||
m_document->setContextLineCount(s->value(contextLineCountKeyC, 3).toInt());
|
||||
Core::Id id = Core::Id::fromSetting(s->value(diffViewKeyC));
|
||||
s->endGroup();
|
||||
|
||||
IDiffView *view = Utils::findOr(m_views, m_views.at(0),
|
||||
@@ -633,7 +618,7 @@ IDiffView *DiffEditor::loadSettings()
|
||||
void DiffEditor::saveSetting(const QString &key, const QVariant &value) const
|
||||
{
|
||||
QSettings *s = Core::ICore::settings();
|
||||
s->beginGroup(QLatin1String(settingsGroupC));
|
||||
s->beginGroup(settingsGroupC);
|
||||
s->setValue(key, value);
|
||||
s->endGroup();
|
||||
}
|
||||
@@ -677,7 +662,7 @@ void DiffEditor::setupView(IDiffView *view)
|
||||
QTC_ASSERT(view, return);
|
||||
setCurrentView(view);
|
||||
|
||||
saveSetting(QLatin1String(diffViewKeyC), currentView()->id().toSetting());
|
||||
saveSetting(diffViewKeyC, currentView()->id().toSetting());
|
||||
|
||||
{
|
||||
Utils::GuardLocker guard(m_ignoreChanges);
|
||||
|
@@ -93,14 +93,14 @@ private:
|
||||
void setupView(IDiffView *view);
|
||||
|
||||
QSharedPointer<DiffEditorDocument> m_document;
|
||||
DescriptionEditorWidget *m_descriptionWidget;
|
||||
UnifiedView *m_unifiedView;
|
||||
SideBySideView *m_sideBySideView;
|
||||
QStackedWidget *m_stackedWidget;
|
||||
DescriptionEditorWidget *m_descriptionWidget = nullptr;
|
||||
UnifiedView *m_unifiedView = nullptr;
|
||||
SideBySideView *m_sideBySideView = nullptr;
|
||||
QStackedWidget *m_stackedWidget = nullptr;
|
||||
QVector<IDiffView *> m_views;
|
||||
QToolBar *m_toolBar;
|
||||
QComboBox *m_entriesComboBox;
|
||||
QSpinBox *m_contextSpinBox;
|
||||
QToolBar *m_toolBar = nullptr;
|
||||
QComboBox *m_entriesComboBox = nullptr;
|
||||
QSpinBox *m_contextSpinBox = nullptr;
|
||||
QAction *m_contextSpinBoxAction = nullptr;
|
||||
QAction *m_toggleSyncAction;
|
||||
QAction *m_whitespaceButtonAction;
|
||||
@@ -109,11 +109,11 @@ private:
|
||||
QAction *m_contextLabelAction = nullptr;
|
||||
QAction *m_viewSwitcherAction;
|
||||
QPair<QString, QString> m_currentFileChunk;
|
||||
int m_currentViewIndex;
|
||||
int m_currentDiffFileIndex;
|
||||
int m_currentViewIndex = -1;
|
||||
int m_currentDiffFileIndex = -1;
|
||||
Utils::Guard m_ignoreChanges;
|
||||
bool m_sync;
|
||||
bool m_showDescription;
|
||||
bool m_sync = false;
|
||||
bool m_showDescription = true;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -39,10 +39,7 @@ namespace DiffEditor {
|
||||
|
||||
DiffEditorController::DiffEditorController(Core::IDocument *document) :
|
||||
QObject(document),
|
||||
m_document(qobject_cast<Internal::DiffEditorDocument *>(document)),
|
||||
m_isReloading(false),
|
||||
m_diffFileIndex(-1),
|
||||
m_chunkIndex(-1)
|
||||
m_document(qobject_cast<Internal::DiffEditorDocument *>(document))
|
||||
{
|
||||
QTC_ASSERT(m_document, return);
|
||||
m_document->setController(this);
|
||||
@@ -109,7 +106,7 @@ void DiffEditorController::setDescription(const QString &description)
|
||||
void DiffEditorController::branchesReceived(const QString &branches)
|
||||
{
|
||||
QString tmp = m_document->description();
|
||||
tmp.replace(QLatin1String(Constants::EXPAND_BRANCHES), branches);
|
||||
tmp.replace(Constants::EXPAND_BRANCHES, branches);
|
||||
m_document->setDescription(tmp);
|
||||
}
|
||||
|
||||
|
@@ -85,9 +85,9 @@ private:
|
||||
|
||||
Internal::DiffEditorDocument *const m_document;
|
||||
|
||||
bool m_isReloading;
|
||||
int m_diffFileIndex;
|
||||
int m_chunkIndex;
|
||||
bool m_isReloading = false;
|
||||
int m_diffFileIndex = -1;
|
||||
int m_chunkIndex = -1;
|
||||
|
||||
friend class Internal::DiffEditorDocument;
|
||||
};
|
||||
|
@@ -46,14 +46,10 @@ namespace DiffEditor {
|
||||
namespace Internal {
|
||||
|
||||
DiffEditorDocument::DiffEditorDocument() :
|
||||
Core::BaseTextDocument(),
|
||||
m_controller(0),
|
||||
m_contextLineCount(3),
|
||||
m_isContextLineCountForced(false),
|
||||
m_ignoreWhitespace(false)
|
||||
Core::BaseTextDocument()
|
||||
{
|
||||
setId(Constants::DIFF_EDITOR_ID);
|
||||
setMimeType(QLatin1String(Constants::DIFF_EDITOR_MIMETYPE));
|
||||
setMimeType(Constants::DIFF_EDITOR_MIMETYPE);
|
||||
setTemporary(true);
|
||||
}
|
||||
|
||||
@@ -111,8 +107,8 @@ QString DiffEditorDocument::makePatch(int fileIndex, int chunkIndex,
|
||||
|
||||
QString leftPrefix, rightPrefix;
|
||||
if (addPrefix) {
|
||||
leftPrefix = QLatin1String("a/");
|
||||
rightPrefix = QLatin1String("b/");
|
||||
leftPrefix = "a/";
|
||||
rightPrefix = "b/";
|
||||
}
|
||||
return DiffUtils::makePatch(chunkData,
|
||||
leftPrefix + fileName,
|
||||
@@ -287,10 +283,10 @@ QString DiffEditorDocument::fallbackSaveAsFileName() const
|
||||
|
||||
const QString desc = description();
|
||||
if (!desc.isEmpty()) {
|
||||
QString name = QString::fromLatin1("0001-%1").arg(desc.left(desc.indexOf(QLatin1Char('\n'))));
|
||||
QString name = QString::fromLatin1("0001-%1").arg(desc.left(desc.indexOf('\n')));
|
||||
name = FileUtils::fileSystemFriendlyName(name);
|
||||
name.truncate(maxSubjectLength);
|
||||
name.append(QLatin1String(".patch"));
|
||||
name.append(".patch");
|
||||
return name;
|
||||
}
|
||||
return QStringLiteral("0001.patch");
|
||||
@@ -303,17 +299,17 @@ static void formatGitDescription(QString *description)
|
||||
{
|
||||
QString result;
|
||||
result.reserve(description->size());
|
||||
foreach (QString line, description->split(QLatin1Char('\n'))) {
|
||||
if (line.startsWith(QLatin1String("commit "))
|
||||
|| line.startsWith(QLatin1String("Branches: <Expand>"))) {
|
||||
const auto descriptionList = description->split('\n');
|
||||
for (QString line : descriptionList) {
|
||||
if (line.startsWith("commit ") || line.startsWith("Branches: <Expand>"))
|
||||
continue;
|
||||
}
|
||||
if (line.startsWith(QLatin1String("Author: ")))
|
||||
line.replace(0, 8, QStringLiteral("From: "));
|
||||
else if (line.startsWith(QLatin1String(" ")))
|
||||
|
||||
if (line.startsWith("Author: "))
|
||||
line.replace(0, 8, "From: ");
|
||||
else if (line.startsWith(" "))
|
||||
line.remove(0, 4);
|
||||
result.append(line);
|
||||
result.append(QLatin1Char('\n'));
|
||||
result.append('\n');
|
||||
}
|
||||
*description = result;
|
||||
}
|
||||
@@ -328,7 +324,7 @@ QString DiffEditorDocument::plainText() const
|
||||
const QString diff = DiffUtils::makePatch(diffFiles(), formattingOptions);
|
||||
if (!diff.isEmpty()) {
|
||||
if (!result.isEmpty())
|
||||
result += QLatin1Char('\n');
|
||||
result += '\n';
|
||||
result += diff;
|
||||
}
|
||||
return result;
|
||||
|
@@ -98,14 +98,14 @@ private:
|
||||
void endReload(bool success);
|
||||
void setController(DiffEditorController *controller);
|
||||
|
||||
DiffEditorController *m_controller;
|
||||
DiffEditorController *m_controller = nullptr;
|
||||
QList<FileData> m_diffFiles;
|
||||
QString m_baseDirectory;
|
||||
QString m_startupFile;
|
||||
QString m_description;
|
||||
int m_contextLineCount;
|
||||
bool m_isContextLineCountForced;
|
||||
bool m_ignoreWhitespace;
|
||||
int m_contextLineCount = 3;
|
||||
bool m_isContextLineCountForced = false;
|
||||
bool m_ignoreWhitespace = false;
|
||||
State m_state = LoadOK;
|
||||
|
||||
friend class ::DiffEditor::DiffEditorController;
|
||||
|
@@ -31,11 +31,11 @@ namespace DiffEditor {
|
||||
namespace Icons {
|
||||
|
||||
const Utils::Icon TOP_BAR({
|
||||
{QLatin1String(":/diffeditor/images/topbar.png"), Utils::Theme::IconsBaseColor}});
|
||||
{":/diffeditor/images/topbar.png", Utils::Theme::IconsBaseColor}});
|
||||
const Utils::Icon UNIFIED_DIFF({
|
||||
{QLatin1String(":/diffeditor/images/unifieddiff.png"), Utils::Theme::IconsBaseColor}});
|
||||
{":/diffeditor/images/unifieddiff.png", Utils::Theme::IconsBaseColor}});
|
||||
const Utils::Icon SIDEBYSIDE_DIFF({
|
||||
{QLatin1String(":/diffeditor/images/sidebysidediff.png"), Utils::Theme::IconsBaseColor}});
|
||||
{":/diffeditor/images/sidebysidediff.png", Utils::Theme::IconsBaseColor}});
|
||||
|
||||
} // namespace Icons
|
||||
} // namespace DiffEditor
|
||||
|
@@ -251,7 +251,7 @@ QList<ReloadInput> DiffOpenFilesController::reloadInputList() const
|
||||
|
||||
const QList<IDocument *> openedDocuments = DocumentModel::openedDocuments();
|
||||
|
||||
foreach (IDocument *doc, openedDocuments) {
|
||||
for (IDocument *doc : openedDocuments) {
|
||||
TextEditor::TextDocument *textDocument = qobject_cast<TextEditor::TextDocument *>(doc);
|
||||
|
||||
if (textDocument && textDocument->isModified()) {
|
||||
@@ -312,7 +312,7 @@ QList<ReloadInput> DiffModifiedFilesController::reloadInputList() const
|
||||
{
|
||||
QList<ReloadInput> result;
|
||||
|
||||
foreach (const QString fileName, m_fileNames) {
|
||||
for (const QString &fileName : m_fileNames) {
|
||||
TextEditor::TextDocument *textDocument = qobject_cast<TextEditor::TextDocument *>(
|
||||
DocumentModel::documentForFilePath(fileName));
|
||||
|
||||
@@ -623,17 +623,17 @@ void DiffEditor::Internal::DiffEditorPlugin::testMakePatch_data()
|
||||
QTest::addColumn<bool>("lastChunk");
|
||||
QTest::addColumn<QString>("patchText");
|
||||
|
||||
const QString fileName = _("a.txt");
|
||||
const QString header = _("--- ") + fileName + _("\n+++ ") + fileName + _("\n");
|
||||
const QString fileName = "a.txt";
|
||||
const QString header = "--- " + fileName + "\n+++ " + fileName + '\n';
|
||||
|
||||
QList<RowData> rows;
|
||||
rows << RowData(_("ABCD"), TextLineData::Separator);
|
||||
rows << RowData(_("EFGH"));
|
||||
ChunkData chunk;
|
||||
chunk.rows = rows;
|
||||
QString patchText = header + _("@@ -1,2 +1,1 @@\n"
|
||||
QString patchText = header + "@@ -1,2 +1,1 @@\n"
|
||||
"-ABCD\n"
|
||||
" EFGH\n");
|
||||
" EFGH\n";
|
||||
QTest::newRow("Simple not a last chunk") << chunk
|
||||
<< fileName
|
||||
<< fileName
|
||||
@@ -643,10 +643,10 @@ void DiffEditor::Internal::DiffEditorPlugin::testMakePatch_data()
|
||||
///////////
|
||||
|
||||
// chunk the same here
|
||||
patchText = header + _("@@ -1,2 +1,1 @@\n"
|
||||
patchText = header + "@@ -1,2 +1,1 @@\n"
|
||||
"-ABCD\n"
|
||||
" EFGH\n"
|
||||
"\\ No newline at end of file\n");
|
||||
"\\ No newline at end of file\n";
|
||||
|
||||
QTest::newRow("Simple last chunk") << chunk
|
||||
<< fileName
|
||||
@@ -660,10 +660,10 @@ void DiffEditor::Internal::DiffEditorPlugin::testMakePatch_data()
|
||||
rows << RowData(_("ABCD"));
|
||||
rows << RowData(_(""), TextLineData::Separator);
|
||||
chunk.rows = rows;
|
||||
patchText = header + _("@@ -1,1 +1,1 @@\n"
|
||||
patchText = header + "@@ -1,1 +1,1 @@\n"
|
||||
"-ABCD\n"
|
||||
"+ABCD\n"
|
||||
"\\ No newline at end of file\n");
|
||||
"\\ No newline at end of file\n";
|
||||
|
||||
QTest::newRow("EOL in last line removed") << chunk
|
||||
<< fileName
|
||||
@@ -674,9 +674,9 @@ void DiffEditor::Internal::DiffEditorPlugin::testMakePatch_data()
|
||||
///////////
|
||||
|
||||
// chunk the same here
|
||||
patchText = header + _("@@ -1,2 +1,1 @@\n"
|
||||
patchText = header + "@@ -1,2 +1,1 @@\n"
|
||||
" ABCD\n"
|
||||
"-\n");
|
||||
"-\n";
|
||||
|
||||
QTest::newRow("Last empty line removed") << chunk
|
||||
<< fileName
|
||||
@@ -691,11 +691,11 @@ void DiffEditor::Internal::DiffEditorPlugin::testMakePatch_data()
|
||||
rows << RowData(_(""), TextLineData::Separator);
|
||||
rows << RowData(_(""), TextLineData::Separator);
|
||||
chunk.rows = rows;
|
||||
patchText = header + _("@@ -1,2 +1,1 @@\n"
|
||||
patchText = header + "@@ -1,2 +1,1 @@\n"
|
||||
"-ABCD\n"
|
||||
"-\n"
|
||||
"+ABCD\n"
|
||||
"\\ No newline at end of file\n");
|
||||
"\\ No newline at end of file\n";
|
||||
|
||||
QTest::newRow("Two last EOLs removed") << chunk
|
||||
<< fileName
|
||||
@@ -709,10 +709,10 @@ void DiffEditor::Internal::DiffEditorPlugin::testMakePatch_data()
|
||||
rows << RowData(_("ABCD"));
|
||||
rows << RowData(TextLineData::Separator, _(""));
|
||||
chunk.rows = rows;
|
||||
patchText = header + _("@@ -1,1 +1,1 @@\n"
|
||||
patchText = header + "@@ -1,1 +1,1 @@\n"
|
||||
"-ABCD\n"
|
||||
"\\ No newline at end of file\n"
|
||||
"+ABCD\n");
|
||||
"+ABCD\n";
|
||||
|
||||
QTest::newRow("EOL to last line added") << chunk
|
||||
<< fileName
|
||||
@@ -723,9 +723,9 @@ void DiffEditor::Internal::DiffEditorPlugin::testMakePatch_data()
|
||||
///////////
|
||||
|
||||
// chunk the same here
|
||||
patchText = header + _("@@ -1,1 +1,2 @@\n"
|
||||
patchText = header + "@@ -1,1 +1,2 @@\n"
|
||||
" ABCD\n"
|
||||
"+\n");
|
||||
"+\n";
|
||||
|
||||
QTest::newRow("Last empty line added") << chunk
|
||||
<< fileName
|
||||
@@ -738,9 +738,9 @@ void DiffEditor::Internal::DiffEditorPlugin::testMakePatch_data()
|
||||
rows.clear();
|
||||
rows << RowData(_("ABCD"), _("EFGH"));
|
||||
chunk.rows = rows;
|
||||
patchText = header + _("@@ -1,1 +1,1 @@\n"
|
||||
patchText = header + "@@ -1,1 +1,1 @@\n"
|
||||
"-ABCD\n"
|
||||
"+EFGH\n");
|
||||
"+EFGH\n";
|
||||
|
||||
QTest::newRow("Last line with a newline modified") << chunk
|
||||
<< fileName
|
||||
@@ -754,10 +754,10 @@ void DiffEditor::Internal::DiffEditorPlugin::testMakePatch_data()
|
||||
rows << RowData(_("ABCD"), _("EFGH"));
|
||||
rows << RowData(_(""));
|
||||
chunk.rows = rows;
|
||||
patchText = header + _("@@ -1,2 +1,2 @@\n"
|
||||
patchText = header + "@@ -1,2 +1,2 @@\n"
|
||||
"-ABCD\n"
|
||||
"+EFGH\n"
|
||||
" \n");
|
||||
" \n";
|
||||
QTest::newRow("Not a last line with a newline modified") << chunk
|
||||
<< fileName
|
||||
<< fileName
|
||||
@@ -769,11 +769,11 @@ void DiffEditor::Internal::DiffEditorPlugin::testMakePatch_data()
|
||||
rows.clear();
|
||||
rows << RowData(_("ABCD"), _("EFGH"));
|
||||
chunk.rows = rows;
|
||||
patchText = header + _("@@ -1,1 +1,1 @@\n"
|
||||
patchText = header + "@@ -1,1 +1,1 @@\n"
|
||||
"-ABCD\n"
|
||||
"\\ No newline at end of file\n"
|
||||
"+EFGH\n"
|
||||
"\\ No newline at end of file\n");
|
||||
"\\ No newline at end of file\n";
|
||||
|
||||
QTest::newRow("Last line without a newline modified") << chunk
|
||||
<< fileName
|
||||
@@ -784,9 +784,9 @@ void DiffEditor::Internal::DiffEditorPlugin::testMakePatch_data()
|
||||
///////////
|
||||
|
||||
// chunk the same here
|
||||
patchText = header + _("@@ -1,1 +1,1 @@\n"
|
||||
patchText = header + "@@ -1,1 +1,1 @@\n"
|
||||
"-ABCD\n"
|
||||
"+EFGH\n");
|
||||
"+EFGH\n";
|
||||
QTest::newRow("Not a last line without a newline modified") << chunk
|
||||
<< fileName
|
||||
<< fileName
|
||||
@@ -799,11 +799,11 @@ void DiffEditor::Internal::DiffEditorPlugin::testMakePatch_data()
|
||||
rows << RowData(_("ABCD"), _("EFGH"));
|
||||
rows << RowData(_("IJKL"));
|
||||
chunk.rows = rows;
|
||||
patchText = header + _("@@ -1,2 +1,2 @@\n"
|
||||
patchText = header + "@@ -1,2 +1,2 @@\n"
|
||||
"-ABCD\n"
|
||||
"+EFGH\n"
|
||||
" IJKL\n"
|
||||
"\\ No newline at end of file\n");
|
||||
"\\ No newline at end of file\n";
|
||||
|
||||
QTest::newRow("Last but one line modified, last line without a newline")
|
||||
<< chunk
|
||||
@@ -815,10 +815,10 @@ void DiffEditor::Internal::DiffEditorPlugin::testMakePatch_data()
|
||||
///////////
|
||||
|
||||
// chunk the same here
|
||||
patchText = header + _("@@ -1,2 +1,2 @@\n"
|
||||
patchText = header + "@@ -1,2 +1,2 @@\n"
|
||||
"-ABCD\n"
|
||||
"+EFGH\n"
|
||||
" IJKL\n");
|
||||
" IJKL\n";
|
||||
|
||||
QTest::newRow("Last but one line modified, last line with a newline")
|
||||
<< chunk
|
||||
@@ -834,11 +834,11 @@ void DiffEditor::Internal::DiffEditorPlugin::testMakePatch_data()
|
||||
rows << RowData(TextLineData::Separator, _(""));
|
||||
rows << RowData(_(""), _("EFGH"));
|
||||
chunk.rows = rows;
|
||||
patchText = header + _("@@ -1,1 +1,3 @@\n"
|
||||
patchText = header + "@@ -1,1 +1,3 @@\n"
|
||||
" ABCD\n"
|
||||
"+\n"
|
||||
"+EFGH\n"
|
||||
"\\ No newline at end of file\n");
|
||||
"\\ No newline at end of file\n";
|
||||
|
||||
QTest::newRow("Blank line followed by No newline")
|
||||
<< chunk
|
||||
@@ -894,7 +894,7 @@ void DiffEditor::Internal::DiffEditorPlugin::testReadPatch_data()
|
||||
QTest::addColumn<QString>("sourcePatch");
|
||||
QTest::addColumn<QList<FileData> >("fileDataList");
|
||||
|
||||
QString patch = _("diff --git a/src/plugins/diffeditor/diffeditor.cpp b/src/plugins/diffeditor/diffeditor.cpp\n"
|
||||
QString patch = "diff --git a/src/plugins/diffeditor/diffeditor.cpp b/src/plugins/diffeditor/diffeditor.cpp\n"
|
||||
"index eab9e9b..082c135 100644\n"
|
||||
"--- a/src/plugins/diffeditor/diffeditor.cpp\n"
|
||||
"+++ b/src/plugins/diffeditor/diffeditor.cpp\n"
|
||||
@@ -972,11 +972,11 @@ void DiffEditor::Internal::DiffEditorPlugin::testReadPatch_data()
|
||||
"-B\n"
|
||||
"+C\n"
|
||||
" D\n"
|
||||
);
|
||||
;
|
||||
|
||||
FileData fileData1;
|
||||
fileData1.leftFileInfo = DiffFileInfo(_("src/plugins/diffeditor/diffeditor.cpp"), _("eab9e9b"));
|
||||
fileData1.rightFileInfo = DiffFileInfo(_("src/plugins/diffeditor/diffeditor.cpp"), _("082c135"));
|
||||
fileData1.leftFileInfo = DiffFileInfo("src/plugins/diffeditor/diffeditor.cpp", "eab9e9b");
|
||||
fileData1.rightFileInfo = DiffFileInfo("src/plugins/diffeditor/diffeditor.cpp", "082c135");
|
||||
ChunkData chunkData1;
|
||||
chunkData1.leftStartingLineNumber = 186;
|
||||
chunkData1.rightStartingLineNumber = 186;
|
||||
@@ -1016,8 +1016,8 @@ void DiffEditor::Internal::DiffEditorPlugin::testReadPatch_data()
|
||||
fileData2.chunks << chunkData2;
|
||||
|
||||
FileData fileData3;
|
||||
fileData3.leftFileInfo = DiffFileInfo(_("new"), _("0000000"));
|
||||
fileData3.rightFileInfo = DiffFileInfo(_("new"), _("257cc56"));
|
||||
fileData3.leftFileInfo = DiffFileInfo("new", "0000000");
|
||||
fileData3.rightFileInfo = DiffFileInfo("new", "257cc56");
|
||||
fileData3.fileOperation = FileData::NewFile;
|
||||
ChunkData chunkData3;
|
||||
chunkData3.leftStartingLineNumber = -1;
|
||||
@@ -1030,8 +1030,8 @@ void DiffEditor::Internal::DiffEditorPlugin::testReadPatch_data()
|
||||
fileData3.chunks << chunkData3;
|
||||
|
||||
FileData fileData4;
|
||||
fileData4.leftFileInfo = DiffFileInfo(_("deleted"), _("257cc56"));
|
||||
fileData4.rightFileInfo = DiffFileInfo(_("deleted"), _("0000000"));
|
||||
fileData4.leftFileInfo = DiffFileInfo("deleted", "257cc56");
|
||||
fileData4.rightFileInfo = DiffFileInfo("deleted", "0000000");
|
||||
fileData4.fileOperation = FileData::DeleteFile;
|
||||
ChunkData chunkData4;
|
||||
chunkData4.leftStartingLineNumber = 0;
|
||||
@@ -1044,18 +1044,18 @@ void DiffEditor::Internal::DiffEditorPlugin::testReadPatch_data()
|
||||
fileData4.chunks << chunkData4;
|
||||
|
||||
FileData fileData5;
|
||||
fileData5.leftFileInfo = DiffFileInfo(_("empty"), _("0000000"));
|
||||
fileData5.rightFileInfo = DiffFileInfo(_("empty"), _("e69de29"));
|
||||
fileData5.leftFileInfo = DiffFileInfo("empty", "0000000");
|
||||
fileData5.rightFileInfo = DiffFileInfo("empty", "e69de29");
|
||||
fileData5.fileOperation = FileData::NewFile;
|
||||
|
||||
FileData fileData6;
|
||||
fileData6.leftFileInfo = DiffFileInfo(_("empty"), _("e69de29"));
|
||||
fileData6.rightFileInfo = DiffFileInfo(_("empty"), _("0000000"));
|
||||
fileData6.leftFileInfo = DiffFileInfo("empty", "e69de29");
|
||||
fileData6.rightFileInfo = DiffFileInfo("empty", "0000000");
|
||||
fileData6.fileOperation = FileData::DeleteFile;
|
||||
|
||||
FileData fileData7;
|
||||
fileData7.leftFileInfo = DiffFileInfo(_("file a.txt"), _("1234567"));
|
||||
fileData7.rightFileInfo = DiffFileInfo(_("file b.txt"), _("9876543"));
|
||||
fileData7.leftFileInfo = DiffFileInfo("file a.txt", "1234567");
|
||||
fileData7.rightFileInfo = DiffFileInfo("file b.txt", "9876543");
|
||||
fileData7.fileOperation = FileData::CopyFile;
|
||||
ChunkData chunkData7;
|
||||
chunkData7.leftStartingLineNumber = 19;
|
||||
@@ -1068,13 +1068,13 @@ void DiffEditor::Internal::DiffEditorPlugin::testReadPatch_data()
|
||||
fileData7.chunks << chunkData7;
|
||||
|
||||
FileData fileData8;
|
||||
fileData8.leftFileInfo = DiffFileInfo(_("file a.txt"));
|
||||
fileData8.rightFileInfo = DiffFileInfo(_("file b.txt"));
|
||||
fileData8.leftFileInfo = DiffFileInfo("file a.txt");
|
||||
fileData8.rightFileInfo = DiffFileInfo("file b.txt");
|
||||
fileData8.fileOperation = FileData::RenameFile;
|
||||
|
||||
FileData fileData9;
|
||||
fileData9.leftFileInfo = DiffFileInfo(_("file.txt"), _("1234567"));
|
||||
fileData9.rightFileInfo = DiffFileInfo(_("file.txt"), _("9876543"));
|
||||
fileData9.leftFileInfo = DiffFileInfo("file.txt", "1234567");
|
||||
fileData9.rightFileInfo = DiffFileInfo("file.txt", "9876543");
|
||||
fileData9.chunks << chunkData7;
|
||||
QList<FileData> fileDataList1;
|
||||
fileDataList1 << fileData1 << fileData2 << fileData3 << fileData4 << fileData5
|
||||
@@ -1085,7 +1085,7 @@ void DiffEditor::Internal::DiffEditorPlugin::testReadPatch_data()
|
||||
|
||||
//////////////
|
||||
|
||||
patch = _("diff --git a/file foo.txt b/file foo.txt\n"
|
||||
patch = "diff --git a/file foo.txt b/file foo.txt\n"
|
||||
"index 1234567..9876543 100644\n"
|
||||
"--- a/file foo.txt\n"
|
||||
"+++ b/file foo.txt\n"
|
||||
@@ -1093,10 +1093,10 @@ void DiffEditor::Internal::DiffEditorPlugin::testReadPatch_data()
|
||||
" A\n"
|
||||
" B\n"
|
||||
" C\n"
|
||||
"+\n");
|
||||
"+\n";
|
||||
|
||||
fileData1.leftFileInfo = DiffFileInfo(_("file foo.txt"), _("1234567"));
|
||||
fileData1.rightFileInfo = DiffFileInfo(_("file foo.txt"), _("9876543"));
|
||||
fileData1.leftFileInfo = DiffFileInfo("file foo.txt", "1234567");
|
||||
fileData1.rightFileInfo = DiffFileInfo("file foo.txt", "9876543");
|
||||
fileData1.fileOperation = FileData::ChangeFile;
|
||||
chunkData1.leftStartingLineNumber = 49;
|
||||
chunkData1.rightStartingLineNumber = 49;
|
||||
@@ -1117,17 +1117,17 @@ void DiffEditor::Internal::DiffEditorPlugin::testReadPatch_data()
|
||||
|
||||
//////////////
|
||||
|
||||
patch = _("diff --git a/file foo.txt b/file foo.txt\n"
|
||||
patch = "diff --git a/file foo.txt b/file foo.txt\n"
|
||||
"index 1234567..9876543 100644\n"
|
||||
"--- a/file foo.txt\n"
|
||||
"+++ b/file foo.txt\n"
|
||||
"@@ -1,1 +1,1 @@\n"
|
||||
"-ABCD\n"
|
||||
"\\ No newline at end of file\n"
|
||||
"+ABCD\n");
|
||||
"+ABCD\n";
|
||||
|
||||
fileData1.leftFileInfo = DiffFileInfo(_("file foo.txt"), _("1234567"));
|
||||
fileData1.rightFileInfo = DiffFileInfo(_("file foo.txt"), _("9876543"));
|
||||
fileData1.leftFileInfo = DiffFileInfo("file foo.txt", "1234567");
|
||||
fileData1.rightFileInfo = DiffFileInfo("file foo.txt", "9876543");
|
||||
fileData1.fileOperation = FileData::ChangeFile;
|
||||
chunkData1.leftStartingLineNumber = 0;
|
||||
chunkData1.rightStartingLineNumber = 0;
|
||||
@@ -1144,7 +1144,7 @@ void DiffEditor::Internal::DiffEditorPlugin::testReadPatch_data()
|
||||
QTest::newRow("Last newline added to a line without newline") << patch
|
||||
<< fileDataList3;
|
||||
|
||||
patch = _("diff --git a/difftest.txt b/difftest.txt\n"
|
||||
patch = "diff --git a/difftest.txt b/difftest.txt\n"
|
||||
"index 1234567..9876543 100644\n"
|
||||
"--- a/difftest.txt\n"
|
||||
"+++ b/difftest.txt\n"
|
||||
@@ -1160,10 +1160,10 @@ void DiffEditor::Internal::DiffEditorPlugin::testReadPatch_data()
|
||||
" D\n"
|
||||
"+E\n"
|
||||
"+F\n"
|
||||
);
|
||||
;
|
||||
|
||||
fileData1.leftFileInfo = DiffFileInfo(_("difftest.txt"), _("1234567"));
|
||||
fileData1.rightFileInfo = DiffFileInfo(_("difftest.txt"), _("9876543"));
|
||||
fileData1.leftFileInfo = DiffFileInfo("difftest.txt", "1234567");
|
||||
fileData1.rightFileInfo = DiffFileInfo("difftest.txt", "9876543");
|
||||
fileData1.fileOperation = FileData::ChangeFile;
|
||||
chunkData1.leftStartingLineNumber = 1;
|
||||
chunkData1.rightStartingLineNumber = 1;
|
||||
@@ -1195,7 +1195,7 @@ void DiffEditor::Internal::DiffEditorPlugin::testReadPatch_data()
|
||||
|
||||
//////////////
|
||||
|
||||
patch = _("diff --git a/file foo.txt b/file foo.txt\n"
|
||||
patch = "diff --git a/file foo.txt b/file foo.txt\n"
|
||||
"index 1234567..9876543 100644\n"
|
||||
"--- a/file foo.txt\n"
|
||||
"+++ b/file foo.txt\n"
|
||||
@@ -1203,10 +1203,10 @@ void DiffEditor::Internal::DiffEditorPlugin::testReadPatch_data()
|
||||
" ABCD\n"
|
||||
"+\n"
|
||||
"+EFGH\n"
|
||||
"\\ No newline at end of file\n");
|
||||
"\\ No newline at end of file\n";
|
||||
|
||||
fileData1.leftFileInfo = DiffFileInfo(_("file foo.txt"), _("1234567"));
|
||||
fileData1.rightFileInfo = DiffFileInfo(_("file foo.txt"), _("9876543"));
|
||||
fileData1.leftFileInfo = DiffFileInfo("file foo.txt", "1234567");
|
||||
fileData1.rightFileInfo = DiffFileInfo("file foo.txt", "9876543");
|
||||
fileData1.fileOperation = FileData::ChangeFile;
|
||||
chunkData1.leftStartingLineNumber = 0;
|
||||
chunkData1.rightStartingLineNumber = 0;
|
||||
@@ -1227,7 +1227,7 @@ void DiffEditor::Internal::DiffEditorPlugin::testReadPatch_data()
|
||||
//////////////
|
||||
|
||||
// Based on 953cdb97
|
||||
patch = _("diff --git a/src/plugins/texteditor/basetextdocument.h b/src/plugins/texteditor/textdocument.h\n"
|
||||
patch = "diff --git a/src/plugins/texteditor/basetextdocument.h b/src/plugins/texteditor/textdocument.h\n"
|
||||
"similarity index 100%\n"
|
||||
"rename from src/plugins/texteditor/basetextdocument.h\n"
|
||||
"rename to src/plugins/texteditor/textdocument.h\n"
|
||||
@@ -1245,15 +1245,15 @@ void DiffEditor::Internal::DiffEditorPlugin::testReadPatch_data()
|
||||
"+Z\n"
|
||||
" D\n"
|
||||
" \n"
|
||||
);
|
||||
;
|
||||
|
||||
fileData1 = FileData();
|
||||
fileData1.leftFileInfo = DiffFileInfo(_("src/plugins/texteditor/basetextdocument.h"));
|
||||
fileData1.rightFileInfo = DiffFileInfo(_("src/plugins/texteditor/textdocument.h"));
|
||||
fileData1.leftFileInfo = DiffFileInfo("src/plugins/texteditor/basetextdocument.h");
|
||||
fileData1.rightFileInfo = DiffFileInfo("src/plugins/texteditor/textdocument.h");
|
||||
fileData1.fileOperation = FileData::RenameFile;
|
||||
fileData2 = FileData();
|
||||
fileData2.leftFileInfo = DiffFileInfo(_("src/plugins/texteditor/basetextdocumentlayout.cpp"), _("0121933"));
|
||||
fileData2.rightFileInfo = DiffFileInfo(_("src/plugins/texteditor/textdocumentlayout.cpp"), _("01cc3a0"));
|
||||
fileData2.leftFileInfo = DiffFileInfo("src/plugins/texteditor/basetextdocumentlayout.cpp", "0121933");
|
||||
fileData2.rightFileInfo = DiffFileInfo("src/plugins/texteditor/textdocumentlayout.cpp", "01cc3a0");
|
||||
fileData2.fileOperation = FileData::RenameFile;
|
||||
chunkData2.leftStartingLineNumber = 1;
|
||||
chunkData2.rightStartingLineNumber = 1;
|
||||
@@ -1276,16 +1276,16 @@ void DiffEditor::Internal::DiffEditorPlugin::testReadPatch_data()
|
||||
//////////////
|
||||
|
||||
// Dirty submodule
|
||||
patch = _("diff --git a/src/shared/qbs b/src/shared/qbs\n"
|
||||
patch = "diff --git a/src/shared/qbs b/src/shared/qbs\n"
|
||||
"--- a/src/shared/qbs\n"
|
||||
"+++ b/src/shared/qbs\n"
|
||||
"@@ -1 +1 @@\n"
|
||||
"-Subproject commit eda76354077a427d692fee05479910de31040d3f\n"
|
||||
"+Subproject commit eda76354077a427d692fee05479910de31040d3f-dirty\n"
|
||||
);
|
||||
;
|
||||
fileData1 = FileData();
|
||||
fileData1.leftFileInfo = DiffFileInfo(_("src/shared/qbs"));
|
||||
fileData1.rightFileInfo = DiffFileInfo(_("src/shared/qbs"));
|
||||
fileData1.leftFileInfo = DiffFileInfo("src/shared/qbs");
|
||||
fileData1.rightFileInfo = DiffFileInfo("src/shared/qbs");
|
||||
chunkData1.leftStartingLineNumber = 0;
|
||||
chunkData1.rightStartingLineNumber = 0;
|
||||
rows1.clear();
|
||||
@@ -1301,7 +1301,7 @@ void DiffEditor::Internal::DiffEditorPlugin::testReadPatch_data()
|
||||
<< fileDataList7;
|
||||
|
||||
//////////////
|
||||
patch = _("diff --git a/demos/arthurplugin/arthurplugin.pro b/demos/arthurplugin/arthurplugin.pro\n"
|
||||
patch = "diff --git a/demos/arthurplugin/arthurplugin.pro b/demos/arthurplugin/arthurplugin.pro\n"
|
||||
"new file mode 100644\n"
|
||||
"index 0000000..c5132b4\n"
|
||||
"--- /dev/null\n"
|
||||
@@ -1316,11 +1316,11 @@ void DiffEditor::Internal::DiffEditorPlugin::testReadPatch_data()
|
||||
"new file mode 100644\n"
|
||||
"index 0000000..f8e022c\n"
|
||||
"Binary files /dev/null and b/demos/arthurplugin/flower.jpg differ\n"
|
||||
);
|
||||
;
|
||||
|
||||
fileData1 = FileData();
|
||||
fileData1.leftFileInfo = DiffFileInfo(_("demos/arthurplugin/arthurplugin.pro"), _("0000000"));
|
||||
fileData1.rightFileInfo = DiffFileInfo(_("demos/arthurplugin/arthurplugin.pro"), _("c5132b4"));
|
||||
fileData1.leftFileInfo = DiffFileInfo("demos/arthurplugin/arthurplugin.pro", "0000000");
|
||||
fileData1.rightFileInfo = DiffFileInfo("demos/arthurplugin/arthurplugin.pro", "c5132b4");
|
||||
fileData1.fileOperation = FileData::NewFile;
|
||||
chunkData1 = ChunkData();
|
||||
chunkData1.leftStartingLineNumber = -1;
|
||||
@@ -1331,13 +1331,13 @@ void DiffEditor::Internal::DiffEditorPlugin::testReadPatch_data()
|
||||
chunkData1.rows = rows1;
|
||||
fileData1.chunks << chunkData1;
|
||||
fileData2 = FileData();
|
||||
fileData2.leftFileInfo = DiffFileInfo(_("demos/arthurplugin/bg1.jpg"), _("0000000"));
|
||||
fileData2.rightFileInfo = DiffFileInfo(_("demos/arthurplugin/bg1.jpg"), _("dfc7cee"));
|
||||
fileData2.leftFileInfo = DiffFileInfo("demos/arthurplugin/bg1.jpg", "0000000");
|
||||
fileData2.rightFileInfo = DiffFileInfo("demos/arthurplugin/bg1.jpg", "dfc7cee");
|
||||
fileData2.fileOperation = FileData::NewFile;
|
||||
fileData2.binaryFiles = true;
|
||||
fileData3 = FileData();
|
||||
fileData3.leftFileInfo = DiffFileInfo(_("demos/arthurplugin/flower.jpg"), _("0000000"));
|
||||
fileData3.rightFileInfo = DiffFileInfo(_("demos/arthurplugin/flower.jpg"), _("f8e022c"));
|
||||
fileData3.leftFileInfo = DiffFileInfo("demos/arthurplugin/flower.jpg", "0000000");
|
||||
fileData3.rightFileInfo = DiffFileInfo("demos/arthurplugin/flower.jpg", "f8e022c");
|
||||
fileData3.fileOperation = FileData::NewFile;
|
||||
fileData3.binaryFiles = true;
|
||||
|
||||
@@ -1348,10 +1348,10 @@ void DiffEditor::Internal::DiffEditorPlugin::testReadPatch_data()
|
||||
<< fileDataList8;
|
||||
|
||||
//////////////
|
||||
patch = _("diff --git a/script.sh b/script.sh\n"
|
||||
patch = "diff --git a/script.sh b/script.sh\n"
|
||||
"old mode 100644\n"
|
||||
"new mode 100755\n"
|
||||
);
|
||||
;
|
||||
|
||||
fileData1 = FileData();
|
||||
fileData1.leftFileInfo = DiffFileInfo("script.sh");
|
||||
@@ -1366,14 +1366,14 @@ void DiffEditor::Internal::DiffEditorPlugin::testReadPatch_data()
|
||||
//////////////
|
||||
|
||||
// Subversion New
|
||||
patch = _("Index: src/plugins/subversion/subversioneditor.cpp\n"
|
||||
patch = "Index: src/plugins/subversion/subversioneditor.cpp\n"
|
||||
"===================================================================\n"
|
||||
"--- src/plugins/subversion/subversioneditor.cpp\t(revision 0)\n"
|
||||
"+++ src/plugins/subversion/subversioneditor.cpp\t(revision 0)\n"
|
||||
"@@ -0,0 +125 @@\n\n");
|
||||
"@@ -0,0 +125 @@\n\n";
|
||||
fileData1 = FileData();
|
||||
fileData1.leftFileInfo = DiffFileInfo(_("src/plugins/subversion/subversioneditor.cpp"));
|
||||
fileData1.rightFileInfo = DiffFileInfo(_("src/plugins/subversion/subversioneditor.cpp"));
|
||||
fileData1.leftFileInfo = DiffFileInfo("src/plugins/subversion/subversioneditor.cpp");
|
||||
fileData1.rightFileInfo = DiffFileInfo("src/plugins/subversion/subversioneditor.cpp");
|
||||
chunkData1 = ChunkData();
|
||||
chunkData1.leftStartingLineNumber = -1;
|
||||
chunkData1.rightStartingLineNumber = 124;
|
||||
@@ -1386,14 +1386,14 @@ void DiffEditor::Internal::DiffEditorPlugin::testReadPatch_data()
|
||||
//////////////
|
||||
|
||||
// Subversion Deleted
|
||||
patch = _("Index: src/plugins/subversion/subversioneditor.cpp\n"
|
||||
patch = "Index: src/plugins/subversion/subversioneditor.cpp\n"
|
||||
"===================================================================\n"
|
||||
"--- src/plugins/subversion/subversioneditor.cpp\t(revision 42)\n"
|
||||
"+++ src/plugins/subversion/subversioneditor.cpp\t(working copy)\n"
|
||||
"@@ -1,125 +0,0 @@\n\n");
|
||||
"@@ -1,125 +0,0 @@\n\n";
|
||||
fileData1 = FileData();
|
||||
fileData1.leftFileInfo = DiffFileInfo(_("src/plugins/subversion/subversioneditor.cpp"));
|
||||
fileData1.rightFileInfo = DiffFileInfo(_("src/plugins/subversion/subversioneditor.cpp"));
|
||||
fileData1.leftFileInfo = DiffFileInfo("src/plugins/subversion/subversioneditor.cpp");
|
||||
fileData1.rightFileInfo = DiffFileInfo("src/plugins/subversion/subversioneditor.cpp");
|
||||
chunkData1 = ChunkData();
|
||||
chunkData1.leftStartingLineNumber = 0;
|
||||
chunkData1.rightStartingLineNumber = -1;
|
||||
@@ -1406,14 +1406,14 @@ void DiffEditor::Internal::DiffEditorPlugin::testReadPatch_data()
|
||||
//////////////
|
||||
|
||||
// Subversion Normal
|
||||
patch = _("Index: src/plugins/subversion/subversioneditor.cpp\n"
|
||||
patch = "Index: src/plugins/subversion/subversioneditor.cpp\n"
|
||||
"===================================================================\n"
|
||||
"--- src/plugins/subversion/subversioneditor.cpp\t(revision 42)\n"
|
||||
"+++ src/plugins/subversion/subversioneditor.cpp\t(working copy)\n"
|
||||
"@@ -120,7 +120,7 @@\n\n");
|
||||
"@@ -120,7 +120,7 @@\n\n";
|
||||
fileData1 = FileData();
|
||||
fileData1.leftFileInfo = DiffFileInfo(_("src/plugins/subversion/subversioneditor.cpp"));
|
||||
fileData1.rightFileInfo = DiffFileInfo(_("src/plugins/subversion/subversioneditor.cpp"));
|
||||
fileData1.leftFileInfo = DiffFileInfo("src/plugins/subversion/subversioneditor.cpp");
|
||||
fileData1.rightFileInfo = DiffFileInfo("src/plugins/subversion/subversioneditor.cpp");
|
||||
chunkData1 = ChunkData();
|
||||
chunkData1.leftStartingLineNumber = 119;
|
||||
chunkData1.rightStartingLineNumber = 119;
|
||||
|
@@ -289,7 +289,7 @@ void DiffEditorWidgetController::slotSendChunkToCodePaster()
|
||||
if (patch.isEmpty())
|
||||
return;
|
||||
|
||||
pasteService->postText(patch, QLatin1String(Constants::DIFF_EDITOR_MIMETYPE));
|
||||
pasteService->postText(patch, Constants::DIFF_EDITOR_MIMETYPE);
|
||||
}
|
||||
|
||||
void DiffEditorWidgetController::slotApplyChunk()
|
||||
|
@@ -81,7 +81,7 @@ private:
|
||||
void showProgress();
|
||||
void hideProgress();
|
||||
|
||||
QWidget *m_diffEditorWidget;
|
||||
QWidget *m_diffEditorWidget = nullptr;
|
||||
|
||||
DiffEditorDocument *m_document = nullptr;
|
||||
|
||||
|
@@ -236,14 +236,14 @@ static int cleanupSemanticsScore(const QString &text1, const QString &text2)
|
||||
|
||||
static bool isWhitespace(const QChar &c)
|
||||
{
|
||||
if (c == QLatin1Char(' ') || c == QLatin1Char('\t'))
|
||||
if (c == ' ' || c == '\t')
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool isNewLine(const QChar &c)
|
||||
{
|
||||
if (c == QLatin1Char('\n'))
|
||||
if (c == '\n')
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
@@ -362,7 +362,7 @@ static QString encodeReducedWhitespace(const QString &input,
|
||||
QChar c = input.at(inputIndex);
|
||||
|
||||
if (isWhitespace(c)) {
|
||||
output.append(QLatin1Char(' '));
|
||||
output.append(' ');
|
||||
codeMap->insert(outputIndex, QString(c));
|
||||
++inputIndex;
|
||||
|
||||
@@ -564,7 +564,7 @@ static QString encodeExpandedWhitespace(const QString &leftEquality,
|
||||
if (leftWhitespaces.count() && rightWhitespaces.count()) {
|
||||
const int replacementPosition = output.count();
|
||||
const int replacementSize = qMax(leftWhitespaces.count(), rightWhitespaces.count());
|
||||
const QString replacement(replacementSize, QLatin1Char(' '));
|
||||
const QString replacement(replacementSize, ' ');
|
||||
leftCodeMap->insert(replacementPosition,
|
||||
qMakePair(replacementSize, leftWhitespaces));
|
||||
rightCodeMap->insert(replacementPosition,
|
||||
@@ -968,17 +968,14 @@ QString Diff::toString() const
|
||||
{
|
||||
QString prettyText = text;
|
||||
// Replace linebreaks with pretty char
|
||||
prettyText.replace(QLatin1Char('\n'), QLatin1Char('\xb6'));
|
||||
return commandString(command) + QLatin1String(" \"")
|
||||
+ prettyText + QLatin1String("\"");
|
||||
prettyText.replace('\n', '\xb6');
|
||||
return commandString(command) + " \"" + prettyText + "\"";
|
||||
}
|
||||
|
||||
///////////////
|
||||
|
||||
Differ::Differ(QFutureInterfaceBase *jobController)
|
||||
: m_diffMode(Differ::LineMode),
|
||||
m_currentDiffMode(Differ::LineMode),
|
||||
m_jobController(jobController)
|
||||
: m_jobController(jobController)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1288,7 +1285,7 @@ int Differ::findSubtextEnd(const QString &text,
|
||||
int subtextStart)
|
||||
{
|
||||
if (m_currentDiffMode == Differ::LineMode) {
|
||||
int subtextEnd = text.indexOf(QLatin1Char('\n'), subtextStart);
|
||||
int subtextEnd = text.indexOf('\n', subtextStart);
|
||||
if (subtextEnd == -1)
|
||||
subtextEnd = text.count() - 1;
|
||||
return ++subtextEnd;
|
||||
|
@@ -109,8 +109,8 @@ private:
|
||||
QMap<QString, int> *lineToCode);
|
||||
int findSubtextEnd(const QString &text,
|
||||
int subTextStart);
|
||||
DiffMode m_diffMode;
|
||||
DiffMode m_currentDiffMode;
|
||||
DiffMode m_diffMode = Differ::LineMode;
|
||||
DiffMode m_currentDiffMode = Differ::LineMode;
|
||||
QFutureInterfaceBase *m_jobController = nullptr;
|
||||
};
|
||||
|
||||
|
@@ -84,7 +84,7 @@ static void handleDifference(const QString &text,
|
||||
QList<TextLineData> *lines,
|
||||
int *lineNumber)
|
||||
{
|
||||
const QStringList newLines = text.split(QLatin1Char('\n'));
|
||||
const QStringList newLines = text.split('\n');
|
||||
for (int line = 0; line < newLines.count(); ++line) {
|
||||
const int startPos = line > 0
|
||||
? -1
|
||||
@@ -133,7 +133,7 @@ ChunkData DiffUtils::calculateOriginalData(const QList<Diff> &leftDiffList,
|
||||
: Diff(Diff::Equal);
|
||||
|
||||
if (leftDiff.command == Diff::Delete) {
|
||||
if (j == rightDiffList.count() && lastLineEqual && leftDiff.text.startsWith(QLatin1Char('\n')))
|
||||
if (j == rightDiffList.count() && lastLineEqual && leftDiff.text.startsWith('\n'))
|
||||
equalLines.insert(leftLineNumber, rightLineNumber);
|
||||
// process delete
|
||||
handleDifference(leftDiff.text, &leftLines, &leftLineNumber);
|
||||
@@ -143,7 +143,7 @@ ChunkData DiffUtils::calculateOriginalData(const QList<Diff> &leftDiffList,
|
||||
i++;
|
||||
}
|
||||
if (rightDiff.command == Diff::Insert) {
|
||||
if (i == leftDiffList.count() && lastLineEqual && rightDiff.text.startsWith(QLatin1Char('\n')))
|
||||
if (i == leftDiffList.count() && lastLineEqual && rightDiff.text.startsWith('\n'))
|
||||
equalLines.insert(leftLineNumber, rightLineNumber);
|
||||
// process insert
|
||||
handleDifference(rightDiff.text, &rightLines, &rightLineNumber);
|
||||
@@ -154,8 +154,8 @@ ChunkData DiffUtils::calculateOriginalData(const QList<Diff> &leftDiffList,
|
||||
}
|
||||
if (leftDiff.command == Diff::Equal && rightDiff.command == Diff::Equal) {
|
||||
// process equal
|
||||
const QStringList newLeftLines = leftDiff.text.split(QLatin1Char('\n'));
|
||||
const QStringList newRightLines = rightDiff.text.split(QLatin1Char('\n'));
|
||||
const QStringList newLeftLines = leftDiff.text.split('\n');
|
||||
const QStringList newRightLines = rightDiff.text.split('\n');
|
||||
|
||||
int line = 0;
|
||||
|
||||
@@ -347,9 +347,9 @@ QString DiffUtils::makePatchLine(const QChar &startLineCharacter,
|
||||
|| addNoNewline; // no addNoNewline case
|
||||
|
||||
if (addLine) {
|
||||
line = startLineCharacter + textLine + QLatin1Char('\n');
|
||||
line = startLineCharacter + textLine + '\n';
|
||||
if (addNoNewline)
|
||||
line += QLatin1String("\\ No newline at end of file\n");
|
||||
line += "\\ No newline at end of file\n";
|
||||
}
|
||||
|
||||
return line;
|
||||
@@ -404,7 +404,7 @@ QString DiffUtils::makePatch(const ChunkData &chunkData,
|
||||
if (rowData.equal && i != rowToBeSplit) {
|
||||
if (leftBuffer.count()) {
|
||||
for (int j = 0; j < leftBuffer.count(); j++) {
|
||||
const QString line = makePatchLine(QLatin1Char('-'),
|
||||
const QString line = makePatchLine('-',
|
||||
leftBuffer.at(j).text,
|
||||
lastChunk,
|
||||
i == chunkData.rows.count()
|
||||
@@ -419,7 +419,7 @@ QString DiffUtils::makePatch(const ChunkData &chunkData,
|
||||
}
|
||||
if (rightBuffer.count()) {
|
||||
for (int j = 0; j < rightBuffer.count(); j++) {
|
||||
const QString line = makePatchLine(QLatin1Char('+'),
|
||||
const QString line = makePatchLine('+',
|
||||
rightBuffer.at(j).text,
|
||||
lastChunk,
|
||||
i == chunkData.rows.count()
|
||||
@@ -433,7 +433,7 @@ QString DiffUtils::makePatch(const ChunkData &chunkData,
|
||||
rightBuffer.clear();
|
||||
}
|
||||
if (i < chunkData.rows.count()) {
|
||||
const QString line = makePatchLine(QLatin1Char(' '),
|
||||
const QString line = makePatchLine(' ',
|
||||
rowData.rightLine.text,
|
||||
lastChunk,
|
||||
i == chunkData.rows.count() - 1);
|
||||
@@ -453,17 +453,17 @@ QString DiffUtils::makePatch(const ChunkData &chunkData,
|
||||
}
|
||||
}
|
||||
|
||||
const QString chunkLine = QLatin1String("@@ -")
|
||||
const QString chunkLine = "@@ -"
|
||||
+ QString::number(chunkData.leftStartingLineNumber + 1)
|
||||
+ QLatin1Char(',')
|
||||
+ ','
|
||||
+ QString::number(leftLineCount)
|
||||
+ QLatin1String(" +")
|
||||
+ " +"
|
||||
+ QString::number(chunkData.rightStartingLineNumber + 1)
|
||||
+ QLatin1Char(',')
|
||||
+ ','
|
||||
+ QString::number(rightLineCount)
|
||||
+ QLatin1String(" @@")
|
||||
+ " @@"
|
||||
+ chunkData.contextInfo
|
||||
+ QLatin1Char('\n');
|
||||
+ '\n';
|
||||
|
||||
diffText.prepend(chunkLine);
|
||||
|
||||
@@ -477,8 +477,8 @@ QString DiffUtils::makePatch(const ChunkData &chunkData,
|
||||
{
|
||||
QString diffText = makePatch(chunkData, lastChunk);
|
||||
|
||||
const QString rightFileInfo = QLatin1String("+++ ") + rightFileName + QLatin1Char('\n');
|
||||
const QString leftFileInfo = QLatin1String("--- ") + leftFileName + QLatin1Char('\n');
|
||||
const QString rightFileInfo = "+++ " + rightFileName + '\n';
|
||||
const QString leftFileInfo = "--- " + leftFileName + '\n';
|
||||
|
||||
diffText.prepend(rightFileInfo);
|
||||
diffText.prepend(leftFileInfo);
|
||||
@@ -568,7 +568,7 @@ static QList<RowData> readLines(QStringRef patch,
|
||||
{
|
||||
QList<Diff> diffList;
|
||||
|
||||
const QChar newLine = QLatin1Char('\n');
|
||||
const QChar newLine = '\n';
|
||||
|
||||
int lastEqual = -1;
|
||||
int lastDelete = -1;
|
||||
@@ -588,7 +588,7 @@ static QList<RowData> readLines(QStringRef patch,
|
||||
break;
|
||||
}
|
||||
const QChar firstCharacter = line.at(0);
|
||||
if (firstCharacter == QLatin1Char('\\')) { // no new line marker
|
||||
if (firstCharacter == '\\') { // no new line marker
|
||||
if (!lastChunk) // can only appear in last chunk of the file
|
||||
break;
|
||||
if (!diffList.isEmpty()) {
|
||||
@@ -612,11 +612,11 @@ static QList<RowData> readLines(QStringRef patch,
|
||||
}
|
||||
} else {
|
||||
Diff::Command command = Diff::Equal;
|
||||
if (firstCharacter == QLatin1Char(' ')) { // common line
|
||||
if (firstCharacter == ' ') { // common line
|
||||
command = Diff::Equal;
|
||||
} else if (firstCharacter == QLatin1Char('-')) { // deleted line
|
||||
} else if (firstCharacter == '-') { // deleted line
|
||||
command = Diff::Delete;
|
||||
} else if (firstCharacter == QLatin1Char('+')) { // inserted line
|
||||
} else if (firstCharacter == '+') { // inserted line
|
||||
command = Diff::Insert;
|
||||
} else { // no other character may exist as the first character
|
||||
if (lastChunk)
|
||||
@@ -1074,9 +1074,9 @@ static bool detectIndexAndBinary(QStringRef patch,
|
||||
const QString rightFileName = fileData->fileOperation == FileData::DeleteFile
|
||||
? devNull : QLatin1String("b/") + fileData->rightFileInfo.fileName;
|
||||
|
||||
const QString binaryLine = QLatin1String("Binary files ")
|
||||
+ leftFileName + QLatin1String(" and ")
|
||||
+ rightFileName + QLatin1String(" differ");
|
||||
const QString binaryLine = "Binary files "
|
||||
+ leftFileName + " and "
|
||||
+ rightFileName + " differ";
|
||||
|
||||
if (*remainingPatch == binaryLine) {
|
||||
fileData->binaryFiles = true;
|
||||
@@ -1084,7 +1084,7 @@ static bool detectIndexAndBinary(QStringRef patch,
|
||||
return true;
|
||||
}
|
||||
|
||||
const QString leftStart = QLatin1String("--- ") + leftFileName;
|
||||
const QString leftStart = "--- " + leftFileName;
|
||||
QStringRef afterMinuses;
|
||||
// --- leftFileName
|
||||
const QStringRef minuses = readLine(*remainingPatch, &afterMinuses, &hasNewLine);
|
||||
@@ -1094,7 +1094,7 @@ static bool detectIndexAndBinary(QStringRef patch,
|
||||
if (!minuses.startsWith(leftStart))
|
||||
return false;
|
||||
|
||||
const QString rightStart = QLatin1String("+++ ") + rightFileName;
|
||||
const QString rightStart = "+++ " + rightFileName;
|
||||
QStringRef afterPluses;
|
||||
// +++ rightFileName
|
||||
const QStringRef pluses = readLine(afterMinuses, &afterPluses, &hasNewLine);
|
||||
|
@@ -63,10 +63,10 @@ public:
|
||||
Separator,
|
||||
Invalid
|
||||
};
|
||||
TextLineData() : textLineType(Invalid) {}
|
||||
TextLineData() {}
|
||||
TextLineData(const QString &txt) : textLineType(TextLine), text(txt) {}
|
||||
TextLineData(TextLineType t) : textLineType(t) {}
|
||||
TextLineType textLineType;
|
||||
TextLineType textLineType = Invalid;
|
||||
QString text;
|
||||
/*
|
||||
* <start position, end position>
|
||||
@@ -79,24 +79,23 @@ public:
|
||||
|
||||
class DIFFEDITOR_EXPORT RowData {
|
||||
public:
|
||||
RowData() : equal(false) {}
|
||||
RowData() {}
|
||||
RowData(const TextLineData &l)
|
||||
: leftLine(l), rightLine(l), equal(true) {}
|
||||
RowData(const TextLineData &l, const TextLineData &r)
|
||||
: leftLine(l), rightLine(r), equal(false) {}
|
||||
: leftLine(l), rightLine(r) {}
|
||||
TextLineData leftLine;
|
||||
TextLineData rightLine;
|
||||
bool equal;
|
||||
bool equal = false;
|
||||
};
|
||||
|
||||
class DIFFEDITOR_EXPORT ChunkData {
|
||||
public:
|
||||
ChunkData() : contextChunk(false),
|
||||
leftStartingLineNumber(0), rightStartingLineNumber(0) {}
|
||||
ChunkData() {}
|
||||
QList<RowData> rows;
|
||||
bool contextChunk;
|
||||
int leftStartingLineNumber;
|
||||
int rightStartingLineNumber;
|
||||
bool contextChunk = false;
|
||||
int leftStartingLineNumber = 0;
|
||||
int rightStartingLineNumber = 0;
|
||||
QString contextInfo;
|
||||
};
|
||||
|
||||
@@ -111,23 +110,15 @@ public:
|
||||
RenameFile
|
||||
};
|
||||
|
||||
FileData()
|
||||
: fileOperation(ChangeFile),
|
||||
binaryFiles(false),
|
||||
lastChunkAtTheEndOfFile(false),
|
||||
contextChunksIncluded(false) {}
|
||||
FileData(const ChunkData &chunkData)
|
||||
: fileOperation(ChangeFile),
|
||||
binaryFiles(false),
|
||||
lastChunkAtTheEndOfFile(false),
|
||||
contextChunksIncluded(false) { chunks.append(chunkData); }
|
||||
FileData() {}
|
||||
FileData(const ChunkData &chunkData) { chunks.append(chunkData); }
|
||||
QList<ChunkData> chunks;
|
||||
DiffFileInfo leftFileInfo;
|
||||
DiffFileInfo rightFileInfo;
|
||||
FileOperation fileOperation;
|
||||
bool binaryFiles;
|
||||
bool lastChunkAtTheEndOfFile;
|
||||
bool contextChunksIncluded;
|
||||
FileOperation fileOperation = ChangeFile;
|
||||
bool binaryFiles = false;
|
||||
bool lastChunkAtTheEndOfFile = false;
|
||||
bool contextChunksIncluded = false;
|
||||
};
|
||||
|
||||
class DIFFEDITOR_EXPORT DiffUtils {
|
||||
|
@@ -38,7 +38,7 @@
|
||||
namespace DiffEditor {
|
||||
namespace Internal {
|
||||
|
||||
IDiffView::IDiffView(QObject *parent) : QObject(parent), m_supportsSync(false)
|
||||
IDiffView::IDiffView(QObject *parent) : QObject(parent)
|
||||
{ }
|
||||
|
||||
QIcon IDiffView::icon() const
|
||||
|
@@ -50,7 +50,7 @@ class IDiffView : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit IDiffView(QObject *parent = 0);
|
||||
explicit IDiffView(QObject *parent = nullptr);
|
||||
|
||||
QIcon icon() const;
|
||||
QString toolTip() const;
|
||||
@@ -82,7 +82,7 @@ private:
|
||||
QIcon m_icon;
|
||||
QString m_toolTip;
|
||||
Core::Id m_id;
|
||||
bool m_supportsSync;
|
||||
bool m_supportsSync = false;
|
||||
QString m_syncToolTip;
|
||||
};
|
||||
|
||||
|
@@ -33,20 +33,20 @@ namespace Internal {
|
||||
class DiffSelection
|
||||
{
|
||||
public:
|
||||
DiffSelection() : start(-1), end(-1), format(0) {}
|
||||
DiffSelection(QTextCharFormat *f) : start(-1), end(-1), format(f) {}
|
||||
DiffSelection() {}
|
||||
DiffSelection(QTextCharFormat *f) : format(f) {}
|
||||
DiffSelection(int s, int e, QTextCharFormat *f) : start(s), end(e), format(f) {}
|
||||
|
||||
int start;
|
||||
int end;
|
||||
QTextCharFormat *format;
|
||||
int start = -1;
|
||||
int end = -1;
|
||||
QTextCharFormat *format = nullptr;
|
||||
};
|
||||
|
||||
class SelectableTextEditorWidget : public TextEditor::TextEditorWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SelectableTextEditorWidget(Core::Id id, QWidget *parent = 0);
|
||||
SelectableTextEditorWidget(Core::Id id, QWidget *parent = nullptr);
|
||||
~SelectableTextEditorWidget() override;
|
||||
void setSelections(const QMap<int, QList<DiffSelection> > &selections);
|
||||
|
||||
|
@@ -57,7 +57,7 @@ class SideDiffEditorWidget : public SelectableTextEditorWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SideDiffEditorWidget(QWidget *parent = 0);
|
||||
SideDiffEditorWidget(QWidget *parent = nullptr);
|
||||
|
||||
// block number, file info
|
||||
QMap<int, DiffFileInfo> fileInfo() const { return m_fileInfo; }
|
||||
@@ -100,7 +100,7 @@ signals:
|
||||
void foldChanged(int blockNumber, bool folded);
|
||||
|
||||
protected:
|
||||
int extraAreaWidth(int *markWidthPtr = 0) const override {
|
||||
int extraAreaWidth(int *markWidthPtr = nullptr) const override {
|
||||
return SelectableTextEditorWidget::extraAreaWidth(markWidthPtr);
|
||||
}
|
||||
void applyFontSettings() override;
|
||||
@@ -281,7 +281,7 @@ QString SideDiffEditorWidget::plainTextFromSelection(const QTextCursor &cursor)
|
||||
text = block.text().mid(startPosition - block.position());
|
||||
} else {
|
||||
if (textInserted)
|
||||
text += QLatin1Char('\n');
|
||||
text += '\n';
|
||||
if (block == endBlock)
|
||||
text += block.text().leftRef(endPosition - block.position());
|
||||
else
|
||||
@@ -394,9 +394,7 @@ void SideDiffEditorWidget::paintSeparator(QPainter &painter,
|
||||
|
||||
painter.setPen(foreground);
|
||||
|
||||
const QString replacementText = QLatin1String(" {")
|
||||
+ foldReplacementText(block)
|
||||
+ QLatin1String("}; ");
|
||||
const QString replacementText = " {" + foldReplacementText(block) + "}; ";
|
||||
const int replacementTextWidth = fontMetrics().width(replacementText) + 24;
|
||||
int x = replacementTextWidth + offset.x();
|
||||
if (x < document()->documentMargin()
|
||||
@@ -806,7 +804,7 @@ void SideBySideDiffEditorWidget::showDiff()
|
||||
|
||||
QString leftTexts, rightTexts;
|
||||
int blockNumber = 0;
|
||||
QChar separator = QLatin1Char('\n');
|
||||
QChar separator = '\n';
|
||||
QHash<int, int> foldingIndent;
|
||||
for (const FileData &contextFileData : m_controller.m_contextFileData) {
|
||||
QString leftText, rightText;
|
||||
@@ -929,8 +927,8 @@ void SideBySideDiffEditorWidget::showDiff()
|
||||
}
|
||||
}
|
||||
}
|
||||
leftText.replace(QLatin1Char('\r'), QLatin1Char(' '));
|
||||
rightText.replace(QLatin1Char('\r'), QLatin1Char(' '));
|
||||
leftText.replace('\r', ' ');
|
||||
rightText.replace('\r', ' ');
|
||||
leftTexts += leftText;
|
||||
rightTexts += rightText;
|
||||
}
|
||||
|
@@ -56,7 +56,7 @@ class SideBySideDiffEditorWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SideBySideDiffEditorWidget(QWidget *parent = 0);
|
||||
explicit SideBySideDiffEditorWidget(QWidget *parent = nullptr);
|
||||
~SideBySideDiffEditorWidget();
|
||||
|
||||
TextEditor::TextEditorWidget *leftEditorWidget() const;
|
||||
@@ -98,17 +98,17 @@ private:
|
||||
|
||||
void showDiff();
|
||||
|
||||
SideDiffEditorWidget *m_leftEditor;
|
||||
SideDiffEditorWidget *m_rightEditor;
|
||||
QSplitter *m_splitter;
|
||||
SideDiffEditorWidget *m_leftEditor = nullptr;
|
||||
SideDiffEditorWidget *m_rightEditor = nullptr;
|
||||
QSplitter *m_splitter = nullptr;
|
||||
|
||||
DiffEditorWidgetController m_controller;
|
||||
|
||||
bool m_horizontalSync = false;
|
||||
|
||||
QTextCharFormat m_spanLineFormat;
|
||||
Core::IContext *m_leftContext;
|
||||
Core::IContext *m_rightContext;
|
||||
Core::IContext *m_leftContext = nullptr;
|
||||
Core::IContext *m_rightContext = nullptr;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -229,15 +229,15 @@ QString UnifiedDiffEditorWidget::lineNumber(int blockNumber) const
|
||||
? QString::number(m_leftLineNumbers.value(blockNumber))
|
||||
: QString();
|
||||
lineNumberString += QString(m_leftLineNumberDigits - leftLine.count(),
|
||||
QLatin1Char(' ')) + leftLine;
|
||||
' ') + leftLine;
|
||||
|
||||
lineNumberString += QLatin1Char('|');
|
||||
lineNumberString += '|';
|
||||
|
||||
const QString rightLine = rightLineExists
|
||||
? QString::number(m_rightLineNumbers.value(blockNumber))
|
||||
: QString();
|
||||
lineNumberString += QString(m_rightLineNumberDigits - rightLine.count(),
|
||||
QLatin1Char(' ')) + rightLine;
|
||||
' ') + rightLine;
|
||||
}
|
||||
return lineNumberString;
|
||||
}
|
||||
@@ -327,13 +327,13 @@ QString UnifiedDiffEditorWidget::showChunk(const ChunkData &chunkData,
|
||||
for (int j = 0; j < leftBuffer.count(); j++) {
|
||||
const TextLineData &lineData = leftBuffer.at(j);
|
||||
const QString line = DiffUtils::makePatchLine(
|
||||
QLatin1Char('-'),
|
||||
'-',
|
||||
lineData.text,
|
||||
lastChunk,
|
||||
i == chunkData.rows.count()
|
||||
&& j == leftBuffer.count() - 1);
|
||||
|
||||
const int blockDelta = line.count(QLatin1Char('\n')); // no new line
|
||||
const int blockDelta = line.count('\n'); // no new line
|
||||
// could have been added
|
||||
for (int k = 0; k < blockDelta; k++)
|
||||
(*selections)[*blockNumber + blockCount + 1 + k].append(&m_controller.m_leftLineFormat);
|
||||
@@ -366,13 +366,13 @@ QString UnifiedDiffEditorWidget::showChunk(const ChunkData &chunkData,
|
||||
for (int j = 0; j < rightBuffer.count(); j++) {
|
||||
const TextLineData &lineData = rightBuffer.at(j);
|
||||
const QString line = DiffUtils::makePatchLine(
|
||||
QLatin1Char('+'),
|
||||
'+',
|
||||
lineData.text,
|
||||
lastChunk,
|
||||
i == chunkData.rows.count()
|
||||
&& j == rightBuffer.count() - 1);
|
||||
|
||||
const int blockDelta = line.count(QLatin1Char('\n')); // no new line
|
||||
const int blockDelta = line.count('\n'); // no new line
|
||||
// could have been added
|
||||
|
||||
for (int k = 0; k < blockDelta; k++)
|
||||
@@ -403,7 +403,7 @@ QString UnifiedDiffEditorWidget::showChunk(const ChunkData &chunkData,
|
||||
rightBuffer.clear();
|
||||
}
|
||||
if (i < chunkData.rows.count()) {
|
||||
const QString line = DiffUtils::makePatchLine(QLatin1Char(' '),
|
||||
const QString line = DiffUtils::makePatchLine(' ',
|
||||
rowData.rightLine.text,
|
||||
lastChunk,
|
||||
i == chunkData.rows.count() - 1);
|
||||
@@ -415,7 +415,7 @@ QString UnifiedDiffEditorWidget::showChunk(const ChunkData &chunkData,
|
||||
setRightLineNumber(*blockNumber + blockCount + 1,
|
||||
chunkData.rightStartingLineNumber
|
||||
+ rightLineCount + 1);
|
||||
blockCount += line.count(QLatin1Char('\n'));
|
||||
blockCount += line.count('\n');
|
||||
++leftLineCount;
|
||||
++rightLineCount;
|
||||
}
|
||||
@@ -432,17 +432,17 @@ QString UnifiedDiffEditorWidget::showChunk(const ChunkData &chunkData,
|
||||
}
|
||||
}
|
||||
|
||||
const QString chunkLine = QLatin1String("@@ -")
|
||||
const QString chunkLine = "@@ -"
|
||||
+ QString::number(chunkData.leftStartingLineNumber + 1)
|
||||
+ QLatin1Char(',')
|
||||
+ ','
|
||||
+ QString::number(leftLineCount)
|
||||
+ QLatin1String(" +")
|
||||
+ " +"
|
||||
+ QString::number(chunkData.rightStartingLineNumber+ 1)
|
||||
+ QLatin1Char(',')
|
||||
+ ','
|
||||
+ QString::number(rightLineCount)
|
||||
+ QLatin1String(" @@")
|
||||
+ " @@"
|
||||
+ chunkData.contextInfo
|
||||
+ QLatin1Char('\n');
|
||||
+ '\n';
|
||||
|
||||
diffText.prepend(chunkLine);
|
||||
|
||||
@@ -466,10 +466,8 @@ void UnifiedDiffEditorWidget::showDiff()
|
||||
QMap<int, QList<DiffSelection> > selections;
|
||||
|
||||
for (const FileData &fileData : m_controller.m_contextFileData) {
|
||||
const QString leftFileInfo = QLatin1String("--- ")
|
||||
+ fileData.leftFileInfo.fileName + QLatin1Char('\n');
|
||||
const QString rightFileInfo = QLatin1String("+++ ")
|
||||
+ fileData.rightFileInfo.fileName + QLatin1Char('\n');
|
||||
const QString leftFileInfo = "--- " + fileData.leftFileInfo.fileName + '\n';
|
||||
const QString rightFileInfo = "+++ " + fileData.rightFileInfo.fileName + '\n';
|
||||
setFileInfo(blockNumber, fileData.leftFileInfo, fileData.rightFileInfo);
|
||||
foldingIndent.insert(blockNumber, 1);
|
||||
selections[blockNumber].append(DiffSelection(&m_controller.m_fileLineFormat));
|
||||
@@ -486,11 +484,11 @@ void UnifiedDiffEditorWidget::showDiff()
|
||||
foldingIndent.insert(blockNumber, 2);
|
||||
selections[blockNumber].append(DiffSelection(&m_controller.m_chunkLineFormat));
|
||||
blockNumber++;
|
||||
const QString binaryLine = QLatin1String("Binary files ")
|
||||
const QString binaryLine = "Binary files "
|
||||
+ fileData.leftFileInfo.fileName
|
||||
+ QLatin1String(" and ")
|
||||
+ " and "
|
||||
+ fileData.rightFileInfo.fileName
|
||||
+ QLatin1String(" differ\n");
|
||||
+ " differ\n";
|
||||
diffText += binaryLine;
|
||||
charNumber += binaryLine.count();
|
||||
} else {
|
||||
@@ -515,7 +513,7 @@ void UnifiedDiffEditorWidget::showDiff()
|
||||
return;
|
||||
}
|
||||
|
||||
diffText.replace(QLatin1Char('\r'), QLatin1Char(' '));
|
||||
diffText.replace('\r', ' ');
|
||||
const bool oldIgnore = m_controller.m_ignoreCurrentIndexChange;
|
||||
m_controller.m_ignoreCurrentIndexChange = true;
|
||||
setPlainText(diffText);
|
||||
|
@@ -48,7 +48,7 @@ class UnifiedDiffEditorWidget : public SelectableTextEditorWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
UnifiedDiffEditorWidget(QWidget *parent = 0);
|
||||
UnifiedDiffEditorWidget(QWidget *parent = nullptr);
|
||||
~UnifiedDiffEditorWidget();
|
||||
|
||||
void setDocument(DiffEditorDocument *document);
|
||||
@@ -113,7 +113,7 @@ private:
|
||||
QMap<int, QPair<int, int> > m_chunkInfo;
|
||||
|
||||
QByteArray m_state;
|
||||
Core::IContext *m_context;
|
||||
Core::IContext *m_context = nullptr;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
Reference in New Issue
Block a user