Extending Qt Creator Manual | TopicCache

Extending Qt Creator Manual 4.3.0

# TopicCache Class

(Core::IVersionControl::TopicCache)

The TopicCache class stores a cache which maps a directory to a topic. More...

Header: | #include <TopicCache>

- List of all members, including inherited members

## Public Functions

virtual | ~TopicCache()
QString | topic(const QString &topLevel)

## Protected Functions

virtual QString | refreshTopic(const QString &repository) = 0
virtual QString | trackFile(const QString &repository) = 0

## Detailed Description

The TopicCache class stores a cache which maps a directory to a topic.

A VCS topic is typically the current active branch name, but it can also have other values (for example the latest tag) when there is no active branch.

It is displayed:

- In the project tree, next to each root project - corresponding to the project.
- In the main window title - corresponding to the current active editor.

In order to enable topic display, an IVersionControl subclass needs to create an instance of the TopicCache subclass with appropriate overrides for its pure virtual functions, and pass this instance to IVersionControl's constructor.

The cache tracks a file in the repository, which is expected to change when the topic changes. When the file is modified, the cache is refreshed. For example: for Git this file is typically <repository>/.git/HEAD

## Member Function Documentation

### `[virtual]` TopicCache::~TopicCache()

Destroys the instance of TopicCache. The destructor is virtual.

### `[pure virtual protected]` QString TopicCache::refreshTopic(const QString &repository)

Returns the path to the file that invalidates the cache for repository when the file is modified.

Returns the current topic for repository.

### QString TopicCache::topic(const QString &topLevel)

### `[pure virtual protected]` QString TopicCache::trackFile(const QString &repository)

Returns the path to the file that invalidates the cache for repository when the file is modified.

Returns the current topic for repository.