diff options
author | hjk <hjk@qt.io> | 2020-01-30 12:31:47 +0100 |
---|---|---|
committer | hjk <hjk@qt.io> | 2020-01-31 12:36:23 +0000 |
commit | b8fe25db258da13a2f7a4e44fcf8845a512af6bf (patch) | |
tree | b5692e17963cc05ca437198b969889d3d78a7b4a /src/plugins/vcsbase | |
parent | a35a2d6bf3f9525c6ba3cead820c13046c0e70b5 (diff) |
Vcs: Merge IVersionControl and VcsBasePlugin hierarchies
They were 1:1 in parallel, with quite a bit of function call
ping-pong inbetween, for code-sharing-by-inheritance. Merge
them by making VcsBasePlugin inherit IVersionControl and
merge the derived classes below.
Size of this patch is hard to avoid as all seven systems have to
move simultaneously. Non-necessary potential follow-up cleanup
have been left out on purpose.
Change-Id: Icb71e4182af3db21069cc637e7ae87ffa3829791
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Diffstat (limited to 'src/plugins/vcsbase')
-rw-r--r-- | src/plugins/vcsbase/vcsbaseclient.h | 3 | ||||
-rw-r--r-- | src/plugins/vcsbase/vcsbaseplugin.cpp | 37 | ||||
-rw-r--r-- | src/plugins/vcsbase/vcsbaseplugin.h | 12 | ||||
-rw-r--r-- | src/plugins/vcsbase/vcsbasesubmiteditor.cpp | 3 |
4 files changed, 16 insertions, 39 deletions
diff --git a/src/plugins/vcsbase/vcsbaseclient.h b/src/plugins/vcsbase/vcsbaseclient.h index 5aecf564b6..f538dfc16e 100644 --- a/src/plugins/vcsbase/vcsbaseclient.h +++ b/src/plugins/vcsbase/vcsbaseclient.h @@ -202,7 +202,7 @@ signals: // Passes on changed signals from VcsJob to Control void changed(const QVariant &v); -protected: +public: enum VcsCommandTag { CreateRepositoryCommand, @@ -221,6 +221,7 @@ protected: LogCommand, StatusCommand }; +protected: virtual QString vcsCommandString(VcsCommandTag cmd) const; virtual Core::Id vcsEditorKind(VcsCommandTag cmd) const = 0; virtual Utils::ExitCodeInterpreter exitCodeInterpreter(VcsCommandTag cmd) const; diff --git a/src/plugins/vcsbase/vcsbaseplugin.cpp b/src/plugins/vcsbase/vcsbaseplugin.cpp index 9ae6f826c4..d46febc0a3 100644 --- a/src/plugins/vcsbase/vcsbaseplugin.cpp +++ b/src/plugins/vcsbase/vcsbaseplugin.cpp @@ -518,26 +518,14 @@ VCSBASE_EXPORT QDebug operator<<(QDebug in, const VcsBasePluginState &state) bool VcsBasePluginPrivate::supportsRepositoryCreation() const { - return m_versionControl && m_versionControl->supportsOperation(IVersionControl::CreateRepositoryOperation); + return supportsOperation(IVersionControl::CreateRepositoryOperation); } static Internal::StateListener *m_listener = nullptr; -VcsBasePluginPrivate::VcsBasePluginPrivate() -{ } - -VcsBasePluginPrivate::~VcsBasePluginPrivate() -{ - delete m_versionControl; -} - -void VcsBasePluginPrivate::initializeVcs(IVersionControl *vc, const Context &context) +VcsBasePluginPrivate::VcsBasePluginPrivate(const Context &context) + : m_context(context) { - QTC_ASSERT(vc, return); - - m_versionControl = vc; - m_context = context; - Internal::VcsPlugin *plugin = Internal::VcsPlugin::instance(); connect(plugin, &Internal::VcsPlugin::submitEditorAboutToClose, this, &VcsBasePluginPrivate::slotSubmitEditorAboutToClose); @@ -547,9 +535,9 @@ void VcsBasePluginPrivate::initializeVcs(IVersionControl *vc, const Context &con connect(m_listener, &Internal::StateListener::stateChanged, this, &VcsBasePluginPrivate::slotStateChanged); // VCSes might have become (un-)available, so clear the VCS directory cache - connect(vc, &IVersionControl::configurationChanged, + connect(this, &IVersionControl::configurationChanged, VcsManager::instance(), &VcsManager::clearVersionControlCache); - connect(vc, &IVersionControl::configurationChanged, + connect(this, &IVersionControl::configurationChanged, m_listener, &Internal::StateListener::slotStateChanged); } @@ -569,14 +557,9 @@ void VcsBasePluginPrivate::slotSubmitEditorAboutToClose(VcsBaseSubmitEditor *sub *result = submitEditorAboutToClose(); } -IVersionControl *VcsBasePluginPrivate::versionControl() const -{ - return m_versionControl; -} - -void VcsBasePluginPrivate::slotStateChanged(const VcsBase::Internal::State &newInternalState, IVersionControl *vc) +void VcsBasePluginPrivate::slotStateChanged(const Internal::State &newInternalState, Core::IVersionControl *vc) { - if (vc == m_versionControl) { + if (vc == this) { // We are directly affected: Change state if (!m_state.equals(newInternalState)) { m_state.setState(newInternalState); @@ -637,7 +620,7 @@ void VcsBasePluginPrivate::promptToDeleteCurrentFile() { const VcsBasePluginState state = currentState(); QTC_ASSERT(state.hasFile(), return); - const bool rc = VcsManager::promptToDelete(versionControl(), state.currentFile()); + const bool rc = VcsManager::promptToDelete(this, state.currentFile()); if (!rc) QMessageBox::warning(ICore::dialogParent(), tr("Version Control"), tr("The file \"%1\" could not be deleted."). @@ -654,7 +637,7 @@ static inline bool ask(QWidget *parent, const QString &title, const QString &que void VcsBasePluginPrivate::createRepository() { - QTC_ASSERT(m_versionControl->supportsOperation(IVersionControl::CreateRepositoryOperation), return); + QTC_ASSERT(supportsOperation(IVersionControl::CreateRepositoryOperation), return); // Find current starting directory QString directory; if (const Project *currentProject = ProjectTree::currentProject()) @@ -675,7 +658,7 @@ void VcsBasePluginPrivate::createRepository() return; } while (true); // Create - const bool rc = m_versionControl->vcsCreateRepository(directory); + const bool rc = vcsCreateRepository(directory); const QString nativeDir = QDir::toNativeSeparators(directory); if (rc) { QMessageBox::information(mw, tr("Repository Created"), diff --git a/src/plugins/vcsbase/vcsbaseplugin.h b/src/plugins/vcsbase/vcsbaseplugin.h index 31c8968b86..7174c295f4 100644 --- a/src/plugins/vcsbase/vcsbaseplugin.h +++ b/src/plugins/vcsbase/vcsbaseplugin.h @@ -154,20 +154,17 @@ VCSBASE_EXPORT Utils::SynchronousProcessResponse runVcs(const QString &workingDi QTextCodec *outputCodec = nullptr, const QProcessEnvironment &env = {}); -class VCSBASE_EXPORT VcsBasePluginPrivate : public QObject +class VCSBASE_EXPORT VcsBasePluginPrivate : public Core::IVersionControl { Q_OBJECT protected: - explicit VcsBasePluginPrivate(); + explicit VcsBasePluginPrivate(const Core::Context &context); public: - ~VcsBasePluginPrivate() override; - void extensionsInitialized(); const VcsBasePluginState ¤tState() const; - Core::IVersionControl *versionControl() const; // Display name of the commit action virtual QString commitDisplayName() const; @@ -209,16 +206,13 @@ protected: // Returns whether actions should be set up further. bool enableMenuAction(ActionState as, QAction *in) const; - void initializeVcs(Core::IVersionControl *vc, const Core::Context &context); - private: void slotSubmitEditorAboutToClose(VcsBaseSubmitEditor *submitEditor, bool *result); - void slotStateChanged(const VcsBase::Internal::State &s, Core::IVersionControl *vc); + void slotStateChanged(const Internal::State &s, Core::IVersionControl *vc); bool supportsRepositoryCreation() const; QPointer<VcsBaseSubmitEditor> m_submitEditor; - QPointer<Core::IVersionControl> m_versionControl; Core::Context m_context; VcsBasePluginState m_state; int m_actionState = -1; diff --git a/src/plugins/vcsbase/vcsbasesubmiteditor.cpp b/src/plugins/vcsbase/vcsbasesubmiteditor.cpp index 1f21badce6..db5513c456 100644 --- a/src/plugins/vcsbase/vcsbasesubmiteditor.cpp +++ b/src/plugins/vcsbase/vcsbasesubmiteditor.cpp @@ -535,8 +535,7 @@ VcsBaseSubmitEditor::PromptSubmitResult return SubmitConfirmed; CheckableMessageBox mb(Core::ICore::dialogParent()); const QString commitName = plugin->commitDisplayName(); - mb.setWindowTitle(tr("Close %1 %2 Editor") - .arg(plugin->versionControl()->displayName(), commitName)); + mb.setWindowTitle(tr("Close %1 %2 Editor").arg(plugin->displayName(), commitName)); mb.setIcon(QMessageBox::Question); QString message; if (canCommit) { |