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:
Tobias Hunger
2015-01-30 16:59:25 +01:00
parent 59640aa7aa
commit b2b8b867d6
28 changed files with 1306 additions and 1948 deletions

View File

@@ -38,6 +38,7 @@
QT_BEGIN_NAMESPACE
class QComboBox;
class QSpinBox;
class QToolBar;
class QToolButton;
class QStackedWidget;
@@ -50,7 +51,6 @@ namespace DiffEditor {
namespace Internal {
class DescriptionEditorWidget;
class DiffEditorDocument;
class DiffEditorGuiController;
class IDiffView;
class DiffEditor : public Core::IEditor
@@ -62,8 +62,6 @@ public:
~DiffEditor();
public:
DiffEditorController *controller() const;
Core::IEditor *duplicate();
bool open(QString *errorString,
@@ -73,44 +71,52 @@ public:
QWidget *toolBar();
public slots:
void activateEntry(int index);
private slots:
void slotCleared(const QString &message);
void slotDiffFilesChanged(const QList<FileData> &diffFileList,
const QString &workingDirectory);
void entryActivated(int index);
void slotDescriptionChanged(const QString &description);
void slotDescriptionVisibilityChanged();
void slotReloaderChanged();
void documentHasChanged();
void toggleDescription();
void updateDescription();
void contextLineCountHasChanged(int lines);
void ignoreWhitespaceHasChanged(bool ignore);
void prepareForReload();
void reloadHasFinished(bool success);
void setCurrentDiffFileIndex(int index);
void documentStateChanged();
void toggleSync();
private:
void loadSettings();
void saveSetting(const QString &key, const QVariant &value) const;
void updateEntryToolTip();
void showDiffView(IDiffView *newEditor);
void showDiffView(IDiffView *view);
void updateDiffEditorSwitcher();
void addView(IDiffView *view);
IDiffView *currentView() const;
void setCurrentView(IDiffView *view);
IDiffView *nextView();
IDiffView *readLegacyCurrentDiffEditorSetting();
IDiffView *readCurrentDiffEditorSetting();
void writeCurrentDiffEditorSetting(IDiffView *currentEditor);
void setupView(IDiffView *view);
QSharedPointer<DiffEditorDocument> m_document;
DescriptionEditorWidget *m_descriptionWidget;
QStackedWidget *m_stackedWidget;
QVector<IDiffView *> m_views;
int m_currentViewIndex;
DiffEditorGuiController *m_guiController;
QToolBar *m_toolBar;
QComboBox *m_entriesComboBox;
QToolButton *m_whitespaceButton;
QSpinBox *m_contextSpinBox;
QAction *m_toggleSyncAction;
QAction *m_whitespaceButtonAction;
QAction *m_contextLabelAction;
QAction *m_contextSpinBoxAction;
QAction *m_toggleDescriptionAction;
QAction *m_reloadAction;
QToolButton *m_diffEditorSwitcher;
QPair<QString, QString> m_currentFileChunk;
int m_currentViewIndex;
int m_currentDiffFileIndex;
bool m_sync;
bool m_showDescription;
bool m_ignoreChanges;
};
} // namespace Internal