The main reason why I initially introduced the
MapDocument was because I wanted to keep file-related stuff like the file name, file format and undo stack out of the basic data structures, like the
Map class. I also wanted to avoid deriving the basic classes from
QObject, but I still needed a way to send out notifications about changes that the UI would need to respond to.
MapDocument does derive from
QObject and houses all the notification signals about changes made to the map.
With Tiled 1.0 it became necessary to introduce a
TilesetDocument class and the shared superclass
Document, to enable external tileset files to be opened on their own.
DocumentManager keeps track of the opened files and manages the related tab bar and editor stack.
I picked the names “document” and “document manager” because this is what similar classes in Qt Creator are called like (which I used to work on for some years). I’m contemplating whether it wouldn’t be better to call it an “asset” in the context of Tiled.