forked from qt-creator/qt-creator
Since we also license under GPL-3.0 WITH Qt-GPL-exception-1.0,
this applies only to a hypothetical newer version of GPL, that doesn't
exist yet. If such a version emerges, we can still decide to relicense...
While at it, replace (deprecated) GPL-3.0 with more explicit GPL-3.0-only
Change was done by running
find . -type f -exec perl -pi -e "s/LicenseRef-Qt-Commercial OR GPL-3.0\+ OR GPL-3.0 WITH Qt-GPL-exception-1.0/LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0/g" {} \;
Change-Id: I5097e6ce8d10233993ee30d7e25120e2659eb10b
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
84 lines
2.4 KiB
C++
84 lines
2.4 KiB
C++
// Copyright (C) 2016 The Qt Company Ltd.
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
|
|
#pragma once
|
|
|
|
#include "diffeditor_global.h"
|
|
#include "diffutils.h"
|
|
|
|
#include <utils/tasktree.h>
|
|
|
|
#include <QObject>
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
class QMenu;
|
|
QT_END_NAMESPACE
|
|
|
|
namespace Core { class IDocument; }
|
|
namespace Utils { class FilePath; }
|
|
|
|
namespace DiffEditor {
|
|
|
|
namespace Internal { class DiffEditorDocument; }
|
|
|
|
class ChunkSelection;
|
|
|
|
class DIFFEDITOR_EXPORT DiffEditorController : public QObject
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit DiffEditorController(Core::IDocument *document);
|
|
|
|
void requestReload();
|
|
bool isReloading() const;
|
|
|
|
Utils::FilePath workingDirectory() const;
|
|
void setWorkingDirectory(const Utils::FilePath &directory);
|
|
int contextLineCount() const;
|
|
bool ignoreWhitespace() const;
|
|
|
|
enum PatchOption {
|
|
NoOption = 0,
|
|
Revert = 1,
|
|
AddPrefix = 2
|
|
};
|
|
Q_DECLARE_FLAGS(PatchOptions, PatchOption)
|
|
QString makePatch(int fileIndex, int chunkIndex, const ChunkSelection &selection,
|
|
PatchOptions options) const;
|
|
|
|
static Core::IDocument *findOrCreateDocument(const QString &vcsId,
|
|
const QString &displayName);
|
|
static DiffEditorController *controller(Core::IDocument *document);
|
|
|
|
void requestChunkActions(QMenu *menu, int fileIndex, int chunkIndex,
|
|
const ChunkSelection &selection);
|
|
bool chunkExists(int fileIndex, int chunkIndex) const;
|
|
Core::IDocument *document() const;
|
|
|
|
signals:
|
|
void chunkActionsRequested(QMenu *menu, int fileIndex, int chunkIndex,
|
|
const ChunkSelection &selection);
|
|
|
|
protected:
|
|
// Core functions:
|
|
void setReloadRecipe(const Utils::Tasking::Group &recipe) { m_reloadRecipe = recipe; }
|
|
void setDiffFiles(const QList<FileData> &diffFileList);
|
|
// Optional:
|
|
void setDisplayName(const QString &name) { m_displayName = name; }
|
|
void setDescription(const QString &description);
|
|
void setStartupFile(const QString &startupFile);
|
|
void forceContextLineCount(int lines);
|
|
|
|
private:
|
|
void reloadFinished(bool success);
|
|
|
|
Internal::DiffEditorDocument *const m_document;
|
|
QString m_displayName;
|
|
std::unique_ptr<Utils::TaskTree> m_taskTree;
|
|
Utils::Tasking::Group m_reloadRecipe;
|
|
};
|
|
|
|
Q_DECLARE_OPERATORS_FOR_FLAGS(DiffEditorController::PatchOptions)
|
|
|
|
} // namespace DiffEditor
|