Core: IVersionControl: Introduce a setTopicCache

More flexible than passing in the constructor.

Change-Id: I7bb5b3fe02682e01ebbce246de547686ff871920
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
hjk
2020-01-31 08:04:25 +01:00
parent f32605fa4a
commit ac9d05013e
5 changed files with 19 additions and 10 deletions

View File

@@ -138,13 +138,17 @@ IVersionControl::RepoUrl IVersionControl::getRepoUrl(const QString &location) co
return RepoUrl(location); return RepoUrl(location);
} }
void IVersionControl::setTopicCache(TopicCache *topicCache)
{
m_topicCache = topicCache;
}
QString IVersionControl::vcsTopic(const QString &topLevel) QString IVersionControl::vcsTopic(const QString &topLevel)
{ {
return m_topicCache ? m_topicCache->topic(topLevel) : QString(); return m_topicCache ? m_topicCache->topic(topLevel) : QString();
} }
IVersionControl::IVersionControl(IVersionControl::TopicCache *topicCache) IVersionControl::IVersionControl()
: m_topicCache(topicCache)
{ {
Core::VcsManager::addVersionControl(this); Core::VcsManager::addVersionControl(this);
} }

View File

@@ -86,7 +86,7 @@ public:
}; };
explicit IVersionControl(TopicCache *topicCache = nullptr); IVersionControl();
~IVersionControl() override; ~IVersionControl() override;
virtual QString displayName() const = 0; virtual QString displayName() const = 0;
@@ -239,13 +239,15 @@ public:
}; };
virtual RepoUrl getRepoUrl(const QString &location) const; virtual RepoUrl getRepoUrl(const QString &location) const;
void setTopicCache(TopicCache *topicCache);
signals: signals:
void repositoryChanged(const QString &repository); void repositoryChanged(const QString &repository);
void filesChanged(const QStringList &files); void filesChanged(const QStringList &files);
void configurationChanged(); void configurationChanged();
private: private:
TopicCache *m_topicCache; TopicCache *m_topicCache = nullptr;
}; };
} // namespace Core } // namespace Core

View File

@@ -62,9 +62,10 @@ private:
}; };
GitVersionControl::GitVersionControl(GitClient *client) : GitVersionControl::GitVersionControl(GitClient *client) :
Core::IVersionControl(new GitTopicCache(client)),
m_client(client) m_client(client)
{ } {
setTopicCache(new GitTopicCache(client));
}
QString GitVersionControl::displayName() const QString GitVersionControl::displayName() const
{ {

View File

@@ -64,9 +64,10 @@ private:
}; };
MercurialControl::MercurialControl(MercurialClient *client) : MercurialControl::MercurialControl(MercurialClient *client) :
Core::IVersionControl(new MercurialTopicCache(client)),
mercurialClient(client) mercurialClient(client)
{ } {
setTopicCache(new MercurialTopicCache(client));
}
QString MercurialControl::displayName() const QString MercurialControl::displayName() const
{ {

View File

@@ -64,9 +64,10 @@ private:
}; };
SubversionControl::SubversionControl(SubversionPluginPrivate *plugin) : SubversionControl::SubversionControl(SubversionPluginPrivate *plugin) :
Core::IVersionControl(new SubversionTopicCache(plugin)),
m_plugin(plugin) m_plugin(plugin)
{ } {
setTopicCache(new SubversionTopicCache(plugin));
}
QString SubversionControl::displayName() const QString SubversionControl::displayName() const
{ {