aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/diffeditor/diffeditorcontroller.h
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@theqtcompany.com>2015-01-30 16:59:25 +0100
committerTobias Hunger <tobias.hunger@theqtcompany.com>2015-03-10 10:25:52 +0000
commitb2b8b867d68e95e9421a15549c1a7bb83949186d (patch)
tree5acf5ac984dae16bb7404cfd6a85910f1ae76f0a /src/plugins/diffeditor/diffeditorcontroller.h
parent59640aa7aaf1220a2739de021203f14834fc12b9 (diff)
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>
Diffstat (limited to 'src/plugins/diffeditor/diffeditorcontroller.h')
-rw-r--r--src/plugins/diffeditor/diffeditorcontroller.h87
1 files changed, 33 insertions, 54 deletions
diff --git a/src/plugins/diffeditor/diffeditorcontroller.h b/src/plugins/diffeditor/diffeditorcontroller.h
index 08d4036ab4..e54016eefb 100644
--- a/src/plugins/diffeditor/diffeditorcontroller.h
+++ b/src/plugins/diffeditor/diffeditorcontroller.h
@@ -36,81 +36,60 @@
#include <QObject>
-namespace DiffEditor {
+namespace Core { class IDocument; }
-class DiffEditorReloader;
+namespace DiffEditor {
+namespace Internal { class DiffEditorDocument; }
class DIFFEDITOR_EXPORT DiffEditorController : public QObject
{
Q_OBJECT
public:
- DiffEditorController(QObject *parent = 0);
- ~DiffEditorController();
+ explicit DiffEditorController(Core::IDocument *document);
- QString clearMessage() const;
+ void requestReload();
+ bool isReloading() const;
- QList<FileData> diffFiles() const;
- QString workingDirectory() const;
- QString description() const;
- bool isDescriptionEnabled() const;
- int contextLinesNumber() const;
- bool isContextLinesNumberEnabled() const;
- bool isIgnoreWhitespace() const;
+ QString baseDirectory() const;
+ int contextLineCount() const;
+ bool ignoreWhitespace() const;
- QString makePatch(bool revert, bool addPrefix = false) const;
- QString contents() const;
+ QString revisionFromDescription() const;
- DiffEditorReloader *reloader() const;
- void setReloader(DiffEditorReloader *reloader);
+ QString makePatch(bool revert, bool addPrefix = false) const;
public slots:
- void clear();
- void clear(const QString &message);
- void setDiffFiles(const QList<FileData> &diffFileList,
- const QString &workingDirectory = QString());
- void setDescription(const QString &description);
- void setDescriptionEnabled(bool on);
- void setContextLinesNumber(int lines);
- void setContextLinesNumberEnabled(bool on);
- void setIgnoreWhitespace(bool ignore);
- void requestReload();
- void requestChunkActions(QMenu *menu,
- int diffFileIndex,
- int chunkIndex);
- void requestSaveState();
- void requestRestoreState();
- void branchesForCommitReceived(const QString &output);
- void expandBranchesRequested();
+ void informationForCommitReceived(const QString &output);
signals:
- void cleared(const QString &message);
- void diffFilesChanged(const QList<FileData> &diffFileList,
- const QString &workingDirectory);
- void descriptionChanged(const QString &description);
- void descriptionEnablementChanged(bool on);
- void contextLinesNumberChanged(int lines);
- void contextLinesNumberEnablementChanged(bool on);
- void ignoreWhitespaceChanged(bool ignore);
void chunkActionsRequested(QMenu *menu, bool isValid);
- void saveStateRequested();
- void restoreStateRequested();
- void requestBranchList(const QString &revision);
- void reloaderChanged();
+ void requestInformationForCommit(const QString &revision);
+
+protected:
+ // reloadFinished() should be called
+ // inside reload() (for synchronous reload)
+ // or later (for asynchronous reload)
+ virtual void reload() = 0;
+ void reloadFinished(bool success);
+
+ void setDiffFiles(const QList<FileData> &diffFileList,
+ const QString &baseDirectory = QString());
+ void setDescription(const QString &description);
+ void forceContextLineCount(int lines);
private:
+ void requestMoreInformation();
+ void requestChunkActions(QMenu *menu, int diffFileIndex, int chunkIndex);
+
QString prepareBranchesForCommit(const QString &output);
- QString m_clearMessage;
- QList<FileData> m_diffFiles;
- QString m_workingDirectory;
- QString m_description;
- DiffEditorReloader *m_reloader;
- int m_contextLinesNumber;
+ Internal::DiffEditorDocument *const m_document;
+
+ bool m_isReloading;
int m_diffFileIndex;
int m_chunkIndex;
- bool m_descriptionEnabled;
- bool m_contextLinesNumberEnabled;
- bool m_ignoreWhitespace;
+
+ friend class Internal::DiffEditorDocument;
};
} // namespace DiffEditor