forked from qt-creator/qt-creator
DiffEditor: Refactor the user-facing parts
* Move all data handling into DiffEditorDocument * Move much of the logic of how to update views into the DiffEditor. * Introduce a base class for the different views on the diff to implement. * Remove DiffEditorGuiController * Make DiffEditorController smaller and merge the DiffEditorReloader into the class * Simplify communication between the classes involved * Make much of the implementation private to the plugin Change-Id: I7ccb9df6061923bcb34cf3090d6d8331895e83c7 Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Jarek Kobus <jaroslaw.kobus@theqtcompany.com>
This commit is contained in:
@@ -31,6 +31,8 @@
|
||||
#ifndef DIFFEDITORDOCUMENT_H
|
||||
#define DIFFEDITORDOCUMENT_H
|
||||
|
||||
#include "diffutils.h"
|
||||
|
||||
#include <coreplugin/textdocument.h>
|
||||
|
||||
namespace DiffEditor {
|
||||
@@ -45,9 +47,26 @@ class DiffEditorDocument : public Core::BaseTextDocument
|
||||
Q_PROPERTY(QString plainText READ plainText STORED false) // For access by code pasters
|
||||
public:
|
||||
DiffEditorDocument();
|
||||
~DiffEditorDocument();
|
||||
|
||||
DiffEditorController *controller() const;
|
||||
|
||||
QString makePatch(int fileIndex, int chunkIndex, bool revert, bool addPrefix = false) const;
|
||||
|
||||
void setDiffFiles(const QList<FileData> &data, const QString &directory);
|
||||
QList<FileData> diffFiles() const;
|
||||
QString baseDirectory() const;
|
||||
|
||||
void setDescription(const QString &description);
|
||||
QString description() const;
|
||||
|
||||
void setContextLineCount(int lines);
|
||||
int contextLineCount() const;
|
||||
void forceContextLineCount(int lines);
|
||||
bool isContextLineCountForced() const;
|
||||
void setIgnoreWhitespace(bool ignore);
|
||||
bool ignoreWhitespace() const;
|
||||
|
||||
bool setContents(const QByteArray &contents);
|
||||
QString defaultPath() const;
|
||||
QString suggestedFileName() const Q_DECL_OVERRIDE;
|
||||
@@ -55,13 +74,35 @@ public:
|
||||
bool isModified() const { return false; }
|
||||
bool isSaveAsAllowed() const { return true; }
|
||||
bool save(QString *errorString, const QString &fileName, bool autoSave);
|
||||
void reload();
|
||||
bool reload(QString *errorString, ReloadFlag flag, ChangeType type);
|
||||
bool open(QString *errorString, const QString &fileName);
|
||||
|
||||
QString plainText() const;
|
||||
|
||||
signals:
|
||||
void temporaryStateChanged();
|
||||
void documentChanged();
|
||||
void descriptionChanged();
|
||||
void chunkActionsRequested(QMenu *menu, int diffFileIndex, int chunkIndex);
|
||||
void requestMoreInformation();
|
||||
|
||||
public slots:
|
||||
void beginReload();
|
||||
void endReload(bool success);
|
||||
|
||||
private:
|
||||
DiffEditorController *const m_controller;
|
||||
void setController(DiffEditorController *controller);
|
||||
|
||||
DiffEditorController *m_controller;
|
||||
QList<FileData> m_diffFiles;
|
||||
QString m_baseDirectory;
|
||||
QString m_description;
|
||||
int m_contextLineCount;
|
||||
bool m_isContextLineCountForced;
|
||||
bool m_ignoreWhitespace;
|
||||
|
||||
friend class ::DiffEditor::DiffEditorController;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
Reference in New Issue
Block a user