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);
}
void IVersionControl::setTopicCache(TopicCache *topicCache)
{
m_topicCache = topicCache;
}
QString IVersionControl::vcsTopic(const QString &topLevel)
{
return m_topicCache ? m_topicCache->topic(topLevel) : QString();
}
IVersionControl::IVersionControl(IVersionControl::TopicCache *topicCache)
: m_topicCache(topicCache)
IVersionControl::IVersionControl()
{
Core::VcsManager::addVersionControl(this);
}

View File

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

View File

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

View File

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

View File

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