What does source files with document in their name represent in Tiled Source code?

(Keshav Sharma) #1

I’m working on a new tileset view based on QListView, and often when browsing through the source code, i see many files that ends with “Document” , for example TilesetDocument.cpp/.h , Document Manager class etc

Can anyone please give me a brief insight into what exactly is the role of these classes and what data does these classes represent ?

(Thorbjørn Lindeijer) #2

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.

The 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.