DocumentManager Class
class Core::DocumentManagerThe DocumentManager class manages a set of documents. More...
Header: | #include <coreplugin/documentmanager.h> |
Detailed Description
The DocumentManager service monitors a set of IDocument objects.
This section uses the following terminology:
- A file means a collection of data stored on a disk under a name (that is, the usual meaning of the term file in computing).
- A document holds content open in Qt Creator. If it corresponds to a file, it might differ from it, because it was modified. But a document might not correspond to a file at all. For example, diff viewer documents or Git blame or log records are created and displayed by Qt Creator upon request.
- An editor provides a view into a document that is actually visible to the user and potentially allows editing the document. Multiple editors can open views into the same document.
Plugins should register documents they work with at the document management service. The files the IDocument objects point to will be monitored at file system level. If a file changes on disk, the status of the IDocument object will be adjusted accordingly. On application exit the user will be asked to save all modified documents.
Different IDocument objects in the set can point to the same file in the file system. The monitoring for an IDocument can be blocked by using the Core::FileChangeBlocker class.
The functions expectFileChange()
and unexpectFileChange()
mark a file change as expected. On expected file changes all IDocument objects are notified to reload themselves.
The DocumentManager service also provides convenience functions for saving documents, such as saveModifiedDocuments() and saveModifiedDocumentsSilently(). They present users with a dialog that lists all modified documents and asks them which documents should be saved.
The service also manages the list of recent files to be shown to the user.
See also addToRecentFiles() and recentFiles().