This commit is contained in:
Martin Marmsoler 2023-01-04 07:40:42 +01:00
parent 2ed66dc966
commit 5472f79196
8 changed files with 30 additions and 32 deletions

View File

@ -136,13 +136,13 @@ bool Patch::isLfsPointer() const {
}
Blob Patch::blob(Diff::File file) {
if (file == Diff::File::NewFile) {
if (mNewBlob.isValid())
return mNewBlob;
} else {
if (mOldBlob.isValid())
return mOldBlob;
}
if (file == Diff::File::NewFile) {
if (mNewBlob.isValid())
return mNewBlob;
} else {
if (mOldBlob.isValid())
return mOldBlob;
}
git_repository *repo = git_patch_owner(d.data());
if (!repo)
@ -157,9 +157,9 @@ Blob Patch::blob(Diff::File file) {
auto b = Blob(reinterpret_cast<git_blob *>(obj));
if (file == Diff::File::NewFile) {
mNewBlob = b;
mNewBlob = b;
} else {
mOldBlob = b;
mOldBlob = b;
}
return b;
@ -351,8 +351,7 @@ QByteArray Patch::generateResult(QList<QList<QByteArray>> &image,
return filtered;
}
QByteArray Patch::apply(const QBitArray &hunks,
const FilterList &filters) {
QByteArray Patch::apply(const QBitArray &hunks, const FilterList &filters) {
QList<QList<QByteArray>> image;
populatePreimage(image);

View File

@ -124,7 +124,7 @@ public:
* \return edited file
*/
QByteArray apply(const QBitArray &hunks,
const FilterList &filters = FilterList());
const FilterList &filters = FilterList());
QByteArray apply(int hidx, QByteArray &hunkData, QByteArray fileContent,
const FilterList &filters = FilterList()) const;

View File

@ -3,8 +3,8 @@
#include "ui/RepoView.h"
#include <QPainterPath>
EditButton::EditButton(git::Patch &patch, int index, bool binary,
bool lfs, QWidget *parent)
EditButton::EditButton(git::Patch &patch, int index, bool binary, bool lfs,
QWidget *parent)
: Button(parent) {
setObjectName("EditButton");

View File

@ -10,7 +10,7 @@ class EditButton : public Button {
public:
EditButton(git::Patch &patch, int index, bool binary, bool lfs,
QWidget *parent = nullptr);
QWidget *parent = nullptr);
void updatePatch(git::Patch &patch, int index, bool init = false);

View File

@ -333,10 +333,10 @@ void _FileWidget::Header::updateCheckState() {
//############### FileWidget ###########################################
//###############################################################################
FileWidget::FileWidget(DiffView *view, const git::Diff &diff,
git::Patch &patch, const git::Patch &staged,
const QModelIndex modelIndex, const QString &name,
const QString &path, bool submodule, QWidget *parent)
FileWidget::FileWidget(DiffView *view, const git::Diff &diff, git::Patch &patch,
const git::Patch &staged, const QModelIndex modelIndex,
const QString &name, const QString &path, bool submodule,
QWidget *parent)
: QWidget(parent), mView(view), mDiff(diff), mPatch(patch),
mModelIndex(modelIndex) {
auto stageState = static_cast<git::Index::StagedState>(

View File

@ -29,7 +29,7 @@ class Header : public QFrame {
public:
Header(const git::Diff &diff, git::Patch &patch, bool binary, bool lfs,
bool submodule, QWidget *parent = nullptr);
bool submodule, QWidget *parent = nullptr);
void updatePatch(git::Patch &patch);
QCheckBox *check() const;
@ -92,7 +92,7 @@ public:
QWidget *parent = nullptr);
bool isEmpty();
void updatePatch(git::Patch &patch, const git::Patch &staged,
const QString &name, const QString &path, bool submodule);
const QString &name, const QString &path, bool submodule);
/*!
* Update hunks after index change and emits the current stage state of the
* hunks \brief updateHunks
@ -106,8 +106,8 @@ public:
QWidget *addImage(DisclosureButton *button, const git::Patch patch,
bool lfs = false);
HunkWidget *addHunk(const git::Diff &diff, git::Patch &patch,
const git::Patch &staged, int index, bool lfs,
bool submodule);
const git::Patch &staged, int index, bool lfs,
bool submodule);
void setStageState(git::Index::StagedState state);
QModelIndex modelIndex();

View File

@ -34,9 +34,8 @@ const QString noNewLineAtEndOfFile =
HunkWidget::tr("No newline at end of file");
} // namespace
_HunkWidget::Header::Header(const git::Diff &diff, git::Patch &patch,
int index, bool lfs, bool submodule,
QWidget *parent)
_HunkWidget::Header::Header(const git::Diff &diff, git::Patch &patch, int index,
bool lfs, bool submodule, QWidget *parent)
: QFrame(parent) {
setObjectName("HunkHeader");
mCheck = new QCheckBox(this);
@ -178,9 +177,9 @@ void _HunkWidget::Header::mouseDoubleClickEvent(QMouseEvent *event) {
//########## HunkWidget ###############################################
//#############################################################################
HunkWidget::HunkWidget(DiffView *view, const git::Diff &diff,
git::Patch &patch, const git::Patch &staged,
int index, bool lfs, bool submodule, QWidget *parent)
HunkWidget::HunkWidget(DiffView *view, const git::Diff &diff, git::Patch &patch,
const git::Patch &staged, int index, bool lfs,
bool submodule, QWidget *parent)
: QFrame(parent), mView(view), mPatch(patch), mStaged(staged),
mIndex(index), mLfs(lfs) {
setObjectName("HunkWidget");

View File

@ -23,7 +23,7 @@ class Header : public QFrame {
Q_OBJECT
public:
Header(const git::Diff &diff, git::Patch &patch, int index, bool lfs,
bool submodule, QWidget *parent = nullptr);
bool submodule, QWidget *parent = nullptr);
QCheckBox *check() const;
DisclosureButton *button() const;
@ -62,8 +62,8 @@ class HunkWidget : public QFrame {
public:
HunkWidget(DiffView *view, const git::Diff &diff, git::Patch &patch,
const git::Patch &staged, int index, bool lfs, bool submodule,
QWidget *parent = nullptr);
const git::Patch &staged, int index, bool lfs, bool submodule,
QWidget *parent = nullptr);
_HunkWidget::Header *header() const;
TextEditor *editor(bool ensureLoaded = true);
void invalidate();