2023-07-10 06:14:12 +03:00
|
|
|
/* This file is part of the KDE project
|
|
|
|
Copyright (C) 2023 Ivailo Monev <xakepa10@gmail.com>
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Library General Public
|
|
|
|
License version 2, as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Library General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Library General Public License
|
|
|
|
along with this library; see the file COPYING.LIB. If not, write to
|
|
|
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
2022-05-14 21:28:45 +03:00
|
|
|
|
|
|
|
#ifndef FILEVIEWGITPLUGIN_H
|
|
|
|
#define FILEVIEWGITPLUGIN_H
|
|
|
|
|
2023-07-13 21:50:05 +03:00
|
|
|
#include "gitcommitdialog.h"
|
|
|
|
|
2022-05-14 21:28:45 +03:00
|
|
|
#include <kfileitem.h>
|
|
|
|
#include <kversioncontrolplugin.h>
|
2023-07-13 21:50:05 +03:00
|
|
|
#include <QPointer>
|
2023-07-10 06:14:12 +03:00
|
|
|
|
|
|
|
#include <git2/repository.h>
|
2023-07-13 20:33:32 +03:00
|
|
|
#include <git2/diff.h>
|
2022-05-14 21:28:45 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Git implementation for the KVersionControlPlugin interface.
|
|
|
|
*/
|
|
|
|
class FileViewGitPlugin : public KVersionControlPlugin
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2023-07-10 06:14:12 +03:00
|
|
|
FileViewGitPlugin(QObject *parent, const QList<QVariant> &args);
|
|
|
|
~FileViewGitPlugin();
|
2022-05-14 21:28:45 +03:00
|
|
|
|
2023-07-10 06:14:12 +03:00
|
|
|
QString fileName() const final;
|
|
|
|
bool beginRetrieval(const QString &directory) final;
|
|
|
|
void endRetrieval() final;
|
|
|
|
KVersionControlPlugin::ItemVersion itemVersion(const KFileItem& item) const final;
|
|
|
|
QList<QAction*> actions(const KFileItemList &items) const final;
|
2022-05-14 21:28:45 +03:00
|
|
|
|
2023-07-14 11:07:15 +03:00
|
|
|
QStringList gitFilesChanged() const;
|
|
|
|
QString gitFilesDiff() const;
|
|
|
|
QString gitCommits() const;
|
2023-07-11 18:04:46 +03:00
|
|
|
|
|
|
|
static int gitStatusCallback(const char *path, unsigned int status_flags, void *payload);
|
2023-07-13 20:33:32 +03:00
|
|
|
static int gitDiffCallback(const git_diff_delta *delta,
|
|
|
|
const git_diff_hunk *hunk,
|
|
|
|
const git_diff_line *line,
|
|
|
|
void *payload);
|
2022-05-14 21:28:45 +03:00
|
|
|
|
2023-07-12 06:19:14 +03:00
|
|
|
static QByteArray getGitError();
|
2023-07-11 17:12:38 +03:00
|
|
|
|
2023-07-10 06:14:12 +03:00
|
|
|
private Q_SLOTS:
|
|
|
|
void slotAdd();
|
|
|
|
void slotRemove();
|
|
|
|
void slotCommit();
|
2023-07-13 21:50:05 +03:00
|
|
|
void slotCommitFinished(const int result);
|
2022-05-14 21:28:45 +03:00
|
|
|
|
2023-07-10 06:14:12 +03:00
|
|
|
private:
|
|
|
|
QByteArray m_directory;
|
|
|
|
git_repository* m_gitrepo;
|
|
|
|
QAction* m_addaction;
|
|
|
|
QAction* m_removeaction;
|
|
|
|
QAction* m_commitaction;
|
|
|
|
mutable KFileItemList m_actionitems;
|
2023-07-13 21:50:05 +03:00
|
|
|
QPointer<GitCommitDialog> m_commitdialog;
|
2022-05-14 21:28:45 +03:00
|
|
|
};
|
2023-07-10 06:14:12 +03:00
|
|
|
|
2022-05-14 21:28:45 +03:00
|
|
|
#endif // FILEVIEWGITPLUGIN_H
|
|
|
|
|